@cocos/ccbuild 1.0.0 → 1.1.0

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 (44) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/lib/build-engine/engine-js/index.d.ts.map +1 -1
  3. package/lib/build-engine/engine-js/index.js +14 -59
  4. package/lib/build-engine/engine-js/index.js.map +1 -1
  5. package/lib/build-engine/engine-js/rollup-plugins/{asset-ref.d.ts → external-wasm-loader.d.ts} +11 -11
  6. package/lib/build-engine/engine-js/rollup-plugins/external-wasm-loader.d.ts.map +1 -0
  7. package/lib/build-engine/engine-js/rollup-plugins/{asset-ref.js → external-wasm-loader.js} +30 -26
  8. package/lib/build-engine/engine-js/rollup-plugins/external-wasm-loader.js.map +1 -0
  9. package/lib/build-engine/engine-ts/engine-builder.d.ts +4 -0
  10. package/lib/build-engine/engine-ts/engine-builder.d.ts.map +1 -1
  11. package/lib/build-engine/engine-ts/engine-builder.js +96 -14
  12. package/lib/build-engine/engine-ts/engine-builder.js.map +1 -1
  13. package/lib/build-engine/engine-ts/field-decorator-helper.d.ts +10 -0
  14. package/lib/build-engine/engine-ts/field-decorator-helper.d.ts.map +1 -0
  15. package/lib/build-engine/engine-ts/field-decorator-helper.js +55 -0
  16. package/lib/build-engine/engine-ts/field-decorator-helper.js.map +1 -0
  17. package/lib/build-engine/engine-ts/plugins/external-wasm-loader.d.ts +7 -0
  18. package/lib/build-engine/engine-ts/plugins/external-wasm-loader.d.ts.map +1 -0
  19. package/lib/build-engine/engine-ts/plugins/external-wasm-loader.js +66 -0
  20. package/lib/build-engine/engine-ts/plugins/external-wasm-loader.js.map +1 -0
  21. package/lib/build-engine/engine-ts/plugins/interface.d.ts +21 -0
  22. package/lib/build-engine/engine-ts/plugins/interface.d.ts.map +1 -0
  23. package/lib/build-engine/engine-ts/plugins/interface.js +2 -0
  24. package/lib/build-engine/engine-ts/plugins/interface.js.map +1 -0
  25. package/lib/stats-query/index.d.ts +1 -0
  26. package/lib/stats-query/index.d.ts.map +1 -1
  27. package/lib/stats-query/index.js +5 -1
  28. package/lib/stats-query/index.js.map +1 -1
  29. package/lib/utils.d.ts +1 -0
  30. package/lib/utils.d.ts.map +1 -1
  31. package/lib/utils.js +6 -1
  32. package/lib/utils.js.map +1 -1
  33. package/package.json +5 -3
  34. package/static/helper-file-decorator.ts +21 -0
  35. package/lib/build-engine/engine-js/rollup-plugins/asset-ref.d.ts.map +0 -1
  36. package/lib/build-engine/engine-js/rollup-plugins/asset-ref.js.map +0 -1
  37. package/lib/build-engine/engine-js/rollup-plugins/asset-url.d.ts +0 -8
  38. package/lib/build-engine/engine-js/rollup-plugins/asset-url.d.ts.map +0 -1
  39. package/lib/build-engine/engine-js/rollup-plugins/asset-url.js +0 -93
  40. package/lib/build-engine/engine-js/rollup-plugins/asset-url.js.map +0 -1
  41. package/lib/build-engine/engine-js/rollup-plugins/code-asset.d.ts +0 -29
  42. package/lib/build-engine/engine-js/rollup-plugins/code-asset.d.ts.map +0 -1
  43. package/lib/build-engine/engine-js/rollup-plugins/code-asset.js +0 -136
  44. package/lib/build-engine/engine-js/rollup-plugins/code-asset.js.map +0 -1
