feat: add noIncompleteNsImportDetection assumption to plugin-transform-modules-commonjs (#13290)

This commit is contained in:
Federico Ciardi
2021-08-03 23:55:09 +02:00
committed by GitHub
parent c35637e247
commit 7e50ee2d82
12 changed files with 64 additions and 11 deletions

View File

@@ -45,6 +45,7 @@ export function rewriteModuleStatementsAndPrepareHeader(
constantReexports = loose,
enumerableModuleMeta = loose,
noIncompleteNsImportDetection,
}: {
exportName?;
strict;
@@ -57,6 +58,7 @@ export function rewriteModuleStatementsAndPrepareHeader(
esNamespaceOnly?;
constantReexports?;
enumerableModuleMeta?;
noIncompleteNsImportDetection?: boolean;
},
) {
validateImportInteropOption(importInterop);
@@ -102,7 +104,12 @@ export function rewriteModuleStatementsAndPrepareHeader(
// Create all of the statically known named exports.
headers.push(
...buildExportInitializationStatements(path, meta, constantReexports),
...buildExportInitializationStatements(
path,
meta,
constantReexports,
noIncompleteNsImportDetection,
),
);
return { meta, headers };
@@ -388,6 +395,7 @@ function buildExportInitializationStatements(
programPath: NodePath,
metadata: ModuleMetadata,
constantReexports: boolean = false,
noIncompleteNsImportDetection = false,
) {
const initStatements = [];
@@ -413,15 +421,17 @@ function buildExportInitializationStatements(
}
}
initStatements.push(
...chunk(exportNames, 100).map(members => {
return buildInitStatement(
metadata,
members,
programPath.scope.buildUndefinedNode(),
);
}),
);
if (!noIncompleteNsImportDetection) {
initStatements.push(
...chunk(exportNames, 100).map(members => {
return buildInitStatement(
metadata,
members,
programPath.scope.buildUndefinedNode(),
);
}),
);
}
return initStatements;
}