@cocos/ccbuild 1.1.17 → 1.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +37 -37
  3. package/lib/api-builder.js +1 -1
  4. package/lib/build-engine/engine-js/index.d.ts +2 -2
  5. package/lib/build-engine/engine-js/index.js +406 -406
  6. package/lib/build-engine/engine-js/rollup-plugins/external-wasm-loader.d.ts +57 -57
  7. package/lib/build-engine/engine-js/rollup-plugins/external-wasm-loader.d.ts.map +1 -1
  8. package/lib/build-engine/engine-js/rollup-plugins/external-wasm-loader.js +323 -298
  9. package/lib/build-engine/engine-js/rollup-plugins/external-wasm-loader.js.map +1 -1
  10. package/lib/build-engine/engine-js/rollup-plugins/remove-deprecated-features.d.ts +2 -2
  11. package/lib/build-engine/engine-js/rollup-plugins/remove-deprecated-features.js +37 -37
  12. package/lib/build-engine/engine-js/rollup-plugins/ts-paths.d.ts +4 -4
  13. package/lib/build-engine/engine-js/rollup-plugins/ts-paths.js +42 -42
  14. package/lib/build-engine/engine-ts/engine-builder.d.ts +57 -57
  15. package/lib/build-engine/engine-ts/engine-builder.js +631 -631
  16. package/lib/build-engine/engine-ts/field-decorator-helper.d.ts +9 -9
  17. package/lib/build-engine/engine-ts/field-decorator-helper.js +54 -54
  18. package/lib/build-engine/engine-ts/index.d.ts +2 -2
  19. package/lib/build-engine/engine-ts/index.js +36 -36
  20. package/lib/build-engine/engine-ts/plugins/external-wasm-loader.d.ts +6 -6
  21. package/lib/build-engine/engine-ts/plugins/external-wasm-loader.js +65 -65
  22. package/lib/build-engine/engine-ts/plugins/interface.d.ts +20 -20
  23. package/lib/build-engine/engine-ts/plugins/interface.js +1 -1
  24. package/lib/build-engine/index.d.ts +145 -145
  25. package/lib/build-engine/index.d.ts.map +1 -1
  26. package/lib/build-engine/index.js +167 -167
  27. package/lib/build-engine/index.js.map +1 -1
  28. package/lib/index.d.ts +4 -4
  29. package/lib/index.js +33 -33
  30. package/lib/module-resolver.d.ts +7 -7
  31. package/lib/module-resolver.js +28 -28
  32. package/lib/stats-query/config-interface.d.ts +129 -129
  33. package/lib/stats-query/config-interface.js +3 -3
  34. package/lib/stats-query/index.d.ts +183 -183
  35. package/lib/stats-query/index.js +531 -531
  36. package/lib/stats-query/path-utils.d.ts +2 -2
  37. package/lib/stats-query/path-utils.js +35 -35
  38. package/lib/transformer/babel.d.ts +5 -5
  39. package/lib/transformer/babel.js +34 -34
  40. package/lib/transformer/index.d.ts +2 -2
  41. package/lib/transformer/index.js +28 -28
  42. package/lib/utils.d.ts +4 -4
  43. package/lib/utils.js +23 -23
  44. package/package.json +1 -1
  45. package/static/helper-dynamic-constants.txt +13 -13
  46. package/static/helper-file-decorator.ts +20 -20
  47. package/static/helper-global-exporter.txt +8 -8
  48. package/static/lib.dom.d.ts +20227 -20227
