File tree 5 files changed +44
-14
lines changed
5 files changed +44
-14
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,22 @@ module.exports = {
37
37
} ]
38
38
] ,
39
39
env : {
40
+ development : {
41
+ plugins : [
42
+ // Adds component stack to warning messages
43
+ require . resolve ( 'babel-plugin-transform-react-jsx-source' ) ,
44
+ // Adds __self attribute to JSX which React will use for some warnings
45
+ require . resolve ( 'babel-plugin-transform-react-jsx-self' )
46
+ ]
47
+ } ,
48
+ test : {
49
+ plugins : [
50
+ // Adds component stack to warning messages
51
+ require . resolve ( 'babel-plugin-transform-react-jsx-source' ) ,
52
+ // Adds __self attribute to JSX which React will use for some warnings
53
+ require . resolve ( 'babel-plugin-transform-react-jsx-self' )
54
+ ]
55
+ } ,
40
56
production : {
41
57
plugins : [
42
58
// Optimization: hoist JSX that never changes out of render()
Original file line number Diff line number Diff line change 14
14
"babel-plugin-transform-class-properties" : " 6.11.5" ,
15
15
"babel-plugin-transform-object-rest-spread" : " 6.8.0" ,
16
16
"babel-plugin-transform-react-constant-elements" : " 6.9.1" ,
17
+ "babel-plugin-transform-react-jsx-self" : " 6.11.0" ,
18
+ "babel-plugin-transform-react-jsx-source" : " 6.9.0" ,
17
19
"babel-plugin-transform-regenerator" : " 6.14.0" ,
18
20
"babel-plugin-transform-runtime" : " 6.15.0" ,
19
21
"babel-preset-latest" : " 6.14.0" ,
Original file line number Diff line number Diff line change 8
8
9
9
const babelJest = require ( 'babel-jest' ) ;
10
10
11
- module . exports = babelJest . createTransformer ( {
12
- presets : [ require . resolve ( 'babel-preset-react-app' ) ]
13
- } ) ;
11
+ module . exports = babelJest . createTransformer (
12
+ // We embed the preset instead of referring to it because otherwise
13
+ // `env` options in the preset do not get taken into account.
14
+ require ( 'babel-preset-react-app' )
15
+ ) ;
Original file line number Diff line number Diff line change @@ -121,10 +121,6 @@ module.exports = {
121
121
include : paths . appSrc ,
122
122
loader : 'babel' ,
123
123
query : {
124
- // @remove -on-eject-begin
125
- babelrc : false ,
126
- presets : [ require . resolve ( 'babel-preset-react-app' ) ] ,
127
- // @remove -on-eject-end
128
124
// This is a feature of `babel-loader` for webpack (not Babel itself).
129
125
// It enables caching results in ./node_modules/.cache/react-scripts/
130
126
// directory for faster rebuilds. We use findCacheDir() because of:
@@ -226,3 +222,13 @@ module.exports = {
226
222
tls : 'empty'
227
223
}
228
224
} ;
225
+
226
+ // @remove -on-eject-begin
227
+ // Override babel-loader options to not read .babelrc.
228
+ var babelLoader = module . exports . module . loaders . find ( l => l . loader === 'babel' ) ;
229
+ babelLoader . query = babelLoader . query || { } ;
230
+ babelLoader . query . babelrc = false ;
231
+ // We embed the preset instead of referring to it because otherwise
232
+ // `env` options in the preset do not get taken into account.
233
+ Object . assign ( babelLoader . query , require ( 'babel-preset-react-app' ) ) ;
234
+ // @remove -on-eject-end
Original file line number Diff line number Diff line change @@ -119,13 +119,7 @@ module.exports = {
119
119
{
120
120
test : / \. ( j s | j s x ) $ / ,
121
121
include : paths . appSrc ,
122
- loader : 'babel' ,
123
- // @remove -on-eject-begin
124
- query : {
125
- babelrc : false ,
126
- presets : [ require . resolve ( 'babel-preset-react-app' ) ] ,
127
- } ,
128
- // @remove -on-eject-end
122
+ loader : 'babel'
129
123
} ,
130
124
// The notation here is somewhat confusing.
131
125
// "postcss" loader applies autoprefixer to our CSS.
@@ -260,3 +254,13 @@ module.exports = {
260
254
tls : 'empty'
261
255
}
262
256
} ;
257
+
258
+ // @remove -on-eject-begin
259
+ // Override babel-loader options to not read .babelrc.
260
+ var babelLoader = module . exports . module . loaders . find ( l => l . loader === 'babel' ) ;
261
+ babelLoader . query = babelLoader . query || { } ;
262
+ babelLoader . query . babelrc = false ;
263
+ // We embed the preset instead of referring to it because otherwise
264
+ // `env` options in the preset do not get taken into account.
265
+ Object . assign ( babelLoader . query , require ( 'babel-preset-react-app' ) ) ;
266
+ // @remove -on-eject-end
You can’t perform that action at this time.
0 commit comments