File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed
react-scripts/fixtures/kitchensink/src/features/syntax Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -30,9 +30,7 @@ const plugins = [
3030 regenerator : true ,
3131 // Resolve the Babel runtime relative to the config.
3232 moduleName : path . dirname ( require . resolve ( 'babel-runtime/package' ) )
33- } ] ,
34- // Enables parsing of import()
35- require . resolve ( 'babel-plugin-syntax-dynamic-import' )
33+ } ]
3634] ;
3735
3836// This is similar to how `env` works in Babel:
@@ -77,7 +75,10 @@ if (env === 'test') {
7775 // JSX, Flow
7876 require . resolve ( 'babel-preset-react' )
7977 ] ,
80- plugins : plugins
78+ plugins : plugins . concat ( [
79+ // Compiles import() to a deferred require()
80+ require . resolve ( 'babel-plugin-dynamic-import-node' )
81+ ] )
8182 } ;
8283} else {
8384 module . exports = {
@@ -97,6 +98,8 @@ if (env === 'test') {
9798 // Async functions are converted to generators by babel-preset-latest
9899 async : false
99100 } ] ,
101+ // Adds syntax support for import()
102+ require . resolve ( 'babel-plugin-syntax-dynamic-import' ) ,
100103 ] )
101104 } ;
102105
Original file line number Diff line number Diff line change 1111 " index.js"
1212 ],
1313 "dependencies" : {
14+ "babel-plugin-dynamic-import-node" : " 1.0.0" ,
1415 "babel-plugin-syntax-dynamic-import" : " 6.18.0" ,
1516 "babel-plugin-transform-class-properties" : " 6.22.0" ,
1617 "babel-plugin-transform-object-rest-spread" : " 6.22.0" ,
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import ReactDOM from 'react-dom' ;
3- import Promises from './Promises' ;
43
54describe ( 'promises' , ( ) => {
65 it ( 'renders without crashing' , ( ) => {
76 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+ } ) ;
1011 } ) ;
1112 } ) ;
1213} ) ;
You can’t perform that action at this time.
0 commit comments