Skip to content

Commit 619cf31

Browse files
committed
prewalk a function declaration
fixes webpack#4709
1 parent 0cbd8fd commit 619cf31

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/Parser.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,12 @@ class Parser extends Tapable {
637637

638638
walkFunctionDeclaration(statement) {
639639
this.inScope(statement.params, function() {
640-
if(statement.body.type === "BlockStatement")
640+
if(statement.body.type === "BlockStatement") {
641+
this.prewalkStatement(statement.body);
641642
this.walkStatement(statement.body);
642-
else
643+
} else {
643644
this.walkExpression(statement.body);
645+
}
644646
}.bind(this));
645647
}
646648

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function getDirectiveRequire(directive) {
2+
var require = directive.require || (directive.controller && directive.name);
3+
4+
if (!isArray(require) && isObject(require)) {
5+
forEach(require, function(value, key) {
6+
var match = value.match(REQUIRE_PREFIX_REGEXP);
7+
var name = value.substring(match[0].length);
8+
if (!name) require[key] = match[0] + key;
9+
});
10+
}
11+
12+
return require;
13+
}
14+
15+
it("should parse these snippets successfully", function() {
16+
17+
});

0 commit comments

Comments
 (0)