Skip to content

Commit 3c711f8

Browse files
authored
feat: Make alias config take precedence over root config (#221)
BREAKING CHANGE: This makes alias taking precedence over the root config because it's usually more specific.
1 parent 0a16ea8 commit 3c711f8

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/resolvePath.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ function resolvePathFromAliasConfig(sourcePath, currentFile, opts) {
7676
}
7777

7878
const resolvers = [
79-
resolvePathFromRootConfig,
8079
resolvePathFromAliasConfig,
80+
resolvePathFromRootConfig,
8181
];
8282

8383
export default function resolvePath(sourcePath, currentFile, opts) {

test/index.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,23 +264,23 @@ describe('module-resolver', () => {
264264
});
265265

266266
describe('root and alias', () => {
267-
const rootTransformerOpts = {
267+
const aliasTransformerOpts = {
268268
babelrc: false,
269269
plugins: [
270270
[plugin, {
271-
root: './test/testproject/src',
271+
root: './test/fakepath/',
272272
alias: {
273-
constants: 'constants/actions',
273+
constants: './test/testproject/src/constants',
274274
},
275275
}],
276276
],
277277
};
278278

279-
it('should resolve the path using root first and alias otherwise', () => {
279+
it('should resolve the path using alias first and root otherwise', () => {
280280
testWithImport(
281281
'constants',
282282
'./test/testproject/src/constants',
283-
rootTransformerOpts,
283+
aliasTransformerOpts,
284284
);
285285
});
286286
});

0 commit comments

Comments
 (0)