@parcel/scope-hoisting
Advanced tools
Comparing version 2.0.0-nightly.263 to 2.0.0-nightly.266
@@ -541,6 +541,2 @@ "use strict"; | ||
exit(path) { | ||
if (path.getData('parcelInserted')) { | ||
return; | ||
} | ||
let { | ||
@@ -573,8 +569,11 @@ object, | ||
let { | ||
parent | ||
} = path; // Check if $id$export$name exists and if so, replace the node by it. | ||
parent, | ||
parentPath | ||
} = path; // If inside an expression, update the actual export binding as well | ||
if ((0, t.isAssignmentExpression)(parent)) { | ||
if ((0, t.isAssignmentExpression)(parent, { | ||
left: path.node | ||
})) { | ||
if ((0, t.isIdentifier)(parent.right)) { | ||
maybeReplaceIdentifier(path.parentPath.get('right')); // do not modify `$id$exports.foo = $id$export$foo` statements | ||
maybeReplaceIdentifier(parentPath.get('right')); // do not modify `$id$exports.foo = $id$export$foo` statements | ||
@@ -586,9 +585,9 @@ if ((0, t.isIdentifier)(parent.right, { | ||
} | ||
} | ||
} // turn `$exports.foo = ...` into `$exports.foo = $export$foo = ...` | ||
let [stmt] = path.parentPath.parentPath.insertAfter(t.expressionStatement(t.assignmentExpression('=', t.cloneNode(path.node), t.identifier(identifier)))); | ||
stmt.get('expression.left').setData('parcelInserted', true); | ||
parentPath.get('right').replaceWith(t.assignmentExpression('=', t.identifier(identifier), parent.right)); | ||
} else { | ||
path.replaceWith(t.identifier(identifier)); | ||
} | ||
path.replaceWith(t.identifier(identifier)); | ||
} | ||
@@ -595,0 +594,0 @@ |
{ | ||
"name": "@parcel/scope-hoisting", | ||
"version": "2.0.0-nightly.263+64ae007b", | ||
"version": "2.0.0-nightly.266+4210f2fb", | ||
"description": "Blazing fast, zero configuration web application bundler", | ||
@@ -24,9 +24,9 @@ "license": "MIT", | ||
"@babel/types": "^7.3.3", | ||
"@parcel/babylon-walk": "2.0.0-nightly.1885+64ae007b", | ||
"@parcel/diagnostic": "2.0.0-nightly.263+64ae007b", | ||
"@parcel/babylon-walk": "2.0.0-nightly.1888+4210f2fb", | ||
"@parcel/diagnostic": "2.0.0-nightly.266+4210f2fb", | ||
"@parcel/source-map": "2.0.0-alpha.4.9", | ||
"@parcel/utils": "2.0.0-nightly.263+64ae007b", | ||
"@parcel/utils": "2.0.0-nightly.266+4210f2fb", | ||
"nullthrows": "^1.1.1" | ||
}, | ||
"gitHead": "64ae007b915561aa5c5dab10a49d1f10c2df4954" | ||
"gitHead": "4210f2fbf1f5973be24fa268a7bb9b6d52ba326b" | ||
} |
@@ -13,2 +13,3 @@ // @flow | ||
import type { | ||
Node, | ||
Expression, | ||
@@ -19,3 +20,2 @@ File, | ||
LVal, | ||
MemberExpression, | ||
ObjectProperty, | ||
@@ -608,6 +608,2 @@ Statement, | ||
exit(path) { | ||
if (path.getData('parcelInserted')) { | ||
return; | ||
} | ||
let {object, property, computed} = path.node; | ||
@@ -636,8 +632,8 @@ if ( | ||
let {parent} = path; | ||
// Check if $id$export$name exists and if so, replace the node by it. | ||
if (isAssignmentExpression(parent)) { | ||
let {parent, parentPath} = path; | ||
// If inside an expression, update the actual export binding as well | ||
if (isAssignmentExpression(parent, {left: path.node})) { | ||
if (isIdentifier(parent.right)) { | ||
maybeReplaceIdentifier( | ||
path.parentPath.get<NodePath<Identifier>>('right'), | ||
parentPath.get<NodePath<Identifier>>('right'), | ||
); | ||
@@ -650,18 +646,16 @@ | ||
} | ||
let [stmt] = path.parentPath.parentPath.insertAfter( | ||
t.expressionStatement( | ||
// turn `$exports.foo = ...` into `$exports.foo = $export$foo = ...` | ||
parentPath | ||
.get<NodePath<Node>>('right') | ||
.replaceWith( | ||
t.assignmentExpression( | ||
'=', | ||
t.cloneNode(path.node), | ||
t.identifier(identifier), | ||
parent.right, | ||
), | ||
), | ||
); | ||
stmt | ||
.get<NodePath<MemberExpression>>('expression.left') | ||
.setData('parcelInserted', true); | ||
); | ||
} else { | ||
path.replaceWith(t.identifier(identifier)); | ||
} | ||
path.replaceWith(t.identifier(identifier)); | ||
}, | ||
@@ -668,0 +662,0 @@ }, |
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
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
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
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
224918
5993