Skip to content

Commit

Permalink
.mjs should not resolve before .js files (facebook#4085)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
leebyron authored and Craig Mulligan committed Apr 17, 2018
1 parent 836bb39 commit 6ea08c4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react-scripts/scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ module.exports = (resolve, rootDir, srcRoots) => {
},
moduleFileExtensions: [
'web.js',
'mjs',
'js',
'json',
'web.jsx',
'jsx',
'node',
'mjs',
],
};
if (rootDir) {
Expand Down

0 comments on commit 6ea08c4

Please sign in to comment.