Skip to content

Commit

Permalink
feat: Add the .mjs extension to the default extensions (#172)
Browse files Browse the repository at this point in the history
* Add the .mjs extension to the default extensions

* Add a test file with the new extension

* Add a test for the new extension
  • Loading branch information
fatfisz committed May 15, 2017
1 parent 4aa473f commit ea9e457
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/normalizeOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import findBabelConfig from 'find-babel-config';
import glob from 'glob';
import pkgUp from 'pkg-up';

const defaultExtensions = ['.js', '.jsx', '.es', '.es6'];
const defaultExtensions = ['.js', '.jsx', '.es', '.es6', '.mjs'];

function isRegExp(string) {
return string.startsWith('^') || string.endsWith('$');
Expand Down
8 changes: 8 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ describe('module-resolver', () => {
);
});

it('should resolve the file path with the node module extension', () => {
testWithImport(
'nodemodule',
'./test/testproject/src/nodemodule',
rootTransformerOpts,
);
});

it('should not resolve the file path with an unknown extension', () => {
testWithImport(
'text',
Expand Down
1 change: 1 addition & 0 deletions test/testproject/src/nodemodule.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit ea9e457

Please sign in to comment.