Skip to content

Commit

Permalink
[v3.8.5] Disable worker for terser rollup plugin and use nameCache in…
Browse files Browse the repository at this point in the history
… 'split' mode. (#72)

* [v3.8.5] Disable worker for terser rollup plugin and use nameCache in 'split' mode.

* Update version to 2.2.19
  • Loading branch information
dumganhar authored Nov 12, 2024
1 parent b43d039 commit d3c7c48
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
10 changes: 7 additions & 3 deletions modules/build-engine/src/engine-js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import rollup = Bundler.core;
import rpBabel = Bundler.plugins.babel.babel;
import RollupBabelInputPluginOptions = Bundler.plugins.babel.RollupBabelInputPluginOptions;
import json = Bundler.plugins.json;
import resolve = Bundler.plugins.nodeResolve;
import nodeResolve = Bundler.plugins.nodeResolve;
import commonjs = Bundler.plugins.commonjs;
import rpTerser = Bundler.plugins.terser;
import rpVirtual = Bundler.plugins.virtual;
Expand Down Expand Up @@ -285,7 +285,7 @@ export async function buildJsEngine(options: Required<buildEngine.Options>): Pro
configFileName: ps.resolve(options.engine, 'tsconfig.json'),
}),

resolve({
nodeResolve({
extensions: ['.js', '.ts', '.json'],
jail: await realPath(engineRoot),
rootDir: engineRoot,
Expand All @@ -295,7 +295,6 @@ export async function buildJsEngine(options: Required<buildEngine.Options>): Pro
preferConst: true,
}),


commonjs({
include: [
/node_modules[/\\]/,
Expand Down Expand Up @@ -351,6 +350,11 @@ export async function buildJsEngine(options: Required<buildEngine.Options>): Pro
// We only do this for CommonJS.
// Especially, we cannot do this for IIFE.
toplevel: rollupFormat === 'cjs',
// Enabling 'split' will have more than one entry, nameCache will not be able to be shared by different workers in rollup-plugin-terser.
// So disable worker if 'split' mode is enabled.
maxWorkers: split ? 0 : undefined,
// Use name cache if it's in 'split' mode.
nameCache: split ? {} : undefined,
}));
}

Expand Down
2 changes: 1 addition & 1 deletion modules/bundler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@cocos/rollup-plugin-node-resolve": "^15.3.0",
"@rollup/plugin-virtual": "^3.0.2",
"@rollup/plugin-typescript": "~11.1.6",
"@cocos/rollup-plugin-terser": "^0.4.4",
"@cocos/rollup-plugin-terser": "^0.4.5",
"fs-extra": "~11.1.1",
"glob": "~7.2.0"
},
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cocos/ccbuild",
"version": "2.2.18",
"version": "2.2.19",
"description": "The next generation of build tool for Cocos engine.",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down

0 comments on commit d3c7c48

Please sign in to comment.