From 36c0b4e5c171cc09b3f1dd963d63d24476eb13ef Mon Sep 17 00:00:00 2001 From: Lee Byron Date: Tue, 27 Feb 2018 09:20:37 -0800 Subject: [PATCH] BUG MITIGATION: .mjs should not resolve before .js files Support for .mjs files added in #3239 did not account for npm libraries which ship native mjs files alongside js files. This accounts for this by ensuring .js files resolve before their accompanying .mjs file. Note that this is not an ideal end state since selecting a .mjs over a .js extension should be the result of whether `import` was used instead of `require()` in a node environment with native ESM support (currently via `--experimental-modules`). Instead, this change just *always* selects a .js extension before the .mjs extension if it exists. This unbreaks support for using GraphQL (relay, apollo, etc) within create-react-app projects. --- packages/react-scripts/scripts/utils/createJestConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index b4c2cfa5ea9..4c428004a84 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -45,12 +45,12 @@ module.exports = (resolve, rootDir, isEjecting) => { }, moduleFileExtensions: [ 'web.js', - 'mjs', 'js', 'json', 'web.jsx', 'jsx', 'node', + 'mjs', ], }; if (rootDir) {