fix(builder): use require.resolve to get the path of babel-loader (#4150)

This commit is contained in:
Pooya Parsa 2018-10-23 01:18:06 +03:30 committed by GitHub
parent ff6385f5a0
commit 60dbc6ddc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -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()
})
},

View File

@ -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'])
}

View File

@ -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' })