Skip to content

Commit

Permalink
Merge pull request webpack#11207 from webpack/backport/add-roots
Browse files Browse the repository at this point in the history
Backport of resolve.roots for webpack 4
  • Loading branch information
sokra committed Jul 20, 2020
2 parents 1879a81 + 5c9c601 commit 21e3c11
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions declarations/WebpackOptions.d.ts
Expand Up @@ -709,6 +709,10 @@ export interface ResolveOptions {
resolver?: {
[k: string]: any;
};
/**
* A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. On non-windows system these requests are tried to resolve as absolute path first.
*/
roots?: string[];
/**
* Enable resolving symlinks to the original location
*/
Expand Down
1 change: 1 addition & 0 deletions lib/WebpackOptionsDefaulter.js
Expand Up @@ -362,6 +362,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
this.set("resolveLoader.mainFields", ["loader", "main"]);
this.set("resolveLoader.extensions", [".js", ".json"]);
this.set("resolveLoader.mainFiles", ["index"]);
this.set("resolveLoader.roots", "make", options => [options.context]);
this.set("resolveLoader.cacheWithContext", "make", options => {
return (
Array.isArray(options.resolveLoader.plugins) &&
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -13,7 +13,7 @@
"ajv": "^6.10.2",
"ajv-keywords": "^3.4.1",
"chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^4.1.0",
"enhanced-resolve": "^4.3.0",
"eslint-scope": "^4.0.3",
"json-parse-better-errors": "^1.0.2",
"loader-runner": "^2.4.0",
Expand Down
8 changes: 8 additions & 0 deletions schemas/WebpackOptions.json
Expand Up @@ -1229,6 +1229,14 @@
"resolver": {
"description": "Custom resolver"
},
"roots": {
"description": "A list of directories in which requests that are server-relative URLs (starting with '/') are resolved. On non-windows system these requests are tried to resolve as absolute path first.",
"type": "array",
"items": {
"description": "Directory in which requests that are server-relative URLs (starting with '/') are resolved.",
"type": "string"
}
},
"symlinks": {
"description": "Enable resolving symlinks to the original location",
"type": "boolean"
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -1980,10 +1980,10 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0:
dependencies:
once "^1.4.0"

enhanced-resolve@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.1.1.tgz#2937e2b8066cd0fe7ce0990a98f0d71a35189f66"
integrity sha512-98p2zE+rL7/g/DzMHMTF4zZlCgeVdJ7yr6xzEpJRYwFYrGi9ANdn5DnJURg6RpBkyk60XYDnWIv51VfIhfNGuA==
enhanced-resolve@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.3.0.tgz#3b806f3bfafc1ec7de69551ef93cca46c1704126"
integrity sha512-3e87LvavsdxyoCfGusJnrZ5G8SLPOFeHSNpZI/ATL9a5leXo2k0w6MKnbqhdBad9qTobSfB20Ld7UmgoNbAZkQ==
dependencies:
graceful-fs "^4.1.2"
memory-fs "^0.5.0"
Expand Down

0 comments on commit 21e3c11

Please sign in to comment.