@cocos/ccbuild 2.0.3-alpha.12 → 2.0.3-alpha.14

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 (34) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +16 -16
  3. package/modules/build-engine/lib/build-dts.d.ts +7 -0
  4. package/modules/build-engine/lib/build-dts.d.ts.map +1 -0
  5. package/modules/build-engine/lib/build-dts.js +297 -0
  6. package/modules/build-engine/lib/build-dts.js.map +1 -0
  7. package/modules/build-engine/lib/engine-js/rollup-plugins/external-wasm-loader.d.ts +35 -35
  8. package/modules/build-engine/lib/engine-js/rollup-plugins/external-wasm-loader.js +10 -10
  9. package/modules/build-engine/lib/engine-ts/engine-builder.d.ts +1 -0
  10. package/modules/build-engine/lib/engine-ts/engine-builder.d.ts.map +1 -1
  11. package/modules/build-engine/lib/engine-ts/engine-builder.js +75 -6
  12. package/modules/build-engine/lib/engine-ts/engine-builder.js.map +1 -1
  13. package/modules/build-engine/lib/engine-ts/plugins/external-wasm-loader.d.ts +2 -2
  14. package/modules/build-engine/lib/engine-ts/plugins/interface.d.ts +14 -14
  15. package/modules/build-engine/lib/index.d.ts +94 -94
  16. package/modules/build-engine/lib/index.js +16 -16
  17. package/modules/dts-bundler/lib/index.d.ts.map +1 -1
  18. package/modules/dts-bundler/lib/index.js +8 -6
  19. package/modules/dts-bundler/lib/index.js.map +1 -1
  20. package/modules/modularize/lib/module-config.d.ts +74 -70
  21. package/modules/modularize/lib/module-config.d.ts.map +1 -1
  22. package/modules/modularize/lib/module-config.schema.json +4 -0
  23. package/modules/modularize/lib/module-query.d.ts +25 -25
  24. package/modules/modularize/lib/module-query.js +13 -13
  25. package/modules/modularize/lib/platform-config.d.ts +8 -8
  26. package/modules/modularize/lib/platform-config.js +8 -8
  27. package/modules/stats-query/lib/config-interface.d.ts +61 -61
  28. package/modules/stats-query/lib/index.d.ts +61 -61
  29. package/modules/stats-query/lib/index.js +41 -41
  30. package/package.json +1 -1
  31. package/static/helper-dynamic-constants.txt +13 -13
  32. package/static/helper-file-decorator.ts +20 -20
  33. package/static/helper-global-exporter.txt +8 -8
  34. package/static/lib.dom.d.ts +2330 -2330
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log - @cocos/ccbuild
2
2
 
