@modern-js/runtime 2.32.2-alpha.1 → 2.33.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/CHANGELOG.md +15 -7
- package/dist/cjs/ssr/index.node.js +3 -0
- package/dist/cjs/ssr/serverRender/renderToString/entry.js +5 -4
- package/dist/esm/ssr/index.node.js +3 -0
- package/dist/esm/ssr/serverRender/renderToString/entry.js +5 -4
- package/dist/esm-node/ssr/index.node.js +3 -0
- package/dist/esm-node/ssr/serverRender/renderToString/entry.js +5 -4
- package/dist/types/ssr/serverRender/renderToString/entry.d.ts +1 -1
- package/dist/types/ssr/serverRender/renderToString/type.d.ts +2 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
# @modern-js/runtime
|
|
2
2
|
|
|
3
|
-
## 2.
|
|
3
|
+
## 2.33.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2bcff4f: feat(plugin-runtime): support ssr html modifiers
|
|
8
|
+
feat(plugin-runtime): 支持 ssr html 修改者
|
|
4
9
|
|
|
5
10
|
### Patch Changes
|
|
6
11
|
|
|
7
|
-
-
|
|
12
|
+
- 6ea89ab: fix: html has placeholder when not set partials
|
|
8
13
|
fix: html 在没有设置 partials 的时候,会多出占位符
|
|
9
|
-
-
|
|
14
|
+
- ae35c65: fix: ssr htmlModifiers
|
|
15
|
+
fix: ssr htmlModifiers 赋值问题
|
|
16
|
+
- 44da57b: refactor: runtime server ssr
|
|
10
17
|
refactor: 重构 runtime server ssr
|
|
11
|
-
- Updated dependencies [
|
|
12
|
-
|
|
13
|
-
- @modern-js/
|
|
14
|
-
- @modern-js/
|
|
18
|
+
- Updated dependencies [fd82137]
|
|
19
|
+
- Updated dependencies [bc1f8da]
|
|
20
|
+
- @modern-js/utils@2.33.0
|
|
21
|
+
- @modern-js/plugin@2.33.0
|
|
22
|
+
- @modern-js/types@2.33.0
|
|
15
23
|
|
|
16
24
|
## 2.32.1
|
|
17
25
|
|
|
@@ -38,6 +38,9 @@ const ssr = (config = {}) => ({
|
|
|
38
38
|
const { request } = context.ssrContext;
|
|
39
39
|
context.ssrContext.request = (0, _utils.formatServer)(request);
|
|
40
40
|
context.ssrContext.mode = config.mode;
|
|
41
|
+
if (!context.ssrContext.htmlModifiers) {
|
|
42
|
+
context.ssrContext.htmlModifiers = [];
|
|
43
|
+
}
|
|
41
44
|
return next({
|
|
42
45
|
context
|
|
43
46
|
});
|
|
@@ -75,7 +75,8 @@ class Entry {
|
|
|
75
75
|
(0, _buildHtml.createReplaceChunkCss)(this.result.chunksMap.css),
|
|
76
76
|
(0, _buildHtml.createReplaceChunkJs)(this.result.chunksMap.js),
|
|
77
77
|
(0, _buildHtml.createReplaceHtml)(this.result.html || ""),
|
|
78
|
-
(0, _buildHtml.createReplaceSSRDataScript)(ssrDataScripts)
|
|
78
|
+
(0, _buildHtml.createReplaceSSRDataScript)(ssrDataScripts),
|
|
79
|
+
...this.htmlModifiers
|
|
79
80
|
]);
|
|
80
81
|
const helmetData = _reacthelmet.default.renderStatic();
|
|
81
82
|
return helmetData ? (0, _helmet.default)(html, helmetData) : html;
|
|
@@ -143,17 +144,17 @@ class Entry {
|
|
|
143
144
|
_define_property._(this, "template", void 0);
|
|
144
145
|
_define_property._(this, "App", void 0);
|
|
145
146
|
_define_property._(this, "pluginConfig", void 0);
|
|
146
|
-
_define_property._(this, "
|
|
147
|
+
_define_property._(this, "htmlModifiers", void 0);
|
|
147
148
|
_define_property._(this, "nonce", void 0);
|
|
148
149
|
const { ctx, config } = options;
|
|
149
|
-
const { entryName, template,
|
|
150
|
+
const { entryName, template, nonce } = ctx;
|
|
150
151
|
this.template = template;
|
|
151
152
|
this.entryName = entryName;
|
|
152
|
-
this.host = host;
|
|
153
153
|
this.App = options.App;
|
|
154
154
|
this.pluginConfig = config;
|
|
155
155
|
this.tracker = (0, _tracker.createSSRTracker)(ctx);
|
|
156
156
|
this.metrics = ctx.metrics;
|
|
157
|
+
this.htmlModifiers = ctx.htmlModifiers;
|
|
157
158
|
this.nonce = nonce;
|
|
158
159
|
this.result = {
|
|
159
160
|
renderLevel: _types.RenderLevel.CLIENT_RENDER,
|
|
@@ -43,6 +43,9 @@ export var ssr = function() {
|
|
|
43
43
|
var request = context.ssrContext.request;
|
|
44
44
|
context.ssrContext.request = formatServer(request);
|
|
45
45
|
context.ssrContext.mode = config.mode;
|
|
46
|
+
if (!context.ssrContext.htmlModifiers) {
|
|
47
|
+
context.ssrContext.htmlModifiers = [];
|
|
48
|
+
}
|
|
46
49
|
return next({
|
|
47
50
|
context: context
|
|
48
51
|
});
|
|
@@ -3,6 +3,7 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
|
|
|
3
3
|
import { _ as _create_class } from "@swc/helpers/_/_create_class";
|
|
4
4
|
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
5
5
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
6
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
6
7
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
7
8
|
import React from "react";
|
|
8
9
|
import { serializeJson } from "@modern-js/utils/runtime-node";
|
|
@@ -51,17 +52,17 @@ var Entry = /* @__PURE__ */ function() {
|
|
|
51
52
|
_define_property(this, "template", void 0);
|
|
52
53
|
_define_property(this, "App", void 0);
|
|
53
54
|
_define_property(this, "pluginConfig", void 0);
|
|
54
|
-
_define_property(this, "
|
|
55
|
+
_define_property(this, "htmlModifiers", void 0);
|
|
55
56
|
_define_property(this, "nonce", void 0);
|
|
56
57
|
var ctx = options.ctx, config = options.config;
|
|
57
|
-
var entryName = ctx.entryName, template = ctx.template,
|
|
58
|
+
var entryName = ctx.entryName, template = ctx.template, nonce = ctx.nonce;
|
|
58
59
|
this.template = template;
|
|
59
60
|
this.entryName = entryName;
|
|
60
|
-
this.host = host;
|
|
61
61
|
this.App = options.App;
|
|
62
62
|
this.pluginConfig = config;
|
|
63
63
|
this.tracker = createSSRTracker(ctx);
|
|
64
64
|
this.metrics = ctx.metrics;
|
|
65
|
+
this.htmlModifiers = ctx.htmlModifiers;
|
|
65
66
|
this.nonce = nonce;
|
|
66
67
|
this.result = {
|
|
67
68
|
renderLevel: RenderLevel.CLIENT_RENDER,
|
|
@@ -122,7 +123,7 @@ var Entry = /* @__PURE__ */ function() {
|
|
|
122
123
|
createReplaceChunkJs(_this.result.chunksMap.js),
|
|
123
124
|
createReplaceHtml(_this.result.html || ""),
|
|
124
125
|
createReplaceSSRDataScript(ssrDataScripts)
|
|
125
|
-
]);
|
|
126
|
+
].concat(_to_consumable_array(_this.htmlModifiers)));
|
|
126
127
|
helmetData = ReactHelmet.renderStatic();
|
|
127
128
|
return [
|
|
128
129
|
2,
|
|
@@ -16,6 +16,9 @@ export const ssr = (config = {}) => ({
|
|
|
16
16
|
const { request } = context.ssrContext;
|
|
17
17
|
context.ssrContext.request = formatServer(request);
|
|
18
18
|
context.ssrContext.mode = config.mode;
|
|
19
|
+
if (!context.ssrContext.htmlModifiers) {
|
|
20
|
+
context.ssrContext.htmlModifiers = [];
|
|
21
|
+
}
|
|
19
22
|
return next({
|
|
20
23
|
context
|
|
21
24
|
});
|
|
@@ -64,7 +64,8 @@ class Entry {
|
|
|
64
64
|
createReplaceChunkCss(this.result.chunksMap.css),
|
|
65
65
|
createReplaceChunkJs(this.result.chunksMap.js),
|
|
66
66
|
createReplaceHtml(this.result.html || ""),
|
|
67
|
-
createReplaceSSRDataScript(ssrDataScripts)
|
|
67
|
+
createReplaceSSRDataScript(ssrDataScripts),
|
|
68
|
+
...this.htmlModifiers
|
|
68
69
|
]);
|
|
69
70
|
const helmetData = ReactHelmet.renderStatic();
|
|
70
71
|
return helmetData ? helmetReplace(html, helmetData) : html;
|
|
@@ -132,17 +133,17 @@ class Entry {
|
|
|
132
133
|
_define_property(this, "template", void 0);
|
|
133
134
|
_define_property(this, "App", void 0);
|
|
134
135
|
_define_property(this, "pluginConfig", void 0);
|
|
135
|
-
_define_property(this, "
|
|
136
|
+
_define_property(this, "htmlModifiers", void 0);
|
|
136
137
|
_define_property(this, "nonce", void 0);
|
|
137
138
|
const { ctx, config } = options;
|
|
138
|
-
const { entryName, template,
|
|
139
|
+
const { entryName, template, nonce } = ctx;
|
|
139
140
|
this.template = template;
|
|
140
141
|
this.entryName = entryName;
|
|
141
|
-
this.host = host;
|
|
142
142
|
this.App = options.App;
|
|
143
143
|
this.pluginConfig = config;
|
|
144
144
|
this.tracker = createSSRTracker(ctx);
|
|
145
145
|
this.metrics = ctx.metrics;
|
|
146
|
+
this.htmlModifiers = ctx.htmlModifiers;
|
|
146
147
|
this.nonce = nonce;
|
|
147
148
|
this.result = {
|
|
148
149
|
renderLevel: RenderLevel.CLIENT_RENDER,
|
|
@@ -14,7 +14,7 @@ export default class Entry {
|
|
|
14
14
|
private readonly template;
|
|
15
15
|
private readonly App;
|
|
16
16
|
private readonly pluginConfig;
|
|
17
|
-
private readonly
|
|
17
|
+
private readonly htmlModifiers;
|
|
18
18
|
private readonly nonce?;
|
|
19
19
|
constructor(options: EntryOptions);
|
|
20
20
|
renderToHtml(context: RuntimeContext): Promise<string>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BaseSSRServerContext } from '@modern-js/types';
|
|
2
|
+
import type { BuildHtmlCb } from './buildHtml';
|
|
2
3
|
export declare enum RenderLevel {
|
|
3
4
|
CLIENT_RENDER = 0,
|
|
4
5
|
SERVER_PREFETCH = 1,
|
|
@@ -10,6 +11,7 @@ export type SSRServerContext = BaseSSRServerContext & {
|
|
|
10
11
|
cookie: string;
|
|
11
12
|
cookieMap: Record<string, string>;
|
|
12
13
|
};
|
|
14
|
+
htmlModifiers: BuildHtmlCb[];
|
|
13
15
|
};
|
|
14
16
|
export type RenderResult = {
|
|
15
17
|
renderLevel: RenderLevel;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.33.0",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -173,9 +173,9 @@
|
|
|
173
173
|
"redux-logger": "^3.0.6",
|
|
174
174
|
"styled-components": "^5.3.1",
|
|
175
175
|
"@swc/helpers": "0.5.1",
|
|
176
|
-
"@modern-js/plugin": "2.
|
|
177
|
-
"@modern-js/types": "2.
|
|
178
|
-
"@modern-js/utils": "2.
|
|
176
|
+
"@modern-js/plugin": "2.33.0",
|
|
177
|
+
"@modern-js/types": "2.33.0",
|
|
178
|
+
"@modern-js/utils": "2.33.0"
|
|
179
179
|
},
|
|
180
180
|
"peerDependencies": {
|
|
181
181
|
"react": ">=17",
|
|
@@ -196,11 +196,11 @@
|
|
|
196
196
|
"ts-jest": "^29.1.0",
|
|
197
197
|
"typescript": "^5",
|
|
198
198
|
"webpack": "^5.88.1",
|
|
199
|
-
"@modern-js/app-tools": "2.
|
|
200
|
-
"@modern-js/core": "2.
|
|
201
|
-
"@
|
|
202
|
-
"@scripts/
|
|
203
|
-
"@
|
|
199
|
+
"@modern-js/app-tools": "2.33.0",
|
|
200
|
+
"@modern-js/core": "2.33.0",
|
|
201
|
+
"@scripts/build": "2.33.0",
|
|
202
|
+
"@scripts/jest-config": "2.33.0",
|
|
203
|
+
"@modern-js/server-core": "2.33.0"
|
|
204
204
|
},
|
|
205
205
|
"sideEffects": false,
|
|
206
206
|
"publishConfig": {
|