Skip to content

Commit 7056ece

Browse files
committed
fix(webpack): paths plugin wildcard regex fix
1 parent 0365118 commit 7056ece

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/@ngtools/webpack/src/paths-plugin.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export class PathsPlugin implements Tapable {
9696
aliasPattern = new RegExp(`^${excapedAlias}$`);
9797
} else {
9898
let withStarCapturing = excapedAlias.replace('\\*', '(.*)');
99-
aliasPattern = new RegExp(`^${withStarCapturing}`);
99+
aliasPattern = withStarCapturing === '(.*)' ?
100+
new RegExp(excapedAlias) : new RegExp(`^${withStarCapturing}`);
100101
}
101102

102103
this.mappings.push({
@@ -163,7 +164,7 @@ export class PathsPlugin implements Tapable {
163164
}
164165

165166
createPlugin(resolver: ResolverPlugin, mapping: any): any {
166-
return (request: any, callback: Callback<any>) => {
167+
return (request: Request, callback: Callback<any>) => {
167168
try {
168169
this.resolve(resolver, mapping, request, callback);
169170
} catch (err) {

tests/e2e/tests/build/ts-paths.ts

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export default function() {
1313
],
1414
'@shared/*': [
1515
'app/shared/*'
16+
],
17+
'*': [
18+
'app/shared/*'
1619
]
1720
};
1821
})
@@ -25,12 +28,14 @@ export default function() {
2528
import { meaning } from 'app/shared/meaning';
2629
import { meaning as meaning2 } from '@shared';
2730
import { meaning as meaning3 } from '@shared/meaning';
31+
import { meaning as meaning4 } from 'meaning';
2832
2933
// need to use imports otherwise they are ignored and
3034
// no error is outputted, even if baseUrl/paths don't work
3135
console.log(meaning)
3236
console.log(meaning2)
3337
console.log(meaning3)
38+
console.log(meaning4)
3439
`))
3540
.then(() => ng('build'));
3641
}

0 commit comments

Comments
 (0)