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