@cocos/ccbuild 2.0.3-alpha.5 → 2.0.3-alpha.6

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 (42) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/src/index.d.ts +3 -1
  3. package/lib/src/index.d.ts.map +1 -1
  4. package/lib/src/index.js +3 -1
  5. package/lib/src/index.js.map +1 -1
  6. package/modules/build-engine/lib/index.d.ts +6 -0
  7. package/modules/build-engine/lib/index.d.ts.map +1 -1
  8. package/modules/build-engine/lib/index.js +6 -0
  9. package/modules/build-engine/lib/index.js.map +1 -1
  10. package/modules/modularize/lib/index.d.ts +3 -20
  11. package/modules/modularize/lib/index.d.ts.map +1 -1
  12. package/modules/modularize/lib/index.js +20 -75
  13. package/modules/modularize/lib/index.js.map +1 -1
  14. package/modules/modularize/lib/module-config.d.ts +125 -0
  15. package/modules/modularize/lib/module-config.d.ts.map +1 -0
  16. package/modules/modularize/lib/module-config.js +6 -0
  17. package/modules/modularize/lib/module-config.js.map +1 -0
  18. package/modules/modularize/lib/module-config.schema.json +418 -0
  19. package/modules/modularize/lib/module-query.d.ts +50 -0
  20. package/modules/modularize/lib/module-query.d.ts.map +1 -0
  21. package/modules/modularize/lib/module-query.js +164 -0
  22. package/modules/modularize/lib/module-query.js.map +1 -0
  23. package/modules/modularize/lib/platform-config.d.ts +43 -0
  24. package/modules/modularize/lib/platform-config.d.ts.map +1 -0
  25. package/modules/modularize/lib/platform-config.js +52 -0
  26. package/modules/modularize/lib/platform-config.js.map +1 -0
  27. package/modules/stats-query/lib/cc.config.schema.json +216 -0
  28. package/modules/stats-query/lib/config-interface.js +1 -1
  29. package/modules/stats-query/lib/config-interface.js.map +1 -1
  30. package/modules/stats-query/lib/index.d.ts +8 -19
  31. package/modules/stats-query/lib/index.d.ts.map +1 -1
  32. package/modules/stats-query/lib/index.js +5 -0
  33. package/modules/stats-query/lib/index.js.map +1 -1
  34. package/modules/transformer/lib/index.d.ts +2 -1
  35. package/modules/transformer/lib/index.d.ts.map +1 -1
  36. package/modules/transformer/lib/index.js +4 -2
  37. package/modules/transformer/lib/index.js.map +1 -1
  38. package/modules/transformer/lib/typescript/index.d.ts +2 -0
  39. package/modules/transformer/lib/typescript/index.d.ts.map +1 -0
  40. package/modules/transformer/lib/typescript/index.js +39 -0
  41. package/modules/transformer/lib/typescript/index.js.map +1 -0
  42. package/package.json +5 -5
