Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Meta
create-react-app
Commits
5c8000f3
Commit
5c8000f3
authored
7 years ago
by
Joe Haddad
Committed by
Dan Abramov
7 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Add `.mjs` support (#3239)
parent
4add16dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
packages/react-scripts/config/webpack.config.dev.js
+3
-3
packages/react-scripts/config/webpack.config.dev.js
packages/react-scripts/config/webpack.config.prod.js
+3
-3
packages/react-scripts/config/webpack.config.prod.js
packages/react-scripts/scripts/utils/createJestConfig.js
+17
-7
packages/react-scripts/scripts/utils/createJestConfig.js
with
23 additions
and
13 deletions
+23
-13
packages/react-scripts/config/webpack.config.dev.js
+
3
-
3
View file @
5c8000f3
...
@@ -92,7 +92,7 @@ module.exports = {
...
@@ -92,7 +92,7 @@ module.exports = {
// https://github.com/facebookincubator/create-react-app/issues/290
// https://github.com/facebookincubator/create-react-app/issues/290
// `web` extension prefixes have been added for better support
// `web` extension prefixes have been added for better support
// for React Native Web.
// for React Native Web.
extensions
:
[
'
.web.js
'
,
'
.js
'
,
'
.json
'
,
'
.web.jsx
'
,
'
.jsx
'
],
extensions
:
[
'
.web.js
'
,
'
.mjs
'
,
'
.js
'
,
'
.json
'
,
'
.web.jsx
'
,
'
.jsx
'
],
alias
:
{
alias
:
{
// @remove-on-eject-begin
// @remove-on-eject-begin
// Resolve Babel runtime relative to react-scripts.
// Resolve Babel runtime relative to react-scripts.
...
@@ -126,7 +126,7 @@ module.exports = {
...
@@ -126,7 +126,7 @@ module.exports = {
// First, run the linter.
// First, run the linter.
// It's important to do this before Babel processes the JS.
// It's important to do this before Babel processes the JS.
{
{
test
:
/
\.(
js|jsx
)
$/
,
test
:
/
\.(
js|jsx
|mjs
)
$/
,
enforce
:
'
pre
'
,
enforce
:
'
pre
'
,
use
:
[
use
:
[
{
{
...
@@ -164,7 +164,7 @@ module.exports = {
...
@@ -164,7 +164,7 @@ module.exports = {
},
},
// Process JS with Babel.
// Process JS with Babel.
{
{
test
:
/
\.(
js|jsx
)
$/
,
test
:
/
\.(
js|jsx
|mjs
)
$/
,
include
:
paths
.
appSrc
,
include
:
paths
.
appSrc
,
loader
:
require
.
resolve
(
'
babel-loader
'
),
loader
:
require
.
resolve
(
'
babel-loader
'
),
options
:
{
options
:
{
...
...
This diff is collapsed.
Click to expand it.
packages/react-scripts/config/webpack.config.prod.js
+
3
-
3
View file @
5c8000f3
...
@@ -96,7 +96,7 @@ module.exports = {
...
@@ -96,7 +96,7 @@ module.exports = {
// https://github.com/facebookincubator/create-react-app/issues/290
// https://github.com/facebookincubator/create-react-app/issues/290
// `web` extension prefixes have been added for better support
// `web` extension prefixes have been added for better support
// for React Native Web.
// for React Native Web.
extensions
:
[
'
.web.js
'
,
'
.js
'
,
'
.json
'
,
'
.web.jsx
'
,
'
.jsx
'
],
extensions
:
[
'
.web.js
'
,
'
.mjs
'
,
'
.js
'
,
'
.json
'
,
'
.web.jsx
'
,
'
.jsx
'
],
alias
:
{
alias
:
{
// @remove-on-eject-begin
// @remove-on-eject-begin
// Resolve Babel runtime relative to react-scripts.
// Resolve Babel runtime relative to react-scripts.
...
@@ -130,7 +130,7 @@ module.exports = {
...
@@ -130,7 +130,7 @@ module.exports = {
// First, run the linter.
// First, run the linter.
// It's important to do this before Babel processes the JS.
// It's important to do this before Babel processes the JS.
{
{
test
:
/
\.(
js|jsx
)
$/
,
test
:
/
\.(
js|jsx
|mjs
)
$/
,
enforce
:
'
pre
'
,
enforce
:
'
pre
'
,
use
:
[
use
:
[
{
{
...
@@ -169,7 +169,7 @@ module.exports = {
...
@@ -169,7 +169,7 @@ module.exports = {
},
},
// Process JS with Babel.
// Process JS with Babel.
{
{
test
:
/
\.(
js|jsx
)
$/
,
test
:
/
\.(
js|jsx
|mjs
)
$/
,
include
:
paths
.
appSrc
,
include
:
paths
.
appSrc
,
loader
:
require
.
resolve
(
'
babel-loader
'
),
loader
:
require
.
resolve
(
'
babel-loader
'
),
options
:
{
options
:
{
...
...
This diff is collapsed.
Click to expand it.
packages/react-scripts/scripts/utils/createJestConfig.js
+
17
-
7
View file @
5c8000f3
...
@@ -21,27 +21,37 @@ module.exports = (resolve, rootDir, isEjecting) => {
...
@@ -21,27 +21,37 @@ module.exports = (resolve, rootDir, isEjecting) => {
// TODO: I don't know if it's safe or not to just use / as path separator
// TODO: I don't know if it's safe or not to just use / as path separator
// in Jest configs. We need help from somebody with Windows to determine this.
// in Jest configs. We need help from somebody with Windows to determine this.
const
config
=
{
const
config
=
{
collectCoverageFrom
:
[
'
src/**/*.{js,jsx}
'
],
collectCoverageFrom
:
[
'
src/**/*.{js,jsx
,mjs
}
'
],
setupFiles
:
[
resolve
(
'
config/polyfills.js
'
)],
setupFiles
:
[
resolve
(
'
config/polyfills.js
'
)],
setupTestFrameworkScriptFile
:
setupTestsFile
,
setupTestFrameworkScriptFile
:
setupTestsFile
,
testMatch
:
[
testMatch
:
[
'
<rootDir>/src/**/__tests__/**/*.js
?(x)
'
,
'
<rootDir>/src/**/__tests__/**/*.
{
js
,jsx,mjs}
'
,
'
<rootDir>/src/**/?(*.)(spec|test).js
?(x)
'
,
'
<rootDir>/src/**/?(*.)(spec|test).
{
js
,jsx,mjs}
'
,
],
],
testEnvironment
:
'
node
'
,
testEnvironment
:
'
node
'
,
testURL
:
'
http://localhost
'
,
testURL
:
'
http://localhost
'
,
transform
:
{
transform
:
{
'
^.+
\\
.(js|jsx)$
'
:
isEjecting
'
^.+
\\
.(js|jsx
|mjs
)$
'
:
isEjecting
?
'
<rootDir>/node_modules/babel-jest
'
?
'
<rootDir>/node_modules/babel-jest
'
:
resolve
(
'
config/jest/babelTransform.js
'
),
:
resolve
(
'
config/jest/babelTransform.js
'
),
'
^.+
\\
.css$
'
:
resolve
(
'
config/jest/cssTransform.js
'
),
'
^.+
\\
.css$
'
:
resolve
(
'
config/jest/cssTransform.js
'
),
'
^(?!.*
\\
.(js|jsx|css|json)$)
'
:
resolve
(
'
config/jest/fileTransform.js
'
),
'
^(?!.*
\\
.(js|jsx|mjs|css|json)$)
'
:
resolve
(
'
config/jest/fileTransform.js
'
),
},
},
transformIgnorePatterns
:
[
'
[/
\\\\
]node_modules[/
\\\\
].+
\\
.(js|jsx)$
'
],
transformIgnorePatterns
:
[
'
[/
\\\\
]node_modules[/
\\\\
].+
\\
.(js|jsx
|mjs
)$
'
],
moduleNameMapper
:
{
moduleNameMapper
:
{
'
^react-native$
'
:
'
react-native-web
'
,
'
^react-native$
'
:
'
react-native-web
'
,
},
},
moduleFileExtensions
:
[
'
web.js
'
,
'
js
'
,
'
json
'
,
'
web.jsx
'
,
'
jsx
'
,
'
node
'
],
moduleFileExtensions
:
[
'
web.js
'
,
'
mjs
'
,
'
js
'
,
'
json
'
,
'
web.jsx
'
,
'
jsx
'
,
'
node
'
,
],
};
};
if
(
rootDir
)
{
if
(
rootDir
)
{
config
.
rootDir
=
rootDir
;
config
.
rootDir
=
rootDir
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets