Skip to content

Commit

Permalink
Merge pull request #5178 from mikesherov/resolvePerf
Browse files Browse the repository at this point in the history
RFC: Ignore context in resolve caching when resolve or resolveLoader plugins are provided.
  • Loading branch information
sokra committed Jul 1, 2017
2 parents d81cc04 + af9e655 commit aaa6eea
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions lib/WebpackOptionsDefaulter.js
Expand Up @@ -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;
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -9,7 +9,7 @@
"ajv": "^5.1.5",
"ajv-keywords": "^2.0.0",
"async": "^2.1.2",
"enhanced-resolve": "^3.0.0",
"enhanced-resolve": "^3.3.0",
"escope": "^3.6.0",
"interpret": "^1.0.0",
"json-loader": "^0.5.4",
Expand Down
3 changes: 3 additions & 0 deletions schemas/webpackOptionsSchema.json
Expand Up @@ -483,6 +483,9 @@
"cachePredicate": {
"instanceof": "Function"
},
"cacheWithContext": {
"type": "boolean"
},
"descriptionFiles": {
"$ref": "#/definitions/common.arrayOfStringValues"
},
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Expand Up @@ -1102,9 +1102,9 @@ encoding@^0.1.11:
dependencies:
iconv-lite "~0.4.13"

enhanced-resolve@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.1.0.tgz#9f4b626f577245edcf4b2ad83d86e17f4f421dec"
enhanced-resolve@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.3.0.tgz#950964ecc7f0332a42321b673b38dc8ff15535b3"
dependencies:
graceful-fs "^4.1.2"
memory-fs "^0.4.0"
Expand Down

0 comments on commit aaa6eea

Please sign in to comment.