Skip to content

Commit ea9e457

Browse files
authored
feat: Add the .mjs extension to the default extensions (#172)
* Add the .mjs extension to the default extensions * Add a test file with the new extension * Add a test for the new extension
1 parent 4aa473f commit ea9e457

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/normalizeOptions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import findBabelConfig from 'find-babel-config';
55
import glob from 'glob';
66
import pkgUp from 'pkg-up';
77

8-
const defaultExtensions = ['.js', '.jsx', '.es', '.es6'];
8+
const defaultExtensions = ['.js', '.jsx', '.es', '.es6', '.mjs'];
99

1010
function isRegExp(string) {
1111
return string.startsWith('^') || string.endsWith('$');

test/index.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ describe('module-resolver', () => {
6363
);
6464
});
6565

66+
it('should resolve the file path with the node module extension', () => {
67+
testWithImport(
68+
'nodemodule',
69+
'./test/testproject/src/nodemodule',
70+
rootTransformerOpts,
71+
);
72+
});
73+
6674
it('should not resolve the file path with an unknown extension', () => {
6775
testWithImport(
6876
'text',
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)