Skip to content

Commit 0e0f260

Browse files
craigmulligangaearon
authored andcommitted
.mjs should not resolve before .js files (#4085) (#4318)
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.
1 parent d1454fe commit 0e0f260

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/react-scripts/scripts/utils/createJestConfig.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ module.exports = (resolve, rootDir, srcRoots) => {
5353
},
5454
moduleFileExtensions: [
5555
'web.js',
56-
'mjs',
5756
'js',
5857
'json',
5958
'web.jsx',
6059
'jsx',
6160
'node',
61+
'mjs',
6262
],
6363
};
6464
if (rootDir) {

0 commit comments

Comments
 (0)