feat: accept empty string in config.resolve.extensions

- remove minLength from extensions in schema/WebpackOptions
- add tests reflecting the change
- no conflicts with existing tests
- no conflicts with enhanced-resolve
This commit is contained in:
igio 2021-02-06 20:00:21 +00:00 committed by Tobias Koppers
parent 52d71df3cf
commit 164c91a6b9
7 changed files with 32 additions and 2 deletions

View File

@ -3194,8 +3194,7 @@
"type": "array",
"items": {
"description": "Extension added to the request when trying to find the file.",
"type": "string",
"minLength": 1
"type": "string"
}
},
"fallback": {

View File

@ -0,0 +1 @@
module.exports = "1";

View File

@ -0,0 +1 @@
module.exports = "2";

View File

@ -0,0 +1 @@
module.exports = "1"

View File

@ -0,0 +1 @@
{ "b": "2" }

View File

@ -0,0 +1,4 @@
it("should resolve respecting resolve.extensions order when enforceExtension: true", () => {
require("./a");
require("./b")
});

View File

@ -0,0 +1,23 @@
module.exports = {
resolve: {
enforceExtension: true,
extensions: [".js", "", ".json"],
plugins: [
{
apply(resolver) {
resolver.hooks.result.tap("Test", (request, resolverContext) => {
if (/a$|a\.json$/.test(request.path))
throw new Error(
`Trying to resolve respecting resolve.extensions order ${request.path}`
);
if (/b.json$/.test(request.path))
throw new Error(
`Trying to resolve respecting resolve.extensions order ${request.path}`
);
});
}
}
]
}
};