Skip to content

Commit 190559e

Browse files
leebyronPavel Zhytko
authored and
Pavel Zhytko
committed
.mjs should not resolve before .js files (facebook#4085)
Support for .mjs files added in facebook#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 aca6625 commit 190559e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: packages/react-scripts/scripts/utils/createJestConfig.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ module.exports = (resolve, rootDir, isEjecting) => {
4545
},
4646
moduleFileExtensions: [
4747
'web.js',
48-
'mjs',
4948
'js',
5049
'json',
5150
'web.jsx',
5251
'jsx',
5352
'node',
53+
'mjs',
5454
],
5555
};
5656
if (rootDir) {

0 commit comments

Comments
 (0)