@@ -0,0 +1,418 @@
1
+ {
2
+ "$ref": "#/definitions/ModuleConfig",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "ModuleConfig": {
6
+ "additionalProperties": {},
7
+ "properties": {
8
+ "cc": {
9
+ "additionalProperties": false,
10
+ "description": "This is a CC-specific item difference from the node package.json standard specification.",
11
+ "properties": {
12
+ "assetDependencies": {
13
+ "description": "The module asset dependencies, which is an array of asset uuid.",
14
+ "items": {
15
+ "type": "string"
16
+ },
17
+ "type": "array"
18
+ },
19
+ "moduleOverrides": {
20
+ "description": "This is different with conditional exports. Sometimes we just want to override a script file instead of the whole module. Module override could support to do this job.\n- eg. { \"test\": \"context.mode === 'BUILD'\", \"overrides\": { \"/path/to/dev.ts\": \"/path/to/build.ts\" } }",
21
+ "items": {
22
+ "additionalProperties": false,
23
+ "properties": {
24
+ "overrides": {
25
+ "additionalProperties": {
26
+ "type": "string"
27
+ },
28
+ "description": "The override config, override mapping from key to value.",
29
+ "type": "object"
30
+ },
31
+ "test": {
32
+ "description": "The test string to evaluate.",
33
+ "type": "string"
34
+ }
35
+ },
36
+ "required": [
37
+ "test",
38
+ "overrides"
39
+ ],
40
+ "type": "object"
41
+ },
42
+ "type": "array"
43
+ }
44
+ },
45
+ "type": "object"
46
+ },
47
+ "dependencies": {
48
+ "additionalProperties": {
49
+ "type": "string"
50
+ },
51
+ "description": "Specify the module dependencies is required if this module import another one. We need this field to generate the module dependency graph.",
52
+ "type": "object"
53
+ },
54
+ "devDependencies": {
55
+ "additionalProperties": {
56
+ "type": "string"
57
+ },
58
+ "description": "Specify the dev dependencies, these dependencies are always used in `scripts` folder.",
59
+ "type": "object"
60
+ },
61
+ "exports": {
62
+ "additionalProperties": false,
63
+ "description": "The config for conditional exports.",
64
+ "properties": {
65
+ ".": {
66
+ "additionalProperties": {
67
+ "type": "string"
68
+ },
69
+ "description": "This is exported to the game runtime. Also we build the `cc.d.ts` with this export condition's `types` field. `node` field is required to resolve the path of package.json for build tools.",
70
+ "properties": {
71
+ "minigame": {
72
+ "anyOf": [
73
+ {
74
+ "additionalProperties": false,
75
+ "properties": {
76
+ "alipay": {
77
+ "type": "string"
78
+ },
79
+ "baidu": {
80
+ "type": "string"
81
+ },
82
+ "bytedance": {
83
+ "type": "string"
84
+ },
85
+ "cocosplay": {
86
+ "type": "string"
87
+ },
88
+ "default": {
89
+ "description": "Default platform export for unspecified platforms.",
90
+ "type": "string"
91
+ },
92
+ "huawei": {
93
+ "type": "string"
94
+ },
95
+ "linksure": {
96
+ "type": "string"
97
+ },
98
+ "oppo": {
99
+ "type": "string"
100
+ },
101
+ "qtt": {
102
+ "type": "string"
103
+ },
104
+ "taobao": {
105
+ "type": "string"
106
+ },
107
+ "taobao_minigame": {
108
+ "type": "string"
109
+ },
110
+ "vivo": {
111
+ "type": "string"
112
+ },
113
+ "wechat": {
114
+ "type": "string"
115
+ },
116
+ "wechat_mini_program": {
117
+ "type": "string"
118
+ },
119
+ "xiaomi": {
120
+ "type": "string"
121
+ }
122
+ },
123
+ "required": [
124
+ "default"
125
+ ],
126
+ "type": "object"
127
+ },
128
+ {
129
+ "type": "string"
130
+ }
131
+ ],
132
+ "description": "Abstract platform export, like `web`, `native` and `minigame`. Usually this is used for PAL modules. The build tools resolve the relative platform as entry according to the build platform config.\n- The value can be a `string` or a `object` which requires a default item. eg. { \"web\": \"/path/to/index.ts\" } is equals to { \"web\": { default: \"/path/to/index.ts\" } }.\n- We can also specify the exact platform like { \"web\": {default: \"/path/to/index.ts\", \"web-desktop\": \"/path/to/index.ts\" } }."
133
+ },
134
+ "native": {
135
+ "anyOf": [
136
+ {
137
+ "additionalProperties": false,
138
+ "properties": {
139
+ "android": {
140
+ "type": "string"
141
+ },
142
+ "default": {
143
+ "description": "Default platform export for unspecified platforms.",
144
+ "type": "string"
145
+ },
146
+ "ios": {
147
+ "type": "string"
148
+ },
149
+ "linux": {
150
+ "type": "string"
151
+ },
152
+ "mac": {
153
+ "type": "string"
154
+ },
155
+ "native_editor": {
156
+ "type": "string"
157
+ },
158
+ "ohos": {
159
+ "type": "string"
160
+ },
161
+ "open_harmony": {
162
+ "type": "string"
163
+ },
164
+ "windows": {
165
+ "type": "string"
166
+ }
167
+ },
168
+ "required": [
169
+ "default"
170
+ ],
171
+ "type": "object"
172
+ },
173
+ {
174
+ "type": "string"
175
+ }
176
+ ],
177
+ "description": "Abstract platform export, like `web`, `native` and `minigame`. Usually this is used for PAL modules. The build tools resolve the relative platform as entry according to the build platform config.\n- The value can be a `string` or a `object` which requires a default item. eg. { \"web\": \"/path/to/index.ts\" } is equals to { \"web\": { default: \"/path/to/index.ts\" } }.\n- We can also specify the exact platform like { \"web\": {default: \"/path/to/index.ts\", \"web-desktop\": \"/path/to/index.ts\" } }."
178
+ },
179
+ "node": {
180
+ "const": "./package.json",
181
+ "description": "`node` should be specified as './package.json' to resolve the path of package.json for build tools.",
182
+ "type": "string"
183
+ },
184
+ "types": {
185
+ "description": "This is the main module export condition.\n- The dts bundle tools resolve this condition as entry.\n- The API doc tools resolve this condition as entry.\n- If no platform export is specified, the build tools resolve this condition as entry.",
186
+ "type": "string"
187
+ },
188
+ "web": {
189
+ "anyOf": [
190
+ {
191
+ "additionalProperties": false,
192
+ "properties": {
193
+ "default": {
194
+ "description": "Default platform export for unspecified platforms.",
195
+ "type": "string"
196
+ },
197
+ "web_desktop": {
198
+ "type": "string"
199
+ },
200
+ "web_editor": {
201
+ "type": "string"
202
+ },
203
+ "web_mobile": {
204
+ "type": "string"
205
+ }
206
+ },
207
+ "required": [
208
+ "default"
209
+ ],
210
+ "type": "object"
211
+ },
212
+ {
213
+ "type": "string"
214
+ }
215
+ ],
216
+ "description": "Abstract platform export, like `web`, `native` and `minigame`. Usually this is used for PAL modules. The build tools resolve the relative platform as entry according to the build platform config.\n- The value can be a `string` or a `object` which requires a default item. eg. { \"web\": \"/path/to/index.ts\" } is equals to { \"web\": { default: \"/path/to/index.ts\" } }.\n- We can also specify the exact platform like { \"web\": {default: \"/path/to/index.ts\", \"web-desktop\": \"/path/to/index.ts\" } }."
217
+ }
218
+ },
219
+ "required": [
220
+ "node",
221
+ "types"
222
+ ],
223
+ "type": "object"
224
+ },
225
+ "./editor": {
226
+ "additionalProperties": {
227
+ "type": "string"
228
+ },
229
+ "description": "This is exported to the editor, which is useful when we need to export some editor only interfaces. Also we build `cc.editor.d.ts` from this export condition's `types` field. If this is not specified, we use the '.' export condition by default for module editor export, otherwise, the build tools merges '.' and './editor' exports together for editor runtime environment. It is different with `web_editor` or `native_editor` platform export:\n- this condition exports some editor specific interfaces which is not cross-platform.\n- the `web_editor` or `native_editor` platform export is an editor version of implementation of interfaces defined in `types` field which should be cross-platform.",
230
+ "properties": {
231
+ "types": {
232
+ "description": "This is the main module export condition.\n- The dts bundle tools resolve this condition as entry.\n- The API doc tools resolve this condition as entry.\n- If no platform export is specified, the build tools resolve this condition as entry.",
233
+ "type": "string"
234
+ }
235
+ },
236
+ "required": [
237
+ "types"
238
+ ],
239
+ "type": "object"
240
+ },
241
+ "./internal": {
242
+ "additionalProperties": {
243
+ "type": "string"
244
+ },
245
+ "description": "This is exported to the engine internal. It useful when we need to export some friend interfaces for internal engine modules.",
246
+ "properties": {
247
+ "minigame": {
248
+ "anyOf": [
249
+ {
250
+ "additionalProperties": false,
251
+ "properties": {
252
+ "alipay": {
253
+ "type": "string"
254
+ },
255
+ "baidu": {
256
+ "type": "string"
257
+ },
258
+ "bytedance": {
259
+ "type": "string"
260
+ },
261
+ "cocosplay": {
262
+ "type": "string"
263
+ },
264
+ "default": {
265
+ "description": "Default platform export for unspecified platforms.",
266
+ "type": "string"
267
+ },
268
+ "huawei": {
269
+ "type": "string"
270
+ },
271
+ "linksure": {
272
+ "type": "string"
273
+ },
274
+ "oppo": {
275
+ "type": "string"
276
+ },
277
+ "qtt": {
278
+ "type": "string"
279
+ },
280
+ "taobao": {
281
+ "type": "string"
282
+ },
283
+ "taobao_minigame": {
284
+ "type": "string"
285
+ },
286
+ "vivo": {
287
+ "type": "string"
288
+ },
289
+ "wechat": {
290
+ "type": "string"
291
+ },
292
+ "wechat_mini_program": {
293
+ "type": "string"
294
+ },
295
+ "xiaomi": {
296
+ "type": "string"
297
+ }
298
+ },
299
+ "required": [
300
+ "default"
301
+ ],
302
+ "type": "object"
303
+ },
304
+ {
305
+ "type": "string"
306
+ }
307
+ ],
308
+ "description": "Abstract platform export, like `web`, `native` and `minigame`. Usually this is used for PAL modules. The build tools resolve the relative platform as entry according to the build platform config.\n- The value can be a `string` or a `object` which requires a default item. eg. { \"web\": \"/path/to/index.ts\" } is equals to { \"web\": { default: \"/path/to/index.ts\" } }.\n- We can also specify the exact platform like { \"web\": {default: \"/path/to/index.ts\", \"web-desktop\": \"/path/to/index.ts\" } }."
309
+ },
310
+ "native": {
311
+ "anyOf": [
312
+ {
313
+ "additionalProperties": false,
314
+ "properties": {
315
+ "android": {
316
+ "type": "string"
317
+ },
318
+ "default": {
319
+ "description": "Default platform export for unspecified platforms.",
320
+ "type": "string"
321
+ },
322
+ "ios": {
323
+ "type": "string"
324
+ },
325
+ "linux": {
326
+ "type": "string"
327
+ },
328
+ "mac": {
329
+ "type": "string"
330
+ },
331
+ "native_editor": {
332
+ "type": "string"
333
+ },
334
+ "ohos": {
335
+ "type": "string"
336
+ },
337
+ "open_harmony": {
338
+ "type": "string"
339
+ },
340
+ "windows": {
341
+ "type": "string"
342
+ }
343
+ },
344
+ "required": [
345
+ "default"
346
+ ],
347
+ "type": "object"
348
+ },
349
+ {
350
+ "type": "string"
351
+ }
352
+ ],
353
+ "description": "Abstract platform export, like `web`, `native` and `minigame`. Usually this is used for PAL modules. The build tools resolve the relative platform as entry according to the build platform config.\n- The value can be a `string` or a `object` which requires a default item. eg. { \"web\": \"/path/to/index.ts\" } is equals to { \"web\": { default: \"/path/to/index.ts\" } }.\n- We can also specify the exact platform like { \"web\": {default: \"/path/to/index.ts\", \"web-desktop\": \"/path/to/index.ts\" } }."
354
+ },
355
+ "types": {
356
+ "description": "This is the main module export condition.\n- The dts bundle tools resolve this condition as entry.\n- The API doc tools resolve this condition as entry.\n- If no platform export is specified, the build tools resolve this condition as entry.",
357
+ "type": "string"
358
+ },
359
+ "web": {
360
+ "anyOf": [
361
+ {
362
+ "additionalProperties": false,
363
+ "properties": {
364
+ "default": {
365
+ "description": "Default platform export for unspecified platforms.",
366
+ "type": "string"
367
+ },
368
+ "web_desktop": {
369
+ "type": "string"
370
+ },
371
+ "web_editor": {
372
+ "type": "string"
373
+ },
374
+ "web_mobile": {
375
+ "type": "string"
376
+ }
377
+ },
378
+ "required": [
379
+ "default"
380
+ ],
381
+ "type": "object"
382
+ },
383
+ {
384
+ "type": "string"
385
+ }
386
+ ],
387
+ "description": "Abstract platform export, like `web`, `native` and `minigame`. Usually this is used for PAL modules. The build tools resolve the relative platform as entry according to the build platform config.\n- The value can be a `string` or a `object` which requires a default item. eg. { \"web\": \"/path/to/index.ts\" } is equals to { \"web\": { default: \"/path/to/index.ts\" } }.\n- We can also specify the exact platform like { \"web\": {default: \"/path/to/index.ts\", \"web-desktop\": \"/path/to/index.ts\" } }."
388
+ }
389
+ },
390
+ "required": [
391
+ "types"
392
+ ],
393
+ "type": "object"
394
+ }
395
+ },
396
+ "required": [
397
+ "."
398
+ ],
399
+ "type": "object"
400
+ },
401
+ "name": {
402
+ "description": "The module name.",
403
+ "type": "string"
404
+ },
405
+ "version": {
406
+ "description": "The version of module. It is useful when we change the module config, then we need to make some migration. This usually comes with the `cc.migrations` field.",
407
+ "type": "string"
408
+ }
409
+ },
410
+ "required": [
411
+ "name",
412
+ "version",
413
+ "exports"
414
+ ],
415
+ "type": "object"
416
+ }
417
+ }
418
+ }
@@ -0,0 +1,50 @@
1
+ import { ModuleConfig } from './module-config';
2
+ import { StatsQuery } from "../../stats-query/lib/index";
3
+ export interface ModuleQueryContext {
4
+ /**
5
+ * The engine root path.
6
+ */
7
+ engine: string;
8
+ /**
9
+ * The platform to resolve conditional export.
10
+ */
11
+ platform: StatsQuery.ConstantManager.PlatformType;
12
+ /**
13
+ * The custom export condition.
14
+ * The higher the array is sorted, the higher the priority is.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * [ 'webgl1', 'cannon' ] // the backend of 'gfx' and 'physics' modules.
19
+ * ```
20
+ */
21
+ customExportConditions?: string[];
22
+ }
23
+ /**
24
+ * The module info manager.
25
+ */
26
+ export declare class ModuleQuery {
27
+ private _context;
28
+ private _cachedAllModules?;
29
+ private _resolvedCache;
30
+ constructor(context: ModuleQueryContext);
31
+ /**
32
+ * Get all modules' name defined in engine workspaces.
33
+ */
34
+ getAllModules(): Promise<string[]>;
35
+ /**
36
+ * Resolve module package.json path by module name.
37
+ */
38
+ resolvePackageJson(moduleName: string): string;
39
+ /**
40
+ * Get module config by module name.
41
+ */
42
+ getConfig(moduleName: string): Promise<ModuleConfig>;
43
+ /**
44
+ * Resolve module entry path of '.' conditional export by module name.
45
+ */
46
+ resolveExport(moduleName: string): Promise<string>;
47
+ private _isWebPlatform;
48
+ private _isMiniGamePlatform;
49
+ private _isNativePlatform;
50
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-query.d.ts","sourceRoot":"","sources":["../src/module-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,YAAY,EAA2C,MAAM,iBAAiB,CAAC;AAGhH,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKlD,MAAM,WAAW,kBAAkB;IAC/B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,UAAU,CAAC,eAAe,CAAC,YAAY,CAAC;IAClD;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;CACrC;AAED;;GAEG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,iBAAiB,CAAC,CAAW;IACrC,OAAO,CAAC,cAAc,CAA8B;gBAEvC,OAAO,EAAE,kBAAkB;IAIxC;;OAEG;IACU,aAAa,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC;IAsBhD;;OAEG;IACI,kBAAkB,CAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAMtD;;OAEG;IACU,SAAS,CAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAKlE;;OAEG;IACU,aAAa,CAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA4DhE,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,iBAAiB;CAG5B"}
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+
3
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) {
5
+ return value instanceof P ? value : new P(function (resolve) {
6
+ resolve(value);
7
+ });
8
+ }
9
+ return new (P || (P = Promise))(function (resolve, reject) {
10
+ function fulfilled(value) {
11
+ try {
12
+ step(generator.next(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ }
17
+ function rejected(value) {
18
+ try {
19
+ step(generator["throw"](value));
20
+ } catch (e) {
21
+ reject(e);
22
+ }
23
+ }
24
+ function step(result) {
25
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
26
+ }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ var __importDefault = this && this.__importDefault || function (mod) {
31
+ return mod && mod.__esModule ? mod : {
32
+ "default": mod
33
+ };
34
+ };
35
+ Object.defineProperty(exports, "__esModule", {
36
+ value: true
37
+ });
38
+ exports.ModuleQuery = void 0;
39
+ const fs_extra_1 = __importDefault(require("fs-extra"));
40
+ const path_1 = require("path");
41
+ const platform_config_1 = require("./platform-config");
42
+ const glob_1 = __importDefault(require("glob"));
43
+ /**
44
+ * The module info manager.
45
+ */
46
+ class ModuleQuery {
47
+ constructor(context) {
48
+ this._resolvedCache = {}; // module name to module entry file path
49
+ this._context = context;
50
+ }
51
+ /**
52
+ * Get all modules' name defined in engine workspaces.
53
+ */
54
+ getAllModules() {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ if (this._cachedAllModules) {
57
+ return this._cachedAllModules;
58
+ }
59
+ const enginePkg = yield fs_extra_1.default.readJson(path_1.posix.join(this._context.engine, 'package.json'));
60
+ let pkgFiles = [];
61
+ if (enginePkg.workspaces) {
62
+ for (const ws of enginePkg.workspaces) {
63
+ pkgFiles.push(...glob_1.default.sync(path_1.posix.join(this._context.engine, ws), {
64
+ ignore: '**/node_modules/**/*'
65
+ }));
66
+ }
67
+ }
68
+ pkgFiles = pkgFiles.filter(file => file.endsWith('package.json'));
69
+ const moduleNames = [];
70
+ for (const pkg of pkgFiles) {
71
+ const name = (yield fs_extra_1.default.readJson(pkg)).name;
72
+ moduleNames.push(name);
73
+ }
74
+ return this._cachedAllModules = moduleNames;
75
+ });
76
+ }
77
+ /**
78
+ * Resolve module package.json path by module name.
79
+ */
80
+ resolvePackageJson(moduleName) {
81
+ return require.resolve(moduleName, {
82
+ paths: [this._context.engine]
83
+ });
84
+ }
85
+ /**
86
+ * Get module config by module name.
87
+ */
88
+ getConfig(moduleName) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ const modulePath = this.resolvePackageJson(moduleName);
91
+ return yield fs_extra_1.default.readJson(modulePath);
92
+ });
93
+ }
94
+ /**
95
+ * Resolve module entry path of '.' conditional export by module name.
96
+ */
97
+ resolveExport(moduleName) {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ if (this._resolvedCache[moduleName]) {
100
+ return this._resolvedCache[moduleName];
101
+ }
102
+ const moduleRootDir = path_1.posix.dirname(this.resolvePackageJson(moduleName));
103
+ const config = yield this.getConfig(moduleName);
104
+ const rootExport = config.exports['.'];
105
+ // custom condition
106
+ if (this._context.customExportConditions) {
107
+ for (const condition of this._context.customExportConditions) {
108
+ if (typeof rootExport[condition] === 'string') {
109
+ return this._resolvedCache[moduleName] = path_1.posix.join(moduleRootDir, rootExport[condition]);
110
+ }
111
+ }
112
+ }
113
+ // platform condition
114
+ const platform = this._context.platform.toLowerCase();
115
+ if (this._isWebPlatform(platform)) {
116
+ if (typeof rootExport.web === 'string') {
117
+ return this._resolvedCache[moduleName] = path_1.posix.join(moduleRootDir, rootExport.web);
118
+ } else if (typeof rootExport.web === 'object') {
119
+ if (typeof rootExport.web[platform] === 'string') {
120
+ return this._resolvedCache[moduleName] = path_1.posix.join(moduleRootDir, rootExport.web[platform]);
121
+ } else if (typeof rootExport.web.default === 'string') {
122
+ return this._resolvedCache[moduleName] = path_1.posix.join(moduleRootDir, rootExport.web.default);
123
+ }
124
+ }
125
+ } else if (this._isMiniGamePlatform(platform)) {
126
+ if (typeof rootExport.minigame === 'string') {
127
+ return this._resolvedCache[moduleName] = path_1.posix.join(moduleRootDir, rootExport.minigame);
128
+ } else if (typeof rootExport.minigame === 'object') {
129
+ if (typeof rootExport.minigame[platform] === 'string') {
130
+ return this._resolvedCache[moduleName] = path_1.posix.join(moduleRootDir, rootExport.minigame[platform]);
131
+ } else if (typeof rootExport.minigame.default === 'string') {
132
+ return this._resolvedCache[moduleName] = path_1.posix.join(moduleRootDir, rootExport.minigame.default);
133
+ }
134
+ }
135
+ } else if (this._isNativePlatform(platform)) {
136
+ if (typeof rootExport.native === 'string') {
137
+ return this._resolvedCache[moduleName] = path_1.posix.join(moduleRootDir, rootExport.native);
138
+ } else if (typeof rootExport.native === 'object') {
139
+ if (typeof rootExport.native[platform] === 'string') {
140
+ return this._resolvedCache[moduleName] = path_1.posix.join(moduleRootDir, rootExport.native[platform]);
141
+ } else if (typeof rootExport.native.default === 'string') {
142
+ return this._resolvedCache[moduleName] = path_1.posix.join(moduleRootDir, rootExport.native.default);
143
+ }
144
+ }
145
+ }
146
+ // types condition
147
+ if (typeof rootExport.types === 'string') {
148
+ return this._resolvedCache[moduleName] = path_1.posix.join(moduleRootDir, rootExport.types);
149
+ } else {
150
+ throw new Error(`Please specify a least a types export for module: '${moduleName}'.`);
151
+ }
152
+ });
153
+ }
154
+ _isWebPlatform(platform) {
155
+ return platform.toUpperCase() in platform_config_1.WebPlatform;
156
+ }
157
+ _isMiniGamePlatform(platform) {
158
+ return platform.toUpperCase() in platform_config_1.MinigamePlatform;
159
+ }
160
+ _isNativePlatform(platform) {
161
+ return platform.toUpperCase() in platform_config_1.NativePlatform;
162
+ }
163
+ }
164
+ exports.ModuleQuery = ModuleQuery;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-query.js","sourceRoot":"","sources":["../src/module-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,wDAA0B;AAC1B,+BAAmC;AAEnC,uDAAkF;AAClF,gDAAwB;AAwBxB;;GAEG;AACH,MAAa,WAAW;IAKpB,YAAa,OAA2B;QAFhC,mBAAc,GAA2B,EAAE,CAAC,CAAE,wCAAwC;QAG1F,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAED;;OAEG;IACU,aAAa;;YACtB,IAAI,IAAI,CAAC,iBAAiB,EAAE;gBACxB,OAAO,IAAI,CAAC,iBAAiB,CAAC;aACjC;YACD,MAAM,SAAS,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,YAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;YACnF,IAAI,QAAQ,GAAa,EAAE,CAAC;YAC5B,IAAI,SAAS,CAAC,UAAU,EAAE;gBACtB,KAAK,MAAM,EAAE,IAAI,SAAS,CAAC,UAAU,EAAE;oBACnC,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