From 7a3df06eb573d36142bd1a8e03c5ce8752d300b3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 24 May 2017 15:10:37 +0200 Subject: fix build issues and add typedoc --- node_modules/webpack/lib/Parser.js | 53 ++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'node_modules/webpack/lib/Parser.js') diff --git a/node_modules/webpack/lib/Parser.js b/node_modules/webpack/lib/Parser.js index 02db5c562..bd81b55ab 100644 --- a/node_modules/webpack/lib/Parser.js +++ b/node_modules/webpack/lib/Parser.js @@ -636,6 +636,9 @@ class Parser extends Tapable { } walkFunctionDeclaration(statement) { + statement.params.forEach(param => { + this.walkPattern(param); + }); this.inScope(statement.params, function() { if(statement.body.type === "BlockStatement") { this.prewalkStatement(statement.body); @@ -797,24 +800,15 @@ class Parser extends Tapable { switch(declarator.type) { case "VariableDeclarator": { - const renameIdentifier = declarator.init && this.getRenameIdentifier(declarator.init); - if(renameIdentifier && declarator.id.type === "Identifier" && this.applyPluginsBailResult1("can-rename " + renameIdentifier, declarator.init)) { - // renaming with "var a = b;" - if(!this.applyPluginsBailResult1("rename " + renameIdentifier, declarator.init)) { - this.scope.renames["$" + declarator.id.name] = this.scope.renames["$" + renameIdentifier] || renameIdentifier; - const idx = this.scope.definitions.indexOf(declarator.id.name); - if(idx >= 0) this.scope.definitions.splice(idx, 1); - } - } else { - this.enterPattern(declarator.id, (name, decl) => { - if(!this.applyPluginsBailResult1("var-" + declarator.kind + " " + name, decl)) { - if(!this.applyPluginsBailResult1("var " + name, decl)) { - this.scope.renames["$" + name] = undefined; + this.enterPattern(declarator.id, (name, decl) => { + if(!this.applyPluginsBailResult1("var-" + declarator.kind + " " + name, decl)) { + if(!this.applyPluginsBailResult1("var " + name, decl)) { + this.scope.renames["$" + name] = undefined; + if(this.scope.definitions.indexOf(name) < 0) this.scope.definitions.push(name); - } } - }); - } + } + }); break; } } @@ -827,7 +821,14 @@ class Parser extends Tapable { case "VariableDeclarator": { const renameIdentifier = declarator.init && this.getRenameIdentifier(declarator.init); - if(!renameIdentifier || declarator.id.type !== "Identifier" || !this.applyPluginsBailResult1("can-rename " + renameIdentifier, declarator.init)) { + if(renameIdentifier && declarator.id.type === "Identifier" && this.applyPluginsBailResult1("can-rename " + renameIdentifier, declarator.init)) { + // renaming with "var a = b;" + if(!this.applyPluginsBailResult1("rename " + renameIdentifier, declarator.init)) { + this.scope.renames["$" + declarator.id.name] = this.scope.renames["$" + renameIdentifier] || renameIdentifier; + const idx = this.scope.definitions.indexOf(declarator.id.name); + if(idx >= 0) this.scope.definitions.splice(idx, 1); + } + } else { this.walkPattern(declarator.id); if(declarator.init) this.walkExpression(declarator.init); @@ -845,6 +846,11 @@ class Parser extends Tapable { this["walk" + pattern.type](pattern); } + walkAssignmentPattern(pattern) { + this.walkExpression(pattern.right); + this.walkPattern(pattern.left); + } + walkObjectPattern(pattern) { for(let i = 0, len = pattern.properties.length; i < len; i++) { const prop = pattern.properties[i]; @@ -912,6 +918,9 @@ class Parser extends Tapable { } walkFunctionExpression(expression) { + expression.params.forEach(param => { + this.walkPattern(param); + }); this.inScope(expression.params, function() { if(expression.body.type === "BlockStatement") { this.prewalkStatement(expression.body); @@ -923,6 +932,9 @@ class Parser extends Tapable { } walkArrowFunctionExpression(expression) { + expression.params.forEach(param => { + this.walkPattern(param); + }); this.inScope(expression.params, function() { if(expression.body.type === "BlockStatement") { this.prewalkStatement(expression.body); @@ -993,8 +1005,10 @@ class Parser extends Tapable { } } else { this.walkExpression(expression.right); - this.scope.renames["$" + expression.left.name] = undefined; - this.walkExpression(expression.left); + this.walkPattern(expression.left); + this.enterPattern(expression.left, (name, decl) => { + this.scope.renames["$" + name] = undefined; + }); } } @@ -1191,7 +1205,6 @@ class Parser extends Tapable { enterAssignmentPattern(pattern, onIdent) { this.enterPattern(pattern.left, onIdent); - this.walkExpression(pattern.right); } evaluateExpression(expression) { -- cgit v1.2.3