aboutsummaryrefslogtreecommitdiff
path: root/node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
commit0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch)
treef9864d4a4148621378958794cbbfdc2393733283 /node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js
parent6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff)
upgrade dependencies
Diffstat (limited to 'node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js')
-rw-r--r--node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js24
1 files changed, 18 insertions, 6 deletions
diff --git a/node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js b/node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js
index b8a4668df..227f68d36 100644
--- a/node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js
+++ b/node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js
@@ -23,6 +23,18 @@ function isBoundFunctionExpression(expr) {
return true;
}
+function isUnboundFunctionExpression(expr) {
+ if(expr.type === "FunctionExpression") return true;
+ if(expr.type === "ArrowFunctionExpression") return true;
+ return false;
+}
+
+function isCallable(expr) {
+ if(isUnboundFunctionExpression(expr)) return true;
+ if(isBoundFunctionExpression(expr)) return true;
+ return false;
+}
+
class AMDDefineDependencyParserPlugin {
constructor(options) {
this.options = options;
@@ -38,7 +50,7 @@ class AMDDefineDependencyParserPlugin {
let array, fn, obj, namedModule;
switch(expr.arguments.length) {
case 1:
- if(expr.arguments[0].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[0])) {
+ if(isCallable(expr.arguments[0])) {
// define(f() {...})
fn = expr.arguments[0];
} else if(expr.arguments[0].type === "ObjectExpression") {
@@ -54,7 +66,7 @@ class AMDDefineDependencyParserPlugin {
if(expr.arguments[0].type === "Literal") {
namedModule = expr.arguments[0].value;
// define("...", ...)
- if(expr.arguments[1].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[1])) {
+ if(isCallable(expr.arguments[1])) {
// define("...", f() {...})
fn = expr.arguments[1];
} else if(expr.arguments[1].type === "ObjectExpression") {
@@ -67,7 +79,7 @@ class AMDDefineDependencyParserPlugin {
}
} else {
array = expr.arguments[0];
- if(expr.arguments[1].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[1])) {
+ if(isCallable(expr.arguments[1])) {
// define([...], f() {})
fn = expr.arguments[1];
} else if(expr.arguments[1].type === "ObjectExpression") {
@@ -84,7 +96,7 @@ class AMDDefineDependencyParserPlugin {
// define("...", [...], f() {...})
namedModule = expr.arguments[0].value;
array = expr.arguments[1];
- if(expr.arguments[2].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[2])) {
+ if(isCallable(expr.arguments[2])) {
// define("...", [...], f() {})
fn = expr.arguments[2];
} else if(expr.arguments[2].type === "ObjectExpression") {
@@ -102,7 +114,7 @@ class AMDDefineDependencyParserPlugin {
let fnParams = null;
let fnParamsOffset = 0;
if(fn) {
- if(fn.type === "FunctionExpression") fnParams = fn.params;
+ if(isUnboundFunctionExpression(fn)) fnParams = fn.params;
else if(isBoundFunctionExpression(fn)) {
fnParams = fn.callee.object.params;
fnParamsOffset = fn.arguments.length - 1;
@@ -134,7 +146,7 @@ class AMDDefineDependencyParserPlugin {
});
}
let inTry;
- if(fn && fn.type === "FunctionExpression") {
+ if(fn && isUnboundFunctionExpression(fn)) {
inTry = parser.scope.inTry;
parser.inScope(fnParams, () => {
parser.scope.renames = fnRenames;