mirror of https://github.com/webpack/webpack.git
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:
parent
52d71df3cf
commit
164c91a6b9
|
@ -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": {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
module.exports = "1";
|
|
@ -0,0 +1 @@
|
|||
module.exports = "2";
|
|
@ -0,0 +1 @@
|
|||
module.exports = "1"
|
|
@ -0,0 +1 @@
|
|||
{ "b": "2" }
|
|
@ -0,0 +1,4 @@
|
|||
it("should resolve respecting resolve.extensions order when enforceExtension: true", () => {
|
||||
require("./a");
|
||||
require("./b")
|
||||
});
|
|
@ -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}`
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue