[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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 25 deletions

View File

@ -74,6 +74,7 @@ function constructExportCall(
stringSpecifiers: Set<string>, stringSpecifiers: Set<string>,
) { ) {
const statements = []; const statements = [];
if (!exportStarTarget) {
if (exportNames.length === 1) { if (exportNames.length === 1) {
statements.push( statements.push(
t.expressionStatement( t.expressionStatement(
@ -83,7 +84,7 @@ function constructExportCall(
]), ]),
), ),
); );
} else if (!exportStarTarget) { } else {
const objectProperties = []; const objectProperties = [];
for (let i = 0; i < exportNames.length; i++) { for (let i = 0; i < exportNames.length; i++) {
const exportName = exportNames[i]; const exportName = exportNames[i];
@ -102,6 +103,7 @@ function constructExportCall(
t.callExpression(exportIdent, [t.objectExpression(objectProperties)]), t.callExpression(exportIdent, [t.objectExpression(objectProperties)]),
), ),
); );
}
} else { } else {
const exportObj = path.scope.generateUid("exportObj"); const exportObj = path.scope.generateUid("exportObj");

View File

@ -0,0 +1,5 @@
export { default } from 'foo';
export * from 'foo';
export { a, b } from 'bar';
export * from 'bar';

View File

@ -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 () {}
};
});