Skip to content

Commit e5101b4

Browse files
committed
perf: revert babel/ts thread behavior
1 parent 7fd5f25 commit e5101b4

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

packages/@vue/cli-plugin-babel/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ module.exports = {
2222

2323
[cache-loader](https://github.com/webpack-contrib/cache-loader) is enabled by default and cache is stored in `<projectRoot>/node_modules/.cache/babel-loader`.
2424

25+
## Parallelization
26+
27+
[thread-loader](https://github.com/webpack-contrib/thread-loader) is enabled by default when the machine has more than 1 CPU cores. This can be turned off by setting `parallel: false` in `vue.config.js`.
28+
2529
## Installing in an Already Created Project
2630

2731
``` sh

packages/@vue/cli-plugin-babel/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = (api, options) => {
22
const { genCacheConfig } = require('@vue/cli-shared-utils')
3+
const useThreads = process.env.NODE_ENV === 'production' && options.parallel
34
const cliServicePath = require('path').dirname(require.resolve('@vue/cli-service'))
45

56
api.chainWebpack(webpackConfig => {
@@ -29,6 +30,12 @@ module.exports = (api, options) => {
2930
.options(genCacheConfig(api, options, 'babel-loader', 'babel.config.js'))
3031
.end()
3132

33+
if (useThreads) {
34+
jsRule
35+
.use('thread-loader')
36+
.loader('thread-loader')
37+
}
38+
3239
jsRule
3340
.use('babel-loader')
3441
.loader('babel-loader')

packages/@vue/cli-plugin-typescript/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ If opted to use [TSLint](https://palantir.github.io/tslint/) during project crea
1818

1919
[cache-loader](https://github.com/webpack-contrib/cache-loader) is enabled by default and cache is stored in `<projectRoot>/node_modules/.cache/ts-loader`.
2020

21+
## Parallelization
22+
23+
[thread-loader](https://github.com/webpack-contrib/thread-loader) is enabled by default when the machine has more than 1 CPU cores. This can be turned off by setting `parallel: false` in `vue.config.js`.
24+
2125
## Installing in an Already Created Project
2226

2327
``` sh

packages/@vue/cli-plugin-typescript/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ module.exports = (api, options) => {
2626
options: genCacheConfig(api, options, 'ts-loader', 'tsconfig.json')
2727
})
2828

29+
if (useThreads) {
30+
addLoader({
31+
loader: 'thread-loader'
32+
})
33+
}
34+
2935
if (api.hasPlugin('babel')) {
3036
addLoader({
3137
loader: 'babel-loader'

0 commit comments

Comments
 (0)