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] Add mangleProperties option #73

Merged
merged 3 commits into from
Nov 20, 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
5 changes: 5 additions & 0 deletions .api/public.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module "@cocos/ccbuild" {

Check warning on line 1 in .api/public.d.ts

View workflow job for this annotation

GitHub Actions / test

File ignored by default.
/**
* @group Merged Types
*/
Expand Down Expand Up @@ -79,6 +79,11 @@
* @note 此功能要求项目中不能有同名的 enum,如果需要同名,可以定义枚举的时候用不同名字,然后在导出的时候 export as 跟其它模块同名的 enum。
*/
inlineEnum?: boolean;
/**
* 是否需要压缩 $ 后缀的属性,只在 release 模式下生效
* @default true
*/
mangleProperties?: boolean;
/**
* 是否生成 source map。
* 若为 `inline` 则生成内联的 source map。
Expand Down
4 changes: 2 additions & 2 deletions modules/build-engine/src/engine-js/index.ts
Original file line number Diff line number Diff line change
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 Down Expand Up @@ -337,9 +337,9 @@
passes: 2, // first: remove deadcodes and const objects, second: drop variables
},
mangle: {
properties: {
properties: options.mangleProperties ? {
regex: /^[a-zA-Z_][a-zA-Z0-9_]{3,}\$$/,
}
} : false,
},
keep_fnames: false,
output: {
Expand Down
6 changes: 6 additions & 0 deletions modules/build-engine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import fs from 'fs-extra';
import { buildTsEngine } from './engine-ts';

function verifyCache (options: buildEngine.Options): boolean {

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

View workflow job for this annotation

GitHub Actions / test

'options' is defined but never used
// TODO
return false;
}
Expand Down Expand Up @@ -132,6 +132,12 @@
*/
inlineEnum?: boolean;

/**
* 是否需要压缩 $ 后缀的属性,只在 release 模式下生效
* @default true
*/
mangleProperties?: boolean;

/**
* 是否生成 source map。
* 若为 `inline` 则生成内联的 source map。
Expand Down
4 changes: 2 additions & 2 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.19",
"version": "2.2.20",
"description": "The next generation of build tool for Cocos engine.",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
Loading