diff --git a/packages/builder/src/webpack/base.js b/packages/builder/src/webpack/base.js index 5956e1c32f..c7efcadb08 100644 --- a/packages/builder/src/webpack/base.js +++ b/packages/builder/src/webpack/base.js @@ -164,7 +164,7 @@ export default class WebpackBaseConfig { return !modulesToTranspile.some(module => module.test(file)) }, use: perfLoader.pool('js', { - loader: 'babel-loader', + loader: require.resolve('babel-loader'), options: this.getBabelOptions() }) }, diff --git a/packages/builder/src/webpack/utils/perf-loader.js b/packages/builder/src/webpack/utils/perf-loader.js index d9b7bd10cc..5414c84664 100644 --- a/packages/builder/src/webpack/utils/perf-loader.js +++ b/packages/builder/src/webpack/utils/perf-loader.js @@ -22,7 +22,10 @@ export default class PerfLoader { } warmupAll() { - this.warmup(this.workerPools.js, ['babel-loader', '@babel/preset-env']) + this.warmup(this.workerPools.js, [ + require.resolve('babel-loader'), + require.resolve('@babel/preset-env') + ]) this.warmup(this.workerPools.css, ['css-loader']) } diff --git a/test/unit/wp.config.test.js b/test/unit/wp.config.test.js index 8d3aea4deb..b586ece91b 100644 --- a/test/unit/wp.config.test.js +++ b/test/unit/wp.config.test.js @@ -18,7 +18,10 @@ describe('webpack configuration', () => { perfLoader.warmup = jest.fn() perfLoader.warmupAll() expect(perfLoader.warmup).toHaveBeenCalledTimes(2) - expect(perfLoader.warmup).toHaveBeenCalledWith(js, ['babel-loader', '@babel/preset-env']) + expect(perfLoader.warmup).toHaveBeenCalledWith(js, [ + require.resolve('babel-loader'), + require.resolve('@babel/preset-env') + ]) expect(perfLoader.warmup).toHaveBeenCalledWith(css, ['css-loader']) const loaders = perfLoader.pool('js', { loader: 'test-perf-loader' })