@ms-cloudpack/api-server 0.12.1 → 0.12.2
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/lib/apis/addPackageOverride.d.ts +2 -0
- package/lib/apis/ensurePackageBundled.d.ts +484 -0
- package/lib/apis/ensurePackageBundled.d.ts.map +1 -0
- package/lib/apis/ensurePackageBundled.js +106 -0
- package/lib/apis/ensurePackageBundled.js.map +1 -0
- package/lib/apis/getData.d.ts +2 -0
- package/lib/apis/getSessionId.d.ts +2 -0
- package/lib/apis/index.d.ts +1 -0
- package/lib/apis/index.d.ts.map +1 -1
- package/lib/apis/index.js +1 -0
- package/lib/apis/index.js.map +1 -1
- package/lib/apis/onDataChanged.d.ts +2 -0
- package/lib/apis/openCodeEditor.d.ts +2 -0
- package/lib/apis/openConfigEditor.d.ts +2 -0
- package/lib/apis/openFilePath.d.ts +2 -0
- package/lib/apis/reportMetric.d.ts +2 -0
- package/lib/apis/sync.d.ts +71 -0
- package/lib/apis/sync.d.ts.map +1 -0
- package/lib/apis/sync.js +21 -0
- package/lib/apis/sync.js.map +1 -0
- package/lib/apis/validatePackageOverride.d.ts +2 -0
- package/lib/common/prepareOutputPath.d.ts +5 -0
- package/lib/common/prepareOutputPath.d.ts.map +1 -0
- package/lib/common/prepareOutputPath.js +14 -0
- package/lib/common/prepareOutputPath.js.map +1 -0
- package/lib/index.d.ts +8 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -1
- package/lib/index.js.map +1 -1
- package/lib/trpc/common.d.ts +3 -0
- package/lib/trpc/common.d.ts.map +1 -1
- package/lib/trpc/createAppRouter.d.ts +67 -0
- package/lib/trpc/createAppRouter.d.ts.map +1 -1
- package/lib/trpc/createCloudpackServer.d.ts +4 -0
- package/lib/trpc/createCloudpackServer.d.ts.map +1 -1
- package/lib/trpc/createContextFactory.d.ts +2 -0
- package/lib/trpc/createContextFactory.d.ts.map +1 -1
- package/lib/trpc/createContextFactory.js +4 -0
- package/lib/trpc/createContextFactory.js.map +1 -1
- package/lib/trpc/createRouterFromApis.d.ts +1 -0
- package/lib/trpc/createRouterFromApis.d.ts.map +1 -1
- package/lib/types/BundleRequest.d.ts +16 -0
- package/lib/types/BundleRequest.d.ts.map +1 -1
- package/lib/types/BundleRequest.js.map +1 -1
- package/lib/types/BundleTaskOptions.d.ts +4 -0
- package/lib/types/BundleTaskOptions.d.ts.map +1 -0
- package/lib/types/BundleTaskOptions.js +2 -0
- package/lib/types/BundleTaskOptions.js.map +1 -0
- package/lib/types/TaskMessage.d.ts +2 -2
- package/lib/types/TaskResponse.d.ts +12 -12
- package/lib/types/TaskResult.d.ts +8 -8
- package/lib/utilities/bundleTask.d.ts +9 -0
- package/lib/utilities/bundleTask.d.ts.map +1 -0
- package/lib/utilities/bundleTask.js +119 -0
- package/lib/utilities/bundleTask.js.map +1 -0
- package/lib/utilities/createBundleRequestForPackage.d.ts +11 -0
- package/lib/utilities/createBundleRequestForPackage.d.ts.map +1 -0
- package/lib/utilities/createBundleRequestForPackage.js +21 -0
- package/lib/utilities/createBundleRequestForPackage.js.map +1 -0
- package/lib/utilities/createBundleTask.d.ts +10 -0
- package/lib/utilities/createBundleTask.d.ts.map +1 -0
- package/lib/utilities/createBundleTask.js +42 -0
- package/lib/utilities/createBundleTask.js.map +1 -0
- package/lib/utilities/findImports.d.ts +6 -0
- package/lib/utilities/findImports.d.ts.map +1 -0
- package/lib/utilities/findImports.js +73 -0
- package/lib/utilities/findImports.js.map +1 -0
- package/lib/utilities/formatBundleErrors.d.ts +9 -0
- package/lib/utilities/formatBundleErrors.d.ts.map +1 -0
- package/lib/utilities/formatBundleErrors.js +19 -0
- package/lib/utilities/formatBundleErrors.js.map +1 -0
- package/lib/utilities/getBundleDetails.d.ts +14 -0
- package/lib/utilities/getBundleDetails.d.ts.map +1 -0
- package/lib/utilities/getBundleDetails.js +35 -0
- package/lib/utilities/getBundleDetails.js.map +1 -0
- package/lib/utilities/getFileSizeSync.d.ts +5 -0
- package/lib/utilities/getFileSizeSync.d.ts.map +1 -0
- package/lib/utilities/getFileSizeSync.js +16 -0
- package/lib/utilities/getFileSizeSync.js.map +1 -0
- package/lib/utilities/hashPackage.d.ts +6 -0
- package/lib/utilities/hashPackage.d.ts.map +1 -0
- package/lib/utilities/hashPackage.js +21 -0
- package/lib/utilities/hashPackage.js.map +1 -0
- package/package.json +10 -3
|
@@ -17,6 +17,7 @@ export declare function createRouterFromApis<TData extends {
|
|
|
17
17
|
unwatchAll(): Promise<void>;
|
|
18
18
|
};
|
|
19
19
|
packages: import("@ms-cloudpack/bundler-types").PackageDefinitionsCache;
|
|
20
|
+
taskRunner: import("../utilities/TaskRunner.js").TaskRunner;
|
|
20
21
|
dispose(): Promise<void>;
|
|
21
22
|
};
|
|
22
23
|
meta: object;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRouterFromApis.d.ts","sourceRoot":"","sources":["../../src/trpc/createRouterFromApis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,wBAAgB,oBAAoB,CAAC,KAAK,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,SAAS,EAAE,YAAY,CAAA;KAAE,CAAA;CAAE,EAAE,IAAI,EAAE,KAAK
|
|
1
|
+
{"version":3,"file":"createRouterFromApis.d.ts","sourceRoot":"","sources":["../../src/trpc/createRouterFromApis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,wBAAgB,oBAAoB,CAAC,KAAK,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,SAAS,EAAE,YAAY,CAAA;KAAE,CAAA;CAAE,EAAE,IAAI,EAAE,KAAK;;;;;;;;;;;;;;;;;;;;wDAU7G"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { BundleResult, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
|
|
2
|
+
import type { CloudpackConfig } from '@ms-cloudpack/config';
|
|
3
|
+
/**
|
|
4
|
+
* Tracks a given bundle request and its result.
|
|
5
|
+
*/
|
|
1
6
|
export interface BundleRequest {
|
|
2
7
|
id: string;
|
|
3
8
|
packageName: string;
|
|
@@ -5,6 +10,17 @@ export interface BundleRequest {
|
|
|
5
10
|
packagePath: string;
|
|
6
11
|
outputPath: string;
|
|
7
12
|
isExternal: boolean;
|
|
13
|
+
bundlerType?: string;
|
|
14
|
+
result?: BundleResult & {
|
|
15
|
+
dependencies?: string[];
|
|
16
|
+
hash?: string;
|
|
17
|
+
};
|
|
18
|
+
resultFromCache?: boolean;
|
|
19
|
+
isRebuildRequired?: boolean;
|
|
8
20
|
disableSourceMaps?: boolean;
|
|
21
|
+
enableFindImports?: boolean;
|
|
22
|
+
enableCacheInternalPackages?: boolean;
|
|
23
|
+
packages: PackageDefinitionsCache;
|
|
24
|
+
config: CloudpackConfig;
|
|
9
25
|
}
|
|
10
26
|
//# sourceMappingURL=BundleRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BundleRequest.d.ts","sourceRoot":"","sources":["../../src/types/BundleRequest.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BundleRequest.d.ts","sourceRoot":"","sources":["../../src/types/BundleRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,YAAY,GAAG;QAAE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,eAAe,CAAC;CACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BundleRequest.js","sourceRoot":"","sources":["../../src/types/BundleRequest.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"BundleRequest.js","sourceRoot":"","sources":["../../src/types/BundleRequest.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleResult, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\n\n/**\n * Tracks a given bundle request and its result.\n */\n\nexport interface BundleRequest {\n id: string;\n packageName: string;\n version: string;\n packagePath: string;\n outputPath: string;\n isExternal: boolean;\n bundlerType?: string;\n result?: BundleResult & { dependencies?: string[]; hash?: string };\n resultFromCache?: boolean;\n isRebuildRequired?: boolean;\n disableSourceMaps?: boolean;\n enableFindImports?: boolean;\n enableCacheInternalPackages?: boolean;\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BundleTaskOptions.d.ts","sourceRoot":"","sources":["../../src/types/BundleTaskOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BundleTaskOptions.js","sourceRoot":"","sources":["../../src/types/BundleTaskOptions.ts"],"names":[],"mappings":"","sourcesContent":["export interface BundleTaskOptions {\n force?: boolean;\n}\n"]}
|
|
@@ -118,7 +118,7 @@ export declare const ZodTaskMessage: z.ZodObject<{
|
|
|
118
118
|
}, "strip", z.ZodTypeAny, {
|
|
119
119
|
text: string;
|
|
120
120
|
pluginName?: string | undefined;
|
|
121
|
-
type?: "invalid-input" | "
|
|
121
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
122
122
|
location?: {
|
|
123
123
|
line: number;
|
|
124
124
|
column: number;
|
|
@@ -141,7 +141,7 @@ export declare const ZodTaskMessage: z.ZodObject<{
|
|
|
141
141
|
}, {
|
|
142
142
|
text: string;
|
|
143
143
|
pluginName?: string | undefined;
|
|
144
|
-
type?: "invalid-input" | "
|
|
144
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
145
145
|
location?: {
|
|
146
146
|
line: number;
|
|
147
147
|
column: number;
|
|
@@ -75,7 +75,7 @@ export declare const ZodTaskResponse: z.ZodObject<{
|
|
|
75
75
|
}, "strip", z.ZodTypeAny, {
|
|
76
76
|
text: string;
|
|
77
77
|
pluginName?: string | undefined;
|
|
78
|
-
type?: "invalid-input" | "
|
|
78
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
79
79
|
location?: {
|
|
80
80
|
line: number;
|
|
81
81
|
column: number;
|
|
@@ -98,7 +98,7 @@ export declare const ZodTaskResponse: z.ZodObject<{
|
|
|
98
98
|
}, {
|
|
99
99
|
text: string;
|
|
100
100
|
pluginName?: string | undefined;
|
|
101
|
-
type?: "invalid-input" | "
|
|
101
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
102
102
|
location?: {
|
|
103
103
|
line: number;
|
|
104
104
|
column: number;
|
|
@@ -193,7 +193,7 @@ export declare const ZodTaskResponse: z.ZodObject<{
|
|
|
193
193
|
}, "strip", z.ZodTypeAny, {
|
|
194
194
|
text: string;
|
|
195
195
|
pluginName?: string | undefined;
|
|
196
|
-
type?: "invalid-input" | "
|
|
196
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
197
197
|
location?: {
|
|
198
198
|
line: number;
|
|
199
199
|
column: number;
|
|
@@ -216,7 +216,7 @@ export declare const ZodTaskResponse: z.ZodObject<{
|
|
|
216
216
|
}, {
|
|
217
217
|
text: string;
|
|
218
218
|
pluginName?: string | undefined;
|
|
219
|
-
type?: "invalid-input" | "
|
|
219
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
220
220
|
location?: {
|
|
221
221
|
line: number;
|
|
222
222
|
column: number;
|
|
@@ -241,7 +241,7 @@ export declare const ZodTaskResponse: z.ZodObject<{
|
|
|
241
241
|
errors?: {
|
|
242
242
|
text: string;
|
|
243
243
|
pluginName?: string | undefined;
|
|
244
|
-
type?: "invalid-input" | "
|
|
244
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
245
245
|
location?: {
|
|
246
246
|
line: number;
|
|
247
247
|
column: number;
|
|
@@ -265,7 +265,7 @@ export declare const ZodTaskResponse: z.ZodObject<{
|
|
|
265
265
|
warnings?: {
|
|
266
266
|
text: string;
|
|
267
267
|
pluginName?: string | undefined;
|
|
268
|
-
type?: "invalid-input" | "
|
|
268
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
269
269
|
location?: {
|
|
270
270
|
line: number;
|
|
271
271
|
column: number;
|
|
@@ -290,7 +290,7 @@ export declare const ZodTaskResponse: z.ZodObject<{
|
|
|
290
290
|
errors?: {
|
|
291
291
|
text: string;
|
|
292
292
|
pluginName?: string | undefined;
|
|
293
|
-
type?: "invalid-input" | "
|
|
293
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
294
294
|
location?: {
|
|
295
295
|
line: number;
|
|
296
296
|
column: number;
|
|
@@ -314,7 +314,7 @@ export declare const ZodTaskResponse: z.ZodObject<{
|
|
|
314
314
|
warnings?: {
|
|
315
315
|
text: string;
|
|
316
316
|
pluginName?: string | undefined;
|
|
317
|
-
type?: "invalid-input" | "
|
|
317
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
318
318
|
location?: {
|
|
319
319
|
line: number;
|
|
320
320
|
column: number;
|
|
@@ -357,7 +357,7 @@ export declare const ZodTaskResponse: z.ZodObject<{
|
|
|
357
357
|
errors?: {
|
|
358
358
|
text: string;
|
|
359
359
|
pluginName?: string | undefined;
|
|
360
|
-
type?: "invalid-input" | "
|
|
360
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
361
361
|
location?: {
|
|
362
362
|
line: number;
|
|
363
363
|
column: number;
|
|
@@ -381,7 +381,7 @@ export declare const ZodTaskResponse: z.ZodObject<{
|
|
|
381
381
|
warnings?: {
|
|
382
382
|
text: string;
|
|
383
383
|
pluginName?: string | undefined;
|
|
384
|
-
type?: "invalid-input" | "
|
|
384
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
385
385
|
location?: {
|
|
386
386
|
line: number;
|
|
387
387
|
column: number;
|
|
@@ -414,7 +414,7 @@ export declare const ZodTaskResponse: z.ZodObject<{
|
|
|
414
414
|
errors?: {
|
|
415
415
|
text: string;
|
|
416
416
|
pluginName?: string | undefined;
|
|
417
|
-
type?: "invalid-input" | "
|
|
417
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
418
418
|
location?: {
|
|
419
419
|
line: number;
|
|
420
420
|
column: number;
|
|
@@ -438,7 +438,7 @@ export declare const ZodTaskResponse: z.ZodObject<{
|
|
|
438
438
|
warnings?: {
|
|
439
439
|
text: string;
|
|
440
440
|
pluginName?: string | undefined;
|
|
441
|
-
type?: "invalid-input" | "
|
|
441
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
442
442
|
location?: {
|
|
443
443
|
line: number;
|
|
444
444
|
column: number;
|
|
@@ -74,7 +74,7 @@ export declare const ZodTaskResult: z.ZodObject<{
|
|
|
74
74
|
}, "strip", z.ZodTypeAny, {
|
|
75
75
|
text: string;
|
|
76
76
|
pluginName?: string | undefined;
|
|
77
|
-
type?: "invalid-input" | "
|
|
77
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
78
78
|
location?: {
|
|
79
79
|
line: number;
|
|
80
80
|
column: number;
|
|
@@ -97,7 +97,7 @@ export declare const ZodTaskResult: z.ZodObject<{
|
|
|
97
97
|
}, {
|
|
98
98
|
text: string;
|
|
99
99
|
pluginName?: string | undefined;
|
|
100
|
-
type?: "invalid-input" | "
|
|
100
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
101
101
|
location?: {
|
|
102
102
|
line: number;
|
|
103
103
|
column: number;
|
|
@@ -192,7 +192,7 @@ export declare const ZodTaskResult: z.ZodObject<{
|
|
|
192
192
|
}, "strip", z.ZodTypeAny, {
|
|
193
193
|
text: string;
|
|
194
194
|
pluginName?: string | undefined;
|
|
195
|
-
type?: "invalid-input" | "
|
|
195
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
196
196
|
location?: {
|
|
197
197
|
line: number;
|
|
198
198
|
column: number;
|
|
@@ -215,7 +215,7 @@ export declare const ZodTaskResult: z.ZodObject<{
|
|
|
215
215
|
}, {
|
|
216
216
|
text: string;
|
|
217
217
|
pluginName?: string | undefined;
|
|
218
|
-
type?: "invalid-input" | "
|
|
218
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
219
219
|
location?: {
|
|
220
220
|
line: number;
|
|
221
221
|
column: number;
|
|
@@ -240,7 +240,7 @@ export declare const ZodTaskResult: z.ZodObject<{
|
|
|
240
240
|
errors?: {
|
|
241
241
|
text: string;
|
|
242
242
|
pluginName?: string | undefined;
|
|
243
|
-
type?: "invalid-input" | "
|
|
243
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
244
244
|
location?: {
|
|
245
245
|
line: number;
|
|
246
246
|
column: number;
|
|
@@ -264,7 +264,7 @@ export declare const ZodTaskResult: z.ZodObject<{
|
|
|
264
264
|
warnings?: {
|
|
265
265
|
text: string;
|
|
266
266
|
pluginName?: string | undefined;
|
|
267
|
-
type?: "invalid-input" | "
|
|
267
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
268
268
|
location?: {
|
|
269
269
|
line: number;
|
|
270
270
|
column: number;
|
|
@@ -289,7 +289,7 @@ export declare const ZodTaskResult: z.ZodObject<{
|
|
|
289
289
|
errors?: {
|
|
290
290
|
text: string;
|
|
291
291
|
pluginName?: string | undefined;
|
|
292
|
-
type?: "invalid-input" | "
|
|
292
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
293
293
|
location?: {
|
|
294
294
|
line: number;
|
|
295
295
|
column: number;
|
|
@@ -313,7 +313,7 @@ export declare const ZodTaskResult: z.ZodObject<{
|
|
|
313
313
|
warnings?: {
|
|
314
314
|
text: string;
|
|
315
315
|
pluginName?: string | undefined;
|
|
316
|
-
type?: "invalid-input" | "
|
|
316
|
+
type?: "invalid-input" | "input-relative" | "no-entries" | "entry-absolute" | undefined;
|
|
317
317
|
location?: {
|
|
318
318
|
line: number;
|
|
319
319
|
column: number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
2
|
+
import type { BundleTaskOptions } from '../types/BundleTaskOptions.js';
|
|
3
|
+
import type { BundleRequest } from '../types/BundleRequest.js';
|
|
4
|
+
export declare function bundleTask({ bundleRequest, options, reporter, }: {
|
|
5
|
+
bundleRequest: BundleRequest;
|
|
6
|
+
options?: BundleTaskOptions;
|
|
7
|
+
reporter?: TaskReporter;
|
|
8
|
+
}): Promise<BundleRequest>;
|
|
9
|
+
//# sourceMappingURL=bundleTask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundleTask.d.ts","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,YAAY,EAElB,MAAM,6BAA6B,CAAC;AAIrC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAO/D,wBAAsB,UAAU,CAAC,EAC/B,aAAa,EACb,OAAY,EACZ,QAAQ,GACT,EAAE;IACD,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB,0BAwDA"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { bundle as bundleInternal, getEntriesMapFromPackage, getExternalsFromPackage } from '@ms-cloudpack/bundler';
|
|
2
|
+
import { readJson, writeJson } from '@ms-cloudpack/json-utilities';
|
|
3
|
+
import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';
|
|
4
|
+
import { bulletedList, formatPackageName, } from '@ms-cloudpack/task-reporter';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { findImports } from './findImports.js';
|
|
7
|
+
import { prepareOutputPath } from '../common/prepareOutputPath.js';
|
|
8
|
+
import { formatBundleErrors } from './formatBundleErrors.js';
|
|
9
|
+
import { getFileSizeSync } from './getFileSizeSync.js';
|
|
10
|
+
import { hashPackage } from './hashPackage.js';
|
|
11
|
+
import { getPackageSettings } from '@ms-cloudpack/config';
|
|
12
|
+
export async function bundleTask({ bundleRequest, options = {}, reporter, }) {
|
|
13
|
+
const { packageName, version } = bundleRequest;
|
|
14
|
+
const { force } = options || {};
|
|
15
|
+
const { rebuild } = bundleRequest?.result || {};
|
|
16
|
+
const taskName = `${rebuild ? `Re-bundle` : `Bundle`} ${formatPackageName({ name: packageName, version })}`;
|
|
17
|
+
const executeBundle = async () => {
|
|
18
|
+
if (rebuild) {
|
|
19
|
+
bundleRequest.result = await rebuild();
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
await bundle(bundleRequest, force);
|
|
23
|
+
}
|
|
24
|
+
const result = (bundleRequest.result ??= {});
|
|
25
|
+
result.outputFiles ??= [];
|
|
26
|
+
result.errors ??= [];
|
|
27
|
+
result.warnings ??= [];
|
|
28
|
+
if (!result.outputFiles.length) {
|
|
29
|
+
result.warnings.push({
|
|
30
|
+
text: `No output files were found for "${packageName}" in "${bundleRequest.outputPath}"`,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
status: result.errors.length ? 'fail' : 'complete',
|
|
35
|
+
...(result.errors?.length
|
|
36
|
+
? formatBundleErrors(result.errors)
|
|
37
|
+
: {
|
|
38
|
+
details: bulletedList([
|
|
39
|
+
`Package: ${bundleRequest.packageName}@${bundleRequest.version}`,
|
|
40
|
+
`Bundler: ${bundleRequest.result?.bundlerName || 'unknown'}`,
|
|
41
|
+
`Input path: ${bundleRequest.packagePath}`,
|
|
42
|
+
`Entries:`,
|
|
43
|
+
Object.values(bundleRequest.result?.entries || {}),
|
|
44
|
+
`Output path: ${bundleRequest.outputPath}`,
|
|
45
|
+
bundleRequest.result?.outputFiles?.map((file) => `${safeRelativePath(path.relative(bundleRequest.outputPath, file.outputPath))} (${getFileSizeSync(file.outputPath)})`),
|
|
46
|
+
]),
|
|
47
|
+
}),
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
if (reporter) {
|
|
51
|
+
await reporter.runTask(taskName, executeBundle);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
await executeBundle();
|
|
55
|
+
}
|
|
56
|
+
return bundleRequest;
|
|
57
|
+
}
|
|
58
|
+
async function bundle(bundleRequest, force) {
|
|
59
|
+
const { packages, config } = bundleRequest;
|
|
60
|
+
const context = { packages, config };
|
|
61
|
+
// If force is set, dispose the existing result.
|
|
62
|
+
if (force && bundleRequest?.result?.dispose) {
|
|
63
|
+
bundleRequest.result.dispose();
|
|
64
|
+
bundleRequest.result = undefined;
|
|
65
|
+
}
|
|
66
|
+
const { packagePath, outputPath, isExternal, disableSourceMaps, enableFindImports, enableCacheInternalPackages } = bundleRequest;
|
|
67
|
+
// Rehydrate the result if not incremental.
|
|
68
|
+
if ((isExternal || enableCacheInternalPackages) && !force) {
|
|
69
|
+
bundleRequest.result = await readJson(path.join(outputPath, 'result.json'));
|
|
70
|
+
}
|
|
71
|
+
const { userPackageSettings } = getPackageSettings({
|
|
72
|
+
name: bundleRequest.packageName,
|
|
73
|
+
version: bundleRequest.version,
|
|
74
|
+
config,
|
|
75
|
+
}) || {};
|
|
76
|
+
const { bundlerType, bundlerOptions } = userPackageSettings || {};
|
|
77
|
+
const bundleOptions = {
|
|
78
|
+
bundlerType: bundleRequest.bundlerType || bundlerType,
|
|
79
|
+
overrideOptions: bundlerOptions,
|
|
80
|
+
inputPath: packagePath,
|
|
81
|
+
outputPath,
|
|
82
|
+
incremental: !isExternal,
|
|
83
|
+
sourcemap: disableSourceMaps ? undefined : 'linked',
|
|
84
|
+
entries: await getEntriesMapFromPackage({ inputPath: packagePath }, context),
|
|
85
|
+
external: await getExternalsFromPackage({ inputPath: packagePath }, context),
|
|
86
|
+
};
|
|
87
|
+
const hash = !isExternal && enableCacheInternalPackages
|
|
88
|
+
? await hashPackage({ packagePath, isExternal, additionalProperties: bundleOptions })
|
|
89
|
+
: undefined;
|
|
90
|
+
if (bundleRequest.result?.errors?.length === 0 &&
|
|
91
|
+
// Dependencies are undefined if the older version of bundleTask was used to bundle the package.
|
|
92
|
+
// In this case, we need to bundle it again with the new version to have dependencies defined in the result.json.
|
|
93
|
+
(!enableFindImports || !!bundleRequest.result?.dependencies) &&
|
|
94
|
+
// Internal packages should be re-bundled if the package hash has changed.
|
|
95
|
+
(isExternal || (enableCacheInternalPackages && bundleRequest.result.hash === hash))) {
|
|
96
|
+
console.debug(`Using cached result for ${bundleRequest.packageName}@${bundleRequest.version}`);
|
|
97
|
+
bundleRequest.resultFromCache = true;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
bundleRequest.resultFromCache = false;
|
|
101
|
+
// Only use cached result if it's successful.
|
|
102
|
+
await prepareOutputPath(outputPath);
|
|
103
|
+
bundleRequest.result = await bundleInternal(bundleOptions);
|
|
104
|
+
bundleRequest.result.hash = hash;
|
|
105
|
+
if (enableFindImports) {
|
|
106
|
+
// Find imports that are in the output files and set dependencies.
|
|
107
|
+
const outputFilePaths = bundleRequest.result.outputFiles?.map((f) => f.outputPath);
|
|
108
|
+
const imports = outputFilePaths && (await findImports(outputFilePaths));
|
|
109
|
+
bundleRequest.result.dependencies = imports && Object.keys(imports);
|
|
110
|
+
}
|
|
111
|
+
// Write the result to disk.
|
|
112
|
+
if (isExternal || enableCacheInternalPackages) {
|
|
113
|
+
bundleRequest.result.rawInput = bundleRequest.result.rawOutput = undefined;
|
|
114
|
+
await writeJson(path.join(outputPath, 'result.json'), bundleRequest.result);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return bundleRequest;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=bundleTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"A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eAAe,GAAG,aAAa,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;YACnF,MAAM,OAAO,GAAG,eAAe,IAAI,CAAC,MAAM,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC;YACxE,aAAa,CAAC,MAAM,CAAC,YAAY,GAAG,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACrE;QAED,4BAA4B;QAC5B,IAAI,UAAU,IAAI,2BAA2B,EAAE;YAC7C,aAAa,CAAC,MAAM,CAAC,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;YAC3E,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;SAC7E;KACF;IAED,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { bundle as bundleInternal, getEntriesMapFromPackage, getExternalsFromPackage } from '@ms-cloudpack/bundler';\nimport { readJson, writeJson } from '@ms-cloudpack/json-utilities';\nimport { safeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport {\n bulletedList,\n formatPackageName,\n type TaskReporter,\n type TaskReporterTaskResult,\n} from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { findImports } from './findImports.js';\nimport { prepareOutputPath } from '../common/prepareOutputPath.js';\nimport type { BundleTaskOptions } from '../types/BundleTaskOptions.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport { formatBundleErrors } from './formatBundleErrors.js';\nimport { getFileSizeSync } from './getFileSizeSync.js';\nimport { hashPackage } from './hashPackage.js';\nimport type { BundleOptions } from '@ms-cloudpack/bundler-types';\nimport { getPackageSettings } from '@ms-cloudpack/config';\n\nexport async function bundleTask({\n bundleRequest,\n options = {},\n reporter,\n}: {\n bundleRequest: BundleRequest;\n options?: BundleTaskOptions;\n reporter?: TaskReporter;\n}) {\n const { packageName, version } = bundleRequest;\n const { force } = options || {};\n\n const { rebuild } = bundleRequest?.result || {};\n const taskName = `${rebuild ? `Re-bundle` : `Bundle`} ${formatPackageName({ name: packageName, version })}`;\n\n const executeBundle = async (): Promise<TaskReporterTaskResult> => {\n if (rebuild) {\n bundleRequest.result = await rebuild();\n } else {\n await bundle(bundleRequest, force);\n }\n\n const result = (bundleRequest.result ??= {});\n\n result.outputFiles ??= [];\n result.errors ??= [];\n result.warnings ??= [];\n\n if (!result.outputFiles.length) {\n result.warnings.push({\n text: `No output files were found for \"${packageName}\" in \"${bundleRequest.outputPath}\"`,\n });\n }\n\n return {\n status: result.errors.length ? 'fail' : 'complete',\n ...(result.errors?.length\n ? formatBundleErrors(result.errors)\n : {\n details: bulletedList([\n `Package: ${bundleRequest.packageName}@${bundleRequest.version}`,\n `Bundler: ${bundleRequest.result?.bundlerName || 'unknown'}`,\n `Input path: ${bundleRequest.packagePath}`,\n `Entries:`,\n Object.values(bundleRequest.result?.entries || {}),\n `Output path: ${bundleRequest.outputPath}`,\n bundleRequest.result?.outputFiles?.map(\n (file) =>\n `${safeRelativePath(path.relative(bundleRequest.outputPath, file.outputPath))} (${getFileSizeSync(\n file.outputPath,\n )})`,\n ),\n ]),\n }),\n };\n };\n\n if (reporter) {\n await reporter.runTask(taskName, executeBundle);\n } else {\n await executeBundle();\n }\n\n return bundleRequest;\n}\n\nasync function bundle(bundleRequest: BundleRequest, force?: boolean): Promise<BundleRequest> {\n const { packages, config } = bundleRequest;\n const context = { packages, config };\n\n // If force is set, dispose the existing result.\n if (force && bundleRequest?.result?.dispose) {\n bundleRequest.result.dispose();\n bundleRequest.result = undefined;\n }\n\n const { packagePath, outputPath, isExternal, disableSourceMaps, enableFindImports, enableCacheInternalPackages } =\n bundleRequest;\n\n // Rehydrate the result if not incremental.\n if ((isExternal || enableCacheInternalPackages) && !force) {\n bundleRequest.result = await readJson(path.join(outputPath, 'result.json'));\n }\n\n const { userPackageSettings } =\n getPackageSettings({\n name: bundleRequest.packageName,\n version: bundleRequest.version,\n config,\n }) || {};\n const { bundlerType, bundlerOptions } = userPackageSettings || {};\n\n const bundleOptions: BundleOptions = {\n bundlerType: bundleRequest.bundlerType || bundlerType,\n overrideOptions: bundlerOptions,\n inputPath: packagePath,\n outputPath,\n incremental: !isExternal,\n sourcemap: disableSourceMaps ? undefined : 'linked',\n entries: await getEntriesMapFromPackage({ inputPath: packagePath }, context),\n external: await getExternalsFromPackage({ inputPath: packagePath }, context),\n };\n\n const hash =\n !isExternal && enableCacheInternalPackages\n ? await hashPackage({ packagePath, isExternal, additionalProperties: bundleOptions })\n : undefined;\n\n if (\n bundleRequest.result?.errors?.length === 0 &&\n // Dependencies are undefined if the older version of bundleTask was used to bundle the package.\n // In this case, we need to bundle it again with the new version to have dependencies defined in the result.json.\n (!enableFindImports || !!bundleRequest.result?.dependencies) &&\n // Internal packages should be re-bundled if the package hash has changed.\n (isExternal || (enableCacheInternalPackages && bundleRequest.result.hash === hash))\n ) {\n console.debug(`Using cached result for ${bundleRequest.packageName}@${bundleRequest.version}`);\n bundleRequest.resultFromCache = true;\n } else {\n bundleRequest.resultFromCache = false;\n\n // Only use cached result if it's successful.\n await prepareOutputPath(outputPath);\n\n bundleRequest.result = await bundleInternal(bundleOptions);\n bundleRequest.result.hash = hash;\n\n if (enableFindImports) {\n // Find imports that are in the output files and set dependencies.\n const outputFilePaths = bundleRequest.result.outputFiles?.map((f) => f.outputPath);\n const imports = outputFilePaths && (await findImports(outputFilePaths));\n bundleRequest.result.dependencies = imports && Object.keys(imports);\n }\n\n // Write the result to disk.\n if (isExternal || enableCacheInternalPackages) {\n bundleRequest.result.rawInput = bundleRequest.result.rawOutput = undefined;\n await writeJson(path.join(outputPath, 'result.json'), bundleRequest.result);\n }\n }\n\n return bundleRequest;\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CloudpackConfig } from '@ms-cloudpack/config';
|
|
2
|
+
import type { ResolveMapEntry } from '@ms-cloudpack/package-utilities';
|
|
3
|
+
import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
|
|
4
|
+
import type { BundleRequest } from '../types/BundleRequest.js';
|
|
5
|
+
export declare function createBundleRequestForPackage(options: {
|
|
6
|
+
packageEntry: ResolveMapEntry;
|
|
7
|
+
}, context: {
|
|
8
|
+
config: CloudpackConfig;
|
|
9
|
+
packages: PackageDefinitionsCache;
|
|
10
|
+
}): Promise<BundleRequest>;
|
|
11
|
+
//# sourceMappingURL=createBundleRequestForPackage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBundleRequestForPackage.d.ts","sourceRoot":"","sources":["../../src/utilities/createBundleRequestForPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,wBAAsB,6BAA6B,CACjD,OAAO,EAAE;IACP,YAAY,EAAE,eAAe,CAAC;CAC/B,EACD,OAAO,EAAE;IACP,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,uBAAuB,CAAC;CACnC,GACA,OAAO,CAAC,aAAa,CAAC,CAmBxB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getBundleDetails } from '../utilities/getBundleDetails.js';
|
|
2
|
+
export async function createBundleRequestForPackage(options, context) {
|
|
3
|
+
const { packageEntry } = options;
|
|
4
|
+
const { config } = context;
|
|
5
|
+
const { features = {} } = config;
|
|
6
|
+
const { path, version, name } = packageEntry;
|
|
7
|
+
const { bundleId, isExternal, outputLocation } = await getBundleDetails({ packagePath: path }, context);
|
|
8
|
+
return {
|
|
9
|
+
id: bundleId,
|
|
10
|
+
packagePath: path,
|
|
11
|
+
packageName: name,
|
|
12
|
+
isExternal,
|
|
13
|
+
outputPath: outputLocation.path,
|
|
14
|
+
version,
|
|
15
|
+
disableSourceMaps: features.disableSourceMaps,
|
|
16
|
+
enableFindImports: features.enqueueDependencies,
|
|
17
|
+
enableCacheInternalPackages: features.cacheInternalPackages,
|
|
18
|
+
...context,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=createBundleRequestForPackage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBundleRequestForPackage.js","sourceRoot":"","sources":["../../src/utilities/createBundleRequestForPackage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,OAEC,EACD,OAGC;IAED,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACjC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IACjC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC;IAC7C,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,MAAM,gBAAgB,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAExG,OAAO;QACL,EAAE,EAAE,QAAQ;QACZ,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,IAAI;QACjB,UAAU;QACV,UAAU,EAAE,cAAc,CAAC,IAAI;QAC/B,OAAO;QACP,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB;QAC7C,iBAAiB,EAAE,QAAQ,CAAC,mBAAmB;QAC/C,2BAA2B,EAAE,QAAQ,CAAC,qBAAqB;QAC3D,GAAG,OAAO;KACX,CAAC;AACJ,CAAC","sourcesContent":["import type { CloudpackConfig } from '@ms-cloudpack/config';\nimport type { ResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { getBundleDetails } from '../utilities/getBundleDetails.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\n\nexport async function createBundleRequestForPackage(\n options: {\n packageEntry: ResolveMapEntry;\n },\n context: {\n config: CloudpackConfig;\n packages: PackageDefinitionsCache;\n },\n): Promise<BundleRequest> {\n const { packageEntry } = options;\n const { config } = context;\n const { features = {} } = config;\n const { path, version, name } = packageEntry;\n const { bundleId, isExternal, outputLocation } = await getBundleDetails({ packagePath: path }, context);\n\n return {\n id: bundleId,\n packagePath: path,\n packageName: name,\n isExternal,\n outputPath: outputLocation.path,\n version,\n disableSourceMaps: features.disableSourceMaps,\n enableFindImports: features.enqueueDependencies,\n enableCacheInternalPackages: features.cacheInternalPackages,\n ...context,\n };\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BundleTaskOptions } from '../types/BundleTaskOptions.js';
|
|
2
|
+
import type { BundleRequest } from '../types/BundleRequest.js';
|
|
3
|
+
import type { Task } from '../types/Task.js';
|
|
4
|
+
import type { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a bundle task tracked in the task runner of the api server. This allows active tasks to be tracked
|
|
7
|
+
* remotely (e.g. in the browser) and allows the user to cancel tasks.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createBundleTask(bundleRequest: BundleRequest, options?: BundleTaskOptions, reporter?: TaskReporter): Task<BundleRequest>;
|
|
10
|
+
//# sourceMappingURL=createBundleTask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBundleTask.d.ts","sourceRoot":"","sources":["../../src/utilities/createBundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAM7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,iBAAiB,EAC3B,QAAQ,CAAC,EAAE,YAAY,GACtB,IAAI,CAAC,aAAa,CAAC,CAoCrB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { bundleTask } from './/bundleTask.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a bundle task tracked in the task runner of the api server. This allows active tasks to be tracked
|
|
6
|
+
* remotely (e.g. in the browser) and allows the user to cancel tasks.
|
|
7
|
+
*/
|
|
8
|
+
export function createBundleTask(bundleRequest, options, reporter) {
|
|
9
|
+
const { id, packageName, version, outputPath, packagePath, isExternal } = bundleRequest;
|
|
10
|
+
return {
|
|
11
|
+
name: `Bundle ${packageName}@${version}`,
|
|
12
|
+
id,
|
|
13
|
+
dir: `${path.join(packagePath, 'src')}`,
|
|
14
|
+
watch: !isExternal,
|
|
15
|
+
async execute() {
|
|
16
|
+
await bundleTask({ bundleRequest, options, reporter });
|
|
17
|
+
return bundleRequest;
|
|
18
|
+
},
|
|
19
|
+
clear: () => {
|
|
20
|
+
bundleRequest.result?.dispose?.();
|
|
21
|
+
bundleRequest.result = undefined;
|
|
22
|
+
// eslint-disable-next-line no-restricted-syntax -- this function can't be async
|
|
23
|
+
fs.rmSync(outputPath, { recursive: true, force: true });
|
|
24
|
+
},
|
|
25
|
+
onDispose: () => {
|
|
26
|
+
bundleRequest.result?.dispose?.();
|
|
27
|
+
},
|
|
28
|
+
getErrors: () => bundleRequest.result?.errors,
|
|
29
|
+
getStartDescription: () => ({
|
|
30
|
+
id,
|
|
31
|
+
name: `Bundle ${packageName}@${version}`,
|
|
32
|
+
inputPath: packagePath || '',
|
|
33
|
+
outputPath,
|
|
34
|
+
}),
|
|
35
|
+
getEndDescription: (taskResult) => ({
|
|
36
|
+
id,
|
|
37
|
+
errors: taskResult?.result?.errors,
|
|
38
|
+
warnings: taskResult?.result?.warnings,
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=createBundleTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBundleTask.js","sourceRoot":"","sources":["../../src/utilities/createBundleTask.ts"],"names":[],"mappings":"AAKA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,aAA4B,EAC5B,OAA2B,EAC3B,QAAuB;IAEvB,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC;IAExF,OAAO;QACL,IAAI,EAAE,UAAU,WAAW,IAAI,OAAO,EAAE;QACxC,EAAE;QACF,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE;QACvC,KAAK,EAAE,CAAC,UAAU;QAClB,KAAK,CAAC,OAAO;YACX,MAAM,UAAU,CAAC,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;YAEvD,OAAO,aAAa,CAAC;QACvB,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACV,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;YAClC,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC;YACjC,gFAAgF;YAChF,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;QACpC,CAAC;QACD,SAAS,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAgC;QACvE,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;YAC1B,EAAE;YACF,IAAI,EAAE,UAAU,WAAW,IAAI,OAAO,EAAE;YACxC,SAAS,EAAE,WAAW,IAAI,EAAE;YAC5B,UAAU;SACX,CAAC;QACF,iBAAiB,EAAE,CAAC,UAAU,EAAE,EAAE,CAChC,CAAC;YACC,EAAE;YACF,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM;YAClC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ;SACvC,CAAuB;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleTaskOptions } from '../types/BundleTaskOptions.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport type { Task } from '../types/Task.js';\nimport type { TaskError } from '../types/TaskError.js';\nimport type { TaskEndDescription } from '../types/TaskEndDescription.js';\nimport path from 'path';\nimport fs from 'fs';\nimport { bundleTask } from './/bundleTask.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\n\n/**\n * Creates a bundle task tracked in the task runner of the api server. This allows active tasks to be tracked\n * remotely (e.g. in the browser) and allows the user to cancel tasks.\n */\nexport function createBundleTask(\n bundleRequest: BundleRequest,\n options?: BundleTaskOptions,\n reporter?: TaskReporter,\n): Task<BundleRequest> {\n const { id, packageName, version, outputPath, packagePath, isExternal } = bundleRequest;\n\n return {\n name: `Bundle ${packageName}@${version}`,\n id,\n dir: `${path.join(packagePath, 'src')}`,\n watch: !isExternal,\n async execute(): Promise<BundleRequest> {\n await bundleTask({ bundleRequest, options, reporter });\n\n return bundleRequest;\n },\n clear: () => {\n bundleRequest.result?.dispose?.();\n bundleRequest.result = undefined;\n // eslint-disable-next-line no-restricted-syntax -- this function can't be async\n fs.rmSync(outputPath, { recursive: true, force: true });\n },\n onDispose: () => {\n bundleRequest.result?.dispose?.();\n },\n getErrors: () => bundleRequest.result?.errors as unknown as TaskError[],\n getStartDescription: () => ({\n id,\n name: `Bundle ${packageName}@${version}`,\n inputPath: packagePath || '',\n outputPath,\n }),\n getEndDescription: (taskResult) =>\n ({\n id,\n errors: taskResult?.result?.errors,\n warnings: taskResult?.result?.warnings,\n }) as TaskEndDescription,\n };\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a dictionary where key is the package name and value is a set of required paths.
|
|
3
|
+
* Eg. `{ '@fluentui/react': new Set([ '.', './lib/Button' ]) }`
|
|
4
|
+
*/
|
|
5
|
+
export declare function findImports(filePaths: string[]): Promise<Record<string, Set<string>>>;
|
|
6
|
+
//# sourceMappingURL=findImports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findImports.d.ts","sourceRoot":"","sources":["../../src/utilities/findImports.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAoE3F"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { parse } from 'es-module-lexer';
|
|
2
|
+
import fsPromises from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { parseImportString } from '@ms-cloudpack/path-string-parsing';
|
|
5
|
+
import { sourceExtensions } from '@ms-cloudpack/path-utilities';
|
|
6
|
+
import { builtinModules } from 'module';
|
|
7
|
+
/** Treat files with no extension as JS for purposes below */
|
|
8
|
+
const allSourceExtensions = [...sourceExtensions, ''];
|
|
9
|
+
/**
|
|
10
|
+
* Returns a dictionary where key is the package name and value is a set of required paths.
|
|
11
|
+
* Eg. `{ '@fluentui/react': new Set([ '.', './lib/Button' ]) }`
|
|
12
|
+
*/
|
|
13
|
+
export async function findImports(filePaths) {
|
|
14
|
+
const requiredExports = {};
|
|
15
|
+
const visitedPaths = new Set(filePaths);
|
|
16
|
+
const pathsToParse = [...filePaths];
|
|
17
|
+
while (pathsToParse.length) {
|
|
18
|
+
const filePath = pathsToParse.shift();
|
|
19
|
+
// Ignore any non-JS/TS files such as SVGs and sourcemaps
|
|
20
|
+
if (!filePath || !allSourceExtensions.includes(path.extname(filePath))) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const source = await fsPromises.readFile(filePath, 'utf-8');
|
|
24
|
+
let rawImports;
|
|
25
|
+
try {
|
|
26
|
+
[rawImports] = parse(source);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
// This could happen if the source file isn't valid JS
|
|
30
|
+
// (unlikely after adding the check above to only attempt parsing JS/TS files)
|
|
31
|
+
console.warn(`Failed to parse ${filePath}:`, err);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const imports = Array.from(new Set(rawImports))
|
|
35
|
+
.map((i) => {
|
|
36
|
+
// The es-module-lexer returns entries where the "n" property equals the import source.
|
|
37
|
+
// This includes the package name and path. For example, in this case:
|
|
38
|
+
//
|
|
39
|
+
// import { Button } from '@fluentui/react/lib/Button';
|
|
40
|
+
//
|
|
41
|
+
// The "n" property would be "@fluentui/react/lib/Button".
|
|
42
|
+
// The "s" and "e" properties represent the start/end character positions of
|
|
43
|
+
// the import source. The "ss" and "se" properties represent the start/end
|
|
44
|
+
// character positions of the import specifier starting with "import". This
|
|
45
|
+
// may be useful for determining if the import is sync or async.
|
|
46
|
+
//
|
|
47
|
+
// Currently when the import source is a backtick string, the "n" property
|
|
48
|
+
// is undefined. This is a bug in es-module-lexer. We may need to handle this
|
|
49
|
+
// at the javascript layer and expand it into multiple potential imports.
|
|
50
|
+
if (!i.n) {
|
|
51
|
+
console.debug(`Found an import that didn't parse correctly:\nFilename:\n${filePath}\n\nImport:\n${source.slice(i.s, i.e)}`);
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return parseImportString(i.n);
|
|
55
|
+
})
|
|
56
|
+
.filter(Boolean);
|
|
57
|
+
for (const { packageName, importPath } of imports) {
|
|
58
|
+
if (packageName?.startsWith('.')) {
|
|
59
|
+
const localPath = path.resolve(path.dirname(filePath), packageName, importPath || '');
|
|
60
|
+
if (!visitedPaths.has(localPath)) {
|
|
61
|
+
visitedPaths.add(localPath);
|
|
62
|
+
pathsToParse.push(localPath);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (packageName && !packageName.startsWith('node:') && !builtinModules.includes(packageName)) {
|
|
66
|
+
requiredExports[packageName] ??= new Set();
|
|
67
|
+
requiredExports[packageName].add(importPath || '.');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return requiredExports;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=findImports.js.map
|