@cocos/ccbuild 1.1.6 → 1.1.7
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.
- package/CHANGELOG.md +7 -0
- package/README.md +14 -14
- package/lib/api-builder.js +1 -1
- package/lib/build-engine/engine-js/index.d.ts +2 -2
- package/lib/build-engine/engine-js/index.js +412 -412
- package/lib/build-engine/engine-js/index.js.map +1 -1
- package/lib/build-engine/engine-js/rollup-plugins/external-wasm-loader.d.ts +43 -40
- package/lib/build-engine/engine-js/rollup-plugins/external-wasm-loader.d.ts.map +1 -1
- package/lib/build-engine/engine-js/rollup-plugins/external-wasm-loader.js +145 -92
- package/lib/build-engine/engine-js/rollup-plugins/external-wasm-loader.js.map +1 -1
- package/lib/build-engine/engine-js/rollup-plugins/remove-deprecated-features.d.ts +2 -2
- package/lib/build-engine/engine-js/rollup-plugins/remove-deprecated-features.js +37 -37
- package/lib/build-engine/engine-js/rollup-plugins/ts-paths.d.ts +4 -4
- package/lib/build-engine/engine-js/rollup-plugins/ts-paths.js +42 -42
- package/lib/build-engine/engine-ts/engine-builder.d.ts +57 -57
- package/lib/build-engine/engine-ts/engine-builder.js +631 -631
- package/lib/build-engine/engine-ts/field-decorator-helper.d.ts +9 -9
- package/lib/build-engine/engine-ts/field-decorator-helper.js +54 -54
- package/lib/build-engine/engine-ts/index.d.ts +2 -2
- package/lib/build-engine/engine-ts/index.js +34 -34
- package/lib/build-engine/engine-ts/plugins/external-wasm-loader.d.ts +6 -6
- package/lib/build-engine/engine-ts/plugins/external-wasm-loader.js +65 -65
- package/lib/build-engine/engine-ts/plugins/interface.d.ts +20 -20
- package/lib/build-engine/engine-ts/plugins/interface.js +1 -1
- package/lib/build-engine/index.d.ts +130 -130
- package/lib/build-engine/index.js +138 -138
- package/lib/index.d.ts +4 -4
- package/lib/index.js +33 -33
- package/lib/module-resolver.d.ts +7 -7
- package/lib/module-resolver.js +28 -28
- package/lib/stats-query/config-interface.d.ts +129 -129
- package/lib/stats-query/config-interface.js +3 -3
- package/lib/stats-query/index.d.ts +163 -163
- package/lib/stats-query/index.js +531 -531
- package/lib/stats-query/path-utils.d.ts +2 -2
- package/lib/stats-query/path-utils.js +35 -35
- package/lib/transformer/babel.d.ts +5 -5
- package/lib/transformer/babel.js +34 -34
- package/lib/transformer/index.d.ts +2 -2
- package/lib/transformer/index.js +28 -28
- package/lib/utils.d.ts +3 -3
- package/lib/utils.js +19 -19
- package/package.json +2 -2
- package/static/helper-dynamic-constants.txt +13 -13
- package/static/helper-file-decorator.ts +20 -20
- package/static/helper-global-exporter.txt +8 -8
- package/static/lib.dom.d.ts +20227 -20227
|
@@ -1,131 +1,131 @@
|
|
|
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
|
-
dependencyGraph?: Record<string, string[]>;
|
|
118
|
-
hasCriticalWarns: boolean;
|
|
119
|
-
}
|
|
120
|
-
function transform(code: string, moduleOption: ModuleFormat, loose?: boolean): Promise<{
|
|
121
|
-
code: string;
|
|
122
|
-
}>;
|
|
123
|
-
function isSourceChanged(incrementalFile: string): Promise<boolean>;
|
|
124
|
-
/**
|
|
125
|
-
* Enumerates all chunk files that used by specified feature units.
|
|
126
|
-
* @param meta Metadata of build result.
|
|
127
|
-
* @param featureUnits Feature units.
|
|
128
|
-
*/
|
|
129
|
-
function enumerateDependentChunks(meta: buildEngine.Result, featureUnits: string[]): string[];
|
|
130
|
-
}
|
|
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
|
+
dependencyGraph?: Record<string, string[]>;
|
|
118
|
+
hasCriticalWarns: boolean;
|
|
119
|
+
}
|
|
120
|
+
function transform(code: string, moduleOption: ModuleFormat, loose?: boolean): Promise<{
|
|
121
|
+
code: string;
|
|
122
|
+
}>;
|
|
123
|
+
function isSourceChanged(incrementalFile: string): Promise<boolean>;
|
|
124
|
+
/**
|
|
125
|
+
* Enumerates all chunk files that used by specified feature units.
|
|
126
|
+
* @param meta Metadata of build result.
|
|
127
|
+
* @param featureUnits Feature units.
|
|
128
|
+
*/
|
|
129
|
+
function enumerateDependentChunks(meta: buildEngine.Result, featureUnits: string[]): string[];
|
|
130
|
+
}
|
|
131
131
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,139 +1,139 @@
|
|
|
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
|
-
/**
|
|
108
|
-
* Enumerates all chunk files that used by specified feature units.
|
|
109
|
-
* @param meta Metadata of build result.
|
|
110
|
-
* @param featureUnits Feature units.
|
|
111
|
-
*/
|
|
112
|
-
function enumerateDependentChunks(meta, featureUnits) {
|
|
113
|
-
const result = [];
|
|
114
|
-
const visited = new Set();
|
|
115
|
-
const addChunk = (chunkFileName) => {
|
|
116
|
-
if (visited.has(chunkFileName)) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
visited.add(chunkFileName);
|
|
120
|
-
result.push(chunkFileName);
|
|
121
|
-
if (meta.dependencyGraph && chunkFileName in meta.dependencyGraph) {
|
|
122
|
-
for (const dependencyChunk of meta.dependencyGraph[chunkFileName]) {
|
|
123
|
-
addChunk(dependencyChunk);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
for (const featureUnit of featureUnits) {
|
|
128
|
-
const chunkFileName = meta.exports[featureUnit];
|
|
129
|
-
if (!chunkFileName) {
|
|
130
|
-
console.error(`Feature unit ${featureUnit} is not in build result!`);
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
addChunk(chunkFileName);
|
|
134
|
-
}
|
|
135
|
-
return result;
|
|
136
|
-
}
|
|
137
|
-
buildEngine.enumerateDependentChunks = enumerateDependentChunks;
|
|
138
|
-
})(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
|
+
/**
|
|
108
|
+
* Enumerates all chunk files that used by specified feature units.
|
|
109
|
+
* @param meta Metadata of build result.
|
|
110
|
+
* @param featureUnits Feature units.
|
|
111
|
+
*/
|
|
112
|
+
function enumerateDependentChunks(meta, featureUnits) {
|
|
113
|
+
const result = [];
|
|
114
|
+
const visited = new Set();
|
|
115
|
+
const addChunk = (chunkFileName) => {
|
|
116
|
+
if (visited.has(chunkFileName)) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
visited.add(chunkFileName);
|
|
120
|
+
result.push(chunkFileName);
|
|
121
|
+
if (meta.dependencyGraph && chunkFileName in meta.dependencyGraph) {
|
|
122
|
+
for (const dependencyChunk of meta.dependencyGraph[chunkFileName]) {
|
|
123
|
+
addChunk(dependencyChunk);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
for (const featureUnit of featureUnits) {
|
|
128
|
+
const chunkFileName = meta.exports[featureUnit];
|
|
129
|
+
if (!chunkFileName) {
|
|
130
|
+
console.error(`Feature unit ${featureUnit} is not in build result!`);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
addChunk(chunkFileName);
|
|
134
|
+
}
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
buildEngine.enumerateDependentChunks = enumerateDependentChunks;
|
|
138
|
+
})(buildEngine = exports.buildEngine || (exports.buildEngine = {}));
|
|
139
139
|
//# sourceMappingURL=index.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as transformer from './transformer';
|
|
2
|
-
export { buildEngine } from './build-engine';
|
|
3
|
-
export { StatsQuery, ConfigInterface } from './stats-query';
|
|
4
|
-
export { transformer };
|
|
1
|
+
import * as transformer from './transformer';
|
|
2
|
+
export { buildEngine } from './build-engine';
|
|
3
|
+
export { StatsQuery, ConfigInterface } from './stats-query';
|
|
4
|
+
export { transformer };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.transformer = exports.ConfigInterface = exports.StatsQuery = exports.buildEngine = void 0;
|
|
27
|
-
const transformer = __importStar(require("./transformer"));
|
|
28
|
-
exports.transformer = transformer;
|
|
29
|
-
var build_engine_1 = require("./build-engine");
|
|
30
|
-
Object.defineProperty(exports, "buildEngine", { enumerable: true, get: function () { return build_engine_1.buildEngine; } });
|
|
31
|
-
var stats_query_1 = require("./stats-query");
|
|
32
|
-
Object.defineProperty(exports, "StatsQuery", { enumerable: true, get: function () { return stats_query_1.StatsQuery; } });
|
|
33
|
-
Object.defineProperty(exports, "ConfigInterface", { enumerable: true, get: function () { return stats_query_1.ConfigInterface; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.transformer = exports.ConfigInterface = exports.StatsQuery = exports.buildEngine = void 0;
|
|
27
|
+
const transformer = __importStar(require("./transformer"));
|
|
28
|
+
exports.transformer = transformer;
|
|
29
|
+
var build_engine_1 = require("./build-engine");
|
|
30
|
+
Object.defineProperty(exports, "buildEngine", { enumerable: true, get: function () { return build_engine_1.buildEngine; } });
|
|
31
|
+
var stats_query_1 = require("./stats-query");
|
|
32
|
+
Object.defineProperty(exports, "StatsQuery", { enumerable: true, get: function () { return stats_query_1.StatsQuery; } });
|
|
33
|
+
Object.defineProperty(exports, "ConfigInterface", { enumerable: true, get: function () { return stats_query_1.ConfigInterface; } });
|
|
34
34
|
//# sourceMappingURL=index.js.map
|
package/lib/module-resolver.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export interface IResolveResult {
|
|
2
|
-
id: string;
|
|
3
|
-
deps: string[];
|
|
4
|
-
}
|
|
5
|
-
export declare class ModuleResolver {
|
|
6
|
-
resolve(filepath: string): IResolveResult;
|
|
7
|
-
}
|
|
1
|
+
export interface IResolveResult {
|
|
2
|
+
id: string;
|
|
3
|
+
deps: string[];
|
|
4
|
+
}
|
|
5
|
+
export declare class ModuleResolver {
|
|
6
|
+
resolve(filepath: string): IResolveResult;
|
|
7
|
+
}
|
|
8
8
|
//# sourceMappingURL=module-resolver.d.ts.map
|