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 = {
42
42
// https://babeljs.io/docs/en/babel-preset-env#modules
43
43
modules : false ,
44
44
targets : { } ,
45
- forceAllTransforms : webpackConfig . isProduction ( ) ,
46
45
useBuiltIns : webpackConfig . babelOptions . useBuiltIns ,
47
46
corejs : webpackConfig . babelOptions . corejs ,
48
47
} ;
Original file line number Diff line number Diff line change @@ -1148,6 +1148,41 @@ module.exports = {
1148
1148
} ) ;
1149
1149
} ) ;
1150
1150
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
+
1151
1186
it ( 'When enabled, react JSX is transformed!' , ( done ) => {
1152
1187
const config = createWebpackConfig ( 'www/build' , 'dev' ) ;
1153
1188
config . setPublicPath ( '/build' ) ;
You can’t perform that action at this time.
0 commit comments