[systemjs] Fix: export star alongside with named export (#12612)

This commit is contained in:
Leslie Leigh (李的序)
2021-01-13 07:12:12 +08:00
committed by GitHub
parent 58d2f41930
commit 2338b052ad
3 changed files with 61 additions and 25 deletions

View File

@@ -74,34 +74,36 @@ function constructExportCall(
stringSpecifiers: Set<string>,
) {
const statements = [];
if (exportNames.length === 1) {
statements.push(
t.expressionStatement(
t.callExpression(exportIdent, [
t.stringLiteral(exportNames[0]),
exportValues[0],
]),
),
);
} else if (!exportStarTarget) {
const objectProperties = [];
for (let i = 0; i < exportNames.length; i++) {
const exportName = exportNames[i];
const exportValue = exportValues[i];
objectProperties.push(
t.objectProperty(
stringSpecifiers.has(exportName)
? t.stringLiteral(exportName)
: t.identifier(exportName),
exportValue,
if (!exportStarTarget) {
if (exportNames.length === 1) {
statements.push(
t.expressionStatement(
t.callExpression(exportIdent, [
t.stringLiteral(exportNames[0]),
exportValues[0],
]),
),
);
} else {
const objectProperties = [];
for (let i = 0; i < exportNames.length; i++) {
const exportName = exportNames[i];
const exportValue = exportValues[i];
objectProperties.push(
t.objectProperty(
stringSpecifiers.has(exportName)
? t.stringLiteral(exportName)
: t.identifier(exportName),
exportValue,
),
);
}
statements.push(
t.expressionStatement(
t.callExpression(exportIdent, [t.objectExpression(objectProperties)]),
),
);
}
statements.push(
t.expressionStatement(
t.callExpression(exportIdent, [t.objectExpression(objectProperties)]),
),
);
} else {
const exportObj = path.scope.generateUid("exportObj");