@babel/helper-module-transforms
Advanced tools
Comparing version 7.19.6 to 7.20.2
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.getDynamicImportSource = getDynamicImportSource; | ||
var t = require("@babel/types"); | ||
var _template = require("@babel/template"); | ||
@@ -12,0 +10,0 @@ |
@@ -12,3 +12,2 @@ "use strict"; | ||
var _pluginOpts$moduleId, _pluginOpts$moduleIds, _pluginOpts$getModule, _pluginOpts$moduleRoo; | ||
return originalGetModuleName(rootOpts, { | ||
@@ -22,3 +21,2 @@ moduleId: (_pluginOpts$moduleId = pluginOpts.moduleId) != null ? _pluginOpts$moduleId : rootOpts.moduleId, | ||
} | ||
function getModuleName(rootOpts, pluginOpts) { | ||
@@ -41,12 +39,11 @@ const { | ||
} | ||
let moduleName = moduleRoot != null ? moduleRoot + "/" : ""; | ||
if (filenameRelative) { | ||
const sourceRootReplacer = sourceRoot != null ? new RegExp("^" + sourceRoot + "/?") : ""; | ||
moduleName += filenameRelative.replace(sourceRootReplacer, "").replace(/\.(\w*?)$/, ""); | ||
moduleName += filenameRelative | ||
.replace(sourceRootReplacer, "") | ||
.replace(/\.(\w*?)$/, ""); | ||
} | ||
moduleName = moduleName.replace(/\\/g, "/"); | ||
if (getModuleId) { | ||
@@ -53,0 +50,0 @@ return getModuleId(moduleName) || moduleName; |
@@ -46,21 +46,11 @@ "use strict"; | ||
exports.wrapInterop = wrapInterop; | ||
var _assert = require("assert"); | ||
var _t = require("@babel/types"); | ||
var _template = require("@babel/template"); | ||
var _helperModuleImports = require("@babel/helper-module-imports"); | ||
var _rewriteThis = require("./rewrite-this"); | ||
var _rewriteLiveReferences = require("./rewrite-live-references"); | ||
var _normalizeAndLoadMetadata = require("./normalize-and-load-metadata"); | ||
var _dynamicImport = require("./dynamic-import"); | ||
var _getModuleName = require("./get-module-name"); | ||
const { | ||
@@ -81,3 +71,2 @@ booleanLiteral, | ||
} = _t; | ||
function rewriteModuleStatementsAndPrepareHeader(path, { | ||
@@ -99,5 +88,3 @@ loose, | ||
(0, _normalizeAndLoadMetadata.validateImportInteropOption)(importInterop); | ||
_assert((0, _helperModuleImports.isModule)(path), "Cannot process module statements in a script"); | ||
path.node.sourceType = "script"; | ||
@@ -111,9 +98,6 @@ const meta = (0, _normalizeAndLoadMetadata.default)(path, exportName, { | ||
}); | ||
if (!allowTopLevelThis) { | ||
(0, _rewriteThis.default)(path); | ||
} | ||
(0, _rewriteLiveReferences.default)(path, meta); | ||
if (strictMode !== false) { | ||
@@ -123,3 +107,2 @@ const hasStrict = path.node.directives.some(directive => { | ||
}); | ||
if (!hasStrict) { | ||
@@ -129,11 +112,7 @@ path.unshiftContainer("directives", directive(directiveLiteral("use strict"))); | ||
} | ||
const headers = []; | ||
if ((0, _normalizeAndLoadMetadata.hasExports)(meta) && !strict) { | ||
headers.push(buildESModuleHeader(meta, enumerableModuleMeta)); | ||
} | ||
const nameList = buildExportNameListDeclaration(path, meta); | ||
if (nameList) { | ||
@@ -161,3 +140,2 @@ meta.exportNameListName = nameList.name; | ||
} | ||
if (type === "node-namespace") { | ||
@@ -168,5 +146,3 @@ return callExpression(programPath.hub.addHelper("interopRequireWildcard"), [expr, booleanLiteral(true)]); | ||
} | ||
let helper; | ||
if (type === "default") { | ||
@@ -179,3 +155,2 @@ helper = "interopRequireDefault"; | ||
} | ||
return callExpression(programPath.hub.addHelper(helper), [expr]); | ||
@@ -188,5 +163,5 @@ } | ||
if (sourceMetadata.lazy) srcNamespace = callExpression(srcNamespace, []); | ||
for (const localName of sourceMetadata.importsNamespace) { | ||
if (localName === sourceMetadata.name) continue; | ||
statements.push(_template.default.statement`var NAME = SOURCE;`({ | ||
@@ -197,7 +172,5 @@ NAME: localName, | ||
} | ||
if (constantReexports) { | ||
statements.push(...buildReexportsFromMeta(metadata, sourceMetadata, true)); | ||
} | ||
for (const exportName of sourceMetadata.reexportNamespace) { | ||
@@ -217,12 +190,10 @@ statements.push((sourceMetadata.lazy ? _template.default.statement` | ||
} | ||
if (sourceMetadata.reexportAll) { | ||
const statement = buildNamespaceReexport(metadata, cloneNode(srcNamespace), constantReexports); | ||
statement.loc = sourceMetadata.reexportAll.loc; | ||
statements.push(statement); | ||
} | ||
return statements; | ||
} | ||
const ReexportTemplate = { | ||
@@ -240,4 +211,3 @@ constant: _template.default.statement`EXPORTS.EXPORT_NAME = NAMESPACE_IMPORT;`, | ||
}; | ||
const buildReexportsFromMeta = (meta, metadata, constantReexports) => { | ||
function buildReexportsFromMeta(meta, metadata, constantReexports) { | ||
const namespace = metadata.lazy ? callExpression(identifier(metadata.name), []) : identifier(metadata.name); | ||
@@ -249,4 +219,4 @@ const { | ||
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); | ||
@@ -256,3 +226,2 @@ } else { | ||
} | ||
const astNodes = { | ||
@@ -263,3 +232,2 @@ EXPORTS: meta.exportName, | ||
}; | ||
if (constantReexports || isIdentifier(NAMESPACE_IMPORT)) { | ||
@@ -275,3 +243,3 @@ if (stringSpecifiers.has(exportName)) { | ||
}); | ||
}; | ||
} | ||
@@ -299,3 +267,4 @@ function buildESModuleHeader(metadata, enumerableModuleMeta = false) { | ||
}); | ||
` : _template.default.statement` | ||
` : | ||
_template.default.statement` | ||
Object.keys(NAMESPACE).forEach(function(key) { | ||
@@ -326,3 +295,2 @@ if (key === "default" || key === "__esModule") return; | ||
const exportedVars = Object.create(null); | ||
for (const data of metadata.local.values()) { | ||
@@ -333,5 +301,3 @@ for (const name of data.names) { | ||
} | ||
let hasReexport = false; | ||
for (const data of metadata.source.values()) { | ||
@@ -341,10 +307,7 @@ for (const exportName of data.reexports.keys()) { | ||
} | ||
for (const exportName of data.reexportNamespace) { | ||
exportedVars[exportName] = true; | ||
} | ||
hasReexport = hasReexport || !!data.reexportAll; | ||
} | ||
if (!hasReexport || Object.keys(exportedVars).length === 0) return null; | ||
@@ -361,6 +324,7 @@ const name = programPath.scope.generateUidIdentifier("exportNames"); | ||
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) { | ||
@@ -372,3 +336,2 @@ for (const exportName of data.names) { | ||
} | ||
for (const data of metadata.source.values()) { | ||
@@ -378,3 +341,2 @@ if (!constantReexports) { | ||
const reexports = [...data.reexports.keys()]; | ||
for (let i = 0; i < reexportsStatements.length; i++) { | ||
@@ -384,3 +346,2 @@ initStatements.push([reexports[i], reexportsStatements[i]]); | ||
} | ||
if (!noIncompleteNsImportDetection) { | ||
@@ -399,3 +360,2 @@ for (const exportName of data.reexportNamespace) { | ||
const results = []; | ||
if (noIncompleteNsImportDetection) { | ||
@@ -407,9 +367,6 @@ for (const [, initStatement] of initStatements) { | ||
const chunkSize = 100; | ||
for (let i = 0; i < initStatements.length; i += chunkSize) { | ||
let uninitializedExportNames = []; | ||
for (let j = 0; j < chunkSize && i + j < initStatements.length; j++) { | ||
const [exportName, initStatement] = initStatements[i + j]; | ||
if (initStatement !== null) { | ||
@@ -420,3 +377,2 @@ if (uninitializedExportNames.length > 0) { | ||
} | ||
results.push(initStatement); | ||
@@ -427,3 +383,2 @@ } else { | ||
} | ||
if (uninitializedExportNames.length > 0) { | ||
@@ -434,3 +389,2 @@ results.push(buildInitStatement(metadata, uninitializedExportNames, programPath.scope.buildUndefinedNode())); | ||
} | ||
return results; | ||
@@ -443,3 +397,2 @@ } | ||
}; | ||
function buildInitStatement(metadata, exportNames, initExpr) { | ||
@@ -456,3 +409,2 @@ const { | ||
}; | ||
if (stringSpecifiers.has(exportName)) { | ||
@@ -459,0 +411,0 @@ return InitTemplate.computed(params); |
@@ -10,9 +10,5 @@ "use strict"; | ||
exports.validateImportInteropOption = validateImportInteropOption; | ||
var _path = require("path"); | ||
var _helperValidatorIdentifier = require("@babel/helper-validator-identifier"); | ||
var _helperSplitExportDeclaration = require("@babel/helper-split-export-declaration"); | ||
function hasExports(metadata) { | ||
@@ -25,3 +21,2 @@ return metadata.hasExports; | ||
} | ||
function validateImportInteropOption(importInterop) { | ||
@@ -31,6 +26,4 @@ if (typeof importInterop !== "function" && importInterop !== "none" && importInterop !== "babel" && importInterop !== "node") { | ||
} | ||
return importInterop; | ||
} | ||
function resolveImportInterop(importInterop, source, filename) { | ||
@@ -40,3 +33,2 @@ if (typeof importInterop === "function") { | ||
} | ||
return importInterop; | ||
@@ -55,3 +47,2 @@ } | ||
} | ||
const stringSpecifiers = new Set(); | ||
@@ -73,5 +64,3 @@ nameAnonymousExports(programPath); | ||
} | ||
const resolvedInterop = resolveImportInterop(importInterop, metadata.source, filename); | ||
if (resolvedInterop === "none") { | ||
@@ -87,3 +76,2 @@ metadata.interop = "none"; | ||
} | ||
return { | ||
@@ -98,3 +86,2 @@ exportName, | ||
} | ||
function getExportSpecifierName(path, stringSpecifiers) { | ||
@@ -105,7 +92,5 @@ if (path.isIdentifier()) { | ||
const stringValue = path.node.value; | ||
if (!(0, _helperValidatorIdentifier.isIdentifierName)(stringValue)) { | ||
stringSpecifiers.add(stringValue); | ||
} | ||
return stringValue; | ||
@@ -116,3 +101,2 @@ } else { | ||
} | ||
function assertExportSpecifier(path) { | ||
@@ -134,7 +118,5 @@ if (path.isExportSpecifier()) { | ||
const sourceData = new Map(); | ||
const getData = sourceNode => { | ||
const source = sourceNode.value; | ||
let data = sourceData.get(source); | ||
if (!data) { | ||
@@ -155,6 +137,4 @@ data = { | ||
} | ||
return data; | ||
}; | ||
let hasExports = false; | ||
@@ -170,3 +150,2 @@ programPath.get("body").forEach(child => { | ||
const reexport = localData.get(localName); | ||
if (reexport) { | ||
@@ -182,3 +161,2 @@ localData.delete(localName); | ||
const reexport = localData.get(localName); | ||
if (reexport) { | ||
@@ -195,3 +173,2 @@ localData.delete(localName); | ||
const reexport = localData.get(localName); | ||
if (reexport) { | ||
@@ -221,3 +198,2 @@ localData.delete(localName); | ||
data.reexports.set(exportName, importName); | ||
if (exportName === "__esModule") { | ||
@@ -231,7 +207,5 @@ throw spec.get("exported").buildCodeFrameError('Illegal export "__esModule".'); | ||
}); | ||
for (const metadata of sourceData.values()) { | ||
let needsDefault = false; | ||
let needsNamed = false; | ||
if (metadata.importsNamespace.size > 0) { | ||
@@ -241,15 +215,11 @@ needsDefault = true; | ||
} | ||
if (metadata.reexportAll) { | ||
needsNamed = true; | ||
} | ||
for (const importName of metadata.imports.values()) { | ||
if (importName === "default") needsDefault = true;else needsNamed = true; | ||
} | ||
for (const importName of metadata.reexports.values()) { | ||
if (importName === "default") needsDefault = true;else needsNamed = true; | ||
} | ||
if (needsDefault && needsNamed) { | ||
@@ -261,3 +231,2 @@ metadata.interop = "namespace"; | ||
} | ||
for (const [source, metadata] of sourceData) { | ||
@@ -276,3 +245,2 @@ if (lazy !== false && !(isSideEffectImport(metadata) || metadata.reexportAll)) { | ||
} | ||
return { | ||
@@ -284,3 +252,2 @@ hasExports, | ||
} | ||
function getLocalExportMetadata(programPath, initializeReexports, stringSpecifiers) { | ||
@@ -290,3 +257,2 @@ const bindingKindLookup = new Map(); | ||
let kind; | ||
if (child.isImportDeclaration()) { | ||
@@ -298,3 +264,2 @@ kind = "import"; | ||
} | ||
if (child.isExportNamedDeclaration()) { | ||
@@ -311,3 +276,2 @@ if (child.node.declaration) { | ||
} | ||
if (child.isFunctionDeclaration()) { | ||
@@ -327,3 +291,2 @@ kind = "hoisted"; | ||
} | ||
Object.keys(child.getOuterBindingIdentifiers()).forEach(name => { | ||
@@ -334,14 +297,10 @@ bindingKindLookup.set(name, kind); | ||
const localMetadata = new Map(); | ||
const getLocalMetadata = idPath => { | ||
const localName = idPath.node.name; | ||
let metadata = localMetadata.get(localName); | ||
if (!metadata) { | ||
const kind = bindingKindLookup.get(localName); | ||
if (kind === undefined) { | ||
throw idPath.buildCodeFrameError(`Exporting local "${localName}", which is not declared.`); | ||
} | ||
metadata = { | ||
@@ -353,6 +312,4 @@ names: [], | ||
} | ||
return metadata; | ||
}; | ||
programPath.get("body").forEach(child => { | ||
@@ -367,3 +324,2 @@ if (child.isExportNamedDeclaration() && (initializeReexports || !child.node.source)) { | ||
} | ||
getLocalMetadata(ids[name]).names.push(name); | ||
@@ -377,7 +333,5 @@ }); | ||
const exportName = getExportSpecifierName(exported, stringSpecifiers); | ||
if (exportName === "__esModule") { | ||
throw exported.buildCodeFrameError('Illegal export "__esModule".'); | ||
} | ||
localMetadata.names.push(exportName); | ||
@@ -388,3 +342,2 @@ }); | ||
const declaration = child.get("declaration"); | ||
if (declaration.isFunctionDeclaration() || declaration.isClassDeclaration()) { | ||
@@ -406,3 +359,2 @@ getLocalMetadata(declaration.get("id")).names.push("default"); | ||
} | ||
function removeModuleDeclarations(programPath) { | ||
@@ -421,3 +373,2 @@ programPath.get("body").forEach(child => { | ||
const declaration = child.get("declaration"); | ||
if (declaration.isFunctionDeclaration() || declaration.isClassDeclaration()) { | ||
@@ -424,0 +375,0 @@ declaration._blockHoist = child.node._blockHoist; |
@@ -7,11 +7,6 @@ "use strict"; | ||
exports.default = rewriteLiveReferences; | ||
var _assert = require("assert"); | ||
var _t = require("@babel/types"); | ||
var _template = require("@babel/template"); | ||
var _helperSimpleAccess = require("@babel/helper-simple-access"); | ||
const { | ||
@@ -35,3 +30,2 @@ assignmentExpression, | ||
} = _t; | ||
function isInType(path) { | ||
@@ -46,6 +40,4 @@ do { | ||
return true; | ||
case "ExportSpecifier": | ||
return path.parentPath.parent.exportKind === "type"; | ||
default: | ||
@@ -55,15 +47,11 @@ if (path.parentPath.isStatement() || path.parentPath.isExpression()) { | ||
} | ||
} | ||
} while (path = path.parentPath); | ||
} | ||
function rewriteLiveReferences(programPath, metadata) { | ||
const imported = new Map(); | ||
const exported = new Map(); | ||
const requeueInParent = path => { | ||
programPath.requeue(path); | ||
}; | ||
for (const [source, data] of metadata.source) { | ||
@@ -73,3 +61,2 @@ for (const [localName, importName] of data.imports) { | ||
} | ||
for (const localName of data.importsNamespace) { | ||
@@ -79,6 +66,4 @@ imported.set(localName, [source, null, localName]); | ||
} | ||
for (const [local, data] of metadata.local) { | ||
let exportMeta = exported.get(local); | ||
if (!exportMeta) { | ||
@@ -88,3 +73,2 @@ exportMeta = []; | ||
} | ||
exportMeta.push(...data.names); | ||
@@ -99,4 +83,8 @@ } | ||
}; | ||
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 = { | ||
@@ -111,18 +99,14 @@ seen: new WeakSet(), | ||
const meta = metadata.source.get(source); | ||
if (localName) { | ||
if (meta.lazy) { | ||
identNode = callExpression(identNode, []); | ||
identNode = callExpression( | ||
identNode, []); | ||
} | ||
return identNode; | ||
} | ||
let namespace = identifier(meta.name); | ||
if (meta.lazy) namespace = callExpression(namespace, []); | ||
if (importName === "default" && meta.interop === "node-default") { | ||
return namespace; | ||
} | ||
const computed = metadata.stringSpecifiers.has(importName); | ||
@@ -139,3 +123,2 @@ return memberExpression(namespace, computed ? stringLiteral(importName) : identifier(importName), computed); | ||
}, | ||
ClassDeclaration(path) { | ||
@@ -153,5 +136,5 @@ const { | ||
const exportNames = exported.get(localName) || []; | ||
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; | ||
@@ -161,3 +144,2 @@ requeueInParent(path.insertAfter(statement)[0]); | ||
}, | ||
VariableDeclaration(path) { | ||
@@ -171,5 +153,5 @@ const { | ||
const exportNames = exported.get(localName) || []; | ||
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; | ||
@@ -180,8 +162,5 @@ requeueInParent(path.insertAfter(statement)[0]); | ||
} | ||
}; | ||
const buildBindingExportAssignmentExpression = (metadata, exportNames, localExpr, scope) => { | ||
const exportsObjectName = metadata.exportName; | ||
for (let currentScope = scope; currentScope != null; currentScope = currentScope.parent) { | ||
@@ -192,3 +171,2 @@ if (currentScope.hasOwnBinding(exportsObjectName)) { | ||
} | ||
return (exportNames || []).reduce((expr, exportName) => { | ||
@@ -202,3 +180,2 @@ const { | ||
}; | ||
const buildImportThrow = localName => { | ||
@@ -211,3 +188,2 @@ return _template.default.expression.ast` | ||
}; | ||
const rewriteReferencesVisitor = { | ||
@@ -226,3 +202,2 @@ ReferencedIdentifier(path) { | ||
const importData = imported.get(localName); | ||
if (importData) { | ||
@@ -232,9 +207,9 @@ if (isInType(path)) { | ||
} | ||
const localBinding = path.scope.getBinding(localName); | ||
const rootBinding = scope.getBinding(localName); | ||
if (rootBinding !== localBinding) return; | ||
const ref = buildImportReference(importData, path.node); | ||
ref.loc = path.node.loc; | ||
if ((path.parentPath.isCallExpression({ | ||
@@ -253,12 +228,13 @@ callee: path.node | ||
} = ref; | ||
path.replaceWith(jsxMemberExpression(jsxIdentifier(object.name), jsxIdentifier(property.name))); | ||
path.replaceWith(jsxMemberExpression( | ||
jsxIdentifier(object.name), | ||
jsxIdentifier(property.name))); | ||
} else { | ||
path.replaceWith(ref); | ||
} | ||
requeueInParent(path); | ||
requeueInParent(path); | ||
path.skip(); | ||
} | ||
}, | ||
UpdateExpression(path) { | ||
@@ -276,5 +252,5 @@ const { | ||
const arg = path.get("argument"); | ||
if (arg.isMemberExpression()) return; | ||
const update = path.node; | ||
if (arg.isIdentifier()) { | ||
@@ -286,6 +262,4 @@ const localName = arg.node.name; | ||
} | ||
const exportedNames = exported.get(localName); | ||
const importData = imported.get(localName); | ||
if ((exportedNames == null ? void 0 : exportedNames.length) > 0 || importData) { | ||
@@ -302,7 +276,5 @@ if (importData) { | ||
} | ||
requeueInParent(path); | ||
path.skip(); | ||
}, | ||
AssignmentExpression: { | ||
@@ -321,4 +293,4 @@ exit(path) { | ||
const left = path.get("left"); | ||
if (left.isMemberExpression()) return; | ||
if (left.isIdentifier()) { | ||
@@ -330,11 +302,7 @@ const localName = left.node.name; | ||
} | ||
const exportedNames = exported.get(localName); | ||
const importData = imported.get(localName); | ||
if ((exportedNames == null ? void 0 : exportedNames.length) > 0 || importData) { | ||
_assert(path.node.operator === "=", "Path was not simplified"); | ||
const assignment = path.node; | ||
if (importData) { | ||
@@ -344,3 +312,2 @@ assignment.left = buildImportReference(importData, left.node); | ||
} | ||
path.replaceWith(buildBindingExportAssignmentExpression(this.metadata, exportedNames, assignment, path.scope)); | ||
@@ -353,3 +320,2 @@ requeueInParent(path); | ||
const id = programScopeIds.find(localName => imported.has(localName)); | ||
if (id) { | ||
@@ -362,3 +328,2 @@ path.node.right = sequenceExpression([path.node.right, buildImportThrow(id)]); | ||
const exportedNames = exported.get(localName) || []; | ||
if (exportedNames.length > 0) { | ||
@@ -368,6 +333,4 @@ items.push(buildBindingExportAssignmentExpression(this.metadata, exportedNames, identifier(localName), path.scope)); | ||
}); | ||
if (items.length > 0) { | ||
let node = sequenceExpression(items); | ||
if (path.parentPath.isExpressionStatement()) { | ||
@@ -377,3 +340,2 @@ node = expressionStatement(node); | ||
} | ||
const statement = path.insertAfter(node)[0]; | ||
@@ -384,5 +346,3 @@ requeueInParent(statement); | ||
} | ||
}, | ||
"ForOfStatement|ForInStatement"(path) { | ||
@@ -401,8 +361,6 @@ const { | ||
} = this; | ||
if (!isVariableDeclaration(left)) { | ||
let didTransformExport = false, | ||
importConstViolationName; | ||
importConstViolationName; | ||
const loopBodyScope = path.get("body").scope; | ||
for (const name of Object.keys(getOuterBindingIdentifiers(left))) { | ||
@@ -412,3 +370,2 @@ if (programScope.getBinding(name) === scope.getBinding(name)) { | ||
didTransformExport = true; | ||
if (loopBodyScope.hasOwnBinding(name)) { | ||
@@ -418,3 +375,2 @@ loopBodyScope.rename(name); | ||
} | ||
if (imported.has(name) && !importConstViolationName) { | ||
@@ -425,7 +381,5 @@ importConstViolationName = name; | ||
} | ||
if (!didTransformExport && !importConstViolationName) { | ||
return; | ||
} | ||
path.ensureBlock(); | ||
@@ -436,7 +390,5 @@ const bodyPath = path.get("body"); | ||
scope.registerDeclaration(path.get("left")); | ||
if (didTransformExport) { | ||
bodyPath.unshiftContainer("body", expressionStatement(assignmentExpression("=", left, newLoopId))); | ||
} | ||
if (importConstViolationName) { | ||
@@ -447,5 +399,4 @@ bodyPath.unshiftContainer("body", expressionStatement(buildImportThrow(importConstViolationName))); | ||
} | ||
}; | ||
//# sourceMappingURL=rewrite-live-references.js.map |
@@ -7,9 +7,5 @@ "use strict"; | ||
exports.default = rewriteThis; | ||
var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor"); | ||
var _traverse = require("@babel/traverse"); | ||
var _t = require("@babel/types"); | ||
const { | ||
@@ -19,3 +15,7 @@ numericLiteral, | ||
} = _t; | ||
const rewriteThisVisitor = _traverse.default.visitors.merge([_helperEnvironmentVisitor.default, { | ||
ThisExpression(path) { | ||
path.replaceWith(unaryExpression("void", numericLiteral(0), true)); | ||
} | ||
}]); | ||
function rewriteThis(programPath) { | ||
@@ -27,9 +27,2 @@ (0, _traverse.default)(programPath.node, Object.assign({}, rewriteThisVisitor, { | ||
const rewriteThisVisitor = _traverse.default.visitors.merge([_helperEnvironmentVisitor.default, { | ||
ThisExpression(path) { | ||
path.replaceWith(unaryExpression("void", numericLiteral(0), true)); | ||
} | ||
}]); | ||
//# sourceMappingURL=rewrite-this.js.map |
{ | ||
"name": "@babel/helper-module-transforms", | ||
"version": "7.19.6", | ||
"version": "7.20.2", | ||
"description": "Babel helper functions for implementing ES6 module transformations", | ||
@@ -20,8 +20,8 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
"@babel/helper-module-imports": "^7.18.6", | ||
"@babel/helper-simple-access": "^7.19.4", | ||
"@babel/helper-simple-access": "^7.20.2", | ||
"@babel/helper-split-export-declaration": "^7.18.6", | ||
"@babel/helper-validator-identifier": "^7.19.1", | ||
"@babel/template": "^7.18.10", | ||
"@babel/traverse": "^7.19.6", | ||
"@babel/types": "^7.19.4" | ||
"@babel/traverse": "^7.20.1", | ||
"@babel/types": "^7.20.2" | ||
}, | ||
@@ -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
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
141310
1151
Updated@babel/traverse@^7.20.1
Updated@babel/types@^7.20.2