Skip to content

Commit 7c71d3e

Browse files
committed
Make most alias paths into relative ones
1 parent 040bb1c commit 7c71d3e

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

test/index.test.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,14 @@ describe('module-resolver', () => {
243243
components: './test/testproject/src/components',
244244
'~': './test/testproject/src',
245245
'awesome/components': './test/testproject/src/components',
246-
underscore: 'lodash',
247-
'^@namespace/foo-(.+)': 'packages/\\1',
248-
'styles/.+\\.(css|less|scss)$': 'style-proxy.\\1',
249-
'^single-backslash': 'pas\\\\sed',
250-
'^non-existing-match': 'pas\\42sed',
251-
'^regexp-priority': 'miss',
252-
'regexp-priority$': 'miss',
253-
'regexp-priority': 'hit',
246+
'babel-kernel': 'babel-core',
247+
'^@namespace/foo-(.+)': './packages/\\1',
248+
'styles/.+\\.(css|less|scss)$': './style-proxy.\\1',
249+
'^single-backslash': './pas\\\\sed',
250+
'^non-existing-match': './pas\\42sed',
251+
'^regexp-priority': './miss',
252+
'regexp-priority$': './miss',
253+
'regexp-priority': './hit',
254254
},
255255
}],
256256
],
@@ -327,9 +327,10 @@ describe('module-resolver', () => {
327327
});
328328

329329
it('should support aliasing a node modules', () => {
330+
// If this test breaks, consider selecting another package used by the plugin
330331
testWithImport(
331-
'underscore/map',
332-
'lodash/map',
332+
'babel-kernel/register',
333+
'babel-core/register',
333334
aliasTransformerOpts,
334335
);
335336
});
@@ -338,15 +339,15 @@ describe('module-resolver', () => {
338339
it('should support replacing parts of a path', () => {
339340
testWithImport(
340341
'@namespace/foo-bar',
341-
'packages/bar',
342+
'./packages/bar',
342343
aliasTransformerOpts,
343344
);
344345
});
345346

346347
it('should support replacing parts of a complex path', () => {
347348
testWithImport(
348349
'@namespace/foo-bar/component.js',
349-
'packages/bar/component.js',
350+
'./packages/bar/component.js',
350351
aliasTransformerOpts,
351352
);
352353
});
@@ -356,7 +357,7 @@ describe('module-resolver', () => {
356357
it(`should handle the alias with the ${extension} extension`, () => {
357358
testWithImport(
358359
`styles/style.${extension}`,
359-
`style-proxy.${extension}`,
360+
`./style-proxy.${extension}`,
360361
aliasTransformerOpts,
361362
);
362363
});
@@ -371,27 +372,27 @@ describe('module-resolver', () => {
371372
);
372373
});
373374

374-
it('should transform a double backslash into a single one', () => {
375+
it('should unescape a double backslash into a single one', () => {
375376
testWithImport(
376377
'single-backslash',
377378
// This is a string literal, so in the code it will actually be "pas\\sed"
378-
'pas\\\\sed',
379+
'./pas/sed',
379380
aliasTransformerOpts,
380381
);
381382
});
382383

383384
it('should replace missing matches with an empty string', () => {
384385
testWithImport(
385386
'non-existing-match',
386-
'passed',
387+
'./passed',
387388
aliasTransformerOpts,
388389
);
389390
});
390391

391392
it('should have higher priority than a simple alias', () => {
392393
testWithImport(
393394
'regexp-priority',
394-
'hit',
395+
'./hit',
395396
aliasTransformerOpts,
396397
);
397398
});
@@ -403,7 +404,7 @@ describe('module-resolver', () => {
403404
[plugin, { root: '.' }],
404405
[plugin, {
405406
alias: {
406-
'^@namespace/foo-(.+)': 'packages/\\1',
407+
'^@namespace/foo-(.+)': './packages/\\1',
407408
},
408409
}],
409410
],
@@ -412,7 +413,7 @@ describe('module-resolver', () => {
412413
it('should support replacing parts of a path', () => {
413414
testWithImport(
414415
'@namespace/foo-bar',
415-
'packages/bar',
416+
'./packages/bar',
416417
doubleAliasTransformerOpts,
417418
);
418419
});

0 commit comments

Comments
 (0)