@parcel/scope-hoisting
Advanced tools
Comparing version 2.0.0-nightly.88 to 2.0.0-nightly.92
@@ -185,4 +185,9 @@ "use strict"; | ||
if (symbol === '*') { | ||
for (let symbol of resolvedAsset.symbols.keys()) { | ||
markUsed(resolvedAsset, symbol); | ||
for (let { | ||
asset, | ||
symbol | ||
} of bundleGraph.getExportedSymbols(resolvedAsset)) { | ||
if (symbol) { | ||
markUsed(asset, symbol); | ||
} | ||
} | ||
@@ -189,0 +194,0 @@ } |
@@ -27,3 +27,3 @@ "use strict"; | ||
const REQUIRE_TEMPLATE = (0, _template.default)('require(BUNDLE)'); | ||
const EXPORT_TEMPLATE = (0, _template.default)('exports.IDENTIFIER = IDENTIFIER'); | ||
const EXPORT_TEMPLATE = (0, _template.default)('exports.NAME = IDENTIFIER'); | ||
const MODULE_EXPORTS_TEMPLATE = (0, _template.default)('module.exports = IDENTIFIER'); | ||
@@ -202,2 +202,3 @@ const INTEROP_TEMPLATE = (0, _template.default)('$parcel$interopDefault(MODULE)'); | ||
statements.push(EXPORT_TEMPLATE({ | ||
NAME: t.identifier(exportsId), | ||
IDENTIFIER: t.identifier(exportsId) | ||
@@ -251,5 +252,7 @@ })); | ||
let binding = path.scope.getBinding(symbol); | ||
(0, _renamer.default)(path.scope, symbol, exportSymbol); | ||
let id = !t.isValidIdentifier(exportSymbol) ? path.scope.generateUid(exportSymbol) : exportSymbol; | ||
(0, _renamer.default)(path.scope, symbol, id); | ||
binding.path.getStatementParent().insertAfter(EXPORT_TEMPLATE({ | ||
IDENTIFIER: t.identifier(exportSymbol) | ||
NAME: t.identifier(exportSymbol), | ||
IDENTIFIER: t.identifier(id) | ||
})); // Exports other than the default export are live bindings. Insert an assignment | ||
@@ -261,3 +264,4 @@ // after each constant violation so this remains true. | ||
path.insertAfter(EXPORT_TEMPLATE({ | ||
IDENTIFIER: t.identifier(exportSymbol) | ||
NAME: t.identifier(exportSymbol), | ||
IDENTIFIER: t.identifier(id) | ||
})); | ||
@@ -264,0 +268,0 @@ } |
@@ -619,3 +619,5 @@ "use strict"; | ||
if (!scope.hasBinding(id.name)) { | ||
scope.getProgramParent().addGlobal(id); | ||
scope.getProgramParent().push({ | ||
id | ||
}); | ||
} | ||
@@ -622,0 +624,0 @@ |
@@ -188,3 +188,3 @@ "use strict"; | ||
if (binding) { | ||
parent = path.findParent(p => p.scope === binding.scope && p.isStatement()); | ||
parent = path.findParent(p => getScopeBefore(p) === binding.scope && p.isStatement()); | ||
} | ||
@@ -205,3 +205,3 @@ | ||
parent.scope.registerDeclaration(decl); | ||
getScopeBefore(parent).registerDeclaration(decl); | ||
} | ||
@@ -220,2 +220,6 @@ | ||
function getScopeBefore(path) { | ||
return path.isScope() ? path.parentPath.scope : path.scope; | ||
} | ||
function isUnusedValue(path) { | ||
@@ -222,0 +226,0 @@ return path.parentPath.isExpressionStatement() || path.parentPath.isSequenceExpression() && (path.key !== path.container.length - 1 || isUnusedValue(path.parentPath)); |
{ | ||
"name": "@parcel/scope-hoisting", | ||
"version": "2.0.0-nightly.88+7f447bec", | ||
"version": "2.0.0-nightly.92+c0655c56", | ||
"description": "Blazing fast, zero configuration web application bundler", | ||
@@ -24,7 +24,7 @@ "license": "MIT", | ||
"@babel/types": "^7.3.3", | ||
"@parcel/utils": "2.0.0-nightly.88+7f447bec", | ||
"@parcel/utils": "2.0.0-nightly.92+c0655c56", | ||
"babylon-walk": "^1.0.2", | ||
"nullthrows": "^1.1.1" | ||
}, | ||
"gitHead": "7f447bec1eaf6d16b64114658b0be67ae042bea5" | ||
"gitHead": "c0655c56f7973492fdb28671029ddd923f17a244" | ||
} |
@@ -167,4 +167,8 @@ // @flow | ||
if (symbol === '*') { | ||
for (let symbol of resolvedAsset.symbols.keys()) { | ||
markUsed(resolvedAsset, symbol); | ||
for (let {asset, symbol} of bundleGraph.getExportedSymbols( | ||
resolvedAsset, | ||
)) { | ||
if (symbol) { | ||
markUsed(asset, symbol); | ||
} | ||
} | ||
@@ -171,0 +175,0 @@ } |
@@ -12,3 +12,3 @@ // @flow | ||
const REQUIRE_TEMPLATE = template('require(BUNDLE)'); | ||
const EXPORT_TEMPLATE = template('exports.IDENTIFIER = IDENTIFIER'); | ||
const EXPORT_TEMPLATE = template('exports.NAME = IDENTIFIER'); | ||
const MODULE_EXPORTS_TEMPLATE = template('module.exports = IDENTIFIER'); | ||
@@ -245,2 +245,3 @@ const INTEROP_TEMPLATE = template('$parcel$interopDefault(MODULE)'); | ||
EXPORT_TEMPLATE({ | ||
NAME: t.identifier(exportsId), | ||
IDENTIFIER: t.identifier(exportsId), | ||
@@ -299,7 +300,11 @@ }), | ||
let binding = path.scope.getBinding(symbol); | ||
rename(path.scope, symbol, exportSymbol); | ||
let id = !t.isValidIdentifier(exportSymbol) | ||
? path.scope.generateUid(exportSymbol) | ||
: exportSymbol; | ||
rename(path.scope, symbol, id); | ||
binding.path.getStatementParent().insertAfter( | ||
EXPORT_TEMPLATE({ | ||
IDENTIFIER: t.identifier(exportSymbol), | ||
NAME: t.identifier(exportSymbol), | ||
IDENTIFIER: t.identifier(id), | ||
}), | ||
@@ -314,3 +319,4 @@ ); | ||
EXPORT_TEMPLATE({ | ||
IDENTIFIER: t.identifier(exportSymbol), | ||
NAME: t.identifier(exportSymbol), | ||
IDENTIFIER: t.identifier(id), | ||
}), | ||
@@ -317,0 +323,0 @@ ); |
@@ -685,3 +685,3 @@ // @flow | ||
if (!scope.hasBinding(id.name)) { | ||
scope.getProgramParent().addGlobal(id); | ||
scope.getProgramParent().push({id}); | ||
} | ||
@@ -688,0 +688,0 @@ |
@@ -179,3 +179,3 @@ // @flow | ||
parent = path.findParent( | ||
p => p.scope === binding.scope && p.isStatement(), | ||
p => getScopeBefore(p) === binding.scope && p.isStatement(), | ||
); | ||
@@ -199,3 +199,3 @@ } | ||
parent.scope.registerDeclaration(decl); | ||
getScopeBefore(parent).registerDeclaration(decl); | ||
} | ||
@@ -214,2 +214,6 @@ | ||
function getScopeBefore(path) { | ||
return path.isScope() ? path.parentPath.scope : path.scope; | ||
} | ||
function isUnusedValue(path) { | ||
@@ -216,0 +220,0 @@ return ( |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
165791
4336