File tree 3 files changed +12
-7
lines changed
react-scripts/fixtures/kitchensink/src/features/syntax
3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -30,9 +30,7 @@ const plugins = [
30
30
regenerator : true ,
31
31
// Resolve the Babel runtime relative to the config.
32
32
moduleName : path . dirname ( require . resolve ( 'babel-runtime/package' ) )
33
- } ] ,
34
- // Enables parsing of import()
35
- require . resolve ( 'babel-plugin-syntax-dynamic-import' )
33
+ } ]
36
34
] ;
37
35
38
36
// This is similar to how `env` works in Babel:
@@ -77,7 +75,10 @@ if (env === 'test') {
77
75
// JSX, Flow
78
76
require . resolve ( 'babel-preset-react' )
79
77
] ,
80
- plugins : plugins
78
+ plugins : plugins . concat ( [
79
+ // Compiles import() to a deferred require()
80
+ require . resolve ( 'babel-plugin-dynamic-import-node' )
81
+ ] )
81
82
} ;
82
83
} else {
83
84
module . exports = {
@@ -97,6 +98,8 @@ if (env === 'test') {
97
98
// Async functions are converted to generators by babel-preset-latest
98
99
async : false
99
100
} ] ,
101
+ // Adds syntax support for import()
102
+ require . resolve ( 'babel-plugin-syntax-dynamic-import' ) ,
100
103
] )
101
104
} ;
102
105
Original file line number Diff line number Diff line change 11
11
" index.js"
12
12
],
13
13
"dependencies" : {
14
+ "babel-plugin-dynamic-import-node" : " 1.0.0" ,
14
15
"babel-plugin-syntax-dynamic-import" : " 6.18.0" ,
15
16
"babel-plugin-transform-class-properties" : " 6.22.0" ,
16
17
"babel-plugin-transform-object-rest-spread" : " 6.22.0" ,
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import ReactDOM from 'react-dom' ;
3
- import Promises from './Promises' ;
4
3
5
4
describe ( 'promises' , ( ) => {
6
5
it ( 'renders without crashing' , ( ) => {
7
6
const div = document . createElement ( 'div' ) ;
8
- return new Promise ( resolve => {
9
- ReactDOM . render ( < Promises onReady = { resolve } /> , div ) ;
7
+ return import ( './Promises' ) . then ( ( { default : Promises } ) => {
8
+ return new Promise ( resolve => {
9
+ ReactDOM . render ( < Promises onReady = { resolve } /> , div ) ;
10
+ } ) ;
10
11
} ) ;
11
12
} ) ;
12
13
} ) ;
You can’t perform that action at this time.
0 commit comments