@sitecore-jss/sitecore-jss-rendering-host 21.1.0-canary.92 → 21.1.0-canary.94
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.
|
@@ -28,7 +28,7 @@ function getDefaultAppInvocationInfoResolver({ appPathResolver = (requestJson) =
|
|
|
28
28
|
// default resolution assumes folder structure of:
|
|
29
29
|
// ./dist/{JSSAppName}/{ServerBundleName}.js
|
|
30
30
|
const modulePath = appPathResolver(requestJson);
|
|
31
|
-
const resolvedModule = import_fresh_1.default(modulePath);
|
|
31
|
+
const resolvedModule = (0, import_fresh_1.default)(modulePath);
|
|
32
32
|
const resolvedRenderFunctionName = requestJson.functionName || 'renderView';
|
|
33
33
|
const renderFunction = resolvedModule[resolvedRenderFunctionName];
|
|
34
34
|
if (!renderFunction) {
|
package/dist/cjs/devServer.js
CHANGED
|
@@ -52,7 +52,7 @@ function startDevServer({ port = 0, tunnelUrl, configFactory, buildArtifactsPath
|
|
|
52
52
|
}
|
|
53
53
|
// Give devs a chance to modify the webpack configurations before creating the compiler instance.
|
|
54
54
|
invokeHook(hooks.beforeWebpackCompilerCreation, configs.clientWebpackConfig, configs.ssrWebpackConfig);
|
|
55
|
-
const compiler = webpack_1.default([configs.clientWebpackConfig, configs.ssrWebpackConfig]);
|
|
55
|
+
const compiler = (0, webpack_1.default)([configs.clientWebpackConfig, configs.ssrWebpackConfig]);
|
|
56
56
|
// `open` and `openPage` don't seem to work when starting webpack dev server via Node API.
|
|
57
57
|
// Seems like this is a known issue with a potential PR: https://github.com/webpack/webpack-dev-server/issues/1510
|
|
58
58
|
// But for now, need to work around it by using the `opn` module. Note: CRA does something similar.
|
|
@@ -65,7 +65,7 @@ function startDevServer({ port = 0, tunnelUrl, configFactory, buildArtifactsPath
|
|
|
65
65
|
compiler.compilers[compiler.compilers.length - 1].hooks.done.tap('OpenBrowserAfterCompilationPlugin', (stats) => {
|
|
66
66
|
if (!browserOpened) {
|
|
67
67
|
console.log('opening browser', stats.compilation.compiler.name);
|
|
68
|
-
opn_1.default(urlToOpenOnStart).then(() => {
|
|
68
|
+
(0, opn_1.default)(urlToOpenOnStart).then(() => {
|
|
69
69
|
browserOpened = true;
|
|
70
70
|
});
|
|
71
71
|
}
|
|
@@ -93,10 +93,17 @@ function startDevServer({ port = 0, tunnelUrl, configFactory, buildArtifactsPath
|
|
|
93
93
|
if (tunnelUrl) {
|
|
94
94
|
serverOptions.public = tunnelUrl;
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
let resolvedServerBundleFilename;
|
|
97
|
+
if (typeof serverBundleFileName === 'function') {
|
|
98
|
+
resolvedServerBundleFilename = serverBundleFileName({ filename: 'server.bundle.js' });
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
resolvedServerBundleFilename = serverBundleFileName;
|
|
102
|
+
}
|
|
103
|
+
const modulePath = path_1.default.join(buildArtifactsPath, resolvedServerBundleFilename);
|
|
97
104
|
console.log('Resolved server bundle path', modulePath);
|
|
98
105
|
const appInvocationInfoResolver = customAppInvocationInfoResolver ||
|
|
99
|
-
defaultAppInvocationInfoResolver_1.getDefaultAppInvocationInfoResolver({ appPathResolver: () => modulePath });
|
|
106
|
+
(0, defaultAppInvocationInfoResolver_1.getDefaultAppInvocationInfoResolver)({ appPathResolver: () => modulePath });
|
|
100
107
|
// Devs may have assigned a value to `serverOptions.after` via `configs.devServerConfig`, so
|
|
101
108
|
// preserve the existing value so we can invoke it later.
|
|
102
109
|
const originalAfter = serverOptions.after;
|
|
@@ -105,7 +112,7 @@ function startDevServer({ port = 0, tunnelUrl, configFactory, buildArtifactsPath
|
|
|
105
112
|
? ssrMiddleware({
|
|
106
113
|
appInvocationInfoResolver,
|
|
107
114
|
})
|
|
108
|
-
: ssrMiddleware_1.ssrMiddleware({
|
|
115
|
+
: (0, ssrMiddleware_1.ssrMiddleware)({
|
|
109
116
|
appInvocationInfoResolver,
|
|
110
117
|
});
|
|
111
118
|
// Give devs a chance to add custom middleware before the SSR middleware is registered,
|
|
@@ -122,7 +129,7 @@ function startDevServer({ port = 0, tunnelUrl, configFactory, buildArtifactsPath
|
|
|
122
129
|
if (clean) {
|
|
123
130
|
const cleanPaths = [`${path_1.default.join(buildArtifactsPath, '**')}`, `!${buildArtifactsPath}`];
|
|
124
131
|
console.log('cleaning paths', cleanPaths);
|
|
125
|
-
const cleanedPaths = del_1.
|
|
132
|
+
const cleanedPaths = (0, del_1.deleteSync)(cleanPaths);
|
|
126
133
|
console.log('cleaned paths', cleanedPaths);
|
|
127
134
|
}
|
|
128
135
|
// Give devs a chance to modify serverOptions and/or the compiler before creating the WDS instance.
|
|
@@ -14,19 +14,19 @@ const defaultAppInvocationInfoResolver_1 = require("./defaultAppInvocationInfoRe
|
|
|
14
14
|
* @param {RenderingHostServerOptions} config
|
|
15
15
|
*/
|
|
16
16
|
function startRenderingHostServer({ port = 0, hostname = 'localhost', hooks = {}, middlewares = {}, enableCompression = true, ssrMiddleware, ssrMiddlewarePath, appInvocationInfoResolver: customAppInvocationInfoResolver, }) {
|
|
17
|
-
const server = express_1.default();
|
|
17
|
+
const server = (0, express_1.default)();
|
|
18
18
|
if (enableCompression) {
|
|
19
19
|
const compressionMiddleware = middlewares.compression && typeof middlewares.compression === 'function'
|
|
20
20
|
? middlewares.compression
|
|
21
|
-
: compression_1.default();
|
|
21
|
+
: (0, compression_1.default)();
|
|
22
22
|
server.use(compressionMiddleware);
|
|
23
23
|
}
|
|
24
|
-
const appInvocationInfoResolver = customAppInvocationInfoResolver || defaultAppInvocationInfoResolver_1.getDefaultAppInvocationInfoResolver({});
|
|
24
|
+
const appInvocationInfoResolver = customAppInvocationInfoResolver || (0, defaultAppInvocationInfoResolver_1.getDefaultAppInvocationInfoResolver)({});
|
|
25
25
|
const middleware = ssrMiddleware
|
|
26
26
|
? ssrMiddleware({
|
|
27
27
|
appInvocationInfoResolver,
|
|
28
28
|
})
|
|
29
|
-
: ssrMiddleware_1.ssrMiddleware({
|
|
29
|
+
: (0, ssrMiddleware_1.ssrMiddleware)({
|
|
30
30
|
appInvocationInfoResolver,
|
|
31
31
|
});
|
|
32
32
|
// Give devs a chance to add custom middleware before the SSR middleware is registered.
|
package/dist/esm/devServer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { deleteSync } from 'del';
|
|
2
2
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import openBrowser from 'opn';
|
|
@@ -87,7 +87,14 @@ export function startDevServer({ port = 0, tunnelUrl, configFactory, buildArtifa
|
|
|
87
87
|
if (tunnelUrl) {
|
|
88
88
|
serverOptions.public = tunnelUrl;
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
let resolvedServerBundleFilename;
|
|
91
|
+
if (typeof serverBundleFileName === 'function') {
|
|
92
|
+
resolvedServerBundleFilename = serverBundleFileName({ filename: 'server.bundle.js' });
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
resolvedServerBundleFilename = serverBundleFileName;
|
|
96
|
+
}
|
|
97
|
+
const modulePath = path.join(buildArtifactsPath, resolvedServerBundleFilename);
|
|
91
98
|
console.log('Resolved server bundle path', modulePath);
|
|
92
99
|
const appInvocationInfoResolver = customAppInvocationInfoResolver ||
|
|
93
100
|
getDefaultAppInvocationInfoResolver({ appPathResolver: () => modulePath });
|
|
@@ -116,7 +123,7 @@ export function startDevServer({ port = 0, tunnelUrl, configFactory, buildArtifa
|
|
|
116
123
|
if (clean) {
|
|
117
124
|
const cleanPaths = [`${path.join(buildArtifactsPath, '**')}`, `!${buildArtifactsPath}`];
|
|
118
125
|
console.log('cleaning paths', cleanPaths);
|
|
119
|
-
const cleanedPaths =
|
|
126
|
+
const cleanedPaths = deleteSync(cleanPaths);
|
|
120
127
|
console.log('cleaned paths', cleanedPaths);
|
|
121
128
|
}
|
|
122
129
|
// Give devs a chance to modify serverOptions and/or the compiler before creating the WDS instance.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-rendering-host",
|
|
3
|
-
"version": "21.1.0-canary.
|
|
3
|
+
"version": "21.1.0-canary.94",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -27,31 +27,30 @@
|
|
|
27
27
|
"url": "https://github.com/sitecore/jss/issues"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"del": "^
|
|
31
|
-
"import-fresh": "^3.
|
|
32
|
-
"ngrok": "^4.
|
|
30
|
+
"del": "^7.0.0",
|
|
31
|
+
"import-fresh": "^3.3.0",
|
|
32
|
+
"ngrok": "^4.3.3",
|
|
33
33
|
"opn": "^6.0.0",
|
|
34
|
-
"webpack": "
|
|
34
|
+
"webpack": "5.75.0",
|
|
35
35
|
"webpack-dev-server": "3.11.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/chai": "^4.2.3",
|
|
39
|
-
"@types/compression": "^1.
|
|
40
|
-
"@types/express": "4.17.
|
|
41
|
-
"@types/
|
|
42
|
-
"@types/
|
|
43
|
-
"@types/
|
|
44
|
-
"@types/
|
|
45
|
-
"@types/webpack": "4.39.2",
|
|
39
|
+
"@types/compression": "^1.7.2",
|
|
40
|
+
"@types/express-serve-static-core": "^4.17.33",
|
|
41
|
+
"@types/glob": "^8.0.1",
|
|
42
|
+
"@types/mocha": "^10.0.1",
|
|
43
|
+
"@types/node": "^18.11.18",
|
|
44
|
+
"@types/webpack": "5.28.0",
|
|
46
45
|
"@types/webpack-dev-middleware": "2.0.5",
|
|
47
46
|
"@types/webpack-dev-server": "3.1.7",
|
|
48
|
-
"chai": "^4.
|
|
47
|
+
"chai": "^4.3.0",
|
|
49
48
|
"del-cli": "^5.0.0",
|
|
50
|
-
"eslint": "^
|
|
51
|
-
"mocha": "^
|
|
49
|
+
"eslint": "^8.33.0",
|
|
50
|
+
"mocha": "^10.2.0",
|
|
52
51
|
"nyc": "^15.1.0",
|
|
53
|
-
"ts-node": "^
|
|
54
|
-
"typescript": "~4.
|
|
52
|
+
"ts-node": "^10.9.1",
|
|
53
|
+
"typescript": "~4.9.5"
|
|
55
54
|
},
|
|
56
55
|
"description": "",
|
|
57
56
|
"types": "types/index.d.ts",
|
|
@@ -67,5 +66,5 @@
|
|
|
67
66
|
"types",
|
|
68
67
|
"/global.d.ts"
|
|
69
68
|
],
|
|
70
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "e89a1c56c8872128f5dc5fcc62435d34a55f5dc6"
|
|
71
70
|
}
|
package/types/devServer.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface ConfigFactoryResult {
|
|
|
9
9
|
clientWebpackConfig: webpack.Configuration;
|
|
10
10
|
devServerConfig: WebpackDevServer.Configuration;
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export type ConfigFactory = (nodeEnv?: string, tunnelUrl?: string) => ConfigFactoryResult;
|
|
13
13
|
export interface DevServerOptions {
|
|
14
14
|
configFactory: ConfigFactory;
|
|
15
15
|
/**
|
package/types/ssrMiddleware.d.ts
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
-
export
|
|
4
|
+
export type RenderCallback = (errorValue: Error, successValue?: string | {
|
|
4
5
|
[key: string]: unknown;
|
|
5
6
|
} | null) => void;
|
|
6
|
-
export
|
|
7
|
+
export type RenderFunction = (callback: RenderCallback, ...args: unknown[]) => void;
|
|
7
8
|
export interface AppInvocationInfo {
|
|
8
9
|
renderFunction: RenderFunction;
|
|
9
10
|
renderFunctionArgs: unknown[];
|
|
10
11
|
renderFunctionCallback?: RenderCallback;
|
|
11
12
|
}
|
|
12
|
-
export
|
|
13
|
+
export type JsonObject = {
|
|
13
14
|
[key: string]: unknown;
|
|
14
15
|
id: string;
|
|
15
16
|
functionName: string;
|
|
16
17
|
moduleName: string;
|
|
17
18
|
args: string[];
|
|
18
19
|
};
|
|
19
|
-
export
|
|
20
|
+
export type AppInvocationInfoResolver = (bodyJson: string | JsonObject, req: IncomingMessage, res: ServerResponse) => AppInvocationInfo;
|
|
20
21
|
export interface SSRMiddlewareOptions {
|
|
21
22
|
appInvocationInfoResolver: AppInvocationInfoResolver;
|
|
22
23
|
}
|
|
23
|
-
export
|
|
24
|
-
export
|
|
24
|
+
export type WebServerMiddleware = (req: IncomingMessage, res: ServerResponse, next?: (err?: unknown) => void) => void;
|
|
25
|
+
export type SSRMiddleware = (options: SSRMiddlewareOptions) => WebServerMiddleware;
|
|
25
26
|
export declare const ssrMiddleware: SSRMiddleware;
|
|
26
27
|
/**
|
|
27
28
|
* @param {ServerResponse} res
|