@ms-cloudpack/app-server 0.18.17 → 0.19.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/renderRoute/renderCustomScript.d.ts.map +1 -1
- package/lib/renderRoute/renderCustomScript.js +28 -2
- package/lib/renderRoute/renderCustomScript.js.map +1 -1
- package/lib/renderRoute/ssr/importMapLoader.d.ts +13 -0
- package/lib/renderRoute/ssr/importMapLoader.d.ts.map +1 -0
- package/lib/renderRoute/ssr/importMapLoader.js +37 -0
- package/lib/renderRoute/ssr/importMapLoader.js.map +1 -0
- package/lib/renderRoute/ssr/runServerEntry.d.ts +4 -0
- package/lib/renderRoute/ssr/runServerEntry.d.ts.map +1 -0
- package/lib/renderRoute/ssr/runServerEntry.js +30 -0
- package/lib/renderRoute/ssr/runServerEntry.js.map +1 -0
- package/lib/renderRoute/ssr/runServerEntryInWorker.d.ts +10 -0
- package/lib/renderRoute/ssr/runServerEntryInWorker.d.ts.map +1 -0
- package/lib/renderRoute/ssr/runServerEntryInWorker.js +54 -0
- package/lib/renderRoute/ssr/runServerEntryInWorker.js.map +1 -0
- package/lib/renderRoute/ssr/types/RunServerEntryOptions.d.ts +9 -0
- package/lib/renderRoute/ssr/types/RunServerEntryOptions.d.ts.map +1 -0
- package/lib/renderRoute/ssr/types/RunServerEntryOptions.js +2 -0
- package/lib/renderRoute/ssr/types/RunServerEntryOptions.js.map +1 -0
- package/lib/renderRoute/ssr/types/RunServerEntryResult.d.ts +8 -0
- package/lib/renderRoute/ssr/types/RunServerEntryResult.d.ts.map +1 -0
- package/lib/renderRoute/ssr/types/RunServerEntryResult.js +2 -0
- package/lib/renderRoute/ssr/types/RunServerEntryResult.js.map +1 -0
- package/lib/renderRoute/ssr/worker/workerEntry.d.ts +2 -0
- package/lib/renderRoute/ssr/worker/workerEntry.d.ts.map +1 -0
- package/lib/renderRoute/ssr/worker/workerEntry.js +26 -0
- package/lib/renderRoute/ssr/worker/workerEntry.js.map +1 -0
- package/package.json +10 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderCustomScript.d.ts","sourceRoot":"","sources":["../../src/renderRoute/renderCustomScript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"renderCustomScript.d.ts","sourceRoot":"","sources":["../../src/renderRoute/renderCustomScript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,qBAAqB,EACrB,oBAAoB,EAErB,MAAM,4BAA4B,CAAC;AAOpC;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,qBAAqB,GAAG;IAAE,gBAAgB,EAAE,MAAM,CAAA;CAAE,GAC3D,OAAO,CAAC,oBAAoB,CAAC,CAoD/B"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { pathToFileURL } from 'url';
|
|
1
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
2
2
|
import { getHtmlErrorResponse } from './getHtmlErrorResponse.js';
|
|
3
3
|
import fsPromises from 'fs/promises';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { runServerEntryInWorker } from './ssr/runServerEntryInWorker.js';
|
|
4
6
|
/**
|
|
5
7
|
* Load the default export from a JS file passed as the `renderScript` in a route,
|
|
6
8
|
* and return either the result of running the function, or an error page if something fails.
|
|
@@ -21,11 +23,16 @@ export async function renderCustomScript(params) {
|
|
|
21
23
|
catch {
|
|
22
24
|
/* no-op */
|
|
23
25
|
}
|
|
26
|
+
const renderScriptUrlWithCacheBreaker = renderScriptUrl + cacheBreakerQueryParam;
|
|
27
|
+
const { config } = options.session;
|
|
28
|
+
if (config.features?.enableSSR) {
|
|
29
|
+
return executeRenderScriptInSsrMode(renderScriptPath, renderScriptUrlWithCacheBreaker, options.importMap);
|
|
30
|
+
}
|
|
24
31
|
// Try importing the script
|
|
25
32
|
let createHtml;
|
|
26
33
|
let errorMessage;
|
|
27
34
|
try {
|
|
28
|
-
const importResult = (await import(
|
|
35
|
+
const importResult = (await import(renderScriptUrlWithCacheBreaker)).default;
|
|
29
36
|
if (typeof importResult === 'function') {
|
|
30
37
|
createHtml = importResult;
|
|
31
38
|
}
|
|
@@ -51,4 +58,23 @@ export async function renderCustomScript(params) {
|
|
|
51
58
|
console.error(errorMessage);
|
|
52
59
|
return getHtmlErrorResponse(errorMessage);
|
|
53
60
|
}
|
|
61
|
+
async function executeRenderScriptInSsrMode(renderScriptPath, renderScriptUrl, importMap) {
|
|
62
|
+
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
63
|
+
// Tests run the worker from the compiled version, so we need to replace /src/ with /lib/ in the path.
|
|
64
|
+
// This replace call has no effect in production, where the worker is always run from the compiled version.
|
|
65
|
+
const loaderPath = path.join(dirname, 'ssr/importMapLoader.js').replace(/\/src\//, '/lib/');
|
|
66
|
+
const serverEntryResult = await runServerEntryInWorker({
|
|
67
|
+
loaderPath,
|
|
68
|
+
renderScriptUrl,
|
|
69
|
+
importMap,
|
|
70
|
+
renderParams: {},
|
|
71
|
+
});
|
|
72
|
+
const { errors, renderedContent } = serverEntryResult;
|
|
73
|
+
if (errors?.length) {
|
|
74
|
+
const errorMessage = errors.map((e) => e.text).join('\n');
|
|
75
|
+
console.error(`Error running render script at "${renderScriptPath}":\n${errorMessage}`);
|
|
76
|
+
return getHtmlErrorResponse(errorMessage);
|
|
77
|
+
}
|
|
78
|
+
return { content: renderedContent, contentType: 'text/html', statusCode: 200 };
|
|
79
|
+
}
|
|
54
80
|
//# sourceMappingURL=renderCustomScript.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderCustomScript.js","sourceRoot":"","sources":["../../src/renderRoute/renderCustomScript.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderCustomScript.js","sourceRoot":"","sources":["../../src/renderRoute/renderCustomScript.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACnD,OAA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E,CAAC;QACnB,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1D,OAAO,CAAC,KAAK,CAAC,mCAAmC,gBAAgB,OAAO,YAAY,EAAE,CAAC,CAAC;QACxF,OAAO,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;AACjF,CAAC","sourcesContent":["import type {\n ExpandedRenderFunctionResult,\n ImportMap,\n RenderFunction,\n RenderFunctionOptions,\n RenderFunctionResult,\n RenderFunctionScript,\n} from '@ms-cloudpack/common-types';\nimport { fileURLToPath, pathToFileURL } from 'url';\nimport { getHtmlErrorResponse } from './getHtmlErrorResponse.js';\nimport fsPromises from 'fs/promises';\nimport path from 'path';\nimport { runServerEntryInWorker } from './ssr/runServerEntryInWorker.js';\n\n/**\n * Load the default export from a JS file passed as the `renderScript` in a route,\n * and return either the result of running the function, or an error page if something fails.\n */\nexport async function renderCustomScript(\n params: RenderFunctionOptions & { renderScriptPath: string },\n): Promise<RenderFunctionResult> {\n const { renderScriptPath, ...options } = params;\n // Get the html factory function from a script default export.\n const renderScriptUrl = pathToFileURL(renderScriptPath).toString();\n\n // Note: because there isn't a way to purge the require cache, we need to add a cache breaker query param to the\n // script path to ensure we get the latest version of the script. This could be improved by using the git hash of\n // the file if it exists, or a hash of the content, or even the timestamp of the file.\n // TODO: this won't work to update anything the file imports, and doesn't seem to work for serverEntry at all...\n let cacheBreakerQueryParam = `?t=${Date.now()}`;\n try {\n const { mtime } = await fsPromises.stat(renderScriptPath);\n cacheBreakerQueryParam = `?t=${mtime.getTime()}`;\n } catch {\n /* no-op */\n }\n\n const renderScriptUrlWithCacheBreaker = renderScriptUrl + cacheBreakerQueryParam;\n\n const { config } = options.session;\n if (config.features?.enableSSR) {\n return executeRenderScriptInSsrMode(renderScriptPath, renderScriptUrlWithCacheBreaker, options.importMap);\n }\n\n // Try importing the script\n let createHtml: RenderFunction | undefined;\n let errorMessage: string | undefined;\n try {\n const importResult = ((await import(renderScriptUrlWithCacheBreaker)) as RenderFunctionScript).default;\n if (typeof importResult === 'function') {\n createHtml = importResult;\n } else {\n errorMessage = `The render script at \"${renderScriptPath}\" does not export a default function.`;\n }\n } catch (e) {\n errorMessage = `Error importing render script at \"${renderScriptUrl}\":\\n${(e as Error).stack || e}`;\n }\n\n if (createHtml) {\n // Try running the script\n try {\n return await createHtml(options);\n } catch (e) {\n errorMessage = `Error running render script at \"${renderScriptPath}\":\\n${(e as Error).stack || e}`;\n }\n }\n\n // Return an error page. Doing this instead of returning a default or empty response ensures that\n // the user is aware of any configuration issues.\n errorMessage ??= `Unknown error loading render script at \"${renderScriptPath}\".`;\n console.error(errorMessage);\n return getHtmlErrorResponse(errorMessage);\n}\n\nasync function executeRenderScriptInSsrMode(\n renderScriptPath: string,\n renderScriptUrl: string,\n importMap: ImportMap,\n): Promise<ExpandedRenderFunctionResult> {\n const dirname = path.dirname(fileURLToPath(import.meta.url));\n // Tests run the worker from the compiled version, so we need to replace /src/ with /lib/ in the path.\n // This replace call has no effect in production, where the worker is always run from the compiled version.\n const loaderPath = path.join(dirname, 'ssr/importMapLoader.js').replace(/\\/src\\//, '/lib/');\n\n const serverEntryResult = await runServerEntryInWorker({\n loaderPath,\n renderScriptUrl,\n importMap,\n renderParams: {},\n });\n\n const { errors, renderedContent } = serverEntryResult;\n if (errors?.length) {\n const errorMessage = errors.map((e) => e.text).join('\\n');\n console.error(`Error running render script at \"${renderScriptPath}\":\\n${errorMessage}`);\n return getHtmlErrorResponse(errorMessage);\n }\n return { content: renderedContent, contentType: 'text/html', statusCode: 200 };\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NOTE: This file is a custom loader for "bare" imports in nodejs
|
|
3
|
+
* It should ONLY import types and not any runtime code.
|
|
4
|
+
*/
|
|
5
|
+
import type { ResolveHookContext, LoadFnOutput, LoadHookContext, ResolveFnOutput } from 'module';
|
|
6
|
+
import type { RunServerEntryOptions } from './types/RunServerEntryOptions.js';
|
|
7
|
+
export declare function initialize(context: RunServerEntryOptions): void;
|
|
8
|
+
type DefaultResolve = (specifier: string, context: ResolveHookContext) => ResolveFnOutput;
|
|
9
|
+
export declare function resolve(specifier: string, context: ResolveHookContext, defaultResolve: DefaultResolve): ResolveFnOutput;
|
|
10
|
+
type DefaultLoad = (url: string, context: LoadHookContext) => Promise<LoadFnOutput>;
|
|
11
|
+
export declare function load(url: string, context: LoadHookContext, defaultLoad: DefaultLoad): Promise<LoadFnOutput>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=importMapLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importMapLoader.d.ts","sourceRoot":"","sources":["../../../src/renderRoute/ssr/importMapLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEjG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAG9E,wBAAgB,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAE/D;AAED,KAAK,cAAc,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,KAAK,eAAe,CAAC;AAE1F,wBAAgB,OAAO,CACrB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,kBAAkB,EAC3B,cAAc,EAAE,cAAc,GAC7B,eAAe,CAYjB;AAED,KAAK,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;AAEpF,wBAAsB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAmBjH"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NOTE: This file is a custom loader for "bare" imports in nodejs
|
|
3
|
+
* It should ONLY import types and not any runtime code.
|
|
4
|
+
*/
|
|
5
|
+
let importMap = { imports: {} };
|
|
6
|
+
export function initialize(context) {
|
|
7
|
+
importMap = context.importMap || { imports: {} };
|
|
8
|
+
}
|
|
9
|
+
export function resolve(specifier, context, defaultResolve) {
|
|
10
|
+
// TODO: Deal with scope
|
|
11
|
+
const target = importMap?.imports?.[specifier];
|
|
12
|
+
if (target) {
|
|
13
|
+
console.log(`Import map redirect: ${specifier} -> ${target}`);
|
|
14
|
+
return {
|
|
15
|
+
url: target,
|
|
16
|
+
shortCircuit: true,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return defaultResolve(specifier, context);
|
|
20
|
+
}
|
|
21
|
+
export async function load(url, context, defaultLoad) {
|
|
22
|
+
if (url.startsWith('http')) {
|
|
23
|
+
console.log(`Importing from URL: ${url}`);
|
|
24
|
+
const res = await fetch(url);
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
throw new Error(`Failed to fetch ${url} (Status: ${res.status})`);
|
|
27
|
+
}
|
|
28
|
+
const source = await res.text();
|
|
29
|
+
return {
|
|
30
|
+
format: 'module',
|
|
31
|
+
source,
|
|
32
|
+
shortCircuit: true,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return defaultLoad(url, context);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=importMapLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importMapLoader.js","sourceRoot":"","sources":["../../../src/renderRoute/ssr/importMapLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,IAAI,SAAS,GAAc,EAAE,OA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nodejs\n * It should ONLY import types and not any runtime code.\n */\n\nimport type { ResolveHookContext, LoadFnOutput, LoadHookContext, ResolveFnOutput } from 'module';\nimport type { ImportMap } from '@ms-cloudpack/common-types';\nimport type { RunServerEntryOptions } from './types/RunServerEntryOptions.js';\n\nlet importMap: ImportMap = { imports: {} };\nexport function initialize(context: RunServerEntryOptions): void {\n importMap = context.importMap || { imports: {} };\n}\n\ntype DefaultResolve = (specifier: string, context: ResolveHookContext) => ResolveFnOutput;\n\nexport function resolve(\n specifier: string,\n context: ResolveHookContext,\n defaultResolve: DefaultResolve,\n): ResolveFnOutput {\n // TODO: Deal with scope\n const target = importMap?.imports?.[specifier];\n if (target) {\n console.log(`Import map redirect: ${specifier} -> ${target}`);\n return {\n url: target,\n shortCircuit: true,\n };\n }\n\n return defaultResolve(specifier, context);\n}\n\ntype DefaultLoad = (url: string, context: LoadHookContext) => Promise<LoadFnOutput>;\n\nexport async function load(url: string, context: LoadHookContext, defaultLoad: DefaultLoad): Promise<LoadFnOutput> {\n if (url.startsWith('http')) {\n console.log(`Importing from URL: ${url}`);\n\n const res = await fetch(url);\n if (!res.ok) {\n throw new Error(`Failed to fetch ${url} (Status: ${res.status})`);\n }\n\n const source = await res.text();\n\n return {\n format: 'module',\n source,\n shortCircuit: true,\n };\n }\n\n return defaultLoad(url, context);\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RunServerEntryOptions } from './types/RunServerEntryOptions.js';
|
|
2
|
+
import type { RunServerEntryResult } from './types/RunServerEntryResult.js';
|
|
3
|
+
export declare function runServerEntry(options: RunServerEntryOptions): Promise<RunServerEntryResult>;
|
|
4
|
+
//# sourceMappingURL=runServerEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runServerEntry.d.ts","sourceRoot":"","sources":["../../../src/renderRoute/ssr/runServerEntry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAS5E,wBAAsB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA4BlG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { register } from 'node:module';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
export async function runServerEntry(options) {
|
|
4
|
+
const { importMap, renderScriptUrl, loaderPath, renderParams } = options;
|
|
5
|
+
// Registers the customer loader, which is responsible for handling base-imports in a nodejs environment..
|
|
6
|
+
register(loaderPath, {
|
|
7
|
+
parentURL: pathToFileURL(import.meta.url),
|
|
8
|
+
data: { importMap },
|
|
9
|
+
});
|
|
10
|
+
// With the custom loader registered, we can now import the render script.
|
|
11
|
+
// We support both named and default exports for the render function.
|
|
12
|
+
const renderedResult = await import(renderScriptUrl)
|
|
13
|
+
.then((mod) => {
|
|
14
|
+
if (typeof mod.render === 'function') {
|
|
15
|
+
return mod.render(renderParams);
|
|
16
|
+
}
|
|
17
|
+
else if (typeof mod.default === 'function') {
|
|
18
|
+
return mod.default(renderParams);
|
|
19
|
+
}
|
|
20
|
+
throw new Error(`No render function found in module: ${renderScriptUrl}`);
|
|
21
|
+
})
|
|
22
|
+
.then((output) => {
|
|
23
|
+
return output;
|
|
24
|
+
})
|
|
25
|
+
.catch((err) => {
|
|
26
|
+
console.log('Error:', err);
|
|
27
|
+
});
|
|
28
|
+
return { renderedContent: renderedResult || '' };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=runServerEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runServerEntry.js","sourceRoot":"","sources":["../../../src/renderRoute/ssr/runServerEntry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAQzC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAA8B;IACjE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAEzE,0GAA0G;IAC1G,QAAQ,CAAC,UAAU,EAAE;QACnB,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QACzC,IAAI,EAAE,EAAE,SAAS,EAAE;KACpB,CAAC,CAAC;IAEH,0EAA0E;IAC1E,qEAAqE;IACrE,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC;SACjD,IAAI,CAAC,CAAC,GAAiB,EAAE,EAAE;QAC1B,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACrC,OAAO,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAClC,CAAC;aAAM,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YAC7C,OAAO,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACnC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,uCAAuC,eAAe,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACf,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEL,OAAO,EAAE,eAAe,EAAE,cAAc,IAAI,EAAE,EAAE,CAAC;AACnD,CAAC","sourcesContent":["import { register } from 'node:module';\nimport type { RunServerEntryOptions } from './types/RunServerEntryOptions.js';\nimport type { RunServerEntryResult } from './types/RunServerEntryResult.js';\nimport { pathToFileURL } from 'node:url';\nimport type { ServerRenderFunctionOptions } from '@ms-cloudpack/common-types';\n\ntype RenderModule = {\n render?: (params?: ServerRenderFunctionOptions) => Promise<string>;\n default?: (params?: ServerRenderFunctionOptions) => Promise<string>;\n};\n\nexport async function runServerEntry(options: RunServerEntryOptions): Promise<RunServerEntryResult> {\n const { importMap, renderScriptUrl, loaderPath, renderParams } = options;\n\n // Registers the customer loader, which is responsible for handling base-imports in a nodejs environment..\n register(loaderPath, {\n parentURL: pathToFileURL(import.meta.url),\n data: { importMap },\n });\n\n // With the custom loader registered, we can now import the render script.\n // We support both named and default exports for the render function.\n const renderedResult = await import(renderScriptUrl)\n .then((mod: RenderModule) => {\n if (typeof mod.render === 'function') {\n return mod.render(renderParams);\n } else if (typeof mod.default === 'function') {\n return mod.default(renderParams);\n }\n throw new Error(`No render function found in module: ${renderScriptUrl}`);\n })\n .then((output) => {\n return output;\n })\n .catch((err) => {\n console.log('Error:', err);\n });\n\n return { renderedContent: renderedResult || '' };\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RunServerEntryOptions } from './types/RunServerEntryOptions.js';
|
|
2
|
+
import type { RunServerEntryResult } from './types/RunServerEntryResult.js';
|
|
3
|
+
/**
|
|
4
|
+
* Run server entry in a worker pool.
|
|
5
|
+
*/
|
|
6
|
+
export declare function runServerEntryInWorker(options: RunServerEntryOptions & {
|
|
7
|
+
maxWorkers?: number;
|
|
8
|
+
}): Promise<RunServerEntryResult>;
|
|
9
|
+
export declare function disposeStubWorkerPool(): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=runServerEntryInWorker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runServerEntryInWorker.d.ts","sourceRoot":"","sources":["../../../src/renderRoute/ssr/runServerEntryInWorker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAW5E;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,qBAAqB,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACvD,OAAO,CAAC,oBAAoB,CAAC,CAqC/B;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAG3D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getAdjustedTimeout } from '@ms-cloudpack/environment';
|
|
2
|
+
import { WorkerPool } from '@ms-cloudpack/worker-pool';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
// Tests run the worker from the compiled version, so we need to replace /src/ with /lib/ in the path.
|
|
7
|
+
// This replace call has no effect in production, where the worker is always run from the compiled version.
|
|
8
|
+
const workerPath = path.join(dirname, 'worker/workerEntry.js').replace(/\/src\//, '/lib/');
|
|
9
|
+
let workerPool;
|
|
10
|
+
/**
|
|
11
|
+
* Run server entry in a worker pool.
|
|
12
|
+
*/
|
|
13
|
+
export async function runServerEntryInWorker(options) {
|
|
14
|
+
workerPool ??= new WorkerPool({
|
|
15
|
+
workerType: 'process',
|
|
16
|
+
name: 'Server Entry Execution',
|
|
17
|
+
entryPath: workerPath,
|
|
18
|
+
maxWorkers: options.maxWorkers || 5,
|
|
19
|
+
// Stop inactive workers after 5 minutes. This is intended to prevent one possible cause of
|
|
20
|
+
// OOM crashes if cloudpack start is left running for a long time (though it's much more likely
|
|
21
|
+
// that the issue is caused by servers or file watchers). The timeout is conservative because
|
|
22
|
+
// the fake browser environment has nontrivial startup time, so killing workers too quickly
|
|
23
|
+
// could slow down rebuilds.
|
|
24
|
+
inactiveTimeout: 5 * 60 * 1000,
|
|
25
|
+
// max heap size for running server entry in worker pool
|
|
26
|
+
maxHeapSize: 500 * 1024 * 1024,
|
|
27
|
+
// console.warn if running a server entry in work pool takes too long
|
|
28
|
+
warnAboveTime: getAdjustedTimeout(2000),
|
|
29
|
+
});
|
|
30
|
+
try {
|
|
31
|
+
const runServerEntryResult = await workerPool.execute({
|
|
32
|
+
method: 'runServerEntry',
|
|
33
|
+
args: [options],
|
|
34
|
+
});
|
|
35
|
+
return runServerEntryResult;
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
return {
|
|
39
|
+
renderedContent: '',
|
|
40
|
+
errors: [
|
|
41
|
+
{
|
|
42
|
+
source: 'Server Entry Execution',
|
|
43
|
+
// note: err won't be an instance of Error because of serialization
|
|
44
|
+
text: err?.stack || err?.message || String(err),
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export async function disposeStubWorkerPool() {
|
|
51
|
+
await workerPool?.dispose();
|
|
52
|
+
workerPool = undefined;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=runServerEntryInWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runServerEntryInWorker.js","sourceRoot":"","sources":["../../../src/renderRoute/ssr/runServerEntryInWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,sGAAsG;AACtG,2GAA2G;AAC3G,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAE3F,IAAI,UAAkC,CAAC;AAEvC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAwD;IAExD,UAAU,KAAK,IAAI,UAAU,CAAC;QAC5B,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE,wBAAwB;QAC9B,SAAS,EAAE,UAAU;QACrB,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC;QACnC,2FAA2F;QAC3F,+FAA+F;QAC/F,6FAA6F;QAC7F,2FAA2F;QAC3F,4BAA4B;QAC5B,eAAe,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI;QAC9B,wDAAwD;QACxD,WAAW,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;QAC9B,qEAAqE;QACrE,aAAa,EAAE,kBAAkB,CAAC,IAAI,CAAC;KACxC,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,oBAAoB,GAAG,MAAM,UAAU,CAAC,OAAO,CAAuB;YAC1E,MAAM,EAAE,gBAAgB;YACxB,IAAI,EAAE,CAAC,OAAO,CAAC;SAChB,CAAC,CAAC;QAEH,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,eAAe,EAAE,EAAE;YACnB,MAAM,EAAE;gBACN;oBACE,MAAM,EAAE,wBAAwB;oBAChC,mEAAmE;oBACnE,IAAI,EAAG,GAAa,EAAE,KAAK,IAAK,GAAa,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC;iBACtE;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,MAAM,UAAU,EAAE,OAAO,EAAE,CAAC;IAC5B,UAAU,GAAG,SAAS,CAAC;AACzB,CAAC","sourcesContent":["import { getAdjustedTimeout } from '@ms-cloudpack/environment';\nimport { WorkerPool } from '@ms-cloudpack/worker-pool';\nimport type { RunServerEntryOptions } from './types/RunServerEntryOptions.js';\nimport type { RunServerEntryResult } from './types/RunServerEntryResult.js';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst dirname = path.dirname(fileURLToPath(import.meta.url));\n// Tests run the worker from the compiled version, so we need to replace /src/ with /lib/ in the path.\n// This replace call has no effect in production, where the worker is always run from the compiled version.\nconst workerPath = path.join(dirname, 'worker/workerEntry.js').replace(/\\/src\\//, '/lib/');\n\nlet workerPool: WorkerPool | undefined;\n\n/**\n * Run server entry in a worker pool.\n */\nexport async function runServerEntryInWorker(\n options: RunServerEntryOptions & { maxWorkers?: number },\n): Promise<RunServerEntryResult> {\n workerPool ??= new WorkerPool({\n workerType: 'process',\n name: 'Server Entry Execution',\n entryPath: workerPath,\n maxWorkers: options.maxWorkers || 5,\n // Stop inactive workers after 5 minutes. This is intended to prevent one possible cause of\n // OOM crashes if cloudpack start is left running for a long time (though it's much more likely\n // that the issue is caused by servers or file watchers). The timeout is conservative because\n // the fake browser environment has nontrivial startup time, so killing workers too quickly\n // could slow down rebuilds.\n inactiveTimeout: 5 * 60 * 1000,\n // max heap size for running server entry in worker pool\n maxHeapSize: 500 * 1024 * 1024,\n // console.warn if running a server entry in work pool takes too long\n warnAboveTime: getAdjustedTimeout(2000),\n });\n\n try {\n const runServerEntryResult = await workerPool.execute<RunServerEntryResult>({\n method: 'runServerEntry',\n args: [options],\n });\n\n return runServerEntryResult;\n } catch (err) {\n return {\n renderedContent: '',\n errors: [\n {\n source: 'Server Entry Execution',\n // note: err won't be an instance of Error because of serialization\n text: (err as Error)?.stack || (err as Error)?.message || String(err),\n },\n ],\n };\n }\n}\n\nexport async function disposeStubWorkerPool(): Promise<void> {\n await workerPool?.dispose();\n workerPool = undefined;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ServerRenderFunctionOptions } from '@ms-cloudpack/common-types';
|
|
2
|
+
import type { ImportMap } from '@ms-cloudpack/import-map';
|
|
3
|
+
export type RunServerEntryOptions = {
|
|
4
|
+
loaderPath: string;
|
|
5
|
+
importMap: ImportMap;
|
|
6
|
+
renderScriptUrl: string;
|
|
7
|
+
renderParams?: ServerRenderFunctionOptions;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=RunServerEntryOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunServerEntryOptions.d.ts","sourceRoot":"","sources":["../../../../src/renderRoute/ssr/types/RunServerEntryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,2BAA2B,CAAC;CAC5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunServerEntryOptions.js","sourceRoot":"","sources":["../../../../src/renderRoute/ssr/types/RunServerEntryOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServerRenderFunctionOptions } from '@ms-cloudpack/common-types';\nimport type { ImportMap } from '@ms-cloudpack/import-map';\n\nexport type RunServerEntryOptions = {\n loaderPath: string;\n importMap: ImportMap;\n renderScriptUrl: string;\n renderParams?: ServerRenderFunctionOptions;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunServerEntryResult.d.ts","sourceRoot":"","sources":["../../../../src/renderRoute/ssr/types/RunServerEntryResult.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IACH,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunServerEntryResult.js","sourceRoot":"","sources":["../../../../src/renderRoute/ssr/types/RunServerEntryResult.ts"],"names":[],"mappings":"","sourcesContent":["export type RunServerEntryResult = {\n errors?: Array<{\n source: string;\n text: string;\n }>;\n renderedContent: string;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerEntry.d.ts","sourceRoot":"","sources":["../../../../src/renderRoute/ssr/worker/workerEntry.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { initializeWorker } from '@ms-cloudpack/worker-pool';
|
|
2
|
+
import { runServerEntry } from '../runServerEntry.js';
|
|
3
|
+
// eslint-disable-next-line no-restricted-properties -- exit handling for a worker
|
|
4
|
+
const processExit = process.exit.bind(process);
|
|
5
|
+
// Then initialize the worker with the appropriate listeners and api dictionary.
|
|
6
|
+
initializeWorker({
|
|
7
|
+
methods: {
|
|
8
|
+
runServerEntry,
|
|
9
|
+
},
|
|
10
|
+
beforeEach: () => {
|
|
11
|
+
// Override process.exit calls to throw rather than exit the process, in case we load some
|
|
12
|
+
// CJS code that calls process.exit. This gives an actual call stack for debugging.
|
|
13
|
+
// eslint-disable-next-line no-restricted-properties
|
|
14
|
+
process.exit = (code) => {
|
|
15
|
+
throw new Error(`process.exit called with code ${code}`);
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
afterEach: () => {
|
|
19
|
+
// eslint-disable-next-line no-restricted-properties
|
|
20
|
+
process.exit = processExit;
|
|
21
|
+
},
|
|
22
|
+
// Stop the worker after 30s. This is much longer than should usually be necessary, but it's
|
|
23
|
+
// good to be conservative here in case of resource contention.
|
|
24
|
+
timeout: 30 * 1000,
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=workerEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerEntry.js","sourceRoot":"","sources":["../../../../src/renderRoute/ssr/worker/workerEntry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,kFAAkF;AAClF,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAE/C,gFAAgF;AAChF,gBAAgB,CAAC;IACf,OAAO,EAAE;QACP,cAAc;KACf;IACD,UAAU,EAAE,GAAG,EAAE;QACf,0FAA0F;QAC1F,mFAAmF;QACnF,oDAAoD;QACpD,OAAO,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,EAAE,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC;IACD,SAAS,EAAE,GAAG,EAAE;QACd,oDAAoD;QACpD,OAAO,CAAC,IAAI,GAAG,WAAW,CAAC;IAC7B,CAAC;IACD,4FAA4F;IAC5F,+DAA+D;IAC/D,OAAO,EAAE,EAAE,GAAG,IAAI;CACnB,CAAC,CAAC","sourcesContent":["import { initializeWorker } from '@ms-cloudpack/worker-pool';\nimport { runServerEntry } from '../runServerEntry.js';\n\n// eslint-disable-next-line no-restricted-properties -- exit handling for a worker\nconst processExit = process.exit.bind(process);\n\n// Then initialize the worker with the appropriate listeners and api dictionary.\ninitializeWorker({\n methods: {\n runServerEntry,\n },\n beforeEach: () => {\n // Override process.exit calls to throw rather than exit the process, in case we load some\n // CJS code that calls process.exit. This gives an actual call stack for debugging.\n // eslint-disable-next-line no-restricted-properties\n process.exit = (code) => {\n throw new Error(`process.exit called with code ${code}`);\n };\n },\n afterEach: () => {\n // eslint-disable-next-line no-restricted-properties\n process.exit = processExit;\n },\n // Stop the worker after 30s. This is much longer than should usually be necessary, but it's\n // good to be conservative here in case of resource contention.\n timeout: 30 * 1000,\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/app-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "An implementation of the App server for Cloudpack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,22 +14,23 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/api-server": "^0.64.
|
|
18
|
-
"@ms-cloudpack/bundle-server": "^0.7.
|
|
19
|
-
"@ms-cloudpack/common-types": "^0.
|
|
20
|
-
"@ms-cloudpack/create-express-app": "^1.10.
|
|
17
|
+
"@ms-cloudpack/api-server": "^0.64.3",
|
|
18
|
+
"@ms-cloudpack/bundle-server": "^0.7.18",
|
|
19
|
+
"@ms-cloudpack/common-types": "^0.26.0",
|
|
20
|
+
"@ms-cloudpack/create-express-app": "^1.10.39",
|
|
21
21
|
"@ms-cloudpack/environment": "^0.1.1",
|
|
22
|
-
"@ms-cloudpack/import-map": "^0.10.
|
|
23
|
-
"@ms-cloudpack/inline-scripts": "^0.2.
|
|
22
|
+
"@ms-cloudpack/import-map": "^0.10.32",
|
|
23
|
+
"@ms-cloudpack/inline-scripts": "^0.2.17",
|
|
24
24
|
"@ms-cloudpack/path-string-parsing": "^1.2.7",
|
|
25
|
-
"@ms-cloudpack/path-utilities": "^3.1.
|
|
25
|
+
"@ms-cloudpack/path-utilities": "^3.1.10",
|
|
26
26
|
"@ms-cloudpack/task-reporter": "^0.17.2",
|
|
27
|
+
"@ms-cloudpack/worker-pool": "^0.4.1",
|
|
27
28
|
"happy-dom": "^18.0.0",
|
|
28
29
|
"http-proxy-middleware": "^2.0.6"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@ms-cloudpack/common-types-browser": "^0.6.2",
|
|
32
|
-
"@ms-cloudpack/config": "^0.35.
|
|
33
|
+
"@ms-cloudpack/config": "^0.35.14",
|
|
33
34
|
"@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
|
|
34
35
|
"@ms-cloudpack/scripts": "^0.0.1",
|
|
35
36
|
"@ms-cloudpack/test-utilities": "^0.5.0"
|