@babel/helper-module-transforms
Advanced tools
Comparing version 7.20.11 to 7.21.0
@@ -10,3 +10,2 @@ "use strict"; | ||
var _template = require("@babel/template"); | ||
function getDynamicImportSource(node) { | ||
@@ -13,0 +12,0 @@ const [source] = node.arguments; |
@@ -9,3 +9,2 @@ "use strict"; | ||
const originalGetModuleName = getModuleName; | ||
exports.default = getModuleName = function getModuleName(rootOpts, pluginOpts) { | ||
@@ -34,3 +33,2 @@ var _pluginOpts$moduleId, _pluginOpts$moduleIds, _pluginOpts$getModule, _pluginOpts$moduleRoo; | ||
if (!moduleIds) return null; | ||
if (moduleId != null && !getModuleId) { | ||
@@ -42,7 +40,4 @@ return moduleId; | ||
const sourceRootReplacer = sourceRoot != null ? new RegExp("^" + sourceRoot + "/?") : ""; | ||
moduleName += filenameRelative | ||
.replace(sourceRootReplacer, "") | ||
.replace(/\.(\w*?)$/, ""); | ||
moduleName += filenameRelative.replace(sourceRootReplacer, "").replace(/\.(\w*?)$/, ""); | ||
} | ||
moduleName = moduleName.replace(/\\/g, "/"); | ||
@@ -49,0 +44,0 @@ if (getModuleId) { |
@@ -122,3 +122,2 @@ "use strict"; | ||
} | ||
headers.push(...buildExportInitializationStatements(path, meta, constantReexports, noIncompleteNsImportDetection)); | ||
@@ -130,3 +129,2 @@ return { | ||
} | ||
function ensureStatementsHoisted(statements) { | ||
@@ -137,3 +135,2 @@ statements.forEach(header => { | ||
} | ||
function wrapInterop(programPath, expr, type) { | ||
@@ -158,3 +155,2 @@ if (type === "none") { | ||
} | ||
function buildNamespaceInitStatements(metadata, sourceMetadata, constantReexports = false) { | ||
@@ -166,3 +162,2 @@ const statements = []; | ||
if (localName === sourceMetadata.name) continue; | ||
statements.push(_template.default.statement`var NAME = SOURCE;`({ | ||
@@ -193,3 +188,2 @@ NAME: localName, | ||
statement.loc = sourceMetadata.reexportAll.loc; | ||
statements.push(statement); | ||
@@ -218,4 +212,3 @@ } | ||
let NAMESPACE_IMPORT = cloneNode(namespace); | ||
if (importName === "default" && metadata.interop === "node-default") { | ||
} else if (stringSpecifiers.has(importName)) { | ||
if (importName === "default" && metadata.interop === "node-default") {} else if (stringSpecifiers.has(importName)) { | ||
NAMESPACE_IMPORT = memberExpression(NAMESPACE_IMPORT, stringLiteral(importName), true); | ||
@@ -241,3 +234,2 @@ } else { | ||
} | ||
function buildESModuleHeader(metadata, enumerableModuleMeta = false) { | ||
@@ -254,3 +246,2 @@ return (enumerableModuleMeta ? _template.default.statement` | ||
} | ||
function buildNamespaceReexport(metadata, namespace, constantReexports) { | ||
@@ -265,4 +256,3 @@ return (constantReexports ? _template.default.statement` | ||
}); | ||
` : | ||
_template.default.statement` | ||
` : _template.default.statement` | ||
Object.keys(NAMESPACE).forEach(function(key) { | ||
@@ -290,3 +280,2 @@ if (key === "default" || key === "__esModule") return; | ||
} | ||
function buildExportNameListDeclaration(programPath, metadata) { | ||
@@ -317,10 +306,7 @@ const exportedVars = Object.create(null); | ||
} | ||
function buildExportInitializationStatements(programPath, metadata, constantReexports = false, noIncompleteNsImportDetection = false) { | ||
const initStatements = []; | ||
for (const [localName, data] of metadata.local) { | ||
if (data.kind === "import") { | ||
} else if (data.kind === "hoisted") { | ||
initStatements.push([ | ||
data.names[0], buildInitStatement(metadata, data.names, identifier(localName))]); | ||
if (data.kind === "import") {} else if (data.kind === "hoisted") { | ||
initStatements.push([data.names[0], buildInitStatement(metadata, data.names, identifier(localName))]); | ||
} else if (!noIncompleteNsImportDetection) { | ||
@@ -346,3 +332,2 @@ for (const exportName of data.names) { | ||
} | ||
initStatements.sort(([a], [b]) => { | ||
@@ -381,3 +366,2 @@ if (a < b) return -1; | ||
} | ||
const InitTemplate = { | ||
@@ -384,0 +368,0 @@ computed: _template.default.expression`EXPORTS["NAME"] = VALUE`, |
@@ -16,3 +16,2 @@ "use strict"; | ||
} | ||
function isSideEffectImport(source) { | ||
@@ -33,3 +32,2 @@ return source.imports.size === 0 && source.importsNamespace.size === 0 && source.reexports.size === 0 && source.reexportNamespace.size === 0 && !source.reexportAll; | ||
} | ||
function normalizeModuleAndLoadMetadata(programPath, exportName, { | ||
@@ -56,3 +54,2 @@ importInterop, | ||
removeImportExportDeclarations(programPath); | ||
for (const [, metadata] of source) { | ||
@@ -104,3 +101,2 @@ if (metadata.importsNamespace.size > 0) { | ||
} | ||
function getModuleMetadata(programPath, { | ||
@@ -326,3 +322,2 @@ lazy, | ||
} | ||
function nameAnonymousExports(programPath) { | ||
@@ -329,0 +324,0 @@ programPath.get("body").forEach(child => { |
@@ -69,3 +69,2 @@ "use strict"; | ||
} | ||
const rewriteBindingInitVisitorState = { | ||
@@ -77,8 +76,4 @@ metadata, | ||
}; | ||
programPath.traverse( | ||
rewriteBindingInitVisitor, rewriteBindingInitVisitorState); | ||
(0, _helperSimpleAccess.default)(programPath, | ||
new Set([...Array.from(imported.keys()), ...Array.from(exported.keys())]), false); | ||
programPath.traverse(rewriteBindingInitVisitor, rewriteBindingInitVisitorState); | ||
(0, _helperSimpleAccess.default)(programPath, new Set([...Array.from(imported.keys()), ...Array.from(exported.keys())]), false); | ||
const rewriteReferencesVisitorState = { | ||
@@ -95,4 +90,3 @@ seen: new WeakSet(), | ||
if (meta.lazy) { | ||
identNode = callExpression( | ||
identNode, []); | ||
identNode = callExpression(identNode, []); | ||
} | ||
@@ -112,3 +106,2 @@ return identNode; | ||
} | ||
const rewriteBindingInitVisitor = { | ||
@@ -131,4 +124,3 @@ Scope(path) { | ||
if (exportNames.length > 0) { | ||
const statement = expressionStatement( | ||
buildBindingExportAssignmentExpression(metadata, exportNames, identifier(localName), path.scope)); | ||
const statement = expressionStatement(buildBindingExportAssignmentExpression(metadata, exportNames, identifier(localName), path.scope)); | ||
statement._blockHoist = path.node._blockHoist; | ||
@@ -147,4 +139,3 @@ requeueInParent(path.insertAfter(statement)[0]); | ||
if (exportNames.length > 0) { | ||
const statement = expressionStatement( | ||
buildBindingExportAssignmentExpression(metadata, exportNames, identifier(localName), path.scope)); | ||
const statement = expressionStatement(buildBindingExportAssignmentExpression(metadata, exportNames, identifier(localName), path.scope)); | ||
statement._blockHoist = path.node._blockHoist; | ||
@@ -197,6 +188,4 @@ requeueInParent(path.insertAfter(statement)[0]); | ||
const rootBinding = scope.getBinding(localName); | ||
if (rootBinding !== localBinding) return; | ||
const ref = buildImportReference(importData, path.node); | ||
ref.loc = path.node.loc; | ||
@@ -216,5 +205,3 @@ if ((path.parentPath.isCallExpression({ | ||
} = ref; | ||
path.replaceWith(jsxMemberExpression( | ||
jsxIdentifier(object.name), | ||
jsxIdentifier(property.name))); | ||
path.replaceWith(jsxMemberExpression(jsxIdentifier(object.name), jsxIdentifier(property.name))); | ||
} else { | ||
@@ -224,3 +211,2 @@ path.replaceWith(ref); | ||
requeueInParent(path); | ||
path.skip(); | ||
@@ -241,3 +227,2 @@ } | ||
const arg = path.get("argument"); | ||
if (arg.isMemberExpression()) return; | ||
@@ -247,3 +232,2 @@ const update = path.node; | ||
const localName = arg.node.name; | ||
if (scope.getBinding(localName) !== path.scope.getBinding(localName)) { | ||
@@ -281,7 +265,5 @@ return; | ||
const left = path.get("left"); | ||
if (left.isMemberExpression()) return; | ||
if (left.isIdentifier()) { | ||
const localName = left.node.name; | ||
if (scope.getBinding(localName) !== path.scope.getBinding(localName)) { | ||
@@ -309,3 +291,2 @@ return; | ||
} | ||
const items = []; | ||
@@ -312,0 +293,0 @@ programScopeIds.forEach(localName => { |
{ | ||
"name": "@babel/helper-module-transforms", | ||
"version": "7.20.11", | ||
"version": "7.21.0", | ||
"description": "Babel helper functions for implementing ES6 module transformations", | ||
@@ -24,4 +24,4 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
"@babel/template": "^7.20.7", | ||
"@babel/traverse": "^7.20.10", | ||
"@babel/types": "^7.20.7" | ||
"@babel/traverse": "^7.21.0", | ||
"@babel/types": "^7.21.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
145246
1178
Updated@babel/traverse@^7.21.0
Updated@babel/types@^7.21.0