From db051eef4f2dd228885b23150bd64cd836dd6a42 Mon Sep 17 00:00:00 2001 From: hackerman <3372410+aeneasr@users.noreply.github.com> Date: Tue, 29 Sep 2020 16:42:08 +0200 Subject: [PATCH] feat(v2): env variable TERSER_PARALLEL to customize TerserPlugin.parallel (#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 --- packages/docusaurus/src/webpack/base.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus/src/webpack/base.ts b/packages/docusaurus/src/webpack/base.ts index 0e033852d7db..3c7c9acf3a0b 100644 --- a/packages/docusaurus/src/webpack/base.ts +++ b/packages/docusaurus/src/webpack/base.ts @@ -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, @@ -103,7 +114,7 @@ export function createBaseConfig( ? [ new TerserPlugin({ cache: true, - parallel: true, + parallel: terserParallel, sourceMap: false, terserOptions: { parse: {