Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/normalizeOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function normalizeAlias(opts) {
opts.alias = aliasKeys.map(key => (
isRegExp(key) ?
getAliasPair(key, alias[key]) :
getAliasPair(`^${key}((?:/|).*)`, `${alias[key]}\\1`)
getAliasPair(`^${key}(/.*|)$`, `${alias[key]}\\1`)
));
} else {
opts.alias = [];
Expand Down
16 changes: 16 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ describe('module-resolver', () => {
);
});

it('should not alias if there is no proper sub path', () => {
testWithImport(
'components_dummy',
'components_dummy',
aliasTransformerOpts,
);
});

it('should alias the sub file path', () => {
testWithImport(
'test/tools',
Expand All @@ -292,6 +300,14 @@ describe('module-resolver', () => {
);
});

it('should not alias if there is no proper sub path', () => {
testWithImport(
'awesome/componentss',
'awesome/componentss',
aliasTransformerOpts,
);
});

it('should alias the sub file path', () => {
testWithImport(
'awesome/components/Header',
Expand Down