Skip to content

Commit 79e2961

Browse files
authored
fix(AliasPlugin): correct wildcard replacement in multi-target aliases (#465)
1 parent b8af813 commit 79e2961

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/AliasPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ module.exports = class AliasPlugin {
107107
prefix.length,
108108
innerRequest.length - suffix.length,
109109
);
110-
newRequestStr = item.alias.toString().replace("*", match);
110+
newRequestStr = alias.toString().replace("*", match);
111111
}
112112

113113
if (

test/alias.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ describe("alias", () => {
2727
"/e/index": "",
2828
"/e/anotherDir/index": "",
2929
"/e/dir/file": "",
30+
"/src/utils/a": "",
31+
"/src/components/b": "",
3032
},
3133
"/",
3234
);
@@ -45,6 +47,7 @@ describe("alias", () => {
4547
"@*": "/*",
4648
"@e*": "/e/*",
4749
"@e*file": "/e*file",
50+
"shared/*": ["/src/utils/*", "/src/components/*"],
4851
ignored: false,
4952
},
5053
modules: "/",
@@ -175,4 +178,8 @@ describe("alias", () => {
175178
done();
176179
});
177180
});
181+
182+
it("should resolve a wildcard alias with multiple targets correctly", () => {
183+
expect(resolver.resolveSync({}, "/", "shared/b")).toBe("/src/components/b");
184+
});
178185
});

0 commit comments

Comments
 (0)