From ea9e4572a5a1d4a1bfee5975118a0f2b41c5a7e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ruci=C5=84ski?= Date: Mon, 15 May 2017 21:01:29 +0200 Subject: [PATCH] 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 --- src/normalizeOptions.js | 2 +- test/index.test.js | 8 ++++++++ test/testproject/src/nodemodule.mjs | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/testproject/src/nodemodule.mjs diff --git a/src/normalizeOptions.js b/src/normalizeOptions.js index 7698d75..3c38f44 100644 --- a/src/normalizeOptions.js +++ b/src/normalizeOptions.js @@ -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('$'); diff --git a/test/index.test.js b/test/index.test.js index 1d7386a..3c660d5 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -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', diff --git a/test/testproject/src/nodemodule.mjs b/test/testproject/src/nodemodule.mjs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/test/testproject/src/nodemodule.mjs @@ -0,0 +1 @@ +