[systemjs] Fix: export star alongside with named export (#12612)
This commit is contained in:
parent
58d2f41930
commit
2338b052ad
@ -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");
|
||||
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
export { default } from 'foo';
|
||||
export * from 'foo';
|
||||
|
||||
export { a, b } from 'bar';
|
||||
export * from 'bar';
|
||||
@ -0,0 +1,29 @@
|
||||
System.register(["foo", "bar"], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
return {
|
||||
setters: [function (_foo) {
|
||||
var _exportObj = {};
|
||||
|
||||
for (var _key in _foo) {
|
||||
if (_key !== "default" && _key !== "__esModule") _exportObj[_key] = _foo[_key];
|
||||
}
|
||||
|
||||
_exportObj.default = _foo.default;
|
||||
|
||||
_export(_exportObj);
|
||||
}, function (_bar) {
|
||||
var _exportObj2 = {};
|
||||
|
||||
for (var _key2 in _bar) {
|
||||
if (_key2 !== "default" && _key2 !== "__esModule") _exportObj2[_key2] = _bar[_key2];
|
||||
}
|
||||
|
||||
_exportObj2.a = _bar.a;
|
||||
_exportObj2.b = _bar.b;
|
||||
|
||||
_export(_exportObj2);
|
||||
}],
|
||||
execute: function () {}
|
||||
};
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user