File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed
Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 1+ async function foo ( ) {
2+ console . log ( 'foo' ) ;
3+ }
4+
5+ foo ( ) . then ( ( ) => {
6+ console . log ( 'bar' ) ;
7+ } ) ;
Original file line number Diff line number Diff line change @@ -42,7 +42,6 @@ module.exports = {
4242 // https://babeljs.io/docs/en/babel-preset-env#modules
4343 modules : false ,
4444 targets : { } ,
45- forceAllTransforms : webpackConfig . isProduction ( ) ,
4645 useBuiltIns : webpackConfig . babelOptions . useBuiltIns ,
4746 corejs : webpackConfig . babelOptions . corejs ,
4847 } ;
Original file line number Diff line number Diff line change @@ -1148,6 +1148,41 @@ module.exports = {
11481148 } ) ;
11491149 } ) ;
11501150
1151+ it ( 'Babel does not force transforms if they are not needed' , ( done ) => {
1152+ const cwd = process . cwd ( ) ;
1153+ after ( ( ) => {
1154+ process . chdir ( cwd ) ;
1155+ } ) ;
1156+
1157+ const appDir = testSetup . createTestAppDir ( ) ;
1158+ process . chdir ( appDir ) ;
1159+
1160+ fs . writeFileSync (
1161+ path . join ( appDir , 'package.json' ) ,
1162+
1163+ // Chrome 55 supports async and arrow functions
1164+ '{"browserslist": "Chrome 55"}'
1165+ ) ;
1166+
1167+ const config = createWebpackConfig ( 'www/build' , 'prod' ) ;
1168+ config . setPublicPath ( '/build' ) ;
1169+ config . addEntry ( 'async' , './js/async_function.js' ) ;
1170+ config . configureBabel ( null , {
1171+ useBuiltIns : 'usage' ,
1172+ corejs : 3 ,
1173+ } ) ;
1174+
1175+ testSetup . runWebpack ( config , async ( webpackAssert ) => {
1176+ webpackAssert . assertOutputFileContains (
1177+ 'async.js' ,
1178+ 'async function(){console.log("foo")}().then(()=>{console.log("bar")})'
1179+ ) ;
1180+
1181+ done ( ) ;
1182+ } ) ;
1183+ } ) ;
1184+
1185+
11511186 it ( 'When enabled, react JSX is transformed!' , ( done ) => {
11521187 const config = createWebpackConfig ( 'www/build' , 'dev' ) ;
11531188 config . setPublicPath ( '/build' ) ;
You can’t perform that action at this time.
0 commit comments