@@ -1,29 +0,0 @@
1
- import type * as rollup from 'rollup';
2
- import * as pluginUtils from '@rollup/pluginutils';
3
- /**
4
- * Excludes specified modules clearly from rollup bundling.
5
- * Requests to these modules are remapped as another place holder module specifiers
6
- * and this plugin will produce a map which records the mapping info.
7
- *
8
- * For instance, give that we want to handle `'@cocos/physx'`. Some modules may have:
9
- * ```ts
10
- * import X from '@cocos/physx';
11
- * ```
12
- * As a result, first, the real `@cocos/physx` module would be wrapped as SystemJS module
13
- * and emitted to build output as a single code file, without bother to rollup(so that pretty fast).
14
- * Then, the bundle generates a module ID, let's say: `placeholder:/@cocos/physx`.
15
- * To use that bundle,
16
- * you need to properly map the `placeholder:/@cocos/physx` for example, through import map,
17
- * to the emitted file.
18
- * The `resultMapping` records which real module the `placeholder:/@cocos/physx` is mapped.
19
- *
20
- * The following requirements should be fulfilled:
21
- * - These modules are all CommonJS modules that only use `exports` and `module.exports`.
22
- * - The module format of rollup bundling should be SystemJS.
23
- */
24
- export declare function codeAsset({ include, exclude, resultMapping, }: {
25
- include?: pluginUtils.FilterPattern;
26
- exclude?: pluginUtils.FilterPattern;
27
- resultMapping: Record<string, string>;
28
- }): rollup.Plugin;
29
- //# sourceMappingURL=code-asset.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"code-asset.d.ts","sourceRoot":"","sources":["../../../../src/build-engine/engine-js/rollup-plugins/code-asset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,QAAQ,CAAC;AAItC,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,SAAS,CAAE,EACvB,OAAO,EACP,OAAO,EACP,aAAa,GAChB,EAAE;IACC,OAAO,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC;IACpC,OAAO,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,GAAG,MAAM,CAAC,MAAM,CAqDhB"}
@@ -1,136 +0,0 @@
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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.codeAsset = void 0;
39
- const fs_extra_1 = __importDefault(require("fs-extra"));
40
- const path_1 = __importDefault(require("path"));
41
- const pluginUtils = __importStar(require("@rollup/pluginutils"));
42
- /**
43
- * Excludes specified modules clearly from rollup bundling.
44
- * Requests to these modules are remapped as another place holder module specifiers
45
- * and this plugin will produce a map which records the mapping info.
46
- *
47
- * For instance, give that we want to handle `'@cocos/physx'`. Some modules may have:
48
- * ```ts
49
- * import X from '@cocos/physx';
50
- * ```
51
- * As a result, first, the real `@cocos/physx` module would be wrapped as SystemJS module
52
- * and emitted to build output as a single code file, without bother to rollup(so that pretty fast).
53
- * Then, the bundle generates a module ID, let's say: `placeholder:/@cocos/physx`.
54
- * To use that bundle,
55
- * you need to properly map the `placeholder:/@cocos/physx` for example, through import map,
56
- * to the emitted file.
57
- * The `resultMapping` records which real module the `placeholder:/@cocos/physx` is mapped.
58
- *
59
- * The following requirements should be fulfilled:
60
- * - These modules are all CommonJS modules that only use `exports` and `module.exports`.
61
- * - The module format of rollup bundling should be SystemJS.
62
- */
63
- function codeAsset({ include, exclude, resultMapping, }) {
64
- const filter = pluginUtils.createFilter(include, exclude);
65
- const emitMap = {};
66
- return {
67
- name: '@cocos/ccbuild|code-asset',
68
- resolveId(source, _importer) {
69
- if (!(source in emitMap)) {
70
- return null;
71
- }
72
- return {
73
- id: source,
74
- external: true,
75
- };
76
- },
77
- load(id) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- if (!filter(id)) {
80
- return null;
81
- }
82
- const placeholderId = generatePlaceholderId(id);
83
- if (!placeholderId) {
84
- this.error(`Can not generate placeholder ID for module ${id}.`);
85
- }
86
- const referenceId = this.emitFile({
87
- type: 'asset',
88
- name: path_1.default.basename(id),
89
- // fileName: path,
90
- source: wrapAsmJs(yield fs_extra_1.default.readFile(id, 'utf8')),
91
- });
92
- const placeholderModuleSpecifier = `split:/${placeholderId}`;
93
- emitMap[placeholderModuleSpecifier] = referenceId;
94
- const code = `
95
- export * from '${placeholderModuleSpecifier}';
96
- import { default as D } from '${placeholderModuleSpecifier}';
97
- export { D as default };
98
- `;
99
- return code;
100
- });
101
- },
102
- generateBundle(_options, _bundle, _isWrite) {
103
- for (const [moduleId, rollupFileReferenceId] of Object.entries(emitMap)) {
104
- resultMapping[moduleId] = this.getFileName(rollupFileReferenceId);
105
- }
106
- },
107
- };
108
- }
109
- exports.codeAsset = codeAsset;
110
- function wrapAsmJs(code) {
111
- return `
112
- System.register([], function (_export) {
113
- return {
114
- execute() {
115
- const _cjsModule = { exports: {} };
116
- const _cjsExports = _cjsModule.exports;
117
- (function(module, exports){
118
- ${code}
119
- })(_cjsModule, _cjsExports);
120
- _export("default", _cjsModule.exports);
121
- },
122
- };
123
- });
124
- `;
125
- }
126
- function generatePlaceholderId(id) {
127
- const parts = id.split(/[\\\/]/g);
128
- if (parts.length !== 0) {
129
- const baseName = parts[parts.length - 1];
130
- if (baseName) {
131
- return baseName;
132
- }
133
- }
134
- return '';
135
- }
136
- //# sourceMappingURL=code-asset.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"code-asset.js","sourceRoot":"","sources":["../../../../src/build-engine/engine-js/rollup-plugins/code-asset.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wDAA0B;AAC1B,gDAAsB;AACtB,iEAAmD;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,SAAS,CAAE,EACvB,OAAO,EACP,OAAO,EACP,aAAa,GAKhB;IACG,MAAM,MAAM,GAAG,WAAW,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAE1D,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,OAAO;QACH,IAAI,EAAE,2BAA2B;QAEjC,SAAS,CAAE,MAAM,EAAE,SAAS;YACxB,IAAI,CAAC,CAAC,MAAM,IAAI,OAAO,CAAC,EAAE;gBACtB,OAAO,IAAI,CAAC;aACf;YACD,OAAO;gBACH,EAAE,EAAE,MAAM;gBACV,QAAQ,EAAE,IAAI;aACjB,CAAC;QACN,CAAC;QAEK,IAAI,CAAE,EAAE;;gBACV,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;oBACb,OAAO,IAAI,CAAC;iBACf;gBAED,MAAM,aAAa,GAAG,qBAAqB,CAAC,EAAE,CAAC,CAAC;gBAChD,IAAI,CAAC,aAAa,EAAE;oBAChB,IAAI,CAAC,KAAK,CAAC,8CAA8C,EAAE,GAAG,CAAC,CAAC;iBACnE;gBAED,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC;oBAC9B,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,cAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACrB,kBAAkB;oBAClB,MAAM,EAAE,SAAS,CAAC,MAAM,kBAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;iBACnD,CAAC,CAAC;gBAEH,MAAM,0BAA0B,GAAG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