@cocos/ccbuild 1.0.0-alpha.1 → 1.0.0-alpha.11
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 +30 -0
- package/lib/api-builder.d.ts +1 -0
- package/lib/api-builder.d.ts.map +1 -0
- package/lib/api-builder.js +2 -0
- package/lib/api-builder.js.map +1 -0
- package/lib/build-engine/engine-js/index.d.ts +3 -0
- package/lib/build-engine/engine-js/index.d.ts.map +1 -0
- package/lib/build-engine/engine-js/index.js +460 -0
- package/lib/build-engine/engine-js/index.js.map +1 -0
- package/lib/build-engine/engine-js/rollup-plugins/asset-ref.d.ts +37 -0
- package/lib/build-engine/engine-js/rollup-plugins/asset-ref.d.ts.map +1 -0
- package/lib/build-engine/engine-js/rollup-plugins/asset-ref.js +88 -0
- package/lib/build-engine/engine-js/rollup-plugins/asset-ref.js.map +1 -0
- package/lib/build-engine/engine-js/rollup-plugins/asset-url.d.ts +8 -0
- package/lib/build-engine/engine-js/rollup-plugins/asset-url.d.ts.map +1 -0
- package/lib/build-engine/engine-js/rollup-plugins/asset-url.js +93 -0
- package/lib/build-engine/engine-js/rollup-plugins/asset-url.js.map +1 -0
- package/lib/build-engine/engine-js/rollup-plugins/code-asset.d.ts +29 -0
- package/lib/build-engine/engine-js/rollup-plugins/code-asset.d.ts.map +1 -0
- package/lib/build-engine/engine-js/rollup-plugins/code-asset.js +136 -0
- package/lib/build-engine/engine-js/rollup-plugins/code-asset.js.map +1 -0
- package/lib/build-engine/engine-js/rollup-plugins/remove-deprecated-features.d.ts +3 -0
- package/lib/build-engine/engine-js/rollup-plugins/remove-deprecated-features.d.ts.map +1 -0
- package/lib/build-engine/engine-js/rollup-plugins/remove-deprecated-features.js +38 -0
- package/lib/build-engine/engine-js/rollup-plugins/remove-deprecated-features.js.map +1 -0
- package/lib/build-engine/engine-js/rollup-plugins/ts-paths.d.ts +5 -0
- package/lib/build-engine/engine-js/rollup-plugins/ts-paths.d.ts.map +1 -0
- package/lib/build-engine/engine-js/rollup-plugins/ts-paths.js +43 -0
- package/lib/build-engine/engine-js/rollup-plugins/ts-paths.js.map +1 -0
- package/lib/build-engine/index.d.ts +119 -0
- package/lib/build-engine/index.d.ts.map +1 -0
- package/lib/build-engine/index.js +124 -0
- package/lib/build-engine/index.js.map +1 -0
- package/lib/engine-builder.d.ts +54 -0
- package/lib/engine-builder.d.ts.map +1 -0
- package/lib/engine-builder.js +550 -0
- package/lib/engine-builder.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +35 -0
- package/lib/index.js.map +1 -0
- package/lib/module-resolver.d.ts +8 -0
- package/lib/module-resolver.d.ts.map +1 -0
- package/lib/module-resolver.js +29 -0
- package/lib/module-resolver.js.map +1 -0
- package/lib/stats-query/config-interface.d.ts +130 -0
- package/lib/stats-query/config-interface.d.ts.map +1 -0
- package/lib/stats-query/config-interface.js +4 -0
- package/lib/stats-query/config-interface.js.map +1 -0
- package/lib/stats-query/index.d.ts +162 -0
- package/lib/stats-query/index.d.ts.map +1 -0
- package/lib/stats-query/index.js +528 -0
- package/lib/stats-query/index.js.map +1 -0
- package/lib/stats-query/path-utils.d.ts +3 -0
- package/lib/stats-query/path-utils.d.ts.map +1 -0
- package/lib/stats-query/path-utils.js +36 -0
- package/lib/stats-query/path-utils.js.map +1 -0
- package/lib/transformer/babel.d.ts +6 -0
- package/lib/transformer/babel.d.ts.map +1 -0
- package/lib/transformer/babel.js +35 -0
- package/lib/transformer/babel.js.map +1 -0
- package/lib/transformer/index.d.ts +3 -0
- package/lib/transformer/index.d.ts.map +1 -0
- package/lib/transformer/index.js +29 -0
- package/lib/transformer/index.js.map +1 -0
- package/lib/utils.d.ts +3 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +15 -0
- package/lib/utils.js.map +1 -0
- package/package.json +34 -11
- package/static/helper-dynamic-constants.txt +12 -0
- package/static/helper-global-exporter.txt +9 -0
- package/static/lib.dom.d.ts +20227 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-ref.js","sourceRoot":"","sources":["../../../../src/build-engine/engine-js/rollup-plugins/asset-ref.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,6BAAwD;AACxD,wDAA0B;AAC1B,gDAAsB;AAEtB;;;;;;;;;;GAUG;AACH,SAAgB,QAAQ,CAAE,OAAyB;IAC/C,OAAO;QACH,IAAI,EAAE,2BAA2B;QACjC,4DAA4D;QACtD,SAAS,CAAQ,MAAM,EAAE,QAAQ;;gBACnC,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;oBAChC,OAAO,MAAM,CAAC;iBACjB;gBACD,OAAO,IAAI,CAAC;YAChB,CAAC;SAAA;QAEK,IAAI,CAAE,EAAE;;gBACV,IAAI,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;oBAC5B,MAAM,QAAQ,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;oBAC/C,MAAM,IAAI,GAAG,IAAA,mBAAa,EAAC,UAAU,QAAQ,EAAE,CAAC,CAAC;oBACjD,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC;wBAC9B,IAAI,EAAE,OAAO;wBACb,IAAI,EAAE,cAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;wBACvB,kBAAkB;wBAClB,MAAM,EAAE,MAAM,kBAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;qBAClC,CAAC,CAAC;oBACH,OAAO,8CAA8C,WAAW,GAAG,CAAC;iBACvE;gBACD,OAAO,IAAI,CAAC;YAChB,CAAC;SAAA;QAED,2DAA2D;QAC3D,cAAc,CAAE;QACZ,kGAAkG;QAClG,QAAQ;QACR,gDAAgD;QAChD,uDAAuD;QACvD,iFAAiF;QACjF,YAAY,GACf;YACG,QAAQ,OAAO,CAAC,MAAM,EAAE;gBACxB,KAAK,qBAAqB;oBACtB,OAAO,IAAI,YAAY,GAAG,CAAC;gBAC/B,KAAK,mBAAmB;oBACpB,OAAO,IAAI,QAAQ,GAAG,CAAC;gBAC3B,KAAK,kBAAkB,CAAC;gBAAC;oBACrB,OAAO,SAAS,CAAC,CAAC,yDAAyD;aAC9E;QACL,CAAC;KACJ,CAAC;AACN,CAAC;AA7CD,4BA6CC;AAyBD;;;GAGG;AACH,SAAgB,iBAAiB,CAAE,IAAY;IAC3C,OAAO,GAAG,WAAW,GAAG,IAAA,mBAAa,EAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC3D,CAAC;AAFD,8CAEC;AAED,MAAM,WAAW,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-url.d.ts","sourceRoot":"","sources":["../../../../src/build-engine/engine-js/rollup-plugins/asset-url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,QAAQ,CAAC;AAItC,UAAU,QAAQ;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAID,wBAAgB,QAAQ,CAAE,EACtB,UAAU,EACV,SAAiB,GACpB,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,CAkD1B"}
|
|
@@ -0,0 +1,93 @@
|
|
|
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.assetUrl = void 0;
|
|
39
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
40
|
+
const path_1 = __importStar(require("path"));
|
|
41
|
+
const URL_PROTOCOL = 'url:';
|
|
42
|
+
const PREFIX = `\0${URL_PROTOCOL}`;
|
|
43
|
+
function assetUrl({ engineRoot, useWebGPU = false, }) {
|
|
44
|
+
const files = new Set();
|
|
45
|
+
return {
|
|
46
|
+
name: '@cocos/ccbuild|external-asset',
|
|
47
|
+
resolveId(source, importer) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
if (source.startsWith(URL_PROTOCOL) && importer) {
|
|
50
|
+
const subPath = source.substring(URL_PROTOCOL.length);
|
|
51
|
+
const externalAssetPath = (0, path_1.join)(engineRoot, subPath);
|
|
52
|
+
return PREFIX + externalAssetPath;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
load(id) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
if (id.startsWith(PREFIX)) {
|
|
60
|
+
const path = id.substring(PREFIX.length);
|
|
61
|
+
if (!useWebGPU) {
|
|
62
|
+
return `export default '';`;
|
|
63
|
+
}
|
|
64
|
+
const referenceId = this.emitFile({
|
|
65
|
+
type: 'asset',
|
|
66
|
+
name: path_1.default.basename(path),
|
|
67
|
+
source: yield fs_extra_1.default.readFile(path),
|
|
68
|
+
});
|
|
69
|
+
files.add(referenceId);
|
|
70
|
+
return `export default import.meta.ROLLUP_FILE_URL_${referenceId};`;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
// Generates the `import.meta.ROLLUP_FILE_URL_referenceId`.
|
|
76
|
+
resolveFileUrl({
|
|
77
|
+
// > The path and file name of the emitted asset, relative to `output.dir` without a leading `./`.
|
|
78
|
+
fileName,
|
|
79
|
+
// > The path and file name of the emitted file,
|
|
80
|
+
// > relative to the chunk the file is referenced from.
|
|
81
|
+
// > This will path will contain no leading `./` but may contain a leading `../`.
|
|
82
|
+
relativePath, referenceId, }) {
|
|
83
|
+
if (files.has(referenceId)) {
|
|
84
|
+
return `'${fileName}'`;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
exports.assetUrl = assetUrl;
|
|
93
|
+
//# sourceMappingURL=asset-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-url.js","sourceRoot":"","sources":["../../../../src/build-engine/engine-js/rollup-plugins/asset-url.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wDAA0B;AAC1B,6CAAgC;AAMhC,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,MAAM,MAAM,GAAG,KAAK,YAAY,EAAE,CAAC;AAEnC,SAAgB,QAAQ,CAAE,EACtB,UAAU,EACV,SAAS,GAAG,KAAK,GACV;IACP,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,OAAO;QACH,IAAI,EAAE,+BAA+B;QAE/B,SAAS,CAAQ,MAAM,EAAE,QAAQ;;gBACnC,IAAI,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,QAAQ,EAAE;oBAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;oBACtD,MAAM,iBAAiB,GAAG,IAAA,WAAI,EAAC,UAAU,EAAE,OAAO,CAAC,CAAC;oBACpD,OAAO,MAAM,GAAG,iBAAiB,CAAC;iBACrC;gBAED,OAAO,IAAI,CAAC;YAChB,CAAC;SAAA;QAEK,IAAI,CAAE,EAAE;;gBACV,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;oBACvB,MAAM,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBACzC,IAAI,CAAC,SAAS,EAAE;wBACZ,OAAO,oBAAoB,CAAC;qBAC/B;oBACD,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC;wBAC9B,IAAI,EAAE,OAAO;wBACb,IAAI,EAAE,cAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;wBACvB,MAAM,EAAE,MAAM,kBAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;qBAClC,CAAC,CAAC;oBACH,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;oBACvB,OAAO,8CAA8C,WAAW,GAAG,CAAC;iBACvE;gBACD,OAAO,IAAI,CAAC;YAChB,CAAC;SAAA;QAED,2DAA2D;QAC3D,cAAc,CAAE;QACZ,kGAAkG;QAClG,QAAQ;QACR,gDAAgD;QAChD,uDAAuD;QACvD,iFAAiF;QACjF,YAAY,EAEZ,WAAW,GACd;YACG,IAAI,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;gBACxB,OAAO,IAAI,QAAQ,GAAG,CAAC;aAC1B;iBAAM;gBACH,OAAO,SAAS,CAAC;aACpB;QACL,CAAC;KACJ,CAAC;AACN,CAAC;AArDD,4BAqDC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,UAAU,aAAa,EAAE,CAAC;gBAC7D,OAAO,CAAC,0BAA0B,CAAC,GAAG,WAAW,CAAC;gBAElD,MAAM,IAAI,GAAG;6BACI,0BAA0B;4CACX,0BAA0B;;aAEzD,CAAC;gBAEF,OAAO,IAAI,CAAC;YAChB,CAAC;SAAA;QAED,cAAc,CAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ;YACvC,KAAK,MAAM,CAAC,QAAQ,EAAE,qBAAqB,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;gBACrE,aAAa,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;aACrE;QACL,CAAC;KACJ,CAAC;AACN,CAAC;AA7DD,8BA6DC;AAED,SAAS,SAAS,CAAE,IAAY;IAC5B,OAAO;;;;;;;sBAOW,IAAI;;;;;;KAMrB,CAAC;AACN,CAAC;AAED,SAAS,qBAAqB,CAAE,EAAU;IACtC,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAClC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACzC,IAAI,QAAQ,EAAE;YACV,OAAO,QAAQ,CAAC;SACnB;KACJ;IACD,OAAO,EAAE,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-deprecated-features.d.ts","sourceRoot":"","sources":["../../../../src/build-engine/engine-js/rollup-plugins/remove-deprecated-features.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAIjC,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAiC/E"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const semver_1 = __importDefault(require("semver"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
function removeDeprecatedFeatures(range) {
|
|
9
|
+
const versionRange = range ? new semver_1.default.Range(range) : undefined;
|
|
10
|
+
return {
|
|
11
|
+
name: '@cocos/ccbuild|remove-deprecated-features',
|
|
12
|
+
load(id) {
|
|
13
|
+
if (!path_1.default.isAbsolute(id)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const stem = path_1.default.basename(id, path_1.default.extname(id));
|
|
17
|
+
const match = /^deprecated(-)?(.*)/.exec(stem);
|
|
18
|
+
if (!match) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const versionString = match[2];
|
|
22
|
+
if (versionString.length !== 0) {
|
|
23
|
+
const parsedVersion = semver_1.default.parse(versionString);
|
|
24
|
+
if (!parsedVersion) {
|
|
25
|
+
console.debug(`${id} looks like a deprecated module, but it contains an invalid version.`);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (versionRange && !semver_1.default.satisfies(parsedVersion, versionRange)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
console.debug(`Exclude deprecated module ${id}`);
|
|
33
|
+
return `export {}`;
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.default = removeDeprecatedFeatures;
|
|
38
|
+
//# sourceMappingURL=remove-deprecated-features.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-deprecated-features.js","sourceRoot":"","sources":["../../../../src/build-engine/engine-js/rollup-plugins/remove-deprecated-features.ts"],"names":[],"mappings":";;;;;AACA,oDAA4B;AAC5B,gDAAsB;AAEtB,SAAwB,wBAAwB,CAAE,KAAc;IAC5D,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,gBAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,OAAO;QACH,IAAI,EAAE,2CAA2C;QAEjD,IAAI,CAAQ,EAAU;YAClB,IAAI,CAAC,cAAE,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE;gBACpB,OAAO,IAAI,CAAC;aACf;YAED,MAAM,IAAI,GAAG,cAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,cAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;YAC7C,MAAM,KAAK,GAAG,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/C,IAAI,CAAC,KAAK,EAAE;gBACR,OAAO,IAAI,CAAC;aACf;YAED,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAC/B,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC5B,MAAM,aAAa,GAAG,gBAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;gBAClD,IAAI,CAAC,aAAa,EAAE;oBAChB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,sEAAsE,CAAC,CAAC;oBAC3F,OAAO,IAAI,CAAC;iBACf;gBAED,IAAI,YAAY,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,aAAa,EAAE,YAAY,CAAC,EAAE;oBAChE,OAAO,IAAI,CAAC;iBACf;aACJ;YAED,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;YACjD,OAAO,WAAW,CAAC;QACvB,CAAC;KACJ,CAAC;AACN,CAAC;AAjCD,2CAiCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-paths.d.ts","sourceRoot":"","sources":["../../../../src/build-engine/engine-js/rollup-plugins/ts-paths.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAIjC,MAAM,CAAC,OAAO,WAAW,EACrB,cAAc,GACjB,EAAE;IACC,cAAc,EAAE,MAAM,CAAC;CAC1B,GAAG,MAAM,CAAC,MAAM,CAgChB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
function default_1({ configFileName, }) {
|
|
9
|
+
const parsedCommandLine = typescript_1.default.getParsedCommandLineOfConfigFile(configFileName, {}, {
|
|
10
|
+
onUnRecoverableConfigFileDiagnostic: () => { },
|
|
11
|
+
useCaseSensitiveFileNames: typescript_1.default.sys.useCaseSensitiveFileNames,
|
|
12
|
+
readDirectory: typescript_1.default.sys.readDirectory,
|
|
13
|
+
getCurrentDirectory: typescript_1.default.sys.getCurrentDirectory,
|
|
14
|
+
fileExists: typescript_1.default.sys.fileExists,
|
|
15
|
+
readFile: typescript_1.default.sys.readFile,
|
|
16
|
+
});
|
|
17
|
+
if (!parsedCommandLine) {
|
|
18
|
+
throw new Error(`Failed to read tsconfig`);
|
|
19
|
+
}
|
|
20
|
+
const { baseUrl, paths } = parsedCommandLine.options;
|
|
21
|
+
let resolveId;
|
|
22
|
+
if (paths) {
|
|
23
|
+
const baseUrlNormalized = path_1.default.resolve(configFileName, baseUrl !== null && baseUrl !== void 0 ? baseUrl : '.');
|
|
24
|
+
const simpleMap = {};
|
|
25
|
+
for (const [key, mapped] of Object.entries(paths)) {
|
|
26
|
+
simpleMap[key] = path_1.default.resolve(baseUrlNormalized, mapped[0]);
|
|
27
|
+
}
|
|
28
|
+
resolveId = function (source, importer) {
|
|
29
|
+
if (!(source in simpleMap)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return simpleMap[source];
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
name: 'ts-paths',
|
|
39
|
+
resolveId,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.default = default_1;
|
|
43
|
+
//# sourceMappingURL=ts-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-paths.js","sourceRoot":"","sources":["../../../../src/build-engine/engine-js/rollup-plugins/ts-paths.ts"],"names":[],"mappings":";;;;;AAEA,4DAA4B;AAC5B,gDAAsB;AAEtB,mBAAyB,EACrB,cAAc,GAGjB;IACG,MAAM,iBAAiB,GAAG,oBAAE,CAAC,gCAAgC,CAAC,cAAc,EAAE,EAAE,EAAE;QAC9E,mCAAmC,EAAE,GAAG,EAAE,GAAE,CAAC;QAC7C,yBAAyB,EAAE,oBAAE,CAAC,GAAG,CAAC,yBAAyB;QAC3D,aAAa,EAAE,oBAAE,CAAC,GAAG,CAAC,aAAa;QACnC,mBAAmB,EAAE,oBAAE,CAAC,GAAG,CAAC,mBAAmB;QAC/C,UAAU,EAAE,oBAAE,CAAC,GAAG,CAAC,UAAU;QAC7B,QAAQ,EAAE,oBAAE,CAAC,GAAG,CAAC,QAAQ;KAC5B,CAAC,CAAC;IACH,IAAI,CAAC,iBAAiB,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC9C;IACD,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC;IACrD,IAAI,SAA2C,CAAC;IAChD,IAAI,KAAK,EAAE;QACP,MAAM,iBAAiB,GAAG,cAAE,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,GAAG,CAAC,CAAC;QACrE,MAAM,SAAS,GAA2B,EAAE,CAAC;QAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC/C,SAAS,CAAC,GAAG,CAAC,GAAG,cAAE,CAAC,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SAC7D;QACD,SAAS,GAAG,UAAgB,MAAM,EAAE,QAAQ;YACxC,IAAI,CAAC,CAAC,MAAM,IAAI,SAAS,CAAC,EAAE;gBACxB,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;aAC5B;QACL,CAAC,CAAC;KACL;IACD,OAAO;QACH,IAAI,EAAE,UAAU;QAChB,SAAS;KACZ,CAAC;AACN,CAAC;AApCD,4BAoCC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
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 false
|
|
56
|
+
*/
|
|
57
|
+
ammoJsWasm?: boolean | 'fallback';
|
|
58
|
+
/**
|
|
59
|
+
* If true, all deprecated features/API are excluded.
|
|
60
|
+
* You can also specify a version range(in semver range) to exclude deprecations in specified version(s).
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
noDeprecatedFeatures?: string | boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Experimental.
|
|
66
|
+
*/
|
|
67
|
+
incremental?: string;
|
|
68
|
+
/**
|
|
69
|
+
* BrowsersList targets.
|
|
70
|
+
*/
|
|
71
|
+
targets?: string | string[] | Record<string, string>;
|
|
72
|
+
/**
|
|
73
|
+
* Enable loose compilation.
|
|
74
|
+
*/
|
|
75
|
+
loose?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* How to generate the reference to external assets:
|
|
78
|
+
* - `'relative-from-out'`
|
|
79
|
+
* Generate the path relative from `out` directory, does not contain the leading './'.
|
|
80
|
+
*
|
|
81
|
+
* - `'relative-from-chunk'`
|
|
82
|
+
* Generate the path relative from the referencing output chunk.
|
|
83
|
+
*
|
|
84
|
+
* - `'dynamic'`(default)
|
|
85
|
+
* Use runtime `URL` API to resolve the absolute URL.
|
|
86
|
+
* This requires `URL` and `import.meta.url` to be valid.
|
|
87
|
+
*/
|
|
88
|
+
assetURLFormat?: 'relative-from-out' | 'relative-from-chunk' | 'runtime-resolved';
|
|
89
|
+
}
|
|
90
|
+
interface Result {
|
|
91
|
+
/**
|
|
92
|
+
* Mappings between feature unit name and their actual chunk file, for example:
|
|
93
|
+
* ```js
|
|
94
|
+
* {
|
|
95
|
+
* "core": "./core.js",
|
|
96
|
+
* "gfx-webgl": "./gfx-webgl.js",
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
exports: Record<string, string>;
|
|
101
|
+
/**
|
|
102
|
+
* The compulsory import mappings that should be applied.
|
|
103
|
+
*/
|
|
104
|
+
chunkAliases: Record<string, string>;
|
|
105
|
+
dependencyGraph?: Record<string, string[]>;
|
|
106
|
+
hasCriticalWarns: boolean;
|
|
107
|
+
}
|
|
108
|
+
function transform(code: string, moduleOption: ModuleFormat, loose?: boolean): Promise<{
|
|
109
|
+
code: string;
|
|
110
|
+
}>;
|
|
111
|
+
function isSourceChanged(incrementalFile: string): Promise<boolean>;
|
|
112
|
+
/**
|
|
113
|
+
* Enumerates all chunk files that used by specified feature units.
|
|
114
|
+
* @param meta Metadata of build result.
|
|
115
|
+
* @param featureUnits Feature units.
|
|
116
|
+
*/
|
|
117
|
+
function enumerateDependentChunks(meta: buildEngine.Result, featureUnits: string[]): string[];
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;AAU5C,wBAAsB,WAAW,CAAE,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAU5F;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,OAAO,CAAC;QAEhB;;;;;;;;WAQG;QACH,UAAU,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;QAElC;;;;WAIG;QACH,oBAAoB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAExC;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;QAIrB;;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;KAiBrF;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,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAE3C,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;IAED;;;;OAIG;IACH,SAAgB,wBAAwB,CAAE,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAwBzF;CACJ"}
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
function verifyCache(options) {
|
|
20
|
+
// TODO
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
function buildEngine(options) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
if (verifyCache(options)) {
|
|
26
|
+
throw 'TODO';
|
|
27
|
+
}
|
|
28
|
+
// if (options.platform === 'OPEN_HARMONY') {
|
|
29
|
+
// // we use a custom engine builder for OPEN_HARMONY platform
|
|
30
|
+
// throw 'TODO';
|
|
31
|
+
// } else {
|
|
32
|
+
return (0, engine_js_1.buildJsEngine)(options);
|
|
33
|
+
// }
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.buildEngine = buildEngine;
|
|
37
|
+
(function (buildEngine) {
|
|
38
|
+
function transform(code, moduleOption, loose) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const babelFormat = moduleOptionsToBabelEnvModules(moduleOption);
|
|
41
|
+
const babelFileResult = yield transformer_1.babel.core.transformAsync(code, {
|
|
42
|
+
presets: [[transformer_1.babel.presetEnv, { modules: babelFormat, loose: loose !== null && loose !== void 0 ? loose : true }]],
|
|
43
|
+
});
|
|
44
|
+
if (!babelFileResult || !babelFileResult.code) {
|
|
45
|
+
throw new Error(`Failed to transform!`);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
code: babelFileResult.code,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
buildEngine.transform = transform;
|
|
53
|
+
function moduleOptionsToBabelEnvModules(moduleOptions) {
|
|
54
|
+
switch (moduleOptions) {
|
|
55
|
+
case 'cjs': return 'commonjs';
|
|
56
|
+
case 'system': return 'systemjs';
|
|
57
|
+
case 'iife':
|
|
58
|
+
case 'esm': return false;
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
60
|
+
default: throw new Error(`Unknown module format ${moduleOptions}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function isSourceChanged(incrementalFile) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
let record;
|
|
66
|
+
try {
|
|
67
|
+
record = yield fs_extra_1.default.readJSON(incrementalFile);
|
|
68
|
+
}
|
|
69
|
+
catch (_a) {
|
|
70
|
+
console.debug(`Failed to read incremental file: ${incrementalFile} - rebuild is needed.`);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
for (const file of Object.keys(record)) {
|
|
74
|
+
const mtime = record[file];
|
|
75
|
+
try {
|
|
76
|
+
/* eslint-disable-next-line no-await-in-loop */
|
|
77
|
+
const mtimeNow = (yield fs_extra_1.default.stat(file)).mtimeMs;
|
|
78
|
+
if (mtimeNow !== mtime) {
|
|
79
|
+
console.debug(`Source ${file} in watch files record ${incrementalFile} has a different time stamp - rebuild is needed.`);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (_b) {
|
|
84
|
+
console.debug(`Failed to read source ${file} in watch files record ${incrementalFile} - rebuild is needed.`);
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
buildEngine.isSourceChanged = isSourceChanged;
|
|
92
|
+
/**
|
|
93
|
+
* Enumerates all chunk files that used by specified feature units.
|
|
94
|
+
* @param meta Metadata of build result.
|
|
95
|
+
* @param featureUnits Feature units.
|
|
96
|
+
*/
|
|
97
|
+
function enumerateDependentChunks(meta, featureUnits) {
|
|
98
|
+
const result = [];
|
|
99
|
+
const visited = new Set();
|
|
100
|
+
const addChunk = (chunkFileName) => {
|
|
101
|
+
if (visited.has(chunkFileName)) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
visited.add(chunkFileName);
|
|
105
|
+
result.push(chunkFileName);
|
|
106
|
+
if (meta.dependencyGraph && chunkFileName in meta.dependencyGraph) {
|
|
107
|
+
for (const dependencyChunk of meta.dependencyGraph[chunkFileName]) {
|
|
108
|
+
addChunk(dependencyChunk);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
for (const featureUnit of featureUnits) {
|
|
113
|
+
const chunkFileName = meta.exports[featureUnit];
|
|
114
|
+
if (!chunkFileName) {
|
|
115
|
+
console.error(`Feature unit ${featureUnit} is not in build result!`);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
addChunk(chunkFileName);
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
buildEngine.enumerateDependentChunks = enumerateDependentChunks;
|
|
123
|
+
})(buildEngine = exports.buildEngine || (exports.buildEngine = {}));
|
|
124
|
+
//# sourceMappingURL=index.js.map
|