3
+ ## 2.0.3-alpha.14
4
+
5
+ ### Patch Changes
6
+
7
+ - optimize: integrate '@types/cc-ambient-types/query' to build dts files
8
+
9
+ ## 2.0.3-alpha.13
10
+
11
+ ### Patch Changes
12
+
13
+ - fix: build ts engine with dynamic import
14
+
3
15
  ## 2.0.3-alpha.12
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
- # CCBUILD
2
-
3
- The next generation of build tool for Cocos engine.
4
-
5
- # What problems does this build tool solve ?
6
-
7
- - To merge `@editor/quick-compiler` and `@cocos/build-engine`
8
- - To support build cache management
9
- - To support generating ts engine for AOT optimization on Open Harmony
10
- - To support API generation
11
- - To support API report
12
- - To support API document model generation
13
- - To support build modular engine
14
- - More human-friendly log info
15
-
16
- > [I am a maintainer of this repo](./README_MAINTAIN.md)
1
+ # CCBUILD
2
+
3
+ The next generation of build tool for Cocos engine.
4
+
5
+ # What problems does this build tool solve ?
6
+
7
+ - To merge `@editor/quick-compiler` and `@cocos/build-engine`
8
+ - To support build cache management
9
+ - To support generating ts engine for AOT optimization on Open Harmony
10
+ - To support API generation
11
+ - To support API report
12
+ - To support API document model generation
13
+ - To support build modular engine
14
+ - More human-friendly log info
15
+
16
+ > [I am a maintainer of this repo](./README_MAINTAIN.md)
@@ -0,0 +1,7 @@
1
+ export declare function buildDTS(options: {
2
+ engine: string;
3
+ outDir: string;
4
+ withIndex: boolean;
5
+ withExports: boolean;
6
+ withEditorExports: boolean;
7
+ }): Promise<boolean>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-dts.d.ts","sourceRoot":"","sources":["../src/build-dts.ts"],"names":[],"mappings":"AAaA,wBAAsB,QAAQ,CAAE,OAAO,EAAE;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;CAC9B,GAAG,OAAO,CAAC,OAAO,CAAC,CA2OnB"}
@@ -0,0 +1,297 @@
1
+ "use strict";
2
+
3
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
20
+ Object.defineProperty(o, "default", {
21
+ enumerable: true,
22
+ value: v
23
+ });
24
+ } : function (o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = this && this.__importStar || function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
35
+ function adopt(value) {
36
+ return value instanceof P ? value : new P(function (resolve) {
37
+ resolve(value);
38
+ });
39
+ }
40
+ return new (P || (P = Promise))(function (resolve, reject) {
41
+ function fulfilled(value) {
42
+ try {
43
+ step(generator.next(value));
44
+ } catch (e) {
45
+ reject(e);
46
+ }
47
+ }
48
+ function rejected(value) {
49
+ try {
50
+ step(generator["throw"](value));
51
+ } catch (e) {
52
+ reject(e);
53
+ }
54
+ }
55
+ function step(result) {
56
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
57
+ }
58
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
59
+ });
60
+ };
61
+ var __importDefault = this && this.__importDefault || function (mod) {
62
+ return mod && mod.__esModule ? mod : {
63
+ "default": mod
64
+ };
65
+ };
66
+ Object.defineProperty(exports, "__esModule", {
67
+ value: true
68
+ });
69
+ exports.buildDTS = void 0;
70
+ const fs_extra_1 = __importDefault(require("fs-extra"));
71
+ const gift = __importStar(require("tfig"));
72
+ const stats_query_1 = require("../../stats-query/lib/index.js");
73
+ const utils_1 = require("../../utils/lib/index.js");
74
+ const transpiler_1 = require("@ccbuild/transpiler");
75
+ var ts = transpiler_1.typescript.core;
76
+ const DEBUG = false;
77
+ const REMOVE_OLD = !DEBUG;
78
+ const RECOMPILE = !DEBUG;
79
+ const REMOVE_UNBUNDLED_CACHE = !DEBUG;
80
+ function buildDTS(options) {
81
+ var _a;
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ console.log(`Typescript version: ${ts.version}`);
84
+ const {
85
+ engine,
86
+ outDir,
87
+ withIndex = true,
88
+ withExports = false,
89
+ withEditorExports = false
90
+ } = options;
91
+ yield fs_extra_1.default.ensureDir(outDir);
92
+ console.debug(`With index: ${withIndex}`);
93
+ console.debug(`With exports: ${withExports}`);
94
+ console.debug(`With editor exports: ${withEditorExports}`);
95
+ const statsQuery = yield stats_query_1.StatsQuery.create(engine);
96
+ const tsConfigPath = statsQuery.tsConfigPath;
97
+ const unbundledOutDir = utils_1.ps.join(outDir, '__before_bundle');
98
+ const parsedCommandLine = ts.getParsedCommandLineOfConfigFile(tsConfigPath, {
99
+ declaration: true,
100
+ noEmit: false,
101
+ emitDeclarationOnly: true,
102
+ outFile: undefined,
103
+ outDir: unbundledOutDir
104
+ }, {
105
+ onUnRecoverableConfigFileDiagnostic: () => {},
106
+ useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
107
+ readDirectory: ts.sys.readDirectory,
108
+ getCurrentDirectory: ts.sys.getCurrentDirectory,
109
+ fileExists: ts.sys.fileExists,
110
+ readFile: ts.sys.readFile
111
+ });
112
+ if (!parsedCommandLine) {
113
+ throw new Error(`Can not get 'parsedCommandLine'.`);
114
+ }
115
+ const unbundledOutDirNormalized = utils_1.ps.resolve(engine, parsedCommandLine.options.outDir);
116
+ console.debug(`Unbundled will write to: ${unbundledOutDirNormalized}`);
117
+ yield fs_extra_1.default.ensureDir(unbundledOutDirNormalized);
118
+ if (REMOVE_OLD) {
119
+ yield fs_extra_1.default.emptyDir(unbundledOutDirNormalized);
120
+ }
121
+ console.log(`Generating...`);
122
+ const featureUnits = statsQuery.getFeatureUnits().filter(m => m !== 'wait-for-ammo-instantiation');
123
+ const editorExportModules = statsQuery.getEditorPublicModules();
124
+ if (RECOMPILE) {
125
+ let fileNames = parsedCommandLine.fileNames;
126
+ if (withEditorExports) {
127
+ fileNames = fileNames.concat(editorExportModules.map(e => statsQuery.getEditorPublicModuleFile(e)));
128
+ }
129
+ const program = ts.createProgram(fileNames, parsedCommandLine.options);
130
+ const emitResult = program.emit(undefined,
131
+ // targetSourceFile
132
+ undefined,
133
+ // writeFile
134
+ undefined,
135
+ // cancellationToken,
136
+ true,
137
+ // emitOnlyDtsFiles
138
+ undefined);
139
+ const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
140
+ for (const diagnostic of allDiagnostics) {
141
+ let printer;
142
+ switch (diagnostic.category) {
143
+ case ts.DiagnosticCategory.Error:
144
+ printer = console.error;
145
+ break;
146
+ case ts.DiagnosticCategory.Warning:
147
+ printer = console.warn;
148
+ break;
149
+ case ts.DiagnosticCategory.Message:
150
+ case ts.DiagnosticCategory.Suggestion:
151
+ default:
152
+ printer = console.log;
153
+ break;
154
+ }
155
+ if (!printer) {
156
+ continue;
157
+ }
158
+ if (diagnostic.file && diagnostic.start !== undefined) {
159
+ const {
160
+ line,
161
+ character
162
+ } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
163
+ const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine);
164
+ printer(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
165
+ } else {
166
+ printer(`${ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n')}`);
167
+ }
168
+ }
169
+ }
170
+ // HACK: fix comments generated on top level namespace
171
+ // // TODO:
172
+ // let code = fs.readFileSync(tscOutputDtsFile, 'utf8');
173
+ // const regExpRef = /(\/\/\/ <reference types.*)/g;
174
+ // const matches = code.match(regExpRef);
175
+ // code = code.replace(regExpRef, '');
176
+ // if (matches) {
177
+ // let outputUnbundledCode = matches.join('\n');
178
+ // outputUnbundledCode += '\ndeclare const __skip_reference__: never;\n';
179
+ // outputUnbundledCode += code;
180
+ // fs.outputFileSync(tscOutputDtsFile, outputUnbundledCode, 'utf8');
181
+ // }
182
+ const patchSpineCoreDtsSource = utils_1.ps.join(engine, 'cocos', 'spine', 'lib', 'spine-core.d.ts');
183
+ const patchSpineCoreDtsTarget = utils_1.ps.join(unbundledOutDirNormalized, 'cocos', 'spine', 'lib', 'spine-core.d.ts');
184
+ if (!(yield fs_extra_1.default.pathExists(patchSpineCoreDtsSource))) {
185
+ console.debug(`Does 'cocos/spine/lib/spine-core.d.ts' no longer existed? I have a patch for it.`);
186
+ } else {
187
+ console.debug(`It's ${new Date().toLocaleString()}, we're still doing the hack for spine-core.d.ts`);
188
+ yield fs_extra_1.default.ensureDir(utils_1.ps.dirname(patchSpineCoreDtsTarget));
189
+ yield fs_extra_1.default.copyFile(patchSpineCoreDtsSource, patchSpineCoreDtsTarget);
190
+ }
191
+ const giftInputs = [];
192
+ const types = (_a = parsedCommandLine.options.types) === null || _a === void 0 ? void 0 : _a.map(typeFile => `${typeFile}.d.ts`);
193
+ if (types) {
194
+ for (let file of types) {
195
+ const isBareSpecifier = !file.includes('/');
196
+ if (isBareSpecifier) {
197
+ file = require.resolve(`@types/${file.slice(0, -'.d.ts'.length)}`);
198
+ }
199
+ giftInputs.push(file);
200
+ }
201
+ }
202
+ const listGiftInputs = dir => __awaiter(this, void 0, void 0, function* () {
203
+ for (const file of yield fs_extra_1.default.readdir(dir)) {
204
+ const path = utils_1.ps.join(dir, file);
205
+ // eslint-disable-next-line no-await-in-loop
206
+ const stats = yield fs_extra_1.default.stat(path);
207
+ if (stats.isFile()) {
208
+ giftInputs.push(path);
209
+ } else if (stats.isDirectory()) {
210
+ // eslint-disable-next-line no-await-in-loop
211
+ yield listGiftInputs(path);
212
+ }
213
+ }
214
+ });
215
+ yield listGiftInputs(unbundledOutDirNormalized);
216
+ const giftEntries = {};
217
+ const getModuleNameInTsOutFile = moduleFile => {
218
+ const path = utils_1.ps.relative(statsQuery.path, moduleFile);
219
+ const pathDts = path.replace(/\.ts$/, '.d.ts');
220
+ return utils_1.ps.join(unbundledOutDirNormalized, pathDts);
221
+ };
222
+ if (withExports) {
223
+ for (const exportEntry of featureUnits) {
224
+ giftEntries[exportEntry] = getModuleNameInTsOutFile(statsQuery.getFeatureUnitFile(exportEntry));
225
+ }
226
+ }
227
+ if (withEditorExports) {
228
+ for (const editorExportModule of editorExportModules) {
229
+ giftEntries[editorExportModule] = getModuleNameInTsOutFile(statsQuery.getEditorPublicModuleFile(editorExportModule));
230
+ }
231
+ }
232
+ let ccDtsFile;
233
+ if (withIndex && !withExports) {
234
+ ccDtsFile = utils_1.ps.join(unbundledOutDirNormalized, 'virtual-cc.d.ts');
235
+ giftEntries.cc = ccDtsFile;
236
+ giftInputs.push(ccDtsFile);
237
+ const code = `// Auto-generated\n${statsQuery.evaluateIndexModuleSource(featureUnits, featureUnit => getModuleNameInTsOutFile(statsQuery.getFeatureUnitFile(featureUnit)).replace(/\\/g, '/').replace(/\.d.ts$/, ''))}\n`;
238
+ yield fs_extra_1.default.writeFile(ccDtsFile, code, {
239
+ encoding: 'utf8'
240
+ });
241
+ }
242
+ console.log(`Bundling...`);
243
+ try {
244
+ const indexOutputPath = utils_1.ps.join(outDir, 'cc.d.ts');
245
+ const giftResult = gift.bundle({
246
+ input: giftInputs,
247
+ rootDir: unbundledOutDirNormalized,
248
+ name: 'cc',
249
+ rootModule: 'index',
250
+ entries: giftEntries,
251
+ priority: [...(ccDtsFile ? [ccDtsFile] : []) // Things should be exported to 'cc' as far as possible.
252
+ ],
253
+
254
+ privateJsDocTag: 'engineInternal',
255
+ groups: [{
256
+ test: /^cc\/editor.*$/,
257
+ path: utils_1.ps.join(outDir, 'cc.editor.d.ts')
258
+ }, {
259
+ test: /^cc\/.*$/,
260
+ path: utils_1.ps.join(outDir, 'index.d.ts')
261
+ }, {
262
+ test: /^cc.*$/,
263
+ path: indexOutputPath
264
+ }],
265
+ nonExportedSymbolDistribution: [{
266
+ sourceModule: /cocos\/animation\/marionette/,
267
+ targetModule: 'cc/editor/new-gen-anim'
268
+ }, {
269
+ sourceModule: /.*/,
270
+ targetModule: 'cc'
271
+ }]
272
+ });
273
+ yield Promise.all(giftResult.groups.map(group => __awaiter(this, void 0, void 0, function* () {
274
+ yield fs_extra_1.default.outputFile(group.path, group.code, {
275
+ encoding: 'utf8'
276
+ });
277
+ })));
278
+ if (withIndex && withExports) {
279
+ yield fs_extra_1.default.outputFile(indexOutputPath, buildIndexModule(featureUnits, statsQuery), {
280
+ encoding: 'utf8'
281
+ });
282
+ }
283
+ } catch (error) {
284
+ console.error(error);
285
+ return false;
286
+ } finally {
287
+ if (REMOVE_UNBUNDLED_CACHE) {
288
+ yield fs_extra_1.default.remove(unbundledOutDirNormalized);
289
+ }
290
+ }
291
+ return true;
292
+ });
293
+ }
294
+ exports.buildDTS = buildDTS;
295
+ function buildIndexModule(featureUnits, statsQuery) {
296
+ return `declare module "cc" {\n${statsQuery.evaluateIndexModuleSource(featureUnits).split('\n').map(line => ` ${line}`).join('\n')}\n}`;
297
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-dts.js","sourceRoot":"","sources":["../src/build-dts.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E,CACvB,CAAC;aACL;SACJ;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,KAAK,CAAC;SAChB;gBAAS;YACN,IAAI,sBAAsB,EAAE;gBACxB,MAAM,kBAAE,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;aAC9C;SACJ;QAED,OAAO,IAAI,CAAC;;CACf;AAjPD,4BAiPC;AAED,SAAS,gBAAgB,CAAE,YAAsB,EAAE,UAAsB;IACrE,OAAO,0BACH,UAAU,CAAC,yBAAyB,CAAC,YAAY,CAAC;SAC7C,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC;SAC5B,IAAI,CAAC,IAAI,CAClB,KAAK,CAAC;AACV,CAAC"}
@@ -1,62 +1,62 @@
1
1
  import { rollup as Bundler } from "../../../../bundler/lib/index";
2
2
  import rollup = Bundler.core;
3
- /**
4
- * This plugin enable to load script or wasm with url based on 'external://' origin.
3
+ /**
4
+ * This plugin enable to load script or wasm with url based on 'external://' origin.
5
5
  */
6
6
  export declare function externalWasmLoader(options: externalWasmLoader.Options): rollup.Plugin;
7
7
  export declare namespace externalWasmLoader {
8
8
  interface Options {
9
- /**
10
- * The root path of external repository
9
+ /**
10
+ * The root path of external repository
11
11
  */
12
12
  externalRoot: string;
13
- /**
14
- * The wasm support mode:
15
- * 0. not support
16
- * 1. support
17
- * 2. maybe support
13
+ /**
14
+ * The wasm support mode:
15
+ * 0. not support
16
+ * 1. support
17
+ * 2. maybe support
18
18
  */
19
19
  wasmSupportMode: number;
20
- /**
21
- * Whether need a fallback of wasm.
22
- * If true, we need to build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten.
20
+ /**
21
+ * Whether need a fallback of wasm.
22
+ * If true, we need to build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten.
23
23
  */
24
24
  wasmFallback: boolean;
25
- /**
26
- * Whether force banning to emit bullet wasm.
25
+ /**
26
+ * Whether force banning to emit bullet wasm.
27
27
  */
28
28
  forceBanningBulletWasm: boolean;
29
- /**
30
- * Whether cull asm js module.
29
+ /**
30
+ * Whether cull asm js module.
31
31
  */
32
32
  cullAsmJsModule: boolean;
33
- /**
34
- * Whether cull meshopt module, including wasm and asm.js.
33
+ /**
34
+ * Whether cull meshopt module, including wasm and asm.js.
35
35
  */
36
36
  cullMeshopt: boolean;
37
- /**
38
- * Build external wasm module as minigame subpackage.
39
- * This feature is for minigame platforms.
37
+ /**
38
+ * Build external wasm module as minigame subpackage.
39
+ * This feature is for minigame platforms.
40
40
  */
41
41
  wasmSubpackage: boolean;
42
42
  format?: Format;
43
43
  }
44
- /**
45
- * How to generate the reference to external assets:
46
- * - `'relative-from-out'`
47
- * Generate the path relative from `out` directory, does not contain the leading './'.
48
- *
49
- * - `'relative-from-chunk'`
50
- * Generate the path relative from the referencing output chunk.
51
- *
52
- * - `'dynamic'`(default)
53
- * Use runtime `URL` API to resolve the absolute URL.
54
- * This requires `URL` and `import.meta.url` to be valid.
44
+ /**
45
+ * How to generate the reference to external assets:
46
+ * - `'relative-from-out'`
47
+ * Generate the path relative from `out` directory, does not contain the leading './'.
48
+ *
49
+ * - `'relative-from-chunk'`
50
+ * Generate the path relative from the referencing output chunk.
51
+ *
52
+ * - `'dynamic'`(default)
53
+ * Use runtime `URL` API to resolve the absolute URL.
54
+ * This requires `URL` and `import.meta.url` to be valid.
55
55
  */
56
56
  type Format = 'relative-from-out' | 'relative-from-chunk' | 'runtime-resolved';
57
57
  }
58
- /**
59
- * Convert the file path to asset ref URL.
60
- * @param file File path in absolute.
58
+ /**
59
+ * Convert the file path to asset ref URL.
60
+ * @param file File path in absolute.
61
61
  */
62
62
  export declare function pathToAssetRefURL(file: string): string;
@@ -53,8 +53,8 @@ const suffixReplaceConfig = {
53
53
  '.mem': '.mem.bin',
54
54
  '.wasm.fallback': '.wasm.fallback.bin'
55
55
  };
56
- /**
57
- * emit asset and return the export statement
56
+ /**
57
+ * emit asset and return the export statement
58
58
  */
59
59
  function emitAsset(context, filePath) {
60
60
  return __awaiter(this, void 0, void 0, function* () {
@@ -140,9 +140,9 @@ const loadConfig = {
140
140
  cullingContent: `export default function () {}`
141
141
  }
142
142
  };
143
- /**
144
- * This is a module bundler for minigame subpacakge.
145
- * We need an entry script called 'game.js' for each subpackage.
143
+ /**
144
+ * This is a module bundler for minigame subpacakge.
145
+ * We need an entry script called 'game.js' for each subpackage.
146
146
  */
147
147
  class ExternalWasmModuleBundler {
148
148
  constructor(options) {
@@ -239,8 +239,8 @@ class ExternalWasmModuleBundler {
239
239
  });
240
240
  }
241
241
  }
242
- /**
243
- * This plugin enable to load script or wasm with url based on 'external://' origin.
242
+ /**
243
+ * This plugin enable to load script or wasm with url based on 'external://' origin.
244
244
  */
245
245
  function externalWasmLoader(options) {
246
246
  const externalWasmModules = [];
@@ -319,9 +319,9 @@ function externalWasmLoader(options) {
319
319
  };
320
320
  }
321
321
  exports.externalWasmLoader = externalWasmLoader;
322
- /**
323
- * Convert the file path to asset ref URL.
324
- * @param file File path in absolute.
322
+ /**
323
+ * Convert the file path to asset ref URL.
324
+ * @param file File path in absolute.
325
325
  */
326
326
  function pathToAssetRefURL(file) {
327
327
  return `${assetPrefix}${(0, url_1.pathToFileURL)(file).pathname}`;
@@ -51,4 +51,5 @@ export declare class EngineBuilder {
51
51
  private _transform;
52
52
  private _buildIndex;
53
53
  private _copyTypes;
54
+ private _requireEngineModules;
54
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"engine-builder.d.ts","sourceRoot":"","sources":["../../src/engine-ts/engine-builder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAMlD,OAAO,eAAe,GAAG,UAAU,CAAC,eAAe,CAAC;AAepD,yBAAiB,aAAa,CAAC;IAE3B,UAAiB,aAAa;QAC1B,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,C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kC;IACtD,OAAO,CAAC,iBAAiB,CAAqC;IAG9D,OAAO,CAAC,UAAU,CAIhB;IACF,OAAO,CAAC,qBAAqB,CAA8B;IAC3D,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,iBAAiB,CAEvB;IACF,OAAO,CAAC,aAAa,CAA+B;IAEvC,KAAK,CAAE,OAAO,EAAE,aAAa,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC;YAgEhF,YAAY;YAgBZ,YAAY;YAoDZ,SAAS;IA+CvB,OAAO,CAAC,cAAc;YAyBR,QAAQ;IAuBtB,OAAO,CAAC,gBAAgB;YAiBV,KAAK;IAkBnB,OAAO,CAAC,aAAa;YAwDP,UAAU;IAuQxB,OAAO,CAAC,WAAW;YA8BL,UAAU;IA6BxB,OAAO,CAAC,qBAAqB;CAMhC"}
@@ -360,7 +360,7 @@ class EngineBuilder {
360
360
  });
361
361
  }
362
362
  _getDepIdList(file, code) {
363
- const depIdList = [];
363
+ let depIdList = [];
364
364
  (0, utils_1.asserts)(!file.includes('\\'), 'We should use posix path');
365
365
  for (const ex of this._excludeTransform) {
366
366
  if (ex.test(file)) {
@@ -393,8 +393,21 @@ class EngineBuilder {
393
393
  });
394
394
  babel.traverse(res, {
395
395
  ImportDeclaration: importExportVisitor,
396
- ExportDeclaration: importExportVisitor
396
+ ExportDeclaration: importExportVisitor,
397
+ CallExpression: path => {
398
+ if (path.node.callee.type === 'Import') {
399
+ const arg0 = path.node.arguments[0];
400
+ if (arg0.type === 'StringLiteral') {
401
+ depIdList.push(arg0.value);
402
+ }
403
+ }
404
+ },
405
+ TSImportType: path => {
406
+ const specifier = path.node.argument.value;
407
+ depIdList.push(specifier);
408
+ }
397
409
  });
410
+ depIdList = depIdList.filter((id, index) => depIdList.indexOf(id) === index);
398
411
  return depIdList;
399
412
  }
400
413
  _transform(file, code) {
@@ -485,7 +498,7 @@ class EngineBuilder {
485
498
  ImportDeclaration: importExportVisitor,
486
499
  ExportDeclaration: importExportVisitor,
487
500
  // TODO: here we rename class Rect and Path
488
- CallExpression(path) {
501
+ CallExpression: path => {
489
502
  if (path.node.callee.type === 'MemberExpression') {
490
503
  const memberExpressionPath = path.get('callee');
491
504
  const objectPath = memberExpressionPath.get('object');
@@ -506,6 +519,49 @@ class EngineBuilder {
506
519
  // TODO: for now, we transform `import('./xxx/xxx.js')` into `window.__cc_module_context__.import('./xxx/xxx.js')`
507
520
  // we need to support import(`project://xxx`) in the future.
508
521
  path.replaceWith(t.callExpression(t.memberExpression(t.memberExpression(t.identifier('window'), t.identifier('__cc_module_context__')), t.identifier('import')), path.node.arguments));
522
+ const arg0 = path.node.arguments[0];
523
+ if (arg0.type === 'StringLiteral') {
524
+ const specifier = arg0.value;
525
+ // transform import/export declaration if needed
526
+ const overrideId = this._getOverrideId(specifier, file);
527
+ if (overrideId) {
528
+ let relativePath = (0, utils_1.formatPath)(ps.relative(ps.dirname(file), overrideId));
529
+ if (!relativePath.startsWith('.')) {
530
+ relativePath = './' + relativePath;
531
+ }
532
+ if (ps.extname(relativePath) === '.ts') {
533
+ relativePath = relativePath.slice(0, -3); // remove '.ts'
534
+ }
535
+
536
+ traverse(path.node, {
537
+ StringLiteral(path) {
538
+ path.replaceWith(babel.types.stringLiteral(relativePath));
539
+ path.skip();
540
+ }
541
+ }, path.scope);
542
+ }
543
+ }
544
+ }
545
+ },
546
+ TSImportType: path => {
547
+ const specifier = path.node.argument.value;
548
+ // transform import/export declaration if needed
549
+ const overrideId = this._getOverrideId(specifier, file);
550
+ if (overrideId) {
551
+ let relativePath = (0, utils_1.formatPath)(ps.relative(ps.dirname(file), overrideId));
552
+ if (!relativePath.startsWith('.')) {
553
+ relativePath = './' + relativePath;
554
+ }
555
+ if (ps.extname(relativePath) === '.ts') {
556
+ relativePath = relativePath.slice(0, -3); // remove '.ts'
557
+ }
558
+
559
+ traverse(path.node, {
560
+ StringLiteral(path) {
561
+ path.replaceWith(babel.types.stringLiteral(relativePath));
562
+ path.skip();
563
+ }
564
+ }, path.scope);
509
565
  }
510
566
  },
511
567
  ClassDeclaration(path) {
@@ -621,9 +677,16 @@ class EngineBuilder {
621
677
  if (!outDir) {
622
678
  return;
623
679
  }
624
- let dtsFiles = glob_1.glob.sync((0, utils_1.formatPath)(ps.join(root, './@types/**/*.d.ts')));
625
- const externalDtsFiles = glob_1.glob.sync((0, utils_1.formatPath)(ps.join(root, './native/external/**/*.d.ts')));
626
- dtsFiles = dtsFiles.concat(externalDtsFiles);
680
+ let dtsFiles;
681
+ try {
682
+ const ccAmbientTypesQuery = this._requireEngineModules('@types/cc-ambient-types/query');
683
+ dtsFiles = ccAmbientTypesQuery.getDtsFiles();
684
+ } catch (e) {
685
+ // NOTE: if failed to resolve '@types/cc-ambient-types', we use the legacy way to copy dts files.
686
+ dtsFiles = glob_1.glob.sync((0, utils_1.formatPath)(ps.join(root, './@types/**/*.d.ts')));
687
+ const externalDtsFiles = glob_1.glob.sync((0, utils_1.formatPath)(ps.join(root, './native/external/**/*.d.ts')));
688
+ dtsFiles = dtsFiles.concat(externalDtsFiles);
689
+ }
627
690
  for (const file of dtsFiles) {
628
691
  const code = fs.readFileSync(file, 'utf8');
629
692
  const relativePath = ps.relative(root, file);
@@ -638,5 +701,11 @@ class EngineBuilder {
638
701
  fs.outputFileSync(targetDomDts, code, 'utf8');
639
702
  });
640
703
  }
704
+ _requireEngineModules(moduleName) {
705
+ const modulePath = require.resolve(moduleName, {
706
+ paths: [this._options.root]
707
+ });
708
+ return require(modulePath);
709
+ }
641
710
  }
642
711
  exports.EngineBuilder = EngineBuilder;