@ms-cloudpack/cli 0.35.6 → 0.36.1
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/commands/start/createBundleRequestForPackage.d.ts +5 -0
- package/lib/commands/start/createBundleRequestForPackage.d.ts.map +1 -0
- package/lib/commands/start/createBundleRequestForPackage.js +16 -0
- package/lib/commands/start/createBundleRequestForPackage.js.map +1 -0
- package/lib/commands/start/getPackageEntry.d.ts +9 -0
- package/lib/commands/start/getPackageEntry.d.ts.map +1 -0
- package/lib/commands/start/getPackageEntry.js +17 -0
- package/lib/commands/start/getPackageEntry.js.map +1 -0
- package/lib/commands/start/start.d.ts.map +1 -1
- package/lib/commands/start/start.js +13 -0
- package/lib/commands/start/start.js.map +1 -1
- package/lib/commands/start/startBundleServer.d.ts +1 -1
- package/lib/commands/start/startBundleServer.d.ts.map +1 -1
- package/lib/commands/start/startBundleServer.js +28 -29
- package/lib/commands/start/startBundleServer.js.map +1 -1
- package/lib/tasks/bundleTask.d.ts.map +1 -1
- package/lib/tasks/bundleTask.js +11 -3
- package/lib/tasks/bundleTask.js.map +1 -1
- package/lib/types.d.ts +4 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Features } from '@ms-cloudpack/config';
|
|
2
|
+
import type { ResolveMapEntry } from '@ms-cloudpack/package-utilities';
|
|
3
|
+
import type { BundleRequest } from '../../types.js';
|
|
4
|
+
export declare function createBundleRequestForPackage(packageEntry: ResolveMapEntry, features?: Features): Promise<BundleRequest>;
|
|
5
|
+
//# sourceMappingURL=createBundleRequestForPackage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBundleRequestForPackage.d.ts","sourceRoot":"","sources":["../../../src/commands/start/createBundleRequestForPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,wBAAsB,6BAA6B,CACjD,YAAY,EAAE,eAAe,EAC7B,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAAC,aAAa,CAAC,CAcxB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getBundleDetails } from '../../common/getBundleDetails.js';
|
|
2
|
+
export async function createBundleRequestForPackage(packageEntry, features) {
|
|
3
|
+
const { path, version, name } = packageEntry;
|
|
4
|
+
const { bundleId, isExternal, outputPath } = await getBundleDetails(path);
|
|
5
|
+
return {
|
|
6
|
+
id: bundleId,
|
|
7
|
+
packagePath: path,
|
|
8
|
+
packageName: name,
|
|
9
|
+
isExternal,
|
|
10
|
+
outputPath,
|
|
11
|
+
version,
|
|
12
|
+
disableSourceMaps: features?.disableSourceMaps,
|
|
13
|
+
enableFindImports: features?.enqueueDependencies,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=createBundleRequestForPackage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBundleRequestForPackage.js","sourceRoot":"","sources":["../../../src/commands/start/createBundleRequestForPackage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,YAA6B,EAC7B,QAAmB;IAEnB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC;IAC7C,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE1E,OAAO;QACL,EAAE,EAAE,QAAQ;QACZ,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,IAAI;QACjB,UAAU;QACV,UAAU;QACV,OAAO;QACP,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB;QAC9C,iBAAiB,EAAE,QAAQ,EAAE,mBAAmB;KACjD,CAAC;AACJ,CAAC","sourcesContent":["import type { Features } from '@ms-cloudpack/config';\nimport type { ResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport { getBundleDetails } from '../../common/getBundleDetails.js';\nimport type { BundleRequest } from '../../types.js';\n\nexport async function createBundleRequestForPackage(\n packageEntry: ResolveMapEntry,\n features?: Features,\n): Promise<BundleRequest> {\n const { path, version, name } = packageEntry;\n const { bundleId, isExternal, outputPath } = await getBundleDetails(path);\n\n return {\n id: bundleId,\n packagePath: path,\n packageName: name,\n isExternal,\n outputPath,\n version,\n disableSourceMaps: features?.disableSourceMaps,\n enableFindImports: features?.enqueueDependencies,\n };\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResolveMap, ResolveMapEntry } from '@ms-cloudpack/package-utilities';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the package entry from the resolve map.
|
|
4
|
+
* If a version is specified, it will return the entry for that version if it exists.
|
|
5
|
+
* If a version is not specified, it will return the primary entry.
|
|
6
|
+
* If the package is not found, it will return undefined.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getPackageEntry(resolveMap: ResolveMap, packageName: string, version?: string): ResolveMapEntry | undefined;
|
|
9
|
+
//# sourceMappingURL=getPackageEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPackageEntry.d.ts","sourceRoot":"","sources":["../../../src/commands/start/getPackageEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEnF;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,eAAe,GAAG,SAAS,CAW7B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the package entry from the resolve map.
|
|
3
|
+
* If a version is specified, it will return the entry for that version if it exists.
|
|
4
|
+
* If a version is not specified, it will return the primary entry.
|
|
5
|
+
* If the package is not found, it will return undefined.
|
|
6
|
+
*/
|
|
7
|
+
export function getPackageEntry(resolveMap, packageName, version) {
|
|
8
|
+
const entry = resolveMap[packageName];
|
|
9
|
+
if (!entry) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
if (!version || version == entry.version) {
|
|
13
|
+
return entry;
|
|
14
|
+
}
|
|
15
|
+
return entry.scopedVersions?.[version];
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=getPackageEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPackageEntry.js","sourceRoot":"","sources":["../../../src/commands/start/getPackageEntry.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,UAAsB,EACtB,WAAmB,EACnB,OAAgB;IAEhB,MAAM,KAAK,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,CAAC,OAAO,IAAI,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE;QACxC,OAAO,KAAK,CAAC;KACd;IAED,OAAO,KAAK,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import type { ResolveMap, ResolveMapEntry } from '@ms-cloudpack/package-utilities';\n\n/**\n * Gets the package entry from the resolve map.\n * If a version is specified, it will return the entry for that version if it exists.\n * If a version is not specified, it will return the primary entry.\n * If the package is not found, it will return undefined.\n */\nexport function getPackageEntry(\n resolveMap: ResolveMap,\n packageName: string,\n version?: string,\n): ResolveMapEntry | undefined {\n const entry = resolveMap[packageName];\n if (!entry) {\n return undefined;\n }\n\n if (!version || version == entry.version) {\n return entry;\n }\n\n return entry.scopedVersions?.[version];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/commands/start/start.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/commands/start/start.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAmB/C;;GAEG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,iBAkGhD"}
|
|
@@ -11,6 +11,17 @@ import { reporter } from '../../reporter.js';
|
|
|
11
11
|
import { readConfig } from '@ms-cloudpack/config';
|
|
12
12
|
import { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';
|
|
13
13
|
import { setSharedTelemetryAttribute, stopTelemetry, rootSpan } from '../../initTelemetry.js';
|
|
14
|
+
import { getPackageEntry } from './getPackageEntry.js';
|
|
15
|
+
import { createBundleRequestForPackage } from './createBundleRequestForPackage.js';
|
|
16
|
+
import { createBundleTask } from './createBundleTask.js';
|
|
17
|
+
async function createAppBundleTask(session, packageName, features) {
|
|
18
|
+
const packageEntry = getPackageEntry(session.resolveMap, packageName);
|
|
19
|
+
if (!packageEntry) {
|
|
20
|
+
throw new Error(`Could not find package ${packageName} in the resolve map.`);
|
|
21
|
+
}
|
|
22
|
+
const bundleRequest = await createBundleRequestForPackage(packageEntry, features);
|
|
23
|
+
return createBundleTask(bundleRequest);
|
|
24
|
+
}
|
|
14
25
|
/**
|
|
15
26
|
* Defines the "start" verb entry point.
|
|
16
27
|
*/
|
|
@@ -39,6 +50,8 @@ export async function start(options) {
|
|
|
39
50
|
}
|
|
40
51
|
// Start api server for tracking status and handling remote requests.
|
|
41
52
|
const apiServer = await startApiServer({ session, config, rootSpan, reporter });
|
|
53
|
+
// Kick off bundling app package as soon as api server is ready.
|
|
54
|
+
void apiServer.addTask(await createAppBundleTask(session, definition.name, config.features));
|
|
42
55
|
// Then start bundle and app servers for hosting the app.
|
|
43
56
|
const bundleServer = await startBundleServer({ session, apiServer, config, useLage: options.unstableLage });
|
|
44
57
|
const appServer = await startAppServer({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/commands/start/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,8BAA8B,EAAE,MAAM,gDAAgD,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/commands/start/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,8BAA8B,EAAE,MAAM,gDAAgD,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAgB,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAA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;IAAC,OAAO,GAAG,EAAE;QACZ,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC","sourcesContent":["import { writeJson } from '@ms-cloudpack/json-utilities';\nimport { PackageDefinitions } from '@ms-cloudpack/package-utilities';\nimport path from 'path';\nimport { createPackageOverrideTransform } from '../../common/createPackageOverrideTransform.js';\nimport { startAppServer } from './appServer/startAppServer.js';\nimport { createSession } from './createSession.js';\nimport { openBrowser } from './openBrowser.js';\nimport { startApiServer, type Session } from '@ms-cloudpack/api-server';\nimport { startBundleServer } from './startBundleServer.js';\nimport type { StartOptions } from './types.js';\nimport { reporter } from '../../reporter.js';\nimport { readConfig, type Features } from '@ms-cloudpack/config';\nimport { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';\nimport { setSharedTelemetryAttribute, stopTelemetry, rootSpan } from '../../initTelemetry.js';\nimport { getPackageEntry } from './getPackageEntry.js';\nimport { createBundleRequestForPackage } from './createBundleRequestForPackage.js';\nimport { createBundleTask } from './createBundleTask.js';\n\nasync function createAppBundleTask(session: Session, packageName: string, features?: Features) {\n const packageEntry = getPackageEntry(session.resolveMap, packageName);\n if (!packageEntry) {\n throw new Error(`Could not find package ${packageName} in the resolve map.`);\n }\n const bundleRequest = await createBundleRequestForPackage(packageEntry, features);\n\n return createBundleTask(bundleRequest);\n}\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport async function start(options: StartOptions) {\n const appPath = process.cwd();\n\n try {\n // Parse config if it exists.\n const config = await readConfig(appPath);\n\n // Initialize package overrides.\n PackageDefinitions.getInstance().registerTransform(createPackageOverrideTransform(config));\n\n // Make sure the package has a valid definition.\n const definition = await PackageDefinitions.getInstance().get(appPath);\n\n if (!definition) {\n throw new Error(`There was no package.json located at \"${appPath}\".`);\n }\n\n if (!definition.name || !definition.version) {\n throw new Error(`The package.json at \"${appPath}\" did not have a name and/or version.`);\n }\n\n // Initialize session definition.\n const session = await createSession({ appPath, config });\n\n // Set shared telemetry attributes which will be sent with all telemetry events.\n setSharedTelemetryAttribute('sessionId', session.id);\n\n if (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n // Start api server for tracking status and handling remote requests.\n const apiServer = await startApiServer({ session, config, rootSpan, reporter });\n\n // Kick off bundling app package as soon as api server is ready.\n void apiServer.addTask(await createAppBundleTask(session, definition.name, config.features));\n\n // Then start bundle and app servers for hosting the app.\n const bundleServer = await startBundleServer({ session, apiServer, config, useLage: options.unstableLage });\n\n const appServer = await startAppServer({\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n });\n\n const cleanup = async () => {\n for (const [name, server] of [\n ['appServer', appServer] as const,\n ['apiServer', apiServer] as const,\n ['bundleServer', bundleServer] as const,\n ]) {\n console.info(`Closing ${name}: ${server.url}`);\n try {\n await server.close();\n } catch (err) {\n console.warn('Error closing server:', err);\n }\n }\n\n // Complete the reporting and list pending tasks as aborted.\n reporter.complete();\n\n // Flush and close telemetry.\n await stopTelemetry();\n };\n\n // Setup cleanup and close things on completion.\n let sigintCount = 0;\n\n process.on('SIGINT', () => {\n sigintCount++;\n if (sigintCount > 1) {\n console.debug('Forcing exit');\n process.exit(1);\n }\n\n cleanup().finally(() => {\n process.exit(0);\n });\n });\n\n // Open the browser.\n const url = appServer.url;\n\n performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);\n openBrowser(url).catch((err) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.warn('Error opening browser:', err?.stack || err);\n console.warn('Please open the browser manually to:', url);\n });\n } catch (err) {\n reporter.complete();\n process.exit(1);\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BundleServer } from '../../types.js';
|
|
2
1
|
import type { ApiServer, Session } from '@ms-cloudpack/api-server';
|
|
3
2
|
import type { CloudpackConfig } from '@ms-cloudpack/config';
|
|
3
|
+
import type { BundleServer } from '../../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* The bundle server handles package requests and returns bundled resources.
|
|
6
6
|
* Resources are bundled on demand and cached locally to avoid re-bundling
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startBundleServer.d.ts","sourceRoot":"","sources":["../../../src/commands/start/startBundleServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"startBundleServer.d.ts","sourceRoot":"","sources":["../../../src/commands/start/startBundleServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAM5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AASnD;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,SAAS,EACT,MAA8B,EAC9B,OAAe,GAChB,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;CAC9B,GAAG,OAAO,CAAC,YAAY,CAAC,CAqBxB"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { createExpressApp } from '@ms-cloudpack/create-express-app';
|
|
2
|
-
import {
|
|
2
|
+
import { isExternalPackage } from '@ms-cloudpack/package-utilities';
|
|
3
3
|
import { slash } from '@ms-cloudpack/path-string-parsing';
|
|
4
|
+
import { isFolder } from '@ms-cloudpack/path-utilities';
|
|
4
5
|
import path from 'path';
|
|
5
|
-
import {
|
|
6
|
+
import { createBundleRequestForPackage } from './createBundleRequestForPackage.js';
|
|
6
7
|
import { createBundleTask } from './createBundleTask.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
8
|
+
import { getPackageEntry } from './getPackageEntry.js';
|
|
9
|
+
import { parseRequestInfo } from './parseRequestInfo.js';
|
|
9
10
|
import { createRequire } from 'node:module';
|
|
10
11
|
const require = createRequire(import.meta.url);
|
|
11
12
|
/**
|
|
@@ -38,9 +39,9 @@ async function handleRequest(req, res, session, apiServer, useLage) {
|
|
|
38
39
|
const { resolveMap } = session;
|
|
39
40
|
const requestPath = slash(req.path.substring(1));
|
|
40
41
|
const { packageName, version, bundled, filePath } = parseRequestInfo(requestPath);
|
|
41
|
-
const packageEntry = resolveMap
|
|
42
|
-
const packagePath = version && packageEntry?.version === version ? packageEntry?.path : packageEntry?.scopedVersions?.[version]?.path;
|
|
42
|
+
const packageEntry = getPackageEntry(resolveMap, packageName, version);
|
|
43
43
|
const force = req.query.force !== undefined;
|
|
44
|
+
const features = session.config.features || {};
|
|
44
45
|
console.debug(`Request: "${packageName}@${version}${filePath}"`);
|
|
45
46
|
// If the package is missing, invalid arguments.
|
|
46
47
|
if (!requestPath || !packageName) {
|
|
@@ -50,17 +51,16 @@ async function handleRequest(req, res, session, apiServer, useLage) {
|
|
|
50
51
|
}
|
|
51
52
|
// If the version is missing, redirect to the primary version.
|
|
52
53
|
if (!version) {
|
|
53
|
-
|
|
54
|
-
if (!resolvedPackage) {
|
|
54
|
+
if (!packageEntry) {
|
|
55
55
|
console.debug(`Response (404): Unrecognized package "${packageName}"`);
|
|
56
56
|
res.status(404).send(`Unrecognized package "${packageName}".`);
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
-
res.redirect(`/${packageName}@${
|
|
59
|
+
res.redirect(`/${packageName}@${packageEntry.version}${filePath}`);
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
// If it's an unrecognized package, 404.
|
|
63
|
-
if (!
|
|
63
|
+
if (!packageEntry) {
|
|
64
64
|
console.debug(`Response (404): "${packageName}@${version}${filePath}"`);
|
|
65
65
|
res
|
|
66
66
|
.status(404)
|
|
@@ -69,32 +69,23 @@ async function handleRequest(req, res, session, apiServer, useLage) {
|
|
|
69
69
|
}
|
|
70
70
|
// If we are accessing a non-bundled asset, return the file directly.
|
|
71
71
|
if (!bundled) {
|
|
72
|
-
const fullPath = path.join(
|
|
73
|
-
if (fullPath.length <
|
|
72
|
+
const fullPath = path.join(packageEntry.path, filePath);
|
|
73
|
+
if (fullPath.length < packageEntry.path.length) {
|
|
74
74
|
console.debug(`Response (400): "${packageName}@${version}${filePath}"`);
|
|
75
75
|
res.status(400).send(`Invalid file path.`);
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
console.debug(`Unbundled response returning: "${packageName}@${version}${filePath}"`);
|
|
79
79
|
// If the package is external, set cache headers.
|
|
80
|
-
if (isExternalPackage(
|
|
80
|
+
if (isExternalPackage(packageEntry.path)) {
|
|
81
81
|
res.setHeader('Cache-Control', 'public, max-age=31536000');
|
|
82
82
|
}
|
|
83
|
-
res.sendFile(path.join(
|
|
83
|
+
res.sendFile(path.join(packageEntry.path, filePath));
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
|
-
const
|
|
86
|
+
const taskResult = await createBundleRequestForPackage(packageEntry, features);
|
|
87
87
|
// Set up for bundling.
|
|
88
|
-
const rerun = !(await isFolder(outputPath)) || force;
|
|
89
|
-
const taskResult = {
|
|
90
|
-
id: bundleId,
|
|
91
|
-
packageName,
|
|
92
|
-
version,
|
|
93
|
-
packagePath,
|
|
94
|
-
outputPath,
|
|
95
|
-
isExternal,
|
|
96
|
-
disableSourceMaps: session.config.features?.disableSourceMaps,
|
|
97
|
-
};
|
|
88
|
+
const rerun = !(await isFolder(taskResult.outputPath)) || force;
|
|
98
89
|
if (useLage) {
|
|
99
90
|
console.debug(`Trying to bundle "${packageName}@${version}" with lage task scheduler`);
|
|
100
91
|
try {
|
|
@@ -104,10 +95,10 @@ async function handleRequest(req, res, session, apiServer, useLage) {
|
|
|
104
95
|
}, { rerun });
|
|
105
96
|
console.debug(`Bundle returning: "${packageName}@${version}${filePath}"`);
|
|
106
97
|
// Try to return the result.
|
|
107
|
-
if (isExternal) {
|
|
98
|
+
if (taskResult.isExternal) {
|
|
108
99
|
res.setHeader('Cache-Control', 'public, max-age=31536000');
|
|
109
100
|
}
|
|
110
|
-
return res.sendFile(path.join(outputPath, filePath));
|
|
101
|
+
return res.sendFile(path.join(taskResult.outputPath, filePath));
|
|
111
102
|
}
|
|
112
103
|
catch (err) {
|
|
113
104
|
return res.status(500).type('json').send(taskResult);
|
|
@@ -121,12 +112,20 @@ async function handleRequest(req, res, session, apiServer, useLage) {
|
|
|
121
112
|
res.status(500).type('json').send(taskResult);
|
|
122
113
|
}
|
|
123
114
|
else {
|
|
115
|
+
if (features.enqueueDependencies && taskResult.result?.dependencies) {
|
|
116
|
+
// Enqueue all dependencies to be bundled.
|
|
117
|
+
for (const dependency of taskResult.result.dependencies) {
|
|
118
|
+
const dependencyBundleRequest = await createBundleRequestForPackage(resolveMap[dependency], features);
|
|
119
|
+
// No need to await, we don't want to wait until the bundle is completed.
|
|
120
|
+
void apiServer.addTask(createBundleTask(dependencyBundleRequest, { force }));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
124
123
|
console.debug(`Bundle returning: "${packageName}@${version}${filePath}"`);
|
|
125
124
|
// Try to return the result.
|
|
126
|
-
if (isExternal) {
|
|
125
|
+
if (taskResult.isExternal) {
|
|
127
126
|
res.setHeader('Cache-Control', 'public, max-age=31536000');
|
|
128
127
|
}
|
|
129
|
-
res.sendFile(path.join(outputPath, filePath));
|
|
128
|
+
res.sendFile(path.join(taskResult.outputPath, filePath));
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
//# sourceMappingURL=startBundleServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startBundleServer.js","sourceRoot":"","sources":["../../../src/commands/start/startBundleServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA6C,MAAM,kCAAkC,CAAC;AAC/G,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE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AU,GAAG,gBAAgB,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,MAAM,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAE/C,iDAAiD;IACjD,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE;QAChD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KAC/C;SAAM;QACL,OAAO,CAAC,KAAK,CAAC,sBAAsB,WAAW,IAAI,OAAO,GAAG,QAAQ,GAAG,CAAC,CAAC;QAC1E,4BAA4B;QAC5B,IAAI,UAAU,EAAE;YACd,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,0BAA0B,CAAC,CAAC;SAC5D;QAED,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;KAC/C;AACH,CAAC","sourcesContent":["import { createExpressApp, type Express, type Request, type Response } from '@ms-cloudpack/create-express-app';\nimport { isFolder } from '@ms-cloudpack/path-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport path from 'path';\nimport { parseRequestInfo } from './parseRequestInfo.js';\nimport { createBundleTask } from './createBundleTask.js';\nimport type { BundleRequest, BundleServer } from '../../types.js';\nimport { getBundleDetails } from '../../common/getBundleDetails.js';\nimport { isExternalPackage } from '@ms-cloudpack/package-utilities';\nimport type { ApiServer, Session } from '@ms-cloudpack/api-server';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\n\nimport { createRequire } from 'node:module';\nconst require = createRequire(import.meta.url);\n\n/**\n * The bundle server handles package requests and returns bundled resources.\n * Resources are bundled on demand and cached locally to avoid re-bundling\n * on each request.\n */\nexport async function startBundleServer({\n session,\n apiServer,\n config = {} as CloudpackConfig,\n useLage = false,\n}: {\n session: Session;\n apiServer: ApiServer;\n config: CloudpackConfig;\n useLage: boolean | undefined;\n}): Promise<BundleServer> {\n const { port, close, url } = await createExpressApp({\n portRange: [5500, 5501, 5502, 5503],\n hostname: config.devServer?.domain,\n sslOptions: config.devServer?.https,\n setupCallback: (app: Express) => {\n // Set up the express app routes.\n app.get('*', (req, res) => {\n handleRequest(req, res, session, apiServer, useLage).catch((err) => {\n console.error((err as Error)?.stack || err);\n res.status(500).send(`Error bundling: ${err}`);\n });\n });\n },\n });\n\n return {\n close,\n port,\n url,\n };\n}\n\nasync function handleRequest(req: Request, res: Response, session: Session, apiServer: ApiServer, useLage: boolean) {\n const { resolveMap } = session;\n const requestPath = slash(req.path.substring(1));\n const { packageName, version, bundled, filePath } = parseRequestInfo(requestPath);\n const packageEntry = resolveMap[packageName];\n const packagePath =\n version && packageEntry?.version === version ? packageEntry?.path : packageEntry?.scopedVersions?.[version]?.path;\n const force = req.query.force !== undefined;\n\n console.debug(`Request: \"${packageName}@${version}${filePath}\"`);\n\n // If the package is missing, invalid arguments.\n if (!requestPath || !packageName) {\n console.debug(`Response (400): \"${packageName}@${version}${filePath}\"`);\n\n res.status(400).send(`Requests must be in the format \"/{packageName}@{version}/{type}/path/file.ext\".`);\n return;\n }\n\n // If the version is missing, redirect to the primary version.\n if (!version) {\n const resolvedPackage = resolveMap[packageName];\n\n if (!resolvedPackage) {\n console.debug(`Response (404): Unrecognized package \"${packageName}\"`);\n\n res.status(404).send(`Unrecognized package \"${packageName}\".`);\n return;\n }\n\n res.redirect(`/${packageName}@${resolvedPackage.version}${filePath}`);\n return;\n }\n\n // If it's an unrecognized package, 404.\n if (!packagePath) {\n console.debug(`Response (404): \"${packageName}@${version}${filePath}\"`);\n\n res\n .status(404)\n .send(`The requested package \"${packageName}@${version}${filePath}\" was not found in the resolve map.`);\n\n return;\n }\n\n // If we are accessing a non-bundled asset, return the file directly.\n if (!bundled) {\n const fullPath = path.join(packagePath, filePath);\n\n if (fullPath.length < packagePath.length) {\n console.debug(`Response (400): \"${packageName}@${version}${filePath}\"`);\n\n res.status(400).send(`Invalid file path.`);\n return;\n }\n\n console.debug(`Unbundled response returning: \"${packageName}@${version}${filePath}\"`);\n // If the package is external, set cache headers.\n if (isExternalPackage(packagePath)) {\n res.setHeader('Cache-Control', 'public, max-age=31536000');\n }\n\n res.sendFile(path.join(packagePath, filePath));\n return;\n }\n\n const { isExternal, bundleId, outputPath } = await getBundleDetails(packagePath);\n\n // Set up for bundling.\n const rerun = !(await isFolder(outputPath)) || force;\n const taskResult: BundleRequest = {\n id: bundleId,\n packageName,\n version,\n packagePath,\n outputPath,\n isExternal,\n disableSourceMaps: session.config.features?.disableSourceMaps,\n };\n\n if (useLage) {\n console.debug(`Trying to bundle \"${packageName}@${version}\" with lage task scheduler`);\n\n try {\n await apiServer.scheduleTask(\n taskResult,\n {\n // TODO: we may want to have away to let users add more types of tasks here\n bundle: require.resolve('../../tasks/bundleTaskWorker.js'),\n },\n { rerun },\n );\n\n console.debug(`Bundle returning: \"${packageName}@${version}${filePath}\"`);\n // Try to return the result.\n if (isExternal) {\n res.setHeader('Cache-Control', 'public, max-age=31536000');\n }\n\n return res.sendFile(path.join(outputPath, filePath));\n } catch (err) {\n return res.status(500).type('json').send(taskResult);\n }\n }\n\n console.debug(`Trying to bundle \"${packageName}@${version}\"`);\n\n const bundleTask = createBundleTask(taskResult, { force });\n await apiServer.addTask(bundleTask, { rerun });\n\n // At this point we should have a Task completed.\n if ((taskResult.result?.errors?.length || 0) > 0) {\n res.status(500).type('json').send(taskResult);\n } else {\n console.debug(`Bundle returning: \"${packageName}@${version}${filePath}\"`);\n // Try to return the result.\n if (isExternal) {\n res.setHeader('Cache-Control', 'public, max-age=31536000');\n }\n\n res.sendFile(path.join(outputPath, filePath));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"startBundleServer.js","sourceRoot":"","sources":["../../../src/commands/start/startBundleServer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,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C,OAAO,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAE/C,iDAAiD;IACjD,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE;QAChD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KAC/C;SAAM;QACL,IAAI,QAAQ,CAAC,mBAAmB,IAAI,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE;YACnE,0CAA0C;YAC1C,KAAK,MAAM,UAAU,IAAI,UAAU,CAAC,MAAM,CAAC,YAAY,EAAE;gBACvD,MAAM,uBAAuB,GAAG,MAAM,6BAA6B,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAC;gBAEtG,yEAAyE;gBACzE,KAAK,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;aAC9E;SACF;QAED,OAAO,CAAC,KAAK,CAAC,sBAAsB,WAAW,IAAI,OAAO,GAAG,QAAQ,GAAG,CAAC,CAAC;QAC1E,4BAA4B;QAC5B,IAAI,UAAU,CAAC,UAAU,EAAE;YACzB,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,0BAA0B,CAAC,CAAC;SAC5D;QAED,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;KAC1D;AACH,CAAC","sourcesContent":["import type { ApiServer, Session } from '@ms-cloudpack/api-server';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\nimport { createExpressApp, type Express, type Request, type Response } from '@ms-cloudpack/create-express-app';\nimport { isExternalPackage } from '@ms-cloudpack/package-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport { isFolder } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport type { BundleServer } from '../../types.js';\nimport { createBundleRequestForPackage } from './createBundleRequestForPackage.js';\nimport { createBundleTask } from './createBundleTask.js';\nimport { getPackageEntry } from './getPackageEntry.js';\nimport { parseRequestInfo } from './parseRequestInfo.js';\n\nimport { createRequire } from 'node:module';\nconst require = createRequire(import.meta.url);\n\n/**\n * The bundle server handles package requests and returns bundled resources.\n * Resources are bundled on demand and cached locally to avoid re-bundling\n * on each request.\n */\nexport async function startBundleServer({\n session,\n apiServer,\n config = {} as CloudpackConfig,\n useLage = false,\n}: {\n session: Session;\n apiServer: ApiServer;\n config: CloudpackConfig;\n useLage: boolean | undefined;\n}): Promise<BundleServer> {\n const { port, close, url } = await createExpressApp({\n portRange: [5500, 5501, 5502, 5503],\n hostname: config.devServer?.domain,\n sslOptions: config.devServer?.https,\n setupCallback: (app: Express) => {\n // Set up the express app routes.\n app.get('*', (req, res) => {\n handleRequest(req, res, session, apiServer, useLage).catch((err) => {\n console.error((err as Error)?.stack || err);\n res.status(500).send(`Error bundling: ${err}`);\n });\n });\n },\n });\n\n return {\n close,\n port,\n url,\n };\n}\n\nasync function handleRequest(req: Request, res: Response, session: Session, apiServer: ApiServer, useLage: boolean) {\n const { resolveMap } = session;\n const requestPath = slash(req.path.substring(1));\n const { packageName, version, bundled, filePath } = parseRequestInfo(requestPath);\n const packageEntry = getPackageEntry(resolveMap, packageName, version);\n\n const force = req.query.force !== undefined;\n const features = session.config.features || {};\n\n console.debug(`Request: \"${packageName}@${version}${filePath}\"`);\n\n // If the package is missing, invalid arguments.\n if (!requestPath || !packageName) {\n console.debug(`Response (400): \"${packageName}@${version}${filePath}\"`);\n\n res.status(400).send(`Requests must be in the format \"/{packageName}@{version}/{type}/path/file.ext\".`);\n return;\n }\n\n // If the version is missing, redirect to the primary version.\n if (!version) {\n if (!packageEntry) {\n console.debug(`Response (404): Unrecognized package \"${packageName}\"`);\n\n res.status(404).send(`Unrecognized package \"${packageName}\".`);\n return;\n }\n\n res.redirect(`/${packageName}@${packageEntry.version}${filePath}`);\n return;\n }\n\n // If it's an unrecognized package, 404.\n if (!packageEntry) {\n console.debug(`Response (404): \"${packageName}@${version}${filePath}\"`);\n\n res\n .status(404)\n .send(`The requested package \"${packageName}@${version}${filePath}\" was not found in the resolve map.`);\n\n return;\n }\n\n // If we are accessing a non-bundled asset, return the file directly.\n if (!bundled) {\n const fullPath = path.join(packageEntry.path, filePath);\n\n if (fullPath.length < packageEntry.path.length) {\n console.debug(`Response (400): \"${packageName}@${version}${filePath}\"`);\n\n res.status(400).send(`Invalid file path.`);\n return;\n }\n\n console.debug(`Unbundled response returning: \"${packageName}@${version}${filePath}\"`);\n // If the package is external, set cache headers.\n if (isExternalPackage(packageEntry.path)) {\n res.setHeader('Cache-Control', 'public, max-age=31536000');\n }\n\n res.sendFile(path.join(packageEntry.path, filePath));\n return;\n }\n\n const taskResult = await createBundleRequestForPackage(packageEntry, features);\n\n // Set up for bundling.\n const rerun = !(await isFolder(taskResult.outputPath)) || force;\n\n if (useLage) {\n console.debug(`Trying to bundle \"${packageName}@${version}\" with lage task scheduler`);\n\n try {\n await apiServer.scheduleTask(\n taskResult,\n {\n // TODO: we may want to have away to let users add more types of tasks here\n bundle: require.resolve('../../tasks/bundleTaskWorker.js'),\n },\n { rerun },\n );\n\n console.debug(`Bundle returning: \"${packageName}@${version}${filePath}\"`);\n // Try to return the result.\n if (taskResult.isExternal) {\n res.setHeader('Cache-Control', 'public, max-age=31536000');\n }\n\n return res.sendFile(path.join(taskResult.outputPath, filePath));\n } catch (err) {\n return res.status(500).type('json').send(taskResult);\n }\n }\n\n console.debug(`Trying to bundle \"${packageName}@${version}\"`);\n\n const bundleTask = createBundleTask(taskResult, { force });\n await apiServer.addTask(bundleTask, { rerun });\n\n // At this point we should have a Task completed.\n if ((taskResult.result?.errors?.length || 0) > 0) {\n res.status(500).type('json').send(taskResult);\n } else {\n if (features.enqueueDependencies && taskResult.result?.dependencies) {\n // Enqueue all dependencies to be bundled.\n for (const dependency of taskResult.result.dependencies) {\n const dependencyBundleRequest = await createBundleRequestForPackage(resolveMap[dependency], features);\n\n // No need to await, we don't want to wait until the bundle is completed.\n void apiServer.addTask(createBundleTask(dependencyBundleRequest, { force }));\n }\n }\n\n console.debug(`Bundle returning: \"${packageName}@${version}${filePath}\"`);\n // Try to return the result.\n if (taskResult.isExternal) {\n res.setHeader('Cache-Control', 'public, max-age=31536000');\n }\n\n res.sendFile(path.join(taskResult.outputPath, filePath));\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleTask.d.ts","sourceRoot":"","sources":["../../src/tasks/bundleTask.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundleTask.d.ts","sourceRoot":"","sources":["../../src/tasks/bundleTask.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAKpE,wBAAsB,UAAU,CAAC,EAC/B,aAAa,EACb,OAAY,GACb,EAAE;IACD,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B,0BAwDA"}
|
package/lib/tasks/bundleTask.js
CHANGED
|
@@ -7,6 +7,7 @@ import { prepareOutputPath } from '../common/prepareOutputPath.js';
|
|
|
7
7
|
import { reporter } from '../reporter.js';
|
|
8
8
|
import { getFileSizeSync } from './getFileSizeSync.js';
|
|
9
9
|
import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';
|
|
10
|
+
import { findImports } from '../commands/init/findImports.js';
|
|
10
11
|
export async function bundleTask({ bundleRequest, options = {}, }) {
|
|
11
12
|
const { packageName, version } = bundleRequest;
|
|
12
13
|
const { force } = options || {};
|
|
@@ -53,12 +54,13 @@ export async function bundleTask({ bundleRequest, options = {}, }) {
|
|
|
53
54
|
return bundleRequest;
|
|
54
55
|
}
|
|
55
56
|
async function bundle(bundleRequest, force) {
|
|
56
|
-
const { packagePath, outputPath, isExternal, disableSourceMaps } = bundleRequest;
|
|
57
|
+
const { packagePath, outputPath, isExternal, disableSourceMaps, enableFindImports } = bundleRequest;
|
|
57
58
|
// Rehydrate the result if not incremental.
|
|
58
59
|
if (isExternal && !force) {
|
|
59
|
-
bundleRequest.result =
|
|
60
|
+
bundleRequest.result = await readJson(path.join(outputPath, 'result.json'));
|
|
60
61
|
}
|
|
61
|
-
if
|
|
62
|
+
// Dependencies are undefined if the older version of bundleTask was used to bundle the package. In this case, we need to bundle it again with the new version to have dependencies defined in the result.json.
|
|
63
|
+
if (bundleRequest.result?.errors?.length === 0 && !!bundleRequest.result?.dependencies) {
|
|
62
64
|
bundleRequest.resultFromCache = true;
|
|
63
65
|
}
|
|
64
66
|
else {
|
|
@@ -72,6 +74,12 @@ async function bundle(bundleRequest, force) {
|
|
|
72
74
|
packages: bundleRequest.packages,
|
|
73
75
|
sourcemap: disableSourceMaps ? undefined : 'linked',
|
|
74
76
|
});
|
|
77
|
+
if (enableFindImports) {
|
|
78
|
+
// Find imports that are in the output files and set dependencies.
|
|
79
|
+
const outputFilePaths = bundleRequest.result.outputFiles?.map((f) => f.outputPath);
|
|
80
|
+
const imports = outputFilePaths && (await findImports(outputFilePaths));
|
|
81
|
+
bundleRequest.result.dependencies = imports && Object.keys(imports);
|
|
82
|
+
}
|
|
75
83
|
// Write the result to disk.
|
|
76
84
|
if (isExternal) {
|
|
77
85
|
bundleRequest.result.rawInput = bundleRequest.result.rawOutput = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/tasks/bundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/tasks/bundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,Y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AAU,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,EAAE;YACd,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 { bundlePackage } from '@ms-cloudpack/bundler';\nimport { bulletedList, formatPackageName, type TaskReporterTaskResult } from '@ms-cloudpack/task-reporter';\nimport { readJson, writeJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\nimport { formatBundleErrors } from './formatBundleErrors.js';\nimport { prepareOutputPath } from '../common/prepareOutputPath.js';\nimport { reporter } from '../reporter.js';\nimport type { BundleRequest, BundleTaskOptions } from '../types.js';\nimport { getFileSizeSync } from './getFileSizeSync.js';\nimport { safeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { findImports } from '../commands/init/findImports.js';\n\nexport async function bundleTask({\n bundleRequest,\n options = {},\n}: {\n bundleRequest: BundleRequest;\n options?: BundleTaskOptions;\n}) {\n const { packageName, version } = bundleRequest;\n const { force } = options || {};\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 { rebuild } = bundleRequest?.result || {};\n const taskName = `${rebuild ? `Re-bundle` : `Bundle`} ${formatPackageName({ name: packageName, version })}`;\n\n await reporter.runTask(taskName, 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 return bundleRequest;\n}\n\nasync function bundle(bundleRequest: BundleRequest, force?: boolean): Promise<BundleRequest> {\n const { packagePath, outputPath, isExternal, disableSourceMaps, enableFindImports } = bundleRequest;\n\n // Rehydrate the result if not incremental.\n if (isExternal && !force) {\n bundleRequest.result = await readJson(path.join(outputPath, 'result.json'));\n }\n\n // Dependencies are undefined if the older version of bundleTask was used to bundle the package. In this case, we need to bundle it again with the new version to have dependencies defined in the result.json.\n if (bundleRequest.result?.errors?.length === 0 && !!bundleRequest.result?.dependencies) {\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 bundlePackage({\n inputPath: packagePath,\n outputPath,\n incremental: !isExternal,\n packages: bundleRequest.packages,\n sourcemap: disableSourceMaps ? undefined : 'linked',\n });\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) {\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"]}
|
package/lib/types.d.ts
CHANGED
|
@@ -13,10 +13,13 @@ export interface BundleRequest {
|
|
|
13
13
|
outputPath: string;
|
|
14
14
|
isExternal: boolean;
|
|
15
15
|
bundlerType?: string;
|
|
16
|
-
result?: BundleResult
|
|
16
|
+
result?: BundleResult & {
|
|
17
|
+
dependencies?: string[];
|
|
18
|
+
};
|
|
17
19
|
resultFromCache?: boolean;
|
|
18
20
|
isRebuildRequired?: boolean;
|
|
19
21
|
disableSourceMaps?: boolean;
|
|
22
|
+
enableFindImports?: boolean;
|
|
20
23
|
packages?: PackageDefinitionsCache;
|
|
21
24
|
}
|
|
22
25
|
export interface BundleTaskOptions {
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD;;GAEG;AACH,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;I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AAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,WAAW,CAAC;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN;IACE,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;AAE9G;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAAC"}
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ImportMap } from '@ms-cloudpack/package-utilities';\nimport type { BundleResult, PackageJson, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { Route } from '@ms-cloudpack/config';\nimport type { Session } from '@ms-cloudpack/api-server';\n\n/**\n * Tracks a given bundle request and its result.\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;\n resultFromCache?: boolean;\n isRebuildRequired?: boolean;\n disableSourceMaps?: boolean;\n packages?: PackageDefinitionsCache;\n}\n\nexport interface BundleTaskOptions {\n force?: boolean;\n}\n\nexport interface BundleServer {\n url: string;\n port: number;\n close: () => Promise<void>;\n}\n\nexport interface Watcher {\n watch: (bundleRequest: BundleRequest) => void;\n}\n\n/**\n * The input options for a createHtml custom server render function.\n */\nexport type CreateHtmlOptions = {\n session: Session;\n route: Route;\n baseUrl: string;\n definition: PackageJson;\n importMap: ImportMap;\n overlayScript: string | undefined;\n entryScript: string | undefined;\n inlineScripts: string[];\n};\n\n/**\n * The expected result of the createHtml custom server render function.\n */\nexport type CreateHtmlResult =\n | string\n | {\n html: string;\n statusCode: number;\n };\n\n/**\n * A custom server render function that can be used to override the default HTML response.\n */\nexport type CreateHtmlFunction = (options: CreateHtmlOptions) => Promise<CreateHtmlResult> | CreateHtmlResult;\n\n/**\n * The expected shape of the createHtml custom server render function script.\n */\nexport type CreateHtmlScript = { default: CreateHtmlFunction };\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ImportMap } from '@ms-cloudpack/package-utilities';\nimport type { BundleResult, PackageJson, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { Route } from '@ms-cloudpack/config';\nimport type { Session } from '@ms-cloudpack/api-server';\n\n/**\n * Tracks a given bundle request and its result.\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[] };\n resultFromCache?: boolean;\n isRebuildRequired?: boolean;\n disableSourceMaps?: boolean;\n enableFindImports?: boolean;\n packages?: PackageDefinitionsCache;\n}\n\nexport interface BundleTaskOptions {\n force?: boolean;\n}\n\nexport interface BundleServer {\n url: string;\n port: number;\n close: () => Promise<void>;\n}\n\nexport interface Watcher {\n watch: (bundleRequest: BundleRequest) => void;\n}\n\n/**\n * The input options for a createHtml custom server render function.\n */\nexport type CreateHtmlOptions = {\n session: Session;\n route: Route;\n baseUrl: string;\n definition: PackageJson;\n importMap: ImportMap;\n overlayScript: string | undefined;\n entryScript: string | undefined;\n inlineScripts: string[];\n};\n\n/**\n * The expected result of the createHtml custom server render function.\n */\nexport type CreateHtmlResult =\n | string\n | {\n html: string;\n statusCode: number;\n };\n\n/**\n * A custom server render function that can be used to override the default HTML response.\n */\nexport type CreateHtmlFunction = (options: CreateHtmlOptions) => Promise<CreateHtmlResult> | CreateHtmlResult;\n\n/**\n * The expected shape of the createHtml custom server render function script.\n */\nexport type CreateHtmlScript = { default: CreateHtmlFunction };\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.1",
|
|
4
4
|
"description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"cloudpack": "./bin/cloudpack.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@ms-cloudpack/api-server": "^0.5.
|
|
19
|
+
"@ms-cloudpack/api-server": "^0.5.7",
|
|
20
20
|
"@ms-cloudpack/bundler": "^0.11.29",
|
|
21
|
-
"@ms-cloudpack/config": "^0.5.
|
|
21
|
+
"@ms-cloudpack/config": "^0.5.3",
|
|
22
22
|
"@ms-cloudpack/create-express-app": "^1.3.3",
|
|
23
23
|
"@ms-cloudpack/data-bus": "^0.1.1",
|
|
24
24
|
"@ms-cloudpack/json-utilities": "^0.0.6",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@ms-cloudpack/package-utilities": "^2.4.3",
|
|
27
27
|
"@ms-cloudpack/path-utilities": "^2.2.1",
|
|
28
28
|
"@ms-cloudpack/path-string-parsing": "^1.0.1",
|
|
29
|
-
"@ms-cloudpack/task-reporter": "^0.3.
|
|
29
|
+
"@ms-cloudpack/task-reporter": "^0.3.1",
|
|
30
30
|
"@ms-cloudpack/telemetry": "^0.3.0",
|
|
31
31
|
"chokidar": "^3.5.3",
|
|
32
32
|
"commander": "^10.0.0",
|