@babel/helper-module-transforms
Advanced tools
Comparing version 7.12.17 to 7.13.0
@@ -66,2 +66,3 @@ "use strict"; | ||
function rewriteModuleStatementsAndPrepareHeader(path, { | ||
loose, | ||
exportName, | ||
@@ -71,6 +72,7 @@ strict, | ||
strictMode, | ||
loose, | ||
noInterop, | ||
lazy, | ||
esNamespaceOnly | ||
esNamespaceOnly, | ||
constantReexports = loose, | ||
enumerableModuleMeta = loose | ||
}) { | ||
@@ -81,3 +83,3 @@ (0, _assert.default)((0, _helperModuleImports.isModule)(path), "Cannot process module statements in a script"); | ||
noInterop, | ||
loose, | ||
initializeReexports: constantReexports, | ||
lazy, | ||
@@ -106,3 +108,3 @@ esNamespaceOnly | ||
if ((0, _normalizeAndLoadMetadata.hasExports)(meta) && !strict) { | ||
headers.push(buildESModuleHeader(meta, loose)); | ||
headers.push(buildESModuleHeader(meta, enumerableModuleMeta)); | ||
} | ||
@@ -117,3 +119,3 @@ | ||
headers.push(...buildExportInitializationStatements(path, meta, loose)); | ||
headers.push(...buildExportInitializationStatements(path, meta, constantReexports)); | ||
return { | ||
@@ -149,3 +151,3 @@ meta, | ||
function buildNamespaceInitStatements(metadata, sourceMetadata, loose = false) { | ||
function buildNamespaceInitStatements(metadata, sourceMetadata, constantReexports = false) { | ||
const statements = []; | ||
@@ -163,4 +165,4 @@ let srcNamespace = t.identifier(sourceMetadata.name); | ||
if (loose) { | ||
statements.push(...buildReexportsFromMeta(metadata, sourceMetadata, loose)); | ||
if (constantReexports) { | ||
statements.push(...buildReexportsFromMeta(metadata, sourceMetadata, true)); | ||
} | ||
@@ -184,3 +186,3 @@ | ||
if (sourceMetadata.reexportAll) { | ||
const statement = buildNamespaceReexport(metadata, t.cloneNode(srcNamespace), loose); | ||
const statement = buildNamespaceReexport(metadata, t.cloneNode(srcNamespace), constantReexports); | ||
statement.loc = sourceMetadata.reexportAll.loc; | ||
@@ -194,4 +196,4 @@ statements.push(statement); | ||
const ReexportTemplate = { | ||
loose: _template.default.statement`EXPORTS.EXPORT_NAME = NAMESPACE_IMPORT;`, | ||
looseComputed: _template.default.statement`EXPORTS["EXPORT_NAME"] = NAMESPACE_IMPORT;`, | ||
constant: _template.default.statement`EXPORTS.EXPORT_NAME = NAMESPACE_IMPORT;`, | ||
constantComputed: _template.default.statement`EXPORTS["EXPORT_NAME"] = NAMESPACE_IMPORT;`, | ||
spec: (0, _template.default)` | ||
@@ -207,3 +209,3 @@ Object.defineProperty(EXPORTS, "EXPORT_NAME", { | ||
const buildReexportsFromMeta = (meta, metadata, loose) => { | ||
const buildReexportsFromMeta = (meta, metadata, constantReexports) => { | ||
const namespace = metadata.lazy ? t.callExpression(t.identifier(metadata.name), []) : t.identifier(metadata.name); | ||
@@ -228,7 +230,7 @@ const { | ||
if (loose) { | ||
if (constantReexports) { | ||
if (stringSpecifiers.has(exportName)) { | ||
return ReexportTemplate.looseComputed(astNodes); | ||
return ReexportTemplate.constantComputed(astNodes); | ||
} else { | ||
return ReexportTemplate.loose(astNodes); | ||
return ReexportTemplate.constant(astNodes); | ||
} | ||
@@ -241,4 +243,4 @@ } else { | ||
function buildESModuleHeader(metadata, enumerable = false) { | ||
return (enumerable ? _template.default.statement` | ||
function buildESModuleHeader(metadata, enumerableModuleMeta = false) { | ||
return (enumerableModuleMeta ? _template.default.statement` | ||
EXPORTS.__esModule = true; | ||
@@ -254,4 +256,4 @@ ` : _template.default.statement` | ||
function buildNamespaceReexport(metadata, namespace, loose) { | ||
return (loose ? _template.default.statement` | ||
function buildNamespaceReexport(metadata, namespace, constantReexports) { | ||
return (constantReexports ? _template.default.statement` | ||
Object.keys(NAMESPACE).forEach(function(key) { | ||
@@ -320,3 +322,3 @@ if (key === "default" || key === "__esModule") return; | ||
function buildExportInitializationStatements(programPath, metadata, loose = false) { | ||
function buildExportInitializationStatements(programPath, metadata, constantReexports = false) { | ||
const initStatements = []; | ||
@@ -334,4 +336,4 @@ const exportNames = []; | ||
for (const data of metadata.source.values()) { | ||
if (!loose) { | ||
initStatements.push(...buildReexportsFromMeta(metadata, data, loose)); | ||
if (!constantReexports) { | ||
initStatements.push(...buildReexportsFromMeta(metadata, data, false)); | ||
} | ||
@@ -338,0 +340,0 @@ |
@@ -28,3 +28,3 @@ "use strict"; | ||
noInterop = false, | ||
loose = false, | ||
initializeReexports = false, | ||
lazy = false, | ||
@@ -44,3 +44,3 @@ esNamespaceOnly = false | ||
} = getModuleMetadata(programPath, { | ||
loose, | ||
initializeReexports, | ||
lazy | ||
@@ -89,6 +89,6 @@ }, stringSpecifiers); | ||
function getModuleMetadata(programPath, { | ||
loose, | ||
lazy | ||
lazy, | ||
initializeReexports | ||
}, stringSpecifiers) { | ||
const localData = getLocalExportMetadata(programPath, loose, stringSpecifiers); | ||
const localData = getLocalExportMetadata(programPath, initializeReexports, stringSpecifiers); | ||
const sourceData = new Map(); | ||
@@ -238,3 +238,3 @@ | ||
function getLocalExportMetadata(programPath, loose, stringSpecifiers) { | ||
function getLocalExportMetadata(programPath, initializeReexports, stringSpecifiers) { | ||
const bindingKindLookup = new Map(); | ||
@@ -252,3 +252,3 @@ programPath.get("body").forEach(child => { | ||
child = child.get("declaration"); | ||
} else if (loose && child.node.source && child.get("source").isStringLiteral()) { | ||
} else if (initializeReexports && child.node.source && child.get("source").isStringLiteral()) { | ||
child.node.specifiers.forEach(specifier => { | ||
@@ -304,3 +304,3 @@ bindingKindLookup.set(specifier.local.name, "block"); | ||
programPath.get("body").forEach(child => { | ||
if (child.isExportNamedDeclaration() && (loose || !child.node.source)) { | ||
if (child.isExportNamedDeclaration() && (initializeReexports || !child.node.source)) { | ||
if (child.node.declaration) { | ||
@@ -307,0 +307,0 @@ const declaration = child.get("declaration"); |
{ | ||
"name": "@babel/helper-module-transforms", | ||
"version": "7.12.17", | ||
"version": "7.13.0", | ||
"description": "Babel helper functions for implementing ES6 module transformations", | ||
@@ -19,3 +19,3 @@ "author": "Logan Smyth <loganfsmyth@gmail.com>", | ||
"@babel/helper-module-imports": "^7.12.13", | ||
"@babel/helper-replace-supers": "^7.12.13", | ||
"@babel/helper-replace-supers": "^7.13.0", | ||
"@babel/helper-simple-access": "^7.12.13", | ||
@@ -25,6 +25,6 @@ "@babel/helper-split-export-declaration": "^7.12.13", | ||
"@babel/template": "^7.12.13", | ||
"@babel/traverse": "^7.12.17", | ||
"@babel/types": "^7.12.17", | ||
"@babel/traverse": "^7.13.0", | ||
"@babel/types": "^7.13.0", | ||
"lodash": "^4.17.19" | ||
} | ||
} |
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
37877
921
Updated@babel/traverse@^7.13.0
Updated@babel/types@^7.13.0