Updated to v1.9.9

This commit is contained in:
Henry Whitaker
2020-11-07 15:27:50 +00:00
parent 15d3583423
commit 8d811862a0
6349 changed files with 338454 additions and 213438 deletions

View File

@@ -3,6 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getExportSpecifierName = getExportSpecifierName;
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
@@ -15,6 +16,8 @@ var _utils = require("babel-plugin-dynamic-import-node/utils");
var _helperModuleTransforms = require("@babel/helper-module-transforms");
var _helperValidatorIdentifier = require("@babel/helper-validator-identifier");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const buildTemplate = (0, _core.template)(`
@@ -23,9 +26,7 @@ const buildTemplate = (0, _core.template)(`
BEFORE_BODY;
return {
setters: SETTERS,
execute: function () {
BODY;
}
execute: EXECUTE,
};
});
`);
@@ -40,7 +41,23 @@ WARNING: Dynamic import() transformation must be enabled using the
no longer transform import() without using that plugin.
`;
function constructExportCall(path, exportIdent, exportNames, exportValues, exportStarTarget) {
function getExportSpecifierName(node, stringSpecifiers) {
if (node.type === "Identifier") {
return node.name;
} else if (node.type === "StringLiteral") {
const stringValue = node.value;
if (!(0, _helperValidatorIdentifier.isIdentifierName)(stringValue)) {
stringSpecifiers.add(stringValue);
}
return stringValue;
} else {
throw new Error(`Expected export specifier to be either Identifier or StringLiteral, got ${node.type}`);
}
}
function constructExportCall(path, exportIdent, exportNames, exportValues, exportStarTarget, stringSpecifiers) {
const statements = [];
if (exportNames.length === 1) {
@@ -51,7 +68,7 @@ function constructExportCall(path, exportIdent, exportNames, exportValues, expor
for (let i = 0; i < exportNames.length; i++) {
const exportName = exportNames[i];
const exportValue = exportValues[i];
objectProperties.push(_core.types.objectProperty(_core.types.identifier(exportName), exportValue));
objectProperties.push(_core.types.objectProperty(stringSpecifiers.has(exportName) ? _core.types.stringLiteral(exportName) : _core.types.identifier(exportName), exportValue));
}
statements.push(_core.types.expressionStatement(_core.types.callExpression(exportIdent, [_core.types.objectExpression(objectProperties)])));
@@ -168,6 +185,7 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
Program: {
enter(path, state) {
state.contextIdent = path.scope.generateUid("context");
state.stringSpecifiers = new Set();
if (!allowTopLevelThis) {
(0, _helperModuleTransforms.rewriteThis)(path);
@@ -177,7 +195,10 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
exit(path, state) {
const scope = path.scope;
const exportIdent = scope.generateUid("export");
const contextIdent = state.contextIdent;
const {
contextIdent,
stringSpecifiers
} = state;
const exportMap = Object.create(null);
const modules = [];
let beforeBody = [];
@@ -306,16 +327,21 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
const nodes = [];
for (const specifier of specifiers) {
const binding = scope.getBinding(specifier.local.name);
const {
local,
exported
} = specifier;
const binding = scope.getBinding(local.name);
const exportedName = getExportSpecifierName(exported, stringSpecifiers);
if (binding && _core.types.isFunctionDeclaration(binding.path.node)) {
exportNames.push(specifier.exported.name);
exportValues.push(_core.types.cloneNode(specifier.local));
exportNames.push(exportedName);
exportValues.push(_core.types.cloneNode(local));
} else if (!binding) {
nodes.push(buildExportCall(specifier.exported.name, specifier.local));
nodes.push(buildExportCall(exportedName, local));
}
addExportName(specifier.local.name, specifier.exported.name);
addExportName(local.name, exportedName);
}
path.replaceWithMultiple(nodes);
@@ -339,7 +365,10 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
}
if (_core.types.isImportSpecifier(specifier)) {
setterBody.push(_core.types.expressionStatement(_core.types.assignmentExpression("=", specifier.local, _core.types.memberExpression(_core.types.identifier(target), specifier.imported))));
const {
imported
} = specifier;
setterBody.push(_core.types.expressionStatement(_core.types.assignmentExpression("=", specifier.local, _core.types.memberExpression(_core.types.identifier(target), specifier.imported, imported.type === "StringLiteral"))));
}
}
@@ -352,12 +381,13 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
if (_core.types.isExportAllDeclaration(node)) {
hasExportStar = true;
} else if (_core.types.isExportSpecifier(node)) {
exportNames.push(node.exported.name);
exportValues.push(_core.types.memberExpression(_core.types.identifier(target), node.local));
const exportedName = getExportSpecifierName(node.exported, stringSpecifiers);
exportNames.push(exportedName);
exportValues.push(_core.types.memberExpression(_core.types.identifier(target), node.local, _core.types.isStringLiteral(node.local)));
} else {}
}
setterBody = setterBody.concat(constructExportCall(path, _core.types.identifier(exportIdent), exportNames, exportValues, hasExportStar ? _core.types.identifier(target) : null));
setterBody = setterBody.concat(constructExportCall(path, _core.types.identifier(exportIdent), exportNames, exportValues, hasExportStar ? _core.types.identifier(target) : null, stringSpecifiers));
}
sources.push(_core.types.stringLiteral(specifiers.key));
@@ -368,9 +398,11 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
(0, _helperHoistVariables.default)(path, (id, name, hasInit) => {
variableIds.push(id);
if (!hasInit) {
exportNames.push(name);
exportValues.push(scope.buildUndefinedNode());
if (!hasInit && name in exportMap) {
for (const exported of exportMap[name]) {
exportNames.push(exported);
exportValues.push(scope.buildUndefinedNode());
}
}
}, null);
@@ -379,7 +411,7 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
}
if (exportNames.length) {
beforeBody = beforeBody.concat(constructExportCall(path, _core.types.identifier(exportIdent), exportNames, exportValues, null));
beforeBody = beforeBody.concat(constructExportCall(path, _core.types.identifier(exportIdent), exportNames, exportValues, null, stringSpecifiers));
}
path.traverse(reassignmentVisitor, {
@@ -392,13 +424,26 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
path.remove();
}
let hasTLA = false;
path.traverse({
AwaitExpression(path) {
hasTLA = true;
path.stop();
},
Function(path) {
path.skip();
},
noScope: true
});
path.node.body = [buildTemplate({
SYSTEM_REGISTER: _core.types.memberExpression(_core.types.identifier(systemGlobal), _core.types.identifier("register")),
BEFORE_BODY: beforeBody,
MODULE_NAME: moduleName,
SETTERS: _core.types.arrayExpression(setters),
EXECUTE: _core.types.functionExpression(null, [], _core.types.blockStatement(path.node.body), false, hasTLA),
SOURCES: _core.types.arrayExpression(sources),
BODY: path.node.body,
EXPORT_IDENTIFIER: _core.types.identifier(exportIdent),
CONTEXT_IDENTIFIER: _core.types.identifier(contextIdent)
})];

View File

@@ -1,50 +1,50 @@
{
"_args": [
[
"@babel/plugin-transform-modules-systemjs@7.10.5",
"@babel/plugin-transform-modules-systemjs@7.12.1",
"/home/henry/Documents/git/Speedtest-tracker-docker/conf/site"
]
],
"_development": true,
"_from": "@babel/plugin-transform-modules-systemjs@7.10.5",
"_id": "@babel/plugin-transform-modules-systemjs@7.10.5",
"_from": "@babel/plugin-transform-modules-systemjs@7.12.1",
"_id": "@babel/plugin-transform-modules-systemjs@7.12.1",
"_inBundle": false,
"_integrity": "sha512-f4RLO/OL14/FP1AEbcsWMzpbUz6tssRaeQg11RH1BP/XnPpRoVwgeYViMFacnkaw4k4wjRSjn3ip1Uw9TaXuMw==",
"_integrity": "sha512-Hn7cVvOavVh8yvW6fLwveFqSnd7rbQN3zJvoPNyNaQSvgfKmDBO9U1YL9+PCXGRlZD9tNdWTy5ACKqMuzyn32Q==",
"_location": "/@babel/plugin-transform-modules-systemjs",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/plugin-transform-modules-systemjs@7.10.5",
"raw": "@babel/plugin-transform-modules-systemjs@7.12.1",
"name": "@babel/plugin-transform-modules-systemjs",
"escapedName": "@babel%2fplugin-transform-modules-systemjs",
"scope": "@babel",
"rawSpec": "7.10.5",
"rawSpec": "7.12.1",
"saveSpec": null,
"fetchSpec": "7.10.5"
"fetchSpec": "7.12.1"
},
"_requiredBy": [
"/@babel/preset-env"
],
"_resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.10.5.tgz",
"_spec": "7.10.5",
"_resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.12.1.tgz",
"_spec": "7.12.1",
"_where": "/home/henry/Documents/git/Speedtest-tracker-docker/conf/site",
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"dependencies": {
"@babel/helper-hoist-variables": "^7.10.4",
"@babel/helper-module-transforms": "^7.10.5",
"@babel/helper-module-transforms": "^7.12.1",
"@babel/helper-plugin-utils": "^7.10.4",
"@babel/helper-validator-identifier": "^7.10.4",
"babel-plugin-dynamic-import-node": "^2.3.3"
},
"description": "This plugin transforms ES2015 modules to SystemJS",
"devDependencies": {
"@babel/core": "^7.10.5",
"@babel/helper-plugin-test-runner": "^7.10.4",
"@babel/core": "^7.12.1",
"@babel/helper-plugin-test-runner": "7.10.4",
"@babel/plugin-syntax-dynamic-import": "^7.8.0"
},
"gitHead": "f7964a9ac51356f7df6404a25b27ba1cffba1ba7",
"homepage": "https://github.com/babel/babel#readme",
"keywords": [
"babel-plugin"
@@ -63,5 +63,5 @@
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-plugin-transform-modules-systemjs"
},
"version": "7.10.5"
"version": "7.12.1"
}