@babel/plugin-transform-modules-systemjs
Advanced tools
Comparing version 7.3.4 to 7.4.0
@@ -111,3 +111,3 @@ "use strict"; | ||
for (const name in arg.getBindingIdentifiers()) { | ||
for (const name of Object.keys(arg.getBindingIdentifiers())) { | ||
if (this.scope.getBinding(name) !== path.scope.getBinding(name)) { | ||
@@ -182,5 +182,6 @@ return; | ||
exit(path, state) { | ||
const undefinedIdent = path.scope.buildUndefinedNode(); | ||
const exportIdent = path.scope.generateUid("export"); | ||
const contextIdent = state.contextIdent; | ||
const exportNames = Object.create(null); | ||
const exportMap = Object.create(null); | ||
const modules = []; | ||
@@ -194,4 +195,4 @@ let beforeBody = []; | ||
function addExportName(key, val) { | ||
exportNames[key] = exportNames[key] || []; | ||
exportNames[key].push(val); | ||
exportMap[key] = exportMap[key] || []; | ||
exportMap[key].push(val); | ||
} | ||
@@ -222,2 +223,4 @@ | ||
const exportNames = []; | ||
const exportValues = []; | ||
const body = path.get("body"); | ||
@@ -229,2 +232,5 @@ | ||
removedPaths.push(path); | ||
} else if (path.isClassDeclaration()) { | ||
variableIds.push(path.node.id); | ||
path.replaceWith(_core().types.expressionStatement(_core().types.assignmentExpression("=", _core().types.cloneNode(path.node.id), _core().types.toExpression(path.node)))); | ||
} else if (path.isImportDeclaration()) { | ||
@@ -234,3 +240,3 @@ const source = path.node.source.value; | ||
for (const name in path.getBindingIdentifiers()) { | ||
for (const name of Object.keys(path.getBindingIdentifiers())) { | ||
path.scope.removeBinding(name); | ||
@@ -246,21 +252,28 @@ variableIds.push(_core().types.identifier(name)); | ||
const declar = path.get("declaration"); | ||
const id = declar.node.id; | ||
if (declar.isClassDeclaration() || declar.isFunctionDeclaration()) { | ||
const id = declar.node.id; | ||
const nodes = []; | ||
if (declar.isClassDeclaration()) { | ||
if (id) { | ||
nodes.push(declar.node); | ||
nodes.push(buildExportCall("default", _core().types.cloneNode(id))); | ||
exportNames.push("default"); | ||
exportValues.push(undefinedIdent); | ||
variableIds.push(id); | ||
addExportName(id.name, "default"); | ||
path.replaceWith(_core().types.expressionStatement(_core().types.assignmentExpression("=", _core().types.cloneNode(id), _core().types.toExpression(declar.node)))); | ||
} else { | ||
nodes.push(buildExportCall("default", _core().types.toExpression(declar.node))); | ||
exportNames.push("default"); | ||
exportValues.push(_core().types.toExpression(declar.node)); | ||
removedPaths.push(path); | ||
} | ||
if (declar.isClassDeclaration()) { | ||
path.replaceWithMultiple(nodes); | ||
} else if (declar.isFunctionDeclaration()) { | ||
if (id) { | ||
beforeBody.push(declar.node); | ||
exportNames.push("default"); | ||
exportValues.push(_core().types.cloneNode(id)); | ||
addExportName(id.name, "default"); | ||
} else { | ||
beforeBody = beforeBody.concat(nodes); | ||
removedPaths.push(path); | ||
exportNames.push("default"); | ||
exportValues.push(_core().types.toExpression(declar.node)); | ||
} | ||
removedPaths.push(path); | ||
} else { | ||
@@ -280,10 +293,14 @@ path.replaceWith(buildExportCall("default", declar.node)); | ||
beforeBody.push(node); | ||
beforeBody.push(buildExportCall(name, _core().types.cloneNode(node.id))); | ||
exportNames.push(name); | ||
exportValues.push(_core().types.cloneNode(node.id)); | ||
removedPaths.push(path); | ||
} else if (path.isClass()) { | ||
const name = declar.node.id.name; | ||
exportNames.push(name); | ||
exportValues.push(undefinedIdent); | ||
variableIds.push(declar.node.id); | ||
path.replaceWith(_core().types.expressionStatement(_core().types.assignmentExpression("=", _core().types.cloneNode(declar.node.id), _core().types.toExpression(declar.node)))); | ||
addExportName(name, name); | ||
path.insertAfter([buildExportCall(name, _core().types.identifier(name))]); | ||
} else { | ||
for (const name in declar.getBindingIdentifiers()) { | ||
for (const name of Object.keys(declar.getBindingIdentifiers())) { | ||
addExportName(name, name); | ||
@@ -306,3 +323,4 @@ } | ||
if (binding && _core().types.isFunctionDeclaration(binding.path.node)) { | ||
beforeBody.push(buildExportCall(specifier.exported.name, _core().types.cloneNode(specifier.local))); | ||
exportNames.push(specifier.exported.name); | ||
exportValues.push(_core().types.cloneNode(specifier.local)); | ||
} else if (!binding) { | ||
@@ -360,3 +378,2 @@ nodes.push(buildExportCall(specifier.exported.name, specifier.local)); | ||
if (moduleName) moduleName = _core().types.stringLiteral(moduleName); | ||
const uninitializedVars = []; | ||
(0, _helperHoistVariables().default)(path, (id, name, hasInit) => { | ||
@@ -366,3 +383,4 @@ variableIds.push(id); | ||
if (!hasInit) { | ||
uninitializedVars.push(name); | ||
exportNames.push(name); | ||
exportValues.push(undefinedIdent); | ||
} | ||
@@ -375,15 +393,8 @@ }, null); | ||
if (uninitializedVars.length) { | ||
const undefinedValues = []; | ||
const undefinedIdent = path.scope.buildUndefinedNode(); | ||
for (let i = 0; i < uninitializedVars.length; i++) { | ||
undefinedValues[i] = undefinedIdent; | ||
} | ||
beforeBody = beforeBody.concat(constructExportCall(path, _core().types.identifier(exportIdent), uninitializedVars, undefinedValues, null)); | ||
if (exportNames.length) { | ||
beforeBody = beforeBody.concat(constructExportCall(path, _core().types.identifier(exportIdent), exportNames, exportValues, null)); | ||
} | ||
path.traverse(reassignmentVisitor, { | ||
exports: exportNames, | ||
exports: exportMap, | ||
buildCall: buildExportCall, | ||
@@ -390,0 +401,0 @@ scope: path.scope |
{ | ||
"name": "@babel/plugin-transform-modules-systemjs", | ||
"version": "7.3.4", | ||
"version": "7.4.0", | ||
"description": "This plugin transforms ES2015 modules to SystemJS", | ||
@@ -12,3 +12,3 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-modules-systemjs", | ||
"dependencies": { | ||
"@babel/helper-hoist-variables": "^7.0.0", | ||
"@babel/helper-hoist-variables": "^7.4.0", | ||
"@babel/helper-plugin-utils": "^7.0.0" | ||
@@ -23,7 +23,7 @@ }, | ||
"devDependencies": { | ||
"@babel/core": "^7.3.4", | ||
"@babel/core": "^7.4.0", | ||
"@babel/helper-plugin-test-runner": "^7.0.0", | ||
"@babel/plugin-syntax-dynamic-import": "^7.2.0" | ||
}, | ||
"gitHead": "1f6454cc90fe33e0a32260871212e2f719f35741" | ||
"gitHead": "f1328fb913b5a93d54dfc6e3728b1f56c8f4a804" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18170
343