Updated node modules

This commit is contained in:
2023-07-15 17:06:30 -05:00
parent 7ef1139ef8
commit 92b3795e10
2280 changed files with 319169 additions and 179621 deletions

View File

@@ -0,0 +1,37 @@
import {TokenType as tt} from "../parser/tokenizer/types";
/**
* Common method sharing code between CJS and ESM cases, since they're the same here.
*/
export default function shouldElideDefaultExport(
isTypeScriptTransformEnabled,
tokens,
declarationInfo,
) {
if (!isTypeScriptTransformEnabled) {
return false;
}
const exportToken = tokens.currentToken();
if (exportToken.rhsEndIndex == null) {
throw new Error("Expected non-null rhsEndIndex on export token.");
}
// The export must be of the form `export default a` or `export default a;`.
const numTokens = exportToken.rhsEndIndex - tokens.currentIndex();
if (
numTokens !== 3 &&
!(numTokens === 4 && tokens.matches1AtIndex(exportToken.rhsEndIndex - 1, tt.semi))
) {
return false;
}
const identifierToken = tokens.tokenAtRelativeIndex(2);
if (identifierToken.type !== tt.name) {
return false;
}
const exportedName = tokens.identifierNameForToken(identifierToken);
return (
declarationInfo.typeDeclarations.has(exportedName) &&
!declarationInfo.valueDeclarations.has(exportedName)
);
}