@@ -369,6 +369,15 @@ ${bannerConfig.copyrightText}${bannerConfig.credit ? creditNote : ''}`,
369
369
hasReact,
370
370
} ;
371
371
372
+ const babelLoaderCacheOptions = {
373
+ // This is a feature of `babel-loader` for webpack (not Babel itself).
374
+ // It enables caching results in ./node_modules/.cache/babel-loader/
375
+ // directory for faster rebuilds.
376
+ cacheDirectory : true ,
377
+ cacheCompression : ! this . isDev ,
378
+ compact : ! this . isDev ,
379
+ } ;
380
+
372
381
// check if babel.config.js is present
373
382
const isBabelConfigPresent = this . config . useBabelConfig ;
374
383
@@ -400,7 +409,7 @@ ${bannerConfig.copyrightText}${bannerConfig.credit ? creditNote : ''}`,
400
409
{
401
410
loader : 'babel-loader' ,
402
411
options : isBabelConfigPresent
403
- ? { }
412
+ ? { ... babelLoaderCacheOptions }
404
413
: this . getOverrideWebpackRuleOptions (
405
414
{
406
415
presets : jsPresets ,
@@ -409,6 +418,7 @@ ${bannerConfig.copyrightText}${bannerConfig.credit ? creditNote : ''}`,
409
418
// rather use the jsBabelOverride
410
419
configFile : false ,
411
420
babelrc : false ,
421
+ ...babelLoaderCacheOptions ,
412
422
} ,
413
423
this . config . jsBabelOverride
414
424
) ,
@@ -432,7 +442,7 @@ ${bannerConfig.copyrightText}${bannerConfig.credit ? creditNote : ''}`,
432
442
{
433
443
loader : 'babel-loader' ,
434
444
options : isBabelConfigPresent
435
- ? { }
445
+ ? { ... babelLoaderCacheOptions }
436
446
: this . getOverrideWebpackRuleOptions (
437
447
{
438
448
presets : tsPresets ,
@@ -441,6 +451,7 @@ ${bannerConfig.copyrightText}${bannerConfig.credit ? creditNote : ''}`,
441
451
// rather use the jsBabelOverride
442
452
configFile : false ,
443
453
babelrc : false ,
454
+ ...babelLoaderCacheOptions ,
444
455
// We don't need plugin-proposal-class-properties
445
456
// because taken care of by @wpackio /base
446
457
// '@babel/proposal-class-properties',
0 commit comments