@@ -1,146 +1,146 @@
1
- import { StatsQuery } from "../stats-query";
2
- export declare function buildEngine(options: buildEngine.Options): Promise<buildEngine.Result>;
3
- export declare namespace buildEngine {
4
- type ModuleFormat = 'esm' | 'cjs' | 'system' | 'iife';
5
- interface Options {
6
- /**
7
- * 引擎仓库目录。
8
- */
9
- engine: string;
10
- /**
11
- * 输出目录。
12
- */
13
- out: string;
14
- mode: StatsQuery.ConstantManager.ModeType;
15
- platform: StatsQuery.ConstantManager.PlatformType;
16
- flags?: Partial<StatsQuery.ConstantManager.IFlagConfig>;
17
- /**
18
- * 包含的功能。
19
- */
20
- features?: string[];
21
- /**
22
- * 输出模块格式。
23
- * @default 'system'
24
- */
25
- moduleFormat?: ModuleFormat;
26
- /**
27
- * 是否对生成结果进行压缩。
28
- * @default false
29
- */
30
- compress?: boolean;
31
- /**
32
- * 是否生成 source map。
33
- * 若为 `inline` 则生成内联的 source map。
34
- * @default false
35
- */
36
- sourceMap?: boolean | 'inline';
37
- /**
38
- * 若 `sourceMap` 为 `true`,此选项指定了 source map 的路径。
39
- * @default `${outputPath.map}`
40
- */
41
- sourceMapFile?: string;
42
- /**
43
- * 若为 `true`,分割出 **所有** 引擎子模块。
44
- * 否则,`.moduleEntries` 指定的所有子模块将被合并成一个单独的 `"cc"` 模块。
45
- * @default false
46
- */
47
- split?: boolean;
48
- /**
49
- * 使用的 ammo.js 版本,也即 `@cocos/ammo` 映射到的版本。
50
- * - 为 `true` 时使用 WebAssembly 版本的 ammo.js;
51
- * - 为 `false` 时使用 asm.js 版本的 ammo.js;
52
- * - 为 `'fallback` 时同时在结果中包含两个版本的 ammo.js,并自动根据环境 fallback 选择。
53
- *
54
- * 注意,`'fallback'` 只有在 SystemJS 和 Async functions 同时支持时才有效。
55
- * @default true
56
- *
57
- * @deprecated 从 1.1.5 版本开始,该选项只会影响 FORCE_BANNING_BULLET_WASM 宏的值
58
- * - 为 `true` 时,FORCE_BANNING_BULLET_WASM 为 false
59
- * - 为 `false` 时,FORCE_BANNING_BULLET_WASM 为 true
60
- * - 为 `'fallback'` 时, FORCE_BANNING_BULLET_WASM 为 false
61
- */
62
- ammoJsWasm?: boolean | 'fallback';
63
- /**
64
- * If true, all deprecated features/API are excluded.
65
- * You can also specify a version range(in semver range) to exclude deprecations in specified version(s).
66
- * @default false
67
- */
68
- noDeprecatedFeatures?: string | boolean;
69
- /**
70
- * Experimental.
71
- */
72
- incremental?: string;
73
- /**
74
- * BrowsersList targets.
75
- */
76
- targets?: string | string[] | Record<string, string>;
77
- /**
78
- * Enable loose compilation.
79
- */
80
- loose?: boolean;
81
- /**
82
- * How to generate the reference to external assets:
83
- * - `'relative-from-out'`
84
- * Generate the path relative from `out` directory, does not contain the leading './'.
85
- *
86
- * - `'relative-from-chunk'`
87
- * Generate the path relative from the referencing output chunk.
88
- *
89
- * - `'dynamic'`(default)
90
- * Use runtime `URL` API to resolve the absolute URL.
91
- * This requires `URL` and `import.meta.url` to be valid.
92
- */
93
- assetURLFormat?: 'relative-from-out' | 'relative-from-chunk' | 'runtime-resolved';
94
- /**
95
- * Preserve engine type info, this options will build a TS engine to the output directory.
96
- * It's useful when we need to take a step towards the AOT optimization.
97
- * This options is only supported on Open Harmony platform for now.
98
- * @default false
99
- */
100
- preserveType?: boolean;
101
- }
102
- interface Result {
103
- /**
104
- * Mappings between feature unit name and their actual chunk file, for example:
105
- * ```js
106
- * {
107
- * "core": "./core.js",
108
- * "gfx-webgl": "./gfx-webgl.js",
109
- * }
110
- * ```
111
- */
112
- exports: Record<string, string>;
113
- /**
114
- * The compulsory import mappings that should be applied.
115
- */
116
- chunkAliases: Record<string, string>;
117
- /**
118
- * The dependency graph, only including dependency chunks.
119
- *
120
- * @deprecated please use `chunkDepGraph` instead.
121
- */
122
- dependencyGraph?: Record<string, string[]>;
123
- chunkDepGraph: Record<string, string[]>;
124
- assetDepGraph: Record<string, string[]>;
125
- hasCriticalWarns: boolean;
126
- }
127
- function transform(code: string, moduleOption: ModuleFormat, loose?: boolean): Promise<{
128
- code: string;
129
- }>;
130
- function isSourceChanged(incrementalFile: string): Promise<boolean>;
131
- /**
132
- * Enumerates all chunk files that used by specified feature units.
133
- * @param meta Metadata of build result.
134
- * @param featureUnits Feature units.
135
- *
136
- * @deprecated since 1.1.11, please use `enumerateAllDependents` instead.
137
- */
138
- function enumerateDependentChunks(meta: buildEngine.Result, featureUnits: string[]): string[];
139
- /**
140
- * Enumerates all chunk files and asset files that used by specified feature units.
141
- * @param meta Metadata of build result.
142
- * @param featureUnits Feature units.
143
- */
144
- function enumerateAllDependents(meta: buildEngine.Result, featureUnits: string[]): string[];
145
- }
1
+ import { StatsQuery } from "../stats-query";
2
+ export declare function buildEngine(options: buildEngine.Options): Promise<buildEngine.Result>;
3
+ export declare namespace buildEngine {
4
+ type ModuleFormat = 'esm' | 'cjs' | 'system' | 'iife';
5
+ interface Options {
6
+ /**
7
+ * 引擎仓库目录。
8
+ */
9
+ engine: string;
10
+ /**
11
+ * 输出目录。
12
+ */
13
+ out: string;
14
+ mode: StatsQuery.ConstantManager.ModeType;
15
+ platform: StatsQuery.ConstantManager.PlatformType;
16
+ flags?: Partial<StatsQuery.ConstantManager.IFlagConfig>;
17
+ /**
18
+ * 包含的功能。
19
+ */
20
+ features?: string[];
21
+ /**
22
+ * 输出模块格式。
23
+ * @default 'system'
24
+ */
25
+ moduleFormat?: ModuleFormat;
26
+ /**
27
+ * 是否对生成结果进行压缩。
28
+ * @default false
29
+ */
30
+ compress?: boolean;
31
+ /**
32
+ * 是否生成 source map。
33
+ * 若为 `inline` 则生成内联的 source map。
34
+ * @default false
35
+ */
36
+ sourceMap?: boolean | 'inline';
37
+ /**
38
+ * 若 `sourceMap` 为 `true`,此选项指定了 source map 的路径。
39
+ * @default `${outputPath.map}`
40
+ */
41
+ sourceMapFile?: string;
42
+ /**
43
+ * 若为 `true`,分割出 **所有** 引擎子模块。
44
+ * 否则,`.moduleEntries` 指定的所有子模块将被合并成一个单独的 `"cc"` 模块。
45
+ * @default false
46
+ */
47
+ split?: boolean;
48
+ /**
49
+ * 使用的 ammo.js 版本,也即 `@cocos/ammo` 映射到的版本。
50
+ * - 为 `true` 时使用 WebAssembly 版本的 ammo.js;
51
+ * - 为 `false` 时使用 asm.js 版本的 ammo.js;
52
+ * - 为 `'fallback` 时同时在结果中包含两个版本的 ammo.js,并自动根据环境 fallback 选择。
53
+ *
54
+ * 注意,`'fallback'` 只有在 SystemJS 和 Async functions 同时支持时才有效。
55
+ * @default true
56
+ *
57
+ * @deprecated 从 1.1.5 版本开始,该选项只会影响 FORCE_BANNING_BULLET_WASM 宏的值
58
+ * - 为 `true` 时,FORCE_BANNING_BULLET_WASM 为 false
59
+ * - 为 `false` 时,FORCE_BANNING_BULLET_WASM 为 true
60
+ * - 为 `'fallback'` 时, FORCE_BANNING_BULLET_WASM 为 false
61
+ */
62
+ ammoJsWasm?: boolean | 'fallback';
63
+ /**
64
+ * If true, all deprecated features/API are excluded.
65
+ * You can also specify a version range(in semver range) to exclude deprecations in specified version(s).
66
+ * @default false
67
+ */
68
+ noDeprecatedFeatures?: string | boolean;
69
+ /**
70
+ * Experimental.
71
+ */
72
+ incremental?: string;
73
+ /**
74
+ * BrowsersList targets.
75
+ */
76
+ targets?: string | string[] | Record<string, string>;
77
+ /**
78
+ * Enable loose compilation.
79
+ */
80
+ loose?: boolean;
81
+ /**
82
+ * How to generate the reference to external assets:
83
+ * - `'relative-from-out'`
84
+ * Generate the path relative from `out` directory, does not contain the leading './'.
85
+ *
86
+ * - `'relative-from-chunk'`
87
+ * Generate the path relative from the referencing output chunk.
88
+ *
89
+ * - `'dynamic'`(default)
90
+ * Use runtime `URL` API to resolve the absolute URL.
91
+ * This requires `URL` and `import.meta.url` to be valid.
92
+ */
93
+ assetURLFormat?: 'relative-from-out' | 'relative-from-chunk' | 'runtime-resolved';
94
+ /**
95
+ * Preserve engine type info, this options will build a TS engine to the output directory.
96
+ * It's useful when we need to take a step towards the AOT optimization.
97
+ * This options is only supported on Open Harmony platform for now.
98
+ * @default false
99
+ */
100
+ preserveType?: boolean;
101
+ }
102
+ interface Result {
103
+ /**
104
+ * Mappings between feature unit name and their actual chunk file, for example:
105
+ * ```js
106
+ * {
107
+ * "core": "./core.js",
108
+ * "gfx-webgl": "./gfx-webgl.js",
109
+ * }
110
+ * ```
111
+ */
112
+ exports: Record<string, string>;
113
+ /**
114
+ * The compulsory import mappings that should be applied.
115
+ */
116
+ chunkAliases: Record<string, string>;
117
+ /**
118
+ * The dependency graph, only including dependency chunks.
119
+ *
120
+ * @deprecated please use `chunkDepGraph` instead.
121
+ */
122
+ dependencyGraph?: Record<string, string[]>;
123
+ chunkDepGraph: Record<string, string[]>;
124
+ assetDepGraph: Record<string, string[]>;
125
+ hasCriticalWarns: boolean;
126
+ }
127
+ function transform(code: string, moduleOption: ModuleFormat, loose?: boolean): Promise<{
128
+ code: string;
129
+ }>;
130
+ function isSourceChanged(incrementalFile: string): Promise<boolean>;
131
+ /**
132
+ * Enumerates all chunk files that used by specified feature units.
133
+ * @param meta Metadata of build result.
134
+ * @param featureUnits Feature units.
135
+ *
136
+ * @deprecated since 1.1.11, please use `enumerateAllDependents` instead.
137
+ */
138
+ function enumerateDependentChunks(meta: buildEngine.Result, featureUnits: string[]): string[];
139
+ /**
140
+ * Enumerates all chunk files and asset files that used by specified feature units.
141
+ * @param meta Metadata of build result.
142
+ * @param featureUnits Feature units.
143
+ */
144
+ function enumerateAllDependents(meta: buildEngine.Result, featureUnits: string[]): string[];
145
+ }
146
146
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build-engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAe5C,wBAAsB,WAAW,CAAE,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAmB5F;AAED,yBAAiB,WAAW,CAAC;IACzB,KAAY,YAAY,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAE7D,UAAiB,OAAO;QACpB;;WAEG;QACH,MAAM,EAAE,MAAM,CAAC;QAEf;;WAEG;QACH,GAAG,EAAE,MAAM,CAAC;QAGZ,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,QAAQ,CAAC;QAE1C,QAAQ,EAAE,UAAU,CAAC,eAAe,CAAC,YAAY,CAAC;QAElD,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;QAExD;;WAEG;QACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QAEpB;;;WAGG;QACH,YAAY,CAAC,EAAE,YAAY,CAAC;QAE5B;;;WAGG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC;QAEnB;;;;WAIG;QACH,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;QAE/B;;;WAGG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;QAEvB;;;;WAIG;QACH,KAAK,CAAC,EAAE,OAA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IrB;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAErD;;WAEG;QACH,KAAK,CAAC,EAAE,OAAO,CAAC;QAEhB;;;;;;;;;;;WAWG;QACH,cAAc,CAAC,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,kBAAkB,CAAC;QAElF;;;;;WAKG;QACH,YAAY,CAAC,EAAE,OAAO,CAAC;KAiB1B;IAED,UAAiB,MAAM;QACnB;;;;;;;;WAQG;QACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAEhC;;WAEG;QACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAErC;;;;WAIG;QACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAE3C,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAExC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAExC,gBAAgB,EAAE,OAAO,CAAC;KAC7B;IAED,SAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,OAAO;;OAWxF;IAaD,SAAsB,eAAe,CAAC,eAAe,EAAE,MAAM,oBAuB5D;IA0CD;;;;;;OAMG;IACH,SAAgB,wBAAwB,CAAE,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAEzF;IAED;;;;OAIG;IACH,SAAgB,sBAAsB,CAAE,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAIvF;CACJ"}
@@ -1,168 +1,168 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.buildEngine = void 0;
16
- const engine_js_1 = require("./engine-js");
17
- const transformer_1 = require("../transformer");
18
- const fs_extra_1 = __importDefault(require("fs-extra"));
19
- const engine_ts_1 = require("./engine-ts");
20
- function verifyCache(options) {
21
- // TODO
22
- return false;
23
- }
24
- function applyDefaultOptions(options) {
25
- var _a;
26
- (_a = options.preserveType) !== null && _a !== void 0 ? _a : (options.preserveType = false);
27
- }
28
- function buildEngine(options) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- applyDefaultOptions(options);
31
- if (verifyCache(options)) {
32
- throw 'TODO';
33
- }
34
- if (options.platform === 'OPEN_HARMONY') {
35
- if (options.preserveType) {
36
- // we use a custom engine builder for OPEN_HARMONY platform when enable preserveType option.
37
- return (0, engine_ts_1.buildTsEngine)(options);
38
- }
39
- else {
40
- return (0, engine_js_1.buildJsEngine)(options);
41
- }
42
- }
43
- else {
44
- if (options.preserveType) {
45
- console.warn(`Currently we haven't support building ts engine on the platform ${options.platform}`);
46
- }
47
- return (0, engine_js_1.buildJsEngine)(options);
48
- }
49
- });
50
- }
51
- exports.buildEngine = buildEngine;
52
- (function (buildEngine) {
53
- function transform(code, moduleOption, loose) {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- const babelFormat = moduleOptionsToBabelEnvModules(moduleOption);
56
- const babelFileResult = yield transformer_1.babel.core.transformAsync(code, {
57
- presets: [[transformer_1.babel.presetEnv, { modules: babelFormat, loose: loose !== null && loose !== void 0 ? loose : true }]],
58
- });
59
- if (!babelFileResult || !babelFileResult.code) {
60
- throw new Error(`Failed to transform!`);
61
- }
62
- return {
63
- code: babelFileResult.code,
64
- };
65
- });
66
- }
67
- buildEngine.transform = transform;
68
- function moduleOptionsToBabelEnvModules(moduleOptions) {
69
- switch (moduleOptions) {
70
- case 'cjs': return 'commonjs';
71
- case 'system': return 'systemjs';
72
- case 'iife':
73
- case 'esm': return false;
74
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
75
- default: throw new Error(`Unknown module format ${moduleOptions}`);
76
- }
77
- }
78
- function isSourceChanged(incrementalFile) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- let record;
81
- try {
82
- record = yield fs_extra_1.default.readJSON(incrementalFile);
83
- }
84
- catch (_a) {
85
- console.debug(`Failed to read incremental file: ${incrementalFile} - rebuild is needed.`);
86
- return true;
87
- }
88
- for (const file of Object.keys(record)) {
89
- const mtime = record[file];
90
- try {
91
- /* eslint-disable-next-line no-await-in-loop */
92
- const mtimeNow = (yield fs_extra_1.default.stat(file)).mtimeMs;
93
- if (mtimeNow !== mtime) {
94
- console.debug(`Source ${file} in watch files record ${incrementalFile} has a different time stamp - rebuild is needed.`);
95
- return true;
96
- }
97
- }
98
- catch (_b) {
99
- console.debug(`Failed to read source ${file} in watch files record ${incrementalFile} - rebuild is needed.`);
100
- return true;
101
- }
102
- }
103
- return false;
104
- });
105
- }
106
- buildEngine.isSourceChanged = isSourceChanged;
107
- function _enumerateDependentChunks(meta, featureUnits) {
108
- const metaExports = meta.exports;
109
- const metaDepGraph = meta.chunkDepGraph;
110
- const result = [];
111
- const visited = new Set();
112
- const addChunk = (chunkFileName) => {
113
- if (visited.has(chunkFileName)) {
114
- return;
115
- }
116
- visited.add(chunkFileName);
117
- result.push(chunkFileName);
118
- if (metaDepGraph && chunkFileName in metaDepGraph) {
119
- for (const dependencyChunk of metaDepGraph[chunkFileName]) {
120
- addChunk(dependencyChunk);
121
- }
122
- }
123
- };
124
- for (const featureUnit of featureUnits) {
125
- const chunkFileName = metaExports[featureUnit];
126
- if (!chunkFileName) {
127
- console.error(`Feature unit ${featureUnit} is not in build result!`);
128
- continue;
129
- }
130
- addChunk(chunkFileName);
131
- }
132
- return result;
133
- }
134
- function _enumerateDependentAssets(meta, dependentChunks) {
135
- const metaDepAsset = meta.assetDepGraph;
136
- let result = [];
137
- for (const chunkName of dependentChunks) {
138
- const depAssets = metaDepAsset[chunkName];
139
- if ((depAssets === null || depAssets === void 0 ? void 0 : depAssets.length) > 0) {
140
- result = result.concat(depAssets);
141
- }
142
- }
143
- return result;
144
- }
145
- /**
146
- * Enumerates all chunk files that used by specified feature units.
147
- * @param meta Metadata of build result.
148
- * @param featureUnits Feature units.
149
- *
150
- * @deprecated since 1.1.11, please use `enumerateAllDependents` instead.
151
- */
152
- function enumerateDependentChunks(meta, featureUnits) {
153
- return _enumerateDependentChunks(meta, featureUnits);
154
- }
155
- buildEngine.enumerateDependentChunks = enumerateDependentChunks;
156
- /**
157
- * Enumerates all chunk files and asset files that used by specified feature units.
158
- * @param meta Metadata of build result.
159
- * @param featureUnits Feature units.
160
- */
161
- function enumerateAllDependents(meta, featureUnits) {
162
- const dependentChunks = _enumerateDependentChunks(meta, featureUnits);
163
- const dependentAssets = _enumerateDependentAssets(meta, dependentChunks);
164
- return dependentAssets.concat(dependentChunks);
165
- }
166
- buildEngine.enumerateAllDependents = enumerateAllDependents;
167
- })(buildEngine = exports.buildEngine || (exports.buildEngine = {}));
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.buildEngine = void 0;
16
+ const engine_js_1 = require("./engine-js");
17
+ const transformer_1 = require("../transformer");
18
+ const fs_extra_1 = __importDefault(require("fs-extra"));
19
+ const engine_ts_1 = require("./engine-ts");
20
+ function verifyCache(options) {
21
+ // TODO
22
+ return false;
23
+ }
24
+ function applyDefaultOptions(options) {
25
+ var _a;
26
+ (_a = options.preserveType) !== null && _a !== void 0 ? _a : (options.preserveType = false);
27
+ }
28
+ function buildEngine(options) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ applyDefaultOptions(options);
31
+ if (verifyCache(options)) {
32
+ throw 'TODO';
33
+ }
34
+ if (options.platform === 'OPEN_HARMONY') {
35
+ if (options.preserveType) {
36
+ // we use a custom engine builder for OPEN_HARMONY platform when enable preserveType option.
37
+ return (0, engine_ts_1.buildTsEngine)(options);
38
+ }
39
+ else {
40
+ return (0, engine_js_1.buildJsEngine)(options);
41
+ }
42
+ }
43
+ else {
44
+ if (options.preserveType) {
45
+ console.warn(`Currently we haven't support building ts engine on the platform ${options.platform}`);
46
+ }
47
+ return (0, engine_js_1.buildJsEngine)(options);
48
+ }
49
+ });
50
+ }
51
+ exports.buildEngine = buildEngine;
52
+ (function (buildEngine) {
53
+ function transform(code, moduleOption, loose) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const babelFormat = moduleOptionsToBabelEnvModules(moduleOption);
56
+ const babelFileResult = yield transformer_1.babel.core.transformAsync(code, {
57
+ presets: [[transformer_1.babel.presetEnv, { modules: babelFormat, loose: loose !== null && loose !== void 0 ? loose : true }]],
58
+ });
59
+ if (!babelFileResult || !babelFileResult.code) {
60
+ throw new Error(`Failed to transform!`);
61
+ }
62
+ return {
63
+ code: babelFileResult.code,
64
+ };
65
+ });
66
+ }
67
+ buildEngine.transform = transform;
68
+ function moduleOptionsToBabelEnvModules(moduleOptions) {
69
+ switch (moduleOptions) {
70
+ case 'cjs': return 'commonjs';
71
+ case 'system': return 'systemjs';
72
+ case 'iife':
73
+ case 'esm': return false;
74
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
75
+ default: throw new Error(`Unknown module format ${moduleOptions}`);
76
+ }
77
+ }
78
+ function isSourceChanged(incrementalFile) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ let record;
81
+ try {
82
+ record = yield fs_extra_1.default.readJSON(incrementalFile);
83
+ }
84
+ catch (_a) {
85
+ console.debug(`Failed to read incremental file: ${incrementalFile} - rebuild is needed.`);
86
+ return true;
87
+ }
88
+ for (const file of Object.keys(record)) {
89
+ const mtime = record[file];
90
+ try {
91
+ /* eslint-disable-next-line no-await-in-loop */
92
+ const mtimeNow = (yield fs_extra_1.default.stat(file)).mtimeMs;
93
+ if (mtimeNow !== mtime) {
94
+ console.debug(`Source ${file} in watch files record ${incrementalFile} has a different time stamp - rebuild is needed.`);
95
+ return true;
96
+ }
97
+ }
98
+ catch (_b) {
99
+ console.debug(`Failed to read source ${file} in watch files record ${incrementalFile} - rebuild is needed.`);
100
+ return true;
101
+ }
102
+ }
103
+ return false;
104
+ });
105
+ }
106
+ buildEngine.isSourceChanged = isSourceChanged;
107
+ function _enumerateDependentChunks(meta, featureUnits) {
108
+ const metaExports = meta.exports;
109
+ const metaDepGraph = meta.chunkDepGraph;
110
+ const result = [];
111
+ const visited = new Set();
112
+ const addChunk = (chunkFileName) => {
113
+ if (visited.has(chunkFileName)) {
114
+ return;
115
+ }
116
+ visited.add(chunkFileName);
117
+ result.push(chunkFileName);
118
+ if (metaDepGraph && chunkFileName in metaDepGraph) {
119
+ for (const dependencyChunk of metaDepGraph[chunkFileName]) {
120
+ addChunk(dependencyChunk);
121
+ }
122
+ }
123
+ };
124
+ for (const featureUnit of featureUnits) {
125
+ const chunkFileName = metaExports[featureUnit];
126
+ if (!chunkFileName) {
127
+ console.error(`Feature unit ${featureUnit} is not in build result!`);
128
+ continue;
129
+ }
130
+ addChunk(chunkFileName);
131
+ }
132
+ return result;
133
+ }
134
+ function _enumerateDependentAssets(meta, dependentChunks) {
135
+ const metaDepAsset = meta.assetDepGraph;
136
+ let result = [];
137
+ for (const chunkName of dependentChunks) {
138
+ const depAssets = metaDepAsset[chunkName];
139
+ if ((depAssets === null || depAssets === void 0 ? void 0 : depAssets.length) > 0) {
140
+ result = result.concat(depAssets);
141
+ }
142
+ }
143
+ return result;
144
+ }
145
+ /**
146
+ * Enumerates all chunk files that used by specified feature units.
147
+ * @param meta Metadata of build result.
148
+ * @param featureUnits Feature units.
149
+ *
150
+ * @deprecated since 1.1.11, please use `enumerateAllDependents` instead.
151
+ */
152
+ function enumerateDependentChunks(meta, featureUnits) {
153
+ return _enumerateDependentChunks(meta, featureUnits);
154
+ }
155
+ buildEngine.enumerateDependentChunks = enumerateDependentChunks;
156
+ /**
157
+ * Enumerates all chunk files and asset files that used by specified feature units.
158
+ * @param meta Metadata of build result.
159
+ * @param featureUnits Feature units.
160
+ */
161
+ function enumerateAllDependents(meta, featureUnits) {
162
+ const dependentChunks = _enumerateDependentChunks(meta, featureUnits);
163
+ const dependentAssets = _enumerateDependentAssets(meta, dependentChunks);
164
+ return dependentAssets.concat(dependentChunks);
165
+ }
166
+ buildEngine.enumerateAllDependents = enumerateAllDependents;
167
+ })(buildEngine = exports.buildEngine || (exports.buildEngine = {}));
168
168
  //# sourceMappingURL=index.js.map