Skip to content

Commit

Permalink
feat(v2): env variable TERSER_PARALLEL to customize TerserPlugin.para…
Browse files Browse the repository at this point in the history
…llel (#3497)

* fix(v2): disable terser parallel on CIs

Do not run Terser in parallel when using CircleCI or similar CI environments
to avoid "Error: Call retries were exceeded" errors. For more information
see https://github.com/webpack-contrib/terser-webpack-plugin#parallel

`CI=true` is true for:
- https://docs.gitlab.com/ee/ci/variables/#debug-logging
- https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
- https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
- https://docs.travis-ci.com/user/environment-variables/

* fix(v2): check for possibly undefined env variable

* fix(v2): configurable terser parallelization

* fix(v2): correct terser codedoc

* fix(v2): explicitly test for undefined

* fix(v2): add radix to parseInt

* fix(v2): add missing semicolon

* fix(v2): resolve prettier issues

* fix(v2): resolve remaining prettier issues
  • Loading branch information
aeneasr authored Sep 29, 2020
1 parent d3a0145 commit db051ee
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/docusaurus/src/webpack/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ export function excludeJS(modulePath: string): boolean {
);
}

// See https://github.com/webpack-contrib/terser-webpack-plugin#parallel
let terserParallel: boolean | number = true;
if (process.env.TERSER_PARALLEL === 'false') {
terserParallel = false;
} else if (
process.env.TERSER_PARALLEL &&
parseInt(process.env.TERSER_PARALLEL, 10) > 0
) {
terserParallel = parseInt(process.env.TERSER_PARALLEL, 10);
}

export function createBaseConfig(
props: Props,
isServer: boolean,
Expand Down Expand Up @@ -103,7 +114,7 @@ export function createBaseConfig(
? [
new TerserPlugin({
cache: true,
parallel: true,
parallel: terserParallel,
sourceMap: false,
terserOptions: {
parse: {
Expand Down

0 comments on commit db051ee

Please sign in to comment.