@ms-cloudpack/api-server 0.23.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/apis/ensurePackageBundled.d.ts +6 -1
- package/lib/apis/ensurePackageBundled.d.ts.map +1 -1
- package/lib/apis/ensurePackageBundled.js +6 -4
- package/lib/apis/ensurePackageBundled.js.map +1 -1
- package/lib/apis/syncDownload.d.ts +1 -1
- package/lib/apis/syncDownload.d.ts.map +1 -1
- package/lib/apis/syncDownload.js +3 -3
- package/lib/apis/syncDownload.js.map +1 -1
- package/lib/apis/syncUpload.d.ts +1 -1
- package/lib/apis/syncUpload.d.ts.map +1 -1
- package/lib/apis/syncUpload.js +3 -0
- package/lib/apis/syncUpload.js.map +1 -1
- package/lib/common/createSession.d.ts.map +1 -1
- package/lib/common/createSession.js +18 -16
- package/lib/common/createSession.js.map +1 -1
- package/lib/index.d.ts +0 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -6
- package/lib/index.js.map +1 -1
- package/lib/startApiServer.d.ts.map +1 -1
- package/lib/startApiServer.js +0 -1
- package/lib/startApiServer.js.map +1 -1
- package/lib/trpc/createAppRouter.d.ts +2 -0
- package/lib/trpc/createAppRouter.d.ts.map +1 -1
- package/lib/trpc/createCloudpackServer.d.ts +1 -0
- package/lib/trpc/createCloudpackServer.d.ts.map +1 -1
- package/lib/types/ApiServer.d.ts +0 -1
- package/lib/types/ApiServer.d.ts.map +1 -1
- package/lib/types/ApiServer.js.map +1 -1
- package/lib/types/BundleRequest.d.ts +3 -0
- package/lib/types/BundleRequest.d.ts.map +1 -1
- package/lib/types/BundleRequest.js.map +1 -1
- package/lib/types/Session.d.ts +2 -4
- package/lib/types/Session.d.ts.map +1 -1
- package/lib/types/Session.js.map +1 -1
- package/lib/utilities/bundleTask.js +6 -3
- package/lib/utilities/bundleTask.js.map +1 -1
- package/lib/utilities/createBundleRequestForPackage.d.ts +3 -0
- package/lib/utilities/createBundleRequestForPackage.d.ts.map +1 -1
- package/lib/utilities/createBundleRequestForPackage.js +1 -0
- package/lib/utilities/createBundleRequestForPackage.js.map +1 -1
- package/lib/utilities/createBundleTask.d.ts +0 -4
- package/lib/utilities/createBundleTask.d.ts.map +1 -1
- package/lib/utilities/createBundleTask.js +6 -5
- package/lib/utilities/createBundleTask.js.map +1 -1
- package/lib/utilities/getBundleLocation.d.ts +4 -0
- package/lib/utilities/getBundleLocation.d.ts.map +1 -1
- package/lib/utilities/getBundleLocation.js +15 -5
- package/lib/utilities/getBundleLocation.js.map +1 -1
- package/lib/utilities/getPackagesToSync.d.ts +4 -0
- package/lib/utilities/getPackagesToSync.d.ts.map +1 -1
- package/lib/utilities/getPackagesToSync.js +2 -2
- package/lib/utilities/getPackagesToSync.js.map +1 -1
- package/lib/utilities/isCachedResultValid.d.ts.map +1 -1
- package/lib/utilities/isCachedResultValid.js +5 -1
- package/lib/utilities/isCachedResultValid.js.map +1 -1
- package/lib/utilities/parseRequestInfo.js +1 -1
- package/lib/utilities/parseRequestInfo.js.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCloudpackServer.d.ts","sourceRoot":"","sources":["../../src/trpc/createCloudpackServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAI/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAKnD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,wBAAsB,qBAAqB,CAAC,OAAO,EAAE;IACnD,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,aAAa,EAAE,aAAa,CAAC;CAC9B
|
|
1
|
+
{"version":3,"file":"createCloudpackServer.d.ts","sourceRoot":"","sources":["../../src/trpc/createCloudpackServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAI/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAKnD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,wBAAsB,qBAAqB,CAAC,OAAO,EAAE;IACnD,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,aAAa,EAAE,aAAa,CAAC;CAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCA;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
package/lib/types/ApiServer.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiServer.d.ts","sourceRoot":"","sources":["../../src/types/ApiServer.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ApiServer.d.ts","sourceRoot":"","sources":["../../src/types/ApiServer.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiServer.js","sourceRoot":"","sources":["../../src/types/ApiServer.ts"],"names":[],"mappings":"","sourcesContent":["export interface ApiServer {\n url: string;\n port: number;\n
|
|
1
|
+
{"version":3,"file":"ApiServer.js","sourceRoot":"","sources":["../../src/types/ApiServer.ts"],"names":[],"mappings":"","sourcesContent":["export interface ApiServer {\n url: string;\n port: number;\n close: () => Promise<void>;\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BundleResult, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
|
|
2
2
|
import type { CloudpackConfig } from '@ms-cloudpack/config';
|
|
3
|
+
import type { PackageHashes } from '@ms-cloudpack/package-hashes';
|
|
3
4
|
/**
|
|
4
5
|
* Tracks a given bundle request and its result.
|
|
5
6
|
*/
|
|
@@ -20,8 +21,10 @@ export interface BundleRequest {
|
|
|
20
21
|
disableSourceMaps?: boolean;
|
|
21
22
|
enableFindImports?: boolean;
|
|
22
23
|
enableCacheInternalPackages?: boolean;
|
|
24
|
+
disableCache?: boolean;
|
|
23
25
|
hashPackages?: boolean;
|
|
24
26
|
packages: PackageDefinitionsCache;
|
|
25
27
|
config: CloudpackConfig;
|
|
28
|
+
packageHashes: PackageHashes;
|
|
26
29
|
}
|
|
27
30
|
//# sourceMappingURL=BundleRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE;;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,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,YAAY,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAClG,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,eAAe,CAAC;IACxB,aAAa,EAAE,aAAa,CAAC;CAC9B"}
|
|
@@ -1 +1 @@
|
|
|
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 & { imports?: Record<string, string[]>; hash?: string; outputPath: string };\n resultFromCache?: boolean;\n disableSourceMaps?: boolean;\n enableFindImports?: boolean;\n enableCacheInternalPackages?: boolean;\n hashPackages?: boolean;\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n}\n"]}
|
|
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';\nimport type { PackageHashes } from '@ms-cloudpack/package-hashes';\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 & { imports?: Record<string, string[]>; hash?: string; outputPath: string };\n resultFromCache?: boolean;\n disableSourceMaps?: boolean;\n enableFindImports?: boolean;\n enableCacheInternalPackages?: boolean;\n disableCache?: boolean;\n hashPackages?: boolean;\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n packageHashes: PackageHashes;\n}\n"]}
|
package/lib/types/Session.d.ts
CHANGED
|
@@ -42,11 +42,9 @@ export interface Session {
|
|
|
42
42
|
*/
|
|
43
43
|
getSessionVersion: () => number;
|
|
44
44
|
/**
|
|
45
|
-
* Used to increment the session version.
|
|
46
|
-
* If version is undefined, the version will be incremented by 1.
|
|
47
|
-
* If version is greater than the current version, the version will be set to the new value.
|
|
45
|
+
* Used to increment the session version by 1.
|
|
48
46
|
*/
|
|
49
|
-
incrementSessionVersion: (
|
|
47
|
+
incrementSessionVersion: () => void;
|
|
50
48
|
/**
|
|
51
49
|
* The name of the project folder.
|
|
52
50
|
* Used to differentiate between multiple projects.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Session.d.ts","sourceRoot":"","sources":["../../src/types/Session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IAExB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAE5B;;;;;;OAMG;IACH,IAAI,EAAE,SAAS,GAAG,aAAa,GAAG,YAAY,CAAC;IAE/C;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IAEvB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,iBAAiB,EAAE,MAAM,MAAM,CAAC;IAEhC
|
|
1
|
+
{"version":3,"file":"Session.d.ts","sourceRoot":"","sources":["../../src/types/Session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IAExB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAE5B;;;;;;OAMG;IACH,IAAI,EAAE,SAAS,GAAG,aAAa,GAAG,YAAY,CAAC;IAE/C;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IAEvB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,iBAAiB,EAAE,MAAM,MAAM,CAAC;IAEhC;;OAEG;IACH,uBAAuB,EAAE,MAAM,IAAI,CAAC;IAEpC;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEvC;;OAEG;IACH,sBAAsB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAEpD;;OAEG;IACH,YAAY,EAAE,MAAM,SAAS,GAAG,SAAS,CAAC;IAE1C,YAAY,EAAE,CAAC,YAAY,EAAE,SAAS,KAAK,SAAS,CAAC;CACtD"}
|
package/lib/types/Session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Session.js","sourceRoot":"","sources":["../../src/types/Session.ts"],"names":[],"mappings":"","sourcesContent":["import type { ImportMap, ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\n\nexport interface Session {\n /**\n * The session id, used for identifying\n */\n id: string;\n\n /**\n * The config used by the session.\n */\n config: CloudpackConfig;\n\n /**\n * The primary application path to monitor.\n */\n appPath: string;\n\n /**\n * The type of session controls how the code is served via start.\n * Web apps require app server and asset hosting, while libraries\n * only need a bundle service.\n */\n type: 'web-app' | 'library';\n\n /**\n * The mode of the session controls how the code is bundled. Library\n * mode bundles each package in isolation, while development and\n * production modes bundle the full app graph together. Library\n * mode is fastest but packages must be complaint for loading in\n * the browser.\n */\n mode: 'library' | 'development' | 'production';\n\n /**\n * Used to resolve packages in the dependency graph.\n */\n resolveMap: ResolveMap;\n\n /**\n * Reload sequence to ensure that the client is always\n * up to date with the latest changes.\n */\n sequence: number;\n\n /**\n * Get session version.\n * Used to force a hard refresh on the client.\n */\n getSessionVersion: () => number;\n\n /**\n * Used to increment the session version
|
|
1
|
+
{"version":3,"file":"Session.js","sourceRoot":"","sources":["../../src/types/Session.ts"],"names":[],"mappings":"","sourcesContent":["import type { ImportMap, ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\n\nexport interface Session {\n /**\n * The session id, used for identifying\n */\n id: string;\n\n /**\n * The config used by the session.\n */\n config: CloudpackConfig;\n\n /**\n * The primary application path to monitor.\n */\n appPath: string;\n\n /**\n * The type of session controls how the code is served via start.\n * Web apps require app server and asset hosting, while libraries\n * only need a bundle service.\n */\n type: 'web-app' | 'library';\n\n /**\n * The mode of the session controls how the code is bundled. Library\n * mode bundles each package in isolation, while development and\n * production modes bundle the full app graph together. Library\n * mode is fastest but packages must be complaint for loading in\n * the browser.\n */\n mode: 'library' | 'development' | 'production';\n\n /**\n * Used to resolve packages in the dependency graph.\n */\n resolveMap: ResolveMap;\n\n /**\n * Reload sequence to ensure that the client is always\n * up to date with the latest changes.\n */\n sequence: number;\n\n /**\n * Get session version.\n * Used to force a hard refresh on the client.\n */\n getSessionVersion: () => number;\n\n /**\n * Used to increment the session version by 1.\n */\n incrementSessionVersion: () => void;\n\n /**\n * The name of the project folder.\n * Used to differentiate between multiple projects.\n */\n projectName: string;\n\n /**\n * The version of each target.\n * Used to force a client cache refresh on a single target.\n */\n targetVersions: Record<string, number>;\n\n /**\n * Increments the version for the given target.\n */\n incrementTargetVersion: (inputPath: string) => void;\n\n /**\n * The import map for the session.\n */\n getImportMap: () => ImportMap | undefined;\n\n setImportMap: (newImportMap: ImportMap) => ImportMap;\n}\n"]}
|
|
@@ -78,8 +78,9 @@ export async function bundleTask(params) {
|
|
|
78
78
|
return bundleRequest;
|
|
79
79
|
}
|
|
80
80
|
async function bundle(bundleRequest, force) {
|
|
81
|
-
const { packages, config } = bundleRequest;
|
|
82
|
-
const context = { packages, config };
|
|
81
|
+
const { packages, config, packageHashes } = bundleRequest;
|
|
82
|
+
const context = { packages, config, packageHashes };
|
|
83
|
+
const { features } = config;
|
|
83
84
|
// If force is set, dispose the existing result.
|
|
84
85
|
if (force && bundleRequest?.result?.dispose) {
|
|
85
86
|
bundleRequest.result.dispose();
|
|
@@ -108,7 +109,9 @@ async function bundle(bundleRequest, force) {
|
|
|
108
109
|
external: await getExternalsFromPackage({ inputPath: packagePath }, context),
|
|
109
110
|
};
|
|
110
111
|
const hash = !isExternal && enableCacheInternalPackages
|
|
111
|
-
?
|
|
112
|
+
? features?.hashPackages
|
|
113
|
+
? await packageHashes.get({ packagePath, isSourceHashingEnabled: true })
|
|
114
|
+
: await hashPackage({ packagePath, isExternal, additionalProperties: bundleOptions })
|
|
112
115
|
: undefined;
|
|
113
116
|
// if the cached result is valid, use it.
|
|
114
117
|
if (!force && isCachedResultValid({ bundleRequest, hash })) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACpH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,iBAAiB,GAGlB,MAAM,6BAA6B,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,EAAE,kBAAkB,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M,eAAe,GAAG,aAAa,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QAC7G,aAAa,CAAC,MAAM,CAAC,OAAO,GAAG,eAAe,IAAI,CAAC,MAAM,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC;KACxF;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';\nimport { isCachedResultValid } from './isCachedResultValid.js';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport { diskCacheRatioMetricEventAggregator } from './diskCacheRatioMetricEventAggregator.js';\nimport { getBundleLocation } from './getBundleLocation.js';\n\nexport async function bundleTask(params: {\n bundleRequest: BundleRequest;\n options?: BundleTaskOptions;\n reporter?: TaskReporter;\n telemetryClient?: TelemetryClient;\n}): Promise<BundleRequest> {\n const { bundleRequest, options = {}, reporter, telemetryClient } = params;\n const { packageName, version } = bundleRequest;\n const { force } = options || {};\n\n const bundleResult = bundleRequest.result;\n const taskName = `${bundleResult?.rebuild ? `Re-bundle` : `Bundle`} ${formatPackageName({\n name: packageName,\n version,\n })}`;\n\n telemetryClient?.performance.registerAggregator(diskCacheRatioMetricEventAggregator);\n\n const executeBundle = async (): Promise<TaskReporterTaskResult> => {\n if (bundleResult?.rebuild) {\n bundleRequest.result = {\n ...(await bundleResult.rebuild()),\n outputPath: bundleResult.outputPath,\n };\n bundleRequest.resultFromCache = false;\n } else {\n await bundle(bundleRequest, force);\n }\n\n diskCacheRatioMetricEventAggregator?.record({\n isCacheHit: !!bundleRequest.resultFromCache,\n isExternal: bundleRequest.isExternal,\n });\n\n const { result } = bundleRequest;\n\n if (!result) {\n return {\n status: 'fail',\n details: `No result was found for \"${packageName}@${version}\"`,\n };\n }\n\n result.outputFiles ??= [];\n result.errors ??= [];\n result.warnings ??= [];\n\n if (!result.outputFiles.length && !result.errors?.length) {\n result.warnings.push({\n text: `No output files were found for \"${packageName}\" in \"${result.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: ${result.bundlerName || 'unknown'}`,\n `Input path: ${bundleRequest.packagePath}`,\n `Entries:`,\n Object.values(result.entries || {}),\n `Output path: ${result.outputPath}`,\n result.outputFiles?.map(\n (file) =>\n `${safeRelativePath(path.relative(result.outputPath, file.outputPath))} (${getFileSizeSync(\n path.resolve(result.outputPath, 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, isExternal, disableSourceMaps, enableFindImports, enableCacheInternalPackages } = bundleRequest;\n\n const outputPath = bundleRequest.outputPath ?? (await getBundleLocation({ packagePath }, context)).path;\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 the cached result is valid, use it.\n if (!force && isCachedResultValid({ bundleRequest, hash })) {\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 const bundleInternalResult = await bundleInternal(bundleOptions);\n bundleRequest.result = {\n ...bundleInternalResult,\n outputPath: bundleOptions.outputPath ?? outputPath,\n hash,\n };\n\n // Write the result to disk.\n if (isExternal || enableCacheInternalPackages) {\n const result = { ...bundleRequest.result };\n\n // Clear the rawInput/output properties.\n result.rawInput = result.rawOutput = undefined;\n\n await writeJson(path.join(outputPath, 'result.json'), bundleRequest.result);\n }\n }\n\n if (enableFindImports && !bundleRequest.result?.errors?.length && bundleRequest.result?.outputFiles?.length) {\n const importsPath = path.join(outputPath, 'imports.json');\n let imports = await readJson<Record<string, string[]>>(importsPath);\n\n // If we couldn't rehydrate imports from cache, compute them.\n if (!imports) {\n const scriptPaths = bundleRequest.result.outputFiles.map((f) => path.resolve(outputPath, f.outputPath));\n\n imports = await findImports(scriptPaths);\n\n // Write to cache for future use. (Ignore the promise result.)\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n writeJson(importsPath, imports);\n }\n\n bundleRequest.result.imports = imports;\n\n // Find imports that are in the output files and set dependencies.\n const outputFilePaths = bundleRequest.result.outputFiles?.map((f) => path.resolve(outputPath, f.outputPath));\n bundleRequest.result.imports = outputFilePaths && (await findImports(outputFilePaths));\n }\n\n return bundleRequest;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACpH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,iBAAiB,GAGlB,MAAM,6BAA6B,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,mCAAmC,EAAE,MAAM,0CAA0C,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAA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,CAAC,CAAC,CAAC;QAC7G,aAAa,CAAC,MAAM,CAAC,OAAO,GAAG,eAAe,IAAI,CAAC,MAAM,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC;KACxF;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';\nimport { isCachedResultValid } from './isCachedResultValid.js';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport { diskCacheRatioMetricEventAggregator } from './diskCacheRatioMetricEventAggregator.js';\nimport { getBundleLocation } from './getBundleLocation.js';\n\nexport async function bundleTask(params: {\n bundleRequest: BundleRequest;\n options?: BundleTaskOptions;\n reporter?: TaskReporter;\n telemetryClient?: TelemetryClient;\n}): Promise<BundleRequest> {\n const { bundleRequest, options = {}, reporter, telemetryClient } = params;\n const { packageName, version } = bundleRequest;\n const { force } = options || {};\n\n const bundleResult = bundleRequest.result;\n const taskName = `${bundleResult?.rebuild ? `Re-bundle` : `Bundle`} ${formatPackageName({\n name: packageName,\n version,\n })}`;\n\n telemetryClient?.performance.registerAggregator(diskCacheRatioMetricEventAggregator);\n\n const executeBundle = async (): Promise<TaskReporterTaskResult> => {\n if (bundleResult?.rebuild) {\n bundleRequest.result = {\n ...(await bundleResult.rebuild()),\n outputPath: bundleResult.outputPath,\n };\n bundleRequest.resultFromCache = false;\n } else {\n await bundle(bundleRequest, force);\n }\n\n diskCacheRatioMetricEventAggregator?.record({\n isCacheHit: !!bundleRequest.resultFromCache,\n isExternal: bundleRequest.isExternal,\n });\n\n const { result } = bundleRequest;\n\n if (!result) {\n return {\n status: 'fail',\n details: `No result was found for \"${packageName}@${version}\"`,\n };\n }\n\n result.outputFiles ??= [];\n result.errors ??= [];\n result.warnings ??= [];\n\n if (!result.outputFiles.length && !result.errors?.length) {\n result.warnings.push({\n text: `No output files were found for \"${packageName}\" in \"${result.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: ${result.bundlerName || 'unknown'}`,\n `Input path: ${bundleRequest.packagePath}`,\n `Entries:`,\n Object.values(result.entries || {}),\n `Output path: ${result.outputPath}`,\n result.outputFiles?.map(\n (file) =>\n `${safeRelativePath(path.relative(result.outputPath, file.outputPath))} (${getFileSizeSync(\n path.resolve(result.outputPath, 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, packageHashes } = bundleRequest;\n const context = { packages, config, packageHashes };\n const { features } = 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, isExternal, disableSourceMaps, enableFindImports, enableCacheInternalPackages } = bundleRequest;\n\n const outputPath = bundleRequest.outputPath ?? (await getBundleLocation({ packagePath }, context)).path;\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 ? features?.hashPackages\n ? await packageHashes.get({ packagePath, isSourceHashingEnabled: true })\n : await hashPackage({ packagePath, isExternal, additionalProperties: bundleOptions })\n : undefined;\n\n // if the cached result is valid, use it.\n if (!force && isCachedResultValid({ bundleRequest, hash })) {\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 const bundleInternalResult = await bundleInternal(bundleOptions);\n bundleRequest.result = {\n ...bundleInternalResult,\n outputPath: bundleOptions.outputPath ?? outputPath,\n hash,\n };\n\n // Write the result to disk.\n if (isExternal || enableCacheInternalPackages) {\n const result = { ...bundleRequest.result };\n\n // Clear the rawInput/output properties.\n result.rawInput = result.rawOutput = undefined;\n\n await writeJson(path.join(outputPath, 'result.json'), bundleRequest.result);\n }\n }\n\n if (enableFindImports && !bundleRequest.result?.errors?.length && bundleRequest.result?.outputFiles?.length) {\n const importsPath = path.join(outputPath, 'imports.json');\n let imports = await readJson<Record<string, string[]>>(importsPath);\n\n // If we couldn't rehydrate imports from cache, compute them.\n if (!imports) {\n const scriptPaths = bundleRequest.result.outputFiles.map((f) => path.resolve(outputPath, f.outputPath));\n\n imports = await findImports(scriptPaths);\n\n // Write to cache for future use. (Ignore the promise result.)\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n writeJson(importsPath, imports);\n }\n\n bundleRequest.result.imports = imports;\n\n // Find imports that are in the output files and set dependencies.\n const outputFilePaths = bundleRequest.result.outputFiles?.map((f) => path.resolve(outputPath, f.outputPath));\n bundleRequest.result.imports = outputFilePaths && (await findImports(outputFilePaths));\n }\n\n return bundleRequest;\n}\n"]}
|
|
@@ -2,14 +2,17 @@ import type { CloudpackConfig } from '@ms-cloudpack/config';
|
|
|
2
2
|
import type { ResolveMapEntry } from '@ms-cloudpack/package-utilities';
|
|
3
3
|
import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
|
|
4
4
|
import type { BundleRequest } from '../types/BundleRequest.js';
|
|
5
|
+
import type { PackageHashes } from '@ms-cloudpack/package-hashes';
|
|
5
6
|
export declare function createBundleRequestForPackage(options: {
|
|
6
7
|
packageEntry: ResolveMapEntry;
|
|
7
8
|
outputPath?: string;
|
|
8
9
|
bundlerType?: string;
|
|
9
10
|
disableSourceMaps?: boolean;
|
|
10
11
|
enableFindImports?: boolean;
|
|
12
|
+
disableCache?: boolean;
|
|
11
13
|
}, context: {
|
|
12
14
|
config: CloudpackConfig;
|
|
13
15
|
packages: PackageDefinitionsCache;
|
|
16
|
+
packageHashes: PackageHashes;
|
|
14
17
|
}): BundleRequest;
|
|
15
18
|
//# sourceMappingURL=createBundleRequestForPackage.d.ts.map
|
|
@@ -1 +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;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;
|
|
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;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE;IACP,YAAY,EAAE,eAAe,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,EACD,OAAO,EAAE;IACP,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,aAAa,EAAE,aAAa,CAAC;CAC9B,GACA,aAAa,CAqBf"}
|
|
@@ -12,6 +12,7 @@ export function createBundleRequestForPackage(options, context) {
|
|
|
12
12
|
version,
|
|
13
13
|
disableSourceMaps: options.disableSourceMaps ?? features.disableSourceMaps,
|
|
14
14
|
enableFindImports: options.enableFindImports ?? features.enqueueDependencies,
|
|
15
|
+
disableCache: options.disableCache,
|
|
15
16
|
enableCacheInternalPackages: features.cacheInternalPackages,
|
|
16
17
|
hashPackages: features.hashPackages,
|
|
17
18
|
bundlerType: options.bundlerType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBundleRequestForPackage.js","sourceRoot":"","sources":["../../src/utilities/createBundleRequestForPackage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createBundleRequestForPackage.js","sourceRoot":"","sources":["../../src/utilities/createBundleRequestForPackage.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,6BAA6B,CAC3C,OAOC,EACD,OAIC;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,UAAU,EAAE,GAAG,YAAY,CAAC;IAEzD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,OAAO;QACP,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,QAAQ,CAAC,iBAAiB;QAC1E,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,QAAQ,CAAC,mBAAmB;QAC5E,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,2BAA2B,EAAE,QAAQ,CAAC,qBAAqB;QAC3D,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,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 type { BundleRequest } from '../types/BundleRequest.js';\nimport type { PackageHashes } from '@ms-cloudpack/package-hashes';\n\nexport function createBundleRequestForPackage(\n options: {\n packageEntry: ResolveMapEntry;\n outputPath?: string;\n bundlerType?: string;\n disableSourceMaps?: boolean;\n enableFindImports?: boolean;\n disableCache?: boolean;\n },\n context: {\n config: CloudpackConfig;\n packages: PackageDefinitionsCache;\n packageHashes: PackageHashes;\n },\n): BundleRequest {\n const { packageEntry } = options;\n const { config } = context;\n const { features = {} } = config;\n const { path, version, name, isExternal } = packageEntry;\n\n return {\n id: path,\n packagePath: path,\n packageName: name,\n isExternal: !!isExternal,\n outputPath: options.outputPath,\n version,\n disableSourceMaps: options.disableSourceMaps ?? features.disableSourceMaps,\n enableFindImports: options.enableFindImports ?? features.enqueueDependencies,\n disableCache: options.disableCache,\n enableCacheInternalPackages: features.cacheInternalPackages,\n hashPackages: features.hashPackages,\n bundlerType: options.bundlerType,\n ...context,\n };\n}\n"]}
|
|
@@ -2,8 +2,6 @@ import type { BundleTaskOptions } from '../types/BundleTaskOptions.js';
|
|
|
2
2
|
import type { BundleRequest } from '../types/BundleRequest.js';
|
|
3
3
|
import type { Task } from '../types/Task.js';
|
|
4
4
|
import type { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
5
|
-
import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
|
|
6
|
-
import type { CloudpackConfig } from '@ms-cloudpack/config';
|
|
7
5
|
import type { Session } from '../types/Session.js';
|
|
8
6
|
import type { TelemetryClient } from '@ms-cloudpack/telemetry';
|
|
9
7
|
import type { PackageImportPaths } from '@ms-cloudpack/package-utilities';
|
|
@@ -12,9 +10,7 @@ import type { PackageImportPaths } from '@ms-cloudpack/package-utilities';
|
|
|
12
10
|
* remotely (e.g. in the browser) and allows the user to cancel tasks.
|
|
13
11
|
*/
|
|
14
12
|
export declare function createBundleTask(bundleRequest: BundleRequest, context: {
|
|
15
|
-
packages: PackageDefinitionsCache;
|
|
16
13
|
packageImportPaths: PackageImportPaths;
|
|
17
|
-
config: CloudpackConfig;
|
|
18
14
|
session: Session;
|
|
19
15
|
reporter?: TaskReporter;
|
|
20
16
|
telemetryClient?: TelemetryClient;
|
|
@@ -1 +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;AAK7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;
|
|
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;AAK7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE;IACP,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,EACD,OAAO,CAAC,EAAE,iBAAiB,GAC1B,IAAI,CAAC,aAAa,CAAC,CA2DrB"}
|
|
@@ -7,8 +7,9 @@ import { addImportMapHash } from '@ms-cloudpack/package-utilities';
|
|
|
7
7
|
* remotely (e.g. in the browser) and allows the user to cancel tasks.
|
|
8
8
|
*/
|
|
9
9
|
export function createBundleTask(bundleRequest, context, options) {
|
|
10
|
-
const { id, packageName, version, outputPath, packagePath, isExternal } = bundleRequest;
|
|
11
|
-
const {
|
|
10
|
+
const { id, packageName, version, outputPath, packagePath, isExternal, packageHashes } = bundleRequest;
|
|
11
|
+
const { session, reporter, telemetryClient, packageImportPaths } = context;
|
|
12
|
+
const { config } = session;
|
|
12
13
|
return {
|
|
13
14
|
name: `Bundle ${packageName}@${version}`,
|
|
14
15
|
id,
|
|
@@ -18,11 +19,11 @@ export function createBundleTask(bundleRequest, context, options) {
|
|
|
18
19
|
await bundleTask({ bundleRequest, options, reporter, telemetryClient });
|
|
19
20
|
if (config?.features?.hashPackages) {
|
|
20
21
|
if (!isExternal) {
|
|
21
|
-
|
|
22
|
+
packageHashes.remove(packagePath);
|
|
22
23
|
}
|
|
23
24
|
try {
|
|
24
|
-
const hash = await
|
|
25
|
-
addImportMapHash(packageName, version, session.getImportMap(), session.resolveMap, hash, {
|
|
25
|
+
const hash = await packageHashes.get({ packagePath, isSourceHashingEnabled: true });
|
|
26
|
+
addImportMapHash({ packageName, version, importMap: session.getImportMap(), resolveMap: session.resolveMap, hash }, {
|
|
26
27
|
packageImportPaths,
|
|
27
28
|
});
|
|
28
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBundleTask.js","sourceRoot":"","sources":["../../src/utilities/createBundleTask.ts"],"names":[],"mappings":"AAIA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"createBundleTask.js","sourceRoot":"","sources":["../../src/utilities/createBundleTask.ts"],"names":[],"mappings":"AAIA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAK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QACD,KAAK,EAAE,GAAG,EAAE;YACV,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;gBACzB,OAAO;aACR;YAED,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;YAEjC,qGAAqG;YACrG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAE7E,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC;QACnC,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,MAAM;QAC7C,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 { 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';\nimport { addImportMapHash } from '@ms-cloudpack/package-utilities';\nimport type { Session } from '../types/Session.js';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { PackageImportPaths } from '@ms-cloudpack/package-utilities';\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 context: {\n packageImportPaths: PackageImportPaths;\n session: Session;\n reporter?: TaskReporter;\n telemetryClient?: TelemetryClient;\n },\n options?: BundleTaskOptions,\n): Task<BundleRequest> {\n const { id, packageName, version, outputPath, packagePath, isExternal, packageHashes } = bundleRequest;\n const { session, reporter, telemetryClient, packageImportPaths } = context;\n const { config } = session;\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, telemetryClient });\n if (config?.features?.hashPackages) {\n if (!isExternal) {\n packageHashes.remove(packagePath);\n }\n try {\n const hash = await packageHashes.get({ packagePath, isSourceHashingEnabled: true });\n addImportMapHash(\n { packageName, version, importMap: session.getImportMap(), resolveMap: session.resolveMap, hash },\n {\n packageImportPaths,\n },\n );\n } catch (e) {\n console.error(`Error adding hash to import map for ${bundleRequest.packagePath}`, e);\n }\n }\n return bundleRequest;\n },\n clear: () => {\n if (!bundleRequest.result) {\n return;\n }\n\n bundleRequest.result.dispose?.();\n\n // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem -- this function can't be async\n fs.rmSync(bundleRequest.result.outputPath, { recursive: true, force: true });\n\n bundleRequest.result = undefined;\n },\n onDispose: () => {\n bundleRequest.result?.dispose?.();\n },\n getErrors: () => bundleRequest.result?.errors,\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"]}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
|
|
2
|
+
import type { PackageHashes } from '@ms-cloudpack/package-hashes';
|
|
3
|
+
import type { CloudpackConfig } from '@ms-cloudpack/config';
|
|
2
4
|
export declare function getBundleLocation(options: {
|
|
3
5
|
packagePath: string;
|
|
4
6
|
}, context: {
|
|
5
7
|
packages: PackageDefinitionsCache;
|
|
8
|
+
packageHashes: PackageHashes;
|
|
9
|
+
config: CloudpackConfig;
|
|
6
10
|
}): Promise<{
|
|
7
11
|
path: string;
|
|
8
12
|
folderName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBundleLocation.d.ts","sourceRoot":"","sources":["../../src/utilities/getBundleLocation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"getBundleLocation.d.ts","sourceRoot":"","sources":["../../src/utilities/getBundleLocation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,wBAAsB,iBAAiB,CACrC,OAAO,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,EAChC,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAC;IAAC,aAAa,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE;;;GAyCtG"}
|
|
@@ -5,7 +5,8 @@ import path from 'path';
|
|
|
5
5
|
import { getCachePath } from './getCachePath.js';
|
|
6
6
|
export async function getBundleLocation(options, context) {
|
|
7
7
|
const { packagePath } = options;
|
|
8
|
-
const { packages } = context;
|
|
8
|
+
const { packages, packageHashes, config } = context;
|
|
9
|
+
const { features } = config;
|
|
9
10
|
const definition = await packages.get(packagePath);
|
|
10
11
|
if (!definition) {
|
|
11
12
|
throw new Error(`Package definition (package.json) missing or invalid at "${packagePath}"`);
|
|
@@ -15,10 +16,19 @@ export async function getBundleLocation(options, context) {
|
|
|
15
16
|
}
|
|
16
17
|
const { name, version } = definition;
|
|
17
18
|
const isExternal = isExternalPackage(packagePath);
|
|
18
|
-
const hashResult =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const hashResult = features?.hashPackages
|
|
20
|
+
? await packageHashes.get({
|
|
21
|
+
packagePath,
|
|
22
|
+
/**
|
|
23
|
+
* We don't use source hashing for location,
|
|
24
|
+
* because we do not want to create a new folder for each change in a package.
|
|
25
|
+
*/
|
|
26
|
+
isSourceHashingEnabled: false,
|
|
27
|
+
})
|
|
28
|
+
: hash({
|
|
29
|
+
...definition,
|
|
30
|
+
version: (isExternal ? version : packagePath) || packagePath,
|
|
31
|
+
});
|
|
22
32
|
// Derive where the output should be.
|
|
23
33
|
const folderName = `${filenamify(name)}-${version}-${hashResult}`;
|
|
24
34
|
const outputPath = path.join(getCachePath(), folderName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBundleLocation.js","sourceRoot":"","sources":["../../src/utilities/getBundleLocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"getBundleLocation.js","sourceRoot":"","sources":["../../src/utilities/getBundleLocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,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;AACJ,CAAC","sourcesContent":["import { isExternalPackage } from '@ms-cloudpack/package-utilities';\nimport hash from 'object-hash';\nimport filenamify from 'filenamify';\nimport path from 'path';\nimport { getCachePath } from './getCachePath.js';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { PackageHashes } from '@ms-cloudpack/package-hashes';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\n\nexport async function getBundleLocation(\n options: { packagePath: string },\n context: { packages: PackageDefinitionsCache; packageHashes: PackageHashes; config: CloudpackConfig },\n) {\n const { packagePath } = options;\n const { packages, packageHashes, config } = context;\n const { features } = config;\n const definition = await packages.get(packagePath);\n\n if (!definition) {\n throw new Error(`Package definition (package.json) missing or invalid at \"${packagePath}\"`);\n }\n\n if (!definition.name) {\n throw new Error(`Package definition (package.json) missing name at \"${packagePath}\"`);\n }\n\n const { name, version } = definition;\n\n const isExternal = isExternalPackage(packagePath);\n\n const hashResult = features?.hashPackages\n ? await packageHashes.get({\n packagePath,\n /**\n * We don't use source hashing for location,\n * because we do not want to create a new folder for each change in a package.\n */\n isSourceHashingEnabled: false,\n })\n : hash({\n ...definition,\n version: (isExternal ? version : packagePath) || packagePath,\n });\n\n // Derive where the output should be.\n const folderName = `${filenamify(name)}-${version}-${hashResult}`;\n const outputPath = path.join(getCachePath(), folderName);\n\n return {\n path: outputPath,\n folderName,\n };\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
|
|
2
2
|
import { type ResolveMap } from '@ms-cloudpack/package-utilities';
|
|
3
|
+
import type { PackageHashes } from '@ms-cloudpack/package-hashes';
|
|
4
|
+
import type { CloudpackConfig } from '@ms-cloudpack/config';
|
|
3
5
|
export interface PackageToSync {
|
|
4
6
|
path: string;
|
|
5
7
|
folderName: string;
|
|
@@ -7,6 +9,8 @@ export interface PackageToSync {
|
|
|
7
9
|
}
|
|
8
10
|
export declare function getPackagesToSync(options: {
|
|
9
11
|
packages: PackageDefinitionsCache;
|
|
12
|
+
packageHashes: PackageHashes;
|
|
10
13
|
resolveMap: ResolveMap;
|
|
14
|
+
config: CloudpackConfig;
|
|
11
15
|
}): Promise<PackageToSync[]>;
|
|
12
16
|
//# sourceMappingURL=getPackagesToSync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackagesToSync.d.ts","sourceRoot":"","sources":["../../src/utilities/getPackagesToSync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"getPackagesToSync.d.ts","sourceRoot":"","sources":["../../src/utilities/getPackagesToSync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAsB,iBAAiB,CAAC,OAAO,EAAE;IAC/C,QAAQ,EAAE,uBAAuB,CAAC;IAClC,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,eAAe,CAAC;CACzB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAsB3B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { findResolveMapEntry, isExternalPackage, } from '@ms-cloudpack/package-utilities';
|
|
2
2
|
import { getBundleLocation } from './getBundleLocation.js';
|
|
3
3
|
export async function getPackagesToSync(options) {
|
|
4
|
-
const { packages, resolveMap } = options;
|
|
4
|
+
const { packages, resolveMap, packageHashes, config } = options;
|
|
5
5
|
const list = [];
|
|
6
6
|
const packageEntries = Object.keys(resolveMap)
|
|
7
7
|
.map((packageName) => findResolveMapEntry({
|
|
@@ -11,7 +11,7 @@ export async function getPackagesToSync(options) {
|
|
|
11
11
|
.filter((item) => item);
|
|
12
12
|
for (const { path: packagePath, name, version } of packageEntries) {
|
|
13
13
|
const isExternal = isExternalPackage(packagePath);
|
|
14
|
-
const outputLocation = await getBundleLocation({ packagePath }, { packages });
|
|
14
|
+
const outputLocation = await getBundleLocation({ packagePath }, { packages, packageHashes, config });
|
|
15
15
|
if (isExternal) {
|
|
16
16
|
list.push({ ...outputLocation, friendlyName: `${name}@${version}` });
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackagesToSync.js","sourceRoot":"","sources":["../../src/utilities/getPackagesToSync.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAGlB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"getPackagesToSync.js","sourceRoot":"","sources":["../../src/utilities/getPackagesToSync.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAGlB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAU3D,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAKvC;IACC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAChE,MAAM,IAAI,GAAoB,EAAE,CAAC;IAEjC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;SAC3C,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CACnB,mBAAmB,CAAC;QAClB,WAAW;QACX,UAAU;KACX,CAAC,CACH;SACA,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAsB,CAAC;IAE/C,KAAK,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,cAAc,EAAE;QACjE,MAAM,UAAU,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAClD,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC;QACrG,IAAI,UAAU,EAAE;YACd,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,cAAc,EAAE,YAAY,EAAE,GAAG,IAAI,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC;SACtE;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport {\n findResolveMapEntry,\n isExternalPackage,\n type ResolveMap,\n type ResolveMapEntry,\n} from '@ms-cloudpack/package-utilities';\nimport { getBundleLocation } from './getBundleLocation.js';\nimport type { PackageHashes } from '@ms-cloudpack/package-hashes';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\n\nexport interface PackageToSync {\n path: string;\n folderName: string;\n friendlyName: string;\n}\n\nexport async function getPackagesToSync(options: {\n packages: PackageDefinitionsCache;\n packageHashes: PackageHashes;\n resolveMap: ResolveMap;\n config: CloudpackConfig;\n}): Promise<PackageToSync[]> {\n const { packages, resolveMap, packageHashes, config } = options;\n const list: PackageToSync[] = [];\n\n const packageEntries = Object.keys(resolveMap)\n .map((packageName) =>\n findResolveMapEntry({\n packageName,\n resolveMap,\n }),\n )\n .filter((item) => item) as ResolveMapEntry[];\n\n for (const { path: packagePath, name, version } of packageEntries) {\n const isExternal = isExternalPackage(packagePath);\n const outputLocation = await getBundleLocation({ packagePath }, { packages, packageHashes, config });\n if (isExternal) {\n list.push({ ...outputLocation, friendlyName: `${name}@${version}` });\n }\n }\n\n return list;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isCachedResultValid.d.ts","sourceRoot":"","sources":["../../src/utilities/isCachedResultValid.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,UAAU,0BAA0B;IAClC,aAAa,EAAE,aAAa,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"isCachedResultValid.d.ts","sourceRoot":"","sources":["../../src/utilities/isCachedResultValid.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,UAAU,0BAA0B;IAClC,aAAa,EAAE,aAAa,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAmChF"}
|
|
@@ -6,7 +6,11 @@ import path from 'path';
|
|
|
6
6
|
*/
|
|
7
7
|
export function isCachedResultValid(options) {
|
|
8
8
|
const { bundleRequest, hash } = options;
|
|
9
|
-
const { enableCacheInternalPackages, isExternal, result } = bundleRequest;
|
|
9
|
+
const { disableCache, enableCacheInternalPackages, isExternal, result } = bundleRequest;
|
|
10
|
+
if (disableCache) {
|
|
11
|
+
// The result is not valid if disableCache is true.
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
10
14
|
if (!result) {
|
|
11
15
|
// The result is undefined, so the result is invalid
|
|
12
16
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isCachedResultValid.js","sourceRoot":"","sources":["../../src/utilities/isCachedResultValid.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAQxB;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAmC;IACrE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,EAAE,2BAA2B,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"isCachedResultValid.js","sourceRoot":"","sources":["../../src/utilities/isCachedResultValid.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAQxB;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAmC;IACrE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,EAAE,YAAY,EAAE,2BAA2B,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC;IAExF,IAAI,YAAY,EAAE;QAChB,mDAAmD;QACnD,OAAO,KAAK,CAAC;KACd;IAED,IAAI,CAAC,MAAM,EAAE;QACX,oDAAoD;QACpD,OAAO,KAAK,CAAC;KACd;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE;QACzB,6CAA6C;QAC7C,OAAO,KAAK,CAAC;KACd;IAED,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;QACtB,+FAA+F;QAC/F,OAAO,KAAK,CAAC;KACd;IAED,IAAI,2BAA2B,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE;QACtE,sHAAsH;QACtH,OAAO,KAAK,CAAC;KACd;IAED,gCAAgC;IAChC,IAAI,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE;QAC7E,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import path from 'path';\nimport type { BundleRequest } from '../types/BundleRequest.js';\n\ninterface IsCachedResultValidOptions {\n bundleRequest: BundleRequest;\n hash?: string;\n}\n\n/**\n * Validates the result of a bundle request.\n * @param options - The options to use when validating the result.\n * @returns True if the result is valid, false otherwise.\n */\nexport function isCachedResultValid(options: IsCachedResultValidOptions): boolean {\n const { bundleRequest, hash } = options;\n const { disableCache, enableCacheInternalPackages, isExternal, result } = bundleRequest;\n\n if (disableCache) {\n // The result is not valid if disableCache is true.\n return false;\n }\n\n if (!result) {\n // The result is undefined, so the result is invalid\n return false;\n }\n\n if (result.errors?.length) {\n // There are errors, so the result is invalid\n return false;\n }\n\n if (!result.outputPath) {\n // outputPath used to be an optional field, however, we do not want it to be undefined anymore.\n return false;\n }\n\n if (enableCacheInternalPackages && !isExternal && result.hash !== hash) {\n // The package is internal, enableCacheInternalPackages is enabled but hashes do not match, this is an invalid result.\n return false;\n }\n\n // Output files must be relative\n if (result.outputFiles?.find(({ outputPath }) => path.isAbsolute(outputPath))) {\n return false;\n }\n\n return true;\n}\n"]}
|
|
@@ -20,7 +20,7 @@ export function parseRequestInfo(requestPath) {
|
|
|
20
20
|
// - Anchoring to the beginning of the string with ^
|
|
21
21
|
const matches = requestPath.match(
|
|
22
22
|
// 1 package name 2 hash 3 version refresh 4 bundled 4 file path end or query
|
|
23
|
-
/^\/?((?:@[-\w.]+\/)?[-\w.]+)(?:@([-\w.]+))?(?:\/h-([0-9a-z.]+))?(?:\/v[\d.]+)?(?:\/(bundled|unbundled))?(\/[-@\w.+/]+)?(?:\?|$)/) || [];
|
|
23
|
+
/^\/?((?:@[-\w.]+\/)?[-\w.]+)(?:@([-\w.]+))?(?:\/h-([-0-9a-z.]+))?(?:\/v[\d.]+)?(?:\/(bundled|unbundled))?(\/[-@\w.+/]+)?(?:\?|$)/) || [];
|
|
24
24
|
return {
|
|
25
25
|
packageName: matches[1] || '',
|
|
26
26
|
version: matches[2] || '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseRequestInfo.js","sourceRoot":"","sources":["../../src/utilities/parseRequestInfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAYlD,gFAAgF;IAChF,4DAA4D;IAC5D,kEAAkE;IAClE,wEAAwE;IACxE,oDAAoD;IACpD,MAAM,OAAO,GACX,WAAW,CAAC,KAAK;IACf,+HAA+H;IAC/H,
|
|
1
|
+
{"version":3,"file":"parseRequestInfo.js","sourceRoot":"","sources":["../../src/utilities/parseRequestInfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAYlD,gFAAgF;IAChF,4DAA4D;IAC5D,kEAAkE;IAClE,wEAAwE;IACxE,oDAAoD;IACpD,MAAM,OAAO,GACX,WAAW,CAAC,KAAK;IACf,+HAA+H;IAC/H,kIAAkI,CACnI,IAAI,EAAE,CAAC;IAEV,OAAO;QACL,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;QAC7B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;QACzB,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;QACtB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS;QACjC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Parse a request for package file from the bundle server, such as\n * `/@scope/package@version/v3.2/bundled/path/to/file.js`\n *\n * Segments:\n * - Package name (and optionally `@version`)\n * - Optional refresh version `v#.#`\n * - Optional type `bundled` or `unbundled` (defaults to unbundled)\n * - Optional file path with leading slash (empty if no path)\n *\n * @param requestPath Pathname (server-relative URL) of the requested file.\n * @returns Info about the requested file. If `requestPath` doesn't follow the expected format,\n * the object will contain empty strings.\n */\nexport function parseRequestInfo(requestPath: string): {\n /** Package name (empty string if invalid request) */\n packageName: string;\n /** Optional package version (default: empty string) */\n version: string;\n /** Optional hash (default: empty string) */\n hash: string;\n /** Whether the bundled version is requested (default: false) */\n bundled: boolean;\n /** Optional file path (default: empty string) */\n filePath: string;\n} {\n // This is a hot path, and the following things appear to make the regex faster:\n // - /(?:Non-capturing groups)/ where capturing isn't needed\n // - /(Indexed capturing groups)/ instead of /(?<namedGroups>...)/\n // - For character classes containing - , putting the - at the beginning\n // - Anchoring to the beginning of the string with ^\n const matches =\n requestPath.match(\n // 1 package name 2 hash 3 version refresh 4 bundled 4 file path end or query\n /^\\/?((?:@[-\\w.]+\\/)?[-\\w.]+)(?:@([-\\w.]+))?(?:\\/h-([-0-9a-z.]+))?(?:\\/v[\\d.]+)?(?:\\/(bundled|unbundled))?(\\/[-@\\w.+/]+)?(?:\\?|$)/,\n ) || [];\n\n return {\n packageName: matches[1] || '',\n version: matches[2] || '',\n hash: matches[3] || '',\n bundled: matches[4] === 'bundled',\n filePath: matches[5] || '',\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/api-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "An implementation of the API server that does interacts with a task scheduler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -28,20 +28,20 @@
|
|
|
28
28
|
"@lage-run/scheduler": "^1.1.9",
|
|
29
29
|
"@lage-run/target-graph": "^0.8.7",
|
|
30
30
|
"@lage-run/hasher": "^1.0.5",
|
|
31
|
-
"@ms-cloudpack/bundler": "^0.15.
|
|
32
|
-
"@ms-cloudpack/bundler-types": "^0.
|
|
33
|
-
"@ms-cloudpack/config": "^0.14.
|
|
31
|
+
"@ms-cloudpack/bundler": "^0.15.5",
|
|
32
|
+
"@ms-cloudpack/bundler-types": "^0.20.0",
|
|
33
|
+
"@ms-cloudpack/config": "^0.14.7",
|
|
34
34
|
"@ms-cloudpack/create-express-app": "^1.3.12",
|
|
35
35
|
"@ms-cloudpack/data-bus": "^0.4.1",
|
|
36
36
|
"@ms-cloudpack/file-watcher": "^0.1.1",
|
|
37
37
|
"@ms-cloudpack/json-utilities": "^0.0.8",
|
|
38
|
-
"@ms-cloudpack/package-hashes": "^0.0.
|
|
39
|
-
"@ms-cloudpack/package-utilities": "^5.
|
|
38
|
+
"@ms-cloudpack/package-hashes": "^0.0.3",
|
|
39
|
+
"@ms-cloudpack/package-utilities": "^5.3.1",
|
|
40
40
|
"@ms-cloudpack/path-string-parsing": "^1.1.1",
|
|
41
41
|
"@ms-cloudpack/path-utilities": "^2.3.5",
|
|
42
42
|
"@ms-cloudpack/task-reporter": "^0.10.0",
|
|
43
|
-
"@ms-cloudpack/telemetry": "^0.4.
|
|
44
|
-
"@ms-cloudpack/remote-cache": "^0.1.
|
|
43
|
+
"@ms-cloudpack/telemetry": "^0.4.3",
|
|
44
|
+
"@ms-cloudpack/remote-cache": "^0.1.15",
|
|
45
45
|
"@trpc/client": "^10.40.0",
|
|
46
46
|
"@trpc/server": "^10.40.0",
|
|
47
47
|
"cors": "^2.8.5",
|