@babel/plugin-transform-modules-commonjs
Advanced tools
Comparing version 7.6.0 to 7.7.0
@@ -8,57 +8,17 @@ "use strict"; | ||
function _helperPluginUtils() { | ||
const data = require("@babel/helper-plugin-utils"); | ||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); | ||
_helperPluginUtils = function () { | ||
return data; | ||
}; | ||
var _helperModuleTransforms = require("@babel/helper-module-transforms"); | ||
return data; | ||
} | ||
var _helperSimpleAccess = _interopRequireDefault(require("@babel/helper-simple-access")); | ||
function _helperModuleTransforms() { | ||
const data = require("@babel/helper-module-transforms"); | ||
var _core = require("@babel/core"); | ||
_helperModuleTransforms = function () { | ||
return data; | ||
}; | ||
var _utils = require("babel-plugin-dynamic-import-node/utils"); | ||
return data; | ||
} | ||
function _helperSimpleAccess() { | ||
const data = _interopRequireDefault(require("@babel/helper-simple-access")); | ||
_helperSimpleAccess = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _core() { | ||
const data = require("@babel/core"); | ||
_core = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _utils() { | ||
const data = require("babel-plugin-dynamic-import-node/utils"); | ||
_utils = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _default = (0, _helperPluginUtils().declare)((api, options) => { | ||
var _default = (0, _helperPluginUtils.declare)((api, options) => { | ||
api.assertVersion(7); | ||
const transformImportCall = (0, _utils().createDynamicImportTransform)(api); | ||
const transformImportCall = (0, _utils.createDynamicImportTransform)(api); | ||
const { | ||
@@ -88,3 +48,3 @@ loose, | ||
const getAssertion = localName => _core().template.expression.ast` | ||
const getAssertion = localName => _core.template.expression.ast` | ||
(function(){ | ||
@@ -128,3 +88,3 @@ throw new Error( | ||
const right = path.get("right"); | ||
right.replaceWith(_core().types.sequenceExpression([right.node, getAssertion(localName)])); | ||
right.replaceWith(_core.types.sequenceExpression([right.node, getAssertion(localName)])); | ||
} else if (left.isPattern()) { | ||
@@ -139,3 +99,3 @@ const ids = left.getOuterBindingIdentifiers(); | ||
const right = path.get("right"); | ||
right.replaceWith(_core().types.sequenceExpression([right.node, getAssertion(localName)])); | ||
right.replaceWith(_core.types.sequenceExpression([right.node, getAssertion(localName)])); | ||
} | ||
@@ -170,3 +130,3 @@ } | ||
exit(path, state) { | ||
if (!(0, _helperModuleTransforms().isModule)(path)) return; | ||
if (!(0, _helperModuleTransforms.isModule)(path)) return; | ||
path.scope.rename("exports"); | ||
@@ -179,3 +139,3 @@ path.scope.rename("module"); | ||
if (!allowCommonJSExports) { | ||
(0, _helperSimpleAccess().default)(path, new Set(["module", "exports"])); | ||
(0, _helperSimpleAccess.default)(path, new Set(["module", "exports"])); | ||
path.traverse(moduleExportsVisitor, { | ||
@@ -187,7 +147,7 @@ scope: path.scope | ||
let moduleName = this.getModuleName(); | ||
if (moduleName) moduleName = _core().types.stringLiteral(moduleName); | ||
if (moduleName) moduleName = _core.types.stringLiteral(moduleName); | ||
const { | ||
meta, | ||
headers | ||
} = (0, _helperModuleTransforms().rewriteModuleStatementsAndPrepareHeader)(path, { | ||
} = (0, _helperModuleTransforms.rewriteModuleStatementsAndPrepareHeader)(path, { | ||
exportName: "exports", | ||
@@ -204,14 +164,14 @@ loose, | ||
for (const [source, metadata] of meta.source) { | ||
const loadExpr = _core().types.callExpression(_core().types.identifier("require"), [_core().types.stringLiteral(source)]); | ||
const loadExpr = _core.types.callExpression(_core.types.identifier("require"), [_core.types.stringLiteral(source)]); | ||
let header; | ||
if ((0, _helperModuleTransforms().isSideEffectImport)(metadata)) { | ||
if ((0, _helperModuleTransforms.isSideEffectImport)(metadata)) { | ||
if (metadata.lazy) throw new Error("Assertion failure"); | ||
header = _core().types.expressionStatement(loadExpr); | ||
header = _core.types.expressionStatement(loadExpr); | ||
} else { | ||
const init = (0, _helperModuleTransforms().wrapInterop)(path, loadExpr, metadata.interop) || loadExpr; | ||
const init = (0, _helperModuleTransforms.wrapInterop)(path, loadExpr, metadata.interop) || loadExpr; | ||
if (metadata.lazy) { | ||
header = _core().template.ast` | ||
header = _core.template.ast` | ||
function ${metadata.name}() { | ||
@@ -224,3 +184,3 @@ const data = ${init}; | ||
} else { | ||
header = _core().template.ast` | ||
header = _core.template.ast` | ||
var ${metadata.name} = ${init}; | ||
@@ -233,6 +193,6 @@ `; | ||
headers.push(header); | ||
headers.push(...(0, _helperModuleTransforms().buildNamespaceInitStatements)(meta, metadata, loose)); | ||
headers.push(...(0, _helperModuleTransforms.buildNamespaceInitStatements)(meta, metadata, loose)); | ||
} | ||
(0, _helperModuleTransforms().ensureStatementsHoisted)(headers); | ||
(0, _helperModuleTransforms.ensureStatementsHoisted)(headers); | ||
path.unshiftContainer("body", headers); | ||
@@ -239,0 +199,0 @@ } |
{ | ||
"name": "@babel/plugin-transform-modules-commonjs", | ||
"version": "7.6.0", | ||
"version": "7.7.0", | ||
"description": "This plugin transforms ES2015 modules to CommonJS", | ||
@@ -12,5 +12,5 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-modules-commonjs", | ||
"dependencies": { | ||
"@babel/helper-module-transforms": "^7.4.4", | ||
"@babel/helper-module-transforms": "^7.7.0", | ||
"@babel/helper-plugin-utils": "^7.0.0", | ||
"@babel/helper-simple-access": "^7.1.0", | ||
"@babel/helper-simple-access": "^7.7.0", | ||
"babel-plugin-dynamic-import-node": "^2.3.0" | ||
@@ -25,7 +25,7 @@ }, | ||
"devDependencies": { | ||
"@babel/core": "^7.6.0", | ||
"@babel/core": "^7.7.0", | ||
"@babel/helper-plugin-test-runner": "^7.0.0", | ||
"@babel/plugin-syntax-object-rest-spread": "^7.2.0" | ||
}, | ||
"gitHead": "cbd5a26e57758e3f748174ff84aa570e8780e85d" | ||
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea" | ||
} |
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
9013
161