Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 @@ -173,7 +173,7 @@
presetEnvOptions.targets = options.targets;
}

const babelPlugins: any[] = [];

Check warning on line 176 in modules/build-engine/src/engine-js/index.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
if (!options.targets) {
babelPlugins.push([babelPluginTransformForOf, {
loose: true,
Expand Down Expand Up @@ -229,7 +229,7 @@
if (!process.env.ENGINE_PATH) {
throw new Error('ENGINE_PATH environment variable not set');
}
babelOptions.presets?.push([(): any => ({ plugins: [[decoratorRecorder]] })]);

Check warning on line 232 in modules/build-engine/src/engine-js/index.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
}

const rollupPlugins: rollup.Plugin[] = [];
Expand Down Expand Up @@ -259,7 +259,7 @@

{
name: '@cocos/ccbuild|module-overrides',
resolveId(source, importer): string | null {

Check warning on line 262 in modules/build-engine/src/engine-js/index.ts

View workflow job for this annotation

GitHub Actions / test

'importer' is defined but never used
if (moduleOverrides[source]) {
return source;
} else {
Expand All @@ -285,7 +285,7 @@
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 @@
preferConst: true,
}),


commonjs({
include: [
/node_modules[/\\]/,
Expand Down Expand Up @@ -351,6 +350,11 @@
// 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
Loading