diff --git a/lib/WebpackOptionsDefaulter.js b/lib/WebpackOptionsDefaulter.js index dcaf641df6a..8f86ef7d53a 100644 --- a/lib/WebpackOptionsDefaulter.js +++ b/lib/WebpackOptionsDefaulter.js @@ -98,11 +98,17 @@ class WebpackOptionsDefaulter extends OptionsDefaulter { else return ["module", "main"]; }); + this.set("resolve.cacheWithContext", "make", (options) => { + return Array.isArray(options.resolve.plugins) && options.resolve.plugins.length > 0; + }); this.set("resolveLoader", {}); this.set("resolveLoader.unsafeCache", true); this.set("resolveLoader.mainFields", ["loader", "main"]); this.set("resolveLoader.extensions", [".js", ".json"]); this.set("resolveLoader.mainFiles", ["index"]); + this.set("resolveLoader.cacheWithContext", "make", (options) => { + return Array.isArray(options.resolveLoader.plugins) && options.resolveLoader.plugins.length > 0; + }); } } diff --git a/package.json b/package.json index 63db2117e0d..3b4fbff6795 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "ajv": "^5.1.5", "ajv-keywords": "^2.0.0", "async": "^2.1.2", - "enhanced-resolve": "^3.0.0", + "enhanced-resolve": "mikesherov/enhanced-resolve#b03799b6f06f82423e0a5c57fcc196b8eaeb8c07", "escope": "^3.6.0", "interpret": "^1.0.0", "json-loader": "^0.5.4", diff --git a/schemas/webpackOptionsSchema.json b/schemas/webpackOptionsSchema.json index 52d1089251b..78be4448438 100644 --- a/schemas/webpackOptionsSchema.json +++ b/schemas/webpackOptionsSchema.json @@ -483,6 +483,9 @@ "cachePredicate": { "instanceof": "Function" }, + "cacheWithContext": { + "type": "boolean" + }, "descriptionFiles": { "$ref": "#/definitions/common.arrayOfStringValues" },