forked from daren.hsu/line_push
update
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
> This plugin transforms ES2015 modules to AMD
|
||||
|
||||
See our website [@babel/plugin-transform-modules-amd](https://babeljs.io/docs/en/next/babel-plugin-transform-modules-amd.html) for more information.
|
||||
See our website [@babel/plugin-transform-modules-amd](https://babeljs.io/docs/en/babel-plugin-transform-modules-amd) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
|
||||
+21
-12
@@ -13,11 +13,12 @@ var _core = require("@babel/core");
|
||||
|
||||
var _utils = require("babel-plugin-dynamic-import-node/utils");
|
||||
|
||||
const buildWrapper = (0, _core.template)(`
|
||||
const buildWrapper = _core.template.statement(`
|
||||
define(MODULE_NAME, AMD_ARGUMENTS, function(IMPORT_NAMES) {
|
||||
})
|
||||
`);
|
||||
const buildAnonymousWrapper = (0, _core.template)(`
|
||||
|
||||
const buildAnonymousWrapper = _core.template.statement(`
|
||||
define(["require"], function(REQUIRE) {
|
||||
})
|
||||
`);
|
||||
@@ -29,21 +30,26 @@ function injectWrapper(path, wrapper) {
|
||||
} = path.node;
|
||||
path.node.directives = [];
|
||||
path.node.body = [];
|
||||
const amdWrapper = path.pushContainer("body", wrapper)[0];
|
||||
const amdFactory = amdWrapper.get("expression.arguments").filter(arg => arg.isFunctionExpression())[0].get("body");
|
||||
const amdFactoryCall = path.pushContainer("body", wrapper)[0].get("expression");
|
||||
const amdFactoryCallArgs = amdFactoryCall.get("arguments");
|
||||
const amdFactory = amdFactoryCallArgs[amdFactoryCallArgs.length - 1].get("body");
|
||||
amdFactory.pushContainer("directives", directives);
|
||||
amdFactory.pushContainer("body", body);
|
||||
}
|
||||
|
||||
var _default = (0, _helperPluginUtils.declare)((api, options) => {
|
||||
var _api$assumption, _api$assumption2;
|
||||
|
||||
api.assertVersion(7);
|
||||
const {
|
||||
loose,
|
||||
allowTopLevelThis,
|
||||
strict,
|
||||
strictMode,
|
||||
importInterop,
|
||||
noInterop
|
||||
} = options;
|
||||
const constantReexports = (_api$assumption = api.assumption("constantReexports")) != null ? _api$assumption : options.loose;
|
||||
const enumerableModuleMeta = (_api$assumption2 = api.assumption("enumerableModuleMeta")) != null ? _api$assumption2 : options.loose;
|
||||
return {
|
||||
name: "transform-modules-amd",
|
||||
|
||||
@@ -80,8 +86,8 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
|
||||
new Promise((${resolveId}, ${rejectId}) =>
|
||||
${requireId}(
|
||||
[${(0, _utils.getImportSource)(_core.types, path.node)}],
|
||||
imported => ${resolveId}(${result}),
|
||||
${rejectId}
|
||||
imported => ${_core.types.cloneNode(resolveId)}(${result}),
|
||||
${_core.types.cloneNode(rejectId)}
|
||||
)
|
||||
)`);
|
||||
},
|
||||
@@ -93,7 +99,7 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
|
||||
if (!(0, _helperModuleTransforms.isModule)(path)) {
|
||||
if (requireId) {
|
||||
injectWrapper(path, buildAnonymousWrapper({
|
||||
REQUIRE: requireId
|
||||
REQUIRE: _core.types.cloneNode(requireId)
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -105,7 +111,7 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
|
||||
|
||||
if (requireId) {
|
||||
amdArgs.push(_core.types.stringLiteral("require"));
|
||||
importNames.push(requireId);
|
||||
importNames.push(_core.types.cloneNode(requireId));
|
||||
}
|
||||
|
||||
let moduleName = (0, _helperModuleTransforms.getModuleName)(this.file.opts, options);
|
||||
@@ -114,11 +120,14 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
|
||||
meta,
|
||||
headers
|
||||
} = (0, _helperModuleTransforms.rewriteModuleStatementsAndPrepareHeader)(path, {
|
||||
loose,
|
||||
enumerableModuleMeta,
|
||||
constantReexports,
|
||||
strict,
|
||||
strictMode,
|
||||
allowTopLevelThis,
|
||||
noInterop
|
||||
importInterop,
|
||||
noInterop,
|
||||
filename: this.file.opts.filename
|
||||
});
|
||||
|
||||
if ((0, _helperModuleTransforms.hasExports)(meta)) {
|
||||
@@ -141,7 +150,7 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
|
||||
}
|
||||
}
|
||||
|
||||
headers.push(...(0, _helperModuleTransforms.buildNamespaceInitStatements)(meta, metadata, loose));
|
||||
headers.push(...(0, _helperModuleTransforms.buildNamespaceInitStatements)(meta, metadata, constantReexports));
|
||||
}
|
||||
|
||||
(0, _helperModuleTransforms.ensureStatementsHoisted)(headers);
|
||||
|
||||
+27
-19
@@ -1,53 +1,60 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@babel/plugin-transform-modules-amd@7.10.4",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"@babel/plugin-transform-modules-amd@7.18.6",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "@babel/plugin-transform-modules-amd@7.10.4",
|
||||
"_id": "@babel/plugin-transform-modules-amd@7.10.4",
|
||||
"_from": "@babel/plugin-transform-modules-amd@7.18.6",
|
||||
"_id": "@babel/plugin-transform-modules-amd@7.18.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-3Fw+H3WLUrTlzi3zMiZWp3AR4xadAEMv6XRCYnd5jAlLM61Rn+CRJaZMaNvIpcJpQ3vs1kyifYvEVPFfoSkKOA==",
|
||||
"_integrity": "sha512-Pra5aXsmTsOnjM3IajS8rTaLCy++nGM4v3YR4esk5PCsyg9z8NA5oQLwxzMUtDBd8F+UmVza3VxoAaWCbzH1rg==",
|
||||
"_location": "/@babel/plugin-transform-modules-amd",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@babel/plugin-transform-modules-amd@7.10.4",
|
||||
"raw": "@babel/plugin-transform-modules-amd@7.18.6",
|
||||
"name": "@babel/plugin-transform-modules-amd",
|
||||
"escapedName": "@babel%2fplugin-transform-modules-amd",
|
||||
"scope": "@babel",
|
||||
"rawSpec": "7.10.4",
|
||||
"rawSpec": "7.18.6",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "7.10.4"
|
||||
"fetchSpec": "7.18.6"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@babel/preset-env"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.10.4.tgz",
|
||||
"_spec": "7.10.4",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.18.6.tgz",
|
||||
"_spec": "7.18.6",
|
||||
"_where": "/home/node/nuxt",
|
||||
"author": {
|
||||
"name": "The Babel Team",
|
||||
"url": "https://babel.dev/team"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/babel/babel/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/helper-module-transforms": "^7.10.4",
|
||||
"@babel/helper-plugin-utils": "^7.10.4",
|
||||
"@babel/helper-module-transforms": "^7.18.6",
|
||||
"@babel/helper-plugin-utils": "^7.18.6",
|
||||
"babel-plugin-dynamic-import-node": "^2.3.3"
|
||||
},
|
||||
"description": "This plugin transforms ES2015 modules to AMD",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.10.4",
|
||||
"@babel/helper-plugin-test-runner": "^7.10.4"
|
||||
"@babel/core": "^7.18.6",
|
||||
"@babel/helper-plugin-test-runner": "^7.18.6",
|
||||
"@babel/plugin-external-helpers": "^7.18.6"
|
||||
},
|
||||
"gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df",
|
||||
"homepage": "https://github.com/babel/babel#readme",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-modules-amd",
|
||||
"keywords": [
|
||||
"babel-plugin"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"main": "./lib/index.js",
|
||||
"name": "@babel/plugin-transform-modules-amd",
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
@@ -60,5 +67,6 @@
|
||||
"url": "git+https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-plugin-transform-modules-amd"
|
||||
},
|
||||
"version": "7.10.4"
|
||||
"type": "commonjs",
|
||||
"version": "7.18.6"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user