From 60dbc6ddc5018532bacd8e46879027d6274c4d6a Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 23 Oct 2018 01:18:06 +0330 Subject: [PATCH] fix(builder): use require.resolve to get the path of babel-loader (#4150) --- packages/builder/src/webpack/base.js | 2 +- packages/builder/src/webpack/utils/perf-loader.js | 5 ++++- test/unit/wp.config.test.js | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) 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' })