Skip to content

Commit a822784

Browse files
authored
Merge pull request webpack#4696 from webpack/bugfix/parser-refactoring
parser refactoring bugfix
2 parents 813053e + ba3688a commit a822784

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎lib/Parser.js‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ class Parser extends Tapable {
708708
{
709709
const renameIdentifier = declarator.init && this.getRenameIdentifier(declarator.init);
710710
if(renameIdentifier && declarator.id.type === "Identifier" && this.applyPluginsBailResult1("can-rename " + renameIdentifier, declarator.init)) {
711-
// renaming with "const a = b;"
711+
// renaming with "var a = b;"
712712
if(!this.applyPluginsBailResult1("rename " + renameIdentifier, declarator.init)) {
713713
this.scope.renames["$" + declarator.id.name] = this.scope.renames["$" + renameIdentifier] || renameIdentifier;
714714
const idx = this.scope.definitions.indexOf(declarator.id.name);
@@ -717,9 +717,11 @@ class Parser extends Tapable {
717717
} else {
718718
this.walkPattern(declarator.id);
719719
this.enterPattern(declarator.id, (name, decl) => {
720-
if(!this.applyPluginsBailResult1("const " + name, decl)) {
721-
this.scope.renames["$" + name] = undefined;
722-
this.scope.definitions.push(name);
720+
if(!this.applyPluginsBailResult1("var-" + declarator.kind + " " + name, decl)) {
721+
if(!this.applyPluginsBailResult1("var " + name, decl)) {
722+
this.scope.renames["$" + name] = undefined;
723+
this.scope.definitions.push(name);
724+
}
723725
}
724726
});
725727
if(declarator.init)

0 commit comments

Comments
 (0)