ssr-plugin-react 7.0.6 → 7.0.7
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 +305 -450
- package/README.md +60 -60
- package/cjs/entry/context.d.ts +1 -1
- package/cjs/entry/context.d.ts.map +1 -1
- package/cjs/entry/context.js +5 -5
- package/cjs/entry/context.js.map +1 -1
- package/cjs/entry/create.d.ts +1 -1
- package/cjs/entry/create.d.ts.map +1 -1
- package/cjs/entry/create.js +1 -1
- package/cjs/entry/create.js.map +1 -1
- package/cjs/entry/react17-client-entry.d.ts.map +1 -1
- package/cjs/entry/react17-client-entry.js +6 -7
- package/cjs/entry/react17-client-entry.js.map +1 -1
- package/cjs/entry/react18-client-entry.d.ts.map +1 -1
- package/cjs/entry/react18-client-entry.js +5 -7
- package/cjs/entry/react18-client-entry.js.map +1 -1
- package/cjs/entry/server-entry.d.ts +2 -2
- package/cjs/entry/server-entry.d.ts.map +1 -1
- package/cjs/entry/server-entry.js +31 -27
- package/cjs/entry/server-entry.js.map +1 -1
- package/cjs/index.js +9 -9
- package/cjs/index.js.map +1 -1
- package/esm/entry/context.d.ts +1 -1
- package/esm/entry/context.d.ts.map +1 -1
- package/esm/entry/context.js +7 -7
- package/esm/entry/context.js.map +1 -1
- package/esm/entry/create.d.ts +1 -1
- package/esm/entry/create.d.ts.map +1 -1
- package/esm/entry/create.js +7 -7
- package/esm/entry/create.js.map +1 -1
- package/esm/entry/react17-client-entry.d.ts.map +1 -1
- package/esm/entry/react17-client-entry.js +13 -14
- package/esm/entry/react17-client-entry.js.map +1 -1
- package/esm/entry/react18-client-entry.d.ts.map +1 -1
- package/esm/entry/react18-client-entry.js +12 -14
- package/esm/entry/react18-client-entry.js.map +1 -1
- package/esm/entry/server-entry.d.ts +2 -2
- package/esm/entry/server-entry.d.ts.map +1 -1
- package/esm/entry/server-entry.js +40 -36
- package/esm/entry/server-entry.js.map +1 -1
- package/esm/index.js +11 -11
- package/esm/index.js.map +1 -1
- package/package.json +31 -32
- package/src/entry/context.tsx +33 -29
- package/src/entry/create.ts +26 -26
- package/src/entry/react17-client-entry.tsx +66 -66
- package/src/entry/react18-client-entry.tsx +72 -72
- package/src/entry/server-entry.tsx +191 -181
- package/src/index.ts +38 -38
- package/tsconfig.cjs.json +2 -4
- package/tsconfig.esm.json +2 -4
package/README.md
CHANGED
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
|
|
26
26
|
The `ssr` framework version `7.x` has been released. Read the [documentation](http://doc.ssr-fc.com/docs/features$v7) for more detailed introduction and upgrade guide. Version 7 brings the following new features:
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
- Supports [Rspack](https://rspack.rs), [Rolldown-Vite](https://vite.dev/guide/rolldown), and `Webpack` build tools to greatly improve build performance.
|
|
29
|
+
- Supports any frontend framework combined with any build tool
|
|
30
|
+
- Brand new dependency design, streamlined dependencies required for initialization
|
|
31
|
+
- Progressive upgrade with almost no breaking changes, v6 projects can smoothly transition to v7
|
|
32
32
|
|
|
33
33
|
Version 7 has been tested to improve build speed by 5-10 times. Dependency size reduced by 2/3 (when using Rspack|Rolldown-Vite scenarios).
|
|
34
34
|
|
|
@@ -56,15 +56,15 @@ Read our [official documentation](http://doc.ssr-fc.com/) for more detailed unde
|
|
|
56
56
|
|
|
57
57
|
## When Should You Choose the SSR Framework
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
- Need to use in scenarios combining `Node.js` with frontend frameworks. Unlike other pure frontend frameworks, the `ssr` framework is specifically built for server-side rendering scenarios or scenarios combining `Node.js` with frontend.
|
|
60
|
+
- Need an out-of-the-box server-side rendering capability without manually combining different frontend frameworks with server-side frameworks.
|
|
61
|
+
- Need framework-level rendering degradation capability that automatically degrades to client-side rendering when server-side rendering fails.
|
|
62
|
+
- Need a framework with simple configuration and clear logic. The `ssr` framework has the clearest rendering logic and application build logic among similar frameworks.
|
|
63
|
+
- May change technology stacks, such as upgrading from `Vue2` to `Vue3`, downgrading from `Vue3` to `Vue2`, or switching between `React/Vue`.
|
|
64
|
+
- Need out-of-the-box support for popular UI libraries like `antd` and `vant` in server-side rendering scenarios.
|
|
65
|
+
- Need to support both `Webpack` and `Vite` development tools to get fast startup speed, HMR speed, and stable production code.
|
|
66
|
+
- Need to use [pinia](https://pinia.vuejs.org/) as data management solution in `Vue3 SSR`.
|
|
67
|
+
- Simply need a faster and better `cra` or `vue-cli`. The `ssr` framework also provides excellent support in pure `csr` scenarios.
|
|
68
68
|
|
|
69
69
|
## Who's Using
|
|
70
70
|
|
|
@@ -167,38 +167,38 @@ Companies (applications) currently using this project. If you are using it but n
|
|
|
167
167
|
|
|
168
168
|
## Features
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
- 🌱 Extremely customizable: Frontend supports modern Web frameworks like React17/React18/Vue2/Vue3;
|
|
171
|
+
- 🚀 Ready to use: Built-in 10+ scaffold extensions like [Pinia](https://pinia.vuejs.org/introduction.html#basic-example), [antd](https://ant.design/components/overview-cn/), [vant](https://github.com/youzan/vant), TypeScript, Hooks, etc.;
|
|
172
|
+
- 🧲 Plugin-driven: Based on plugin architecture, users focus more on business logic;
|
|
173
|
+
- 💯 Serverless-first: One-click deployment to various Serverless platforms, also supports traditional Web Servers like Egg, Midway, Nest, etc.
|
|
174
|
+
- 🛡 High availability scenarios, seamless degradation from SSR to CSR, best disaster recovery solution.
|
|
175
|
+
- 😄 Feature-rich, build tools support both Webpack/Vite, supports four rendering modes `SSR|CSR|SSG|Html`
|
|
176
|
+
- ✨ Supports [bun](https://bun.sh/) as js runtime
|
|
177
177
|
|
|
178
178
|
## Implemented Features
|
|
179
179
|
|
|
180
180
|
🚀 indicates implemented features
|
|
181
181
|
|
|
182
|
-
| Milestone
|
|
183
|
-
|
|
|
184
|
-
| Support combination of any server-side framework with any frontend framework. (Serverless/Midway/NestJS) + (React17/React18/Vue2/Vue3)
|
|
185
|
-
| Smoothest [vite](https://vite-design.surge.sh/) [support](http://doc.ssr-fc.com/docs/features$vite)
|
|
186
|
-
| Minimal and elegant server-side rendering implementation
|
|
187
|
-
| Support [pre-rendering](http://doc.ssr-fc.com/docs/features$ssg) capability
|
|
188
|
-
| Optimized production code bundle size for Serverless scenarios with strict code package size limitations
|
|
189
|
-
| Support both conventional frontend routing and declarative frontend routing
|
|
190
|
-
| Abandon traditional template engines, all page elements unified using frontend components as DSL
|
|
191
|
-
| Support four rendering modes simultaneously, providing one-click degradation from server-side rendering to client-side rendering
|
|
192
|
-
| Unify data fetching methods for different frameworks on server and client sides, achieving high reusability
|
|
193
|
-
| Type-friendly, fully embrace TypeScript
|
|
194
|
-
| Support seamless integration with [antd](https://github.com/ant-design/ant-design) [vant](https://vant-contrib.gitee.io/vant/#/) without modifying any configuration
|
|
195
|
-
| Support using less as CSS preprocessor
|
|
196
|
-
| Seamless [usage](http://doc.ssr-fc.com/docs/features$faq#%E4%B8%8E%20micro-app%20%E7%BB%93%E5%90%88%E4%BD%BF%E7%94%A8) in micro-frontend scenarios
|
|
197
|
-
| Support using context or [valtio](https://github.com/pmndrs/valtio) for minimalist [data management](http://doc.ssr-fc.com/docs/features$communication#React%20%E5%9C%BA%E6%99%AF) solutions, abandoning traditional redux/dva data management solutions
|
|
198
|
-
| Vue3 scenarios provide [Pinia](https://pinia.vuejs.org/introduction.html#basic-example) and [Provide/Inject](http://doc.ssr-fc.com/docs/features$communication#Vue%20%E5%9C%BA%E6%99%AF%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88) to replace `Vuex` for cross-component communication | 🚀
|
|
199
|
-
| Support creation and usage on Alibaba Cloud [platform](https://zhuanlan.zhihu.com/p/139210473)
|
|
200
|
-
| ssr deploy one-click deployment to [Alibaba Cloud](https://www.aliyun.com/) platform
|
|
201
|
-
| ssr deploy --tencent one-click deployment to [Tencent Cloud](https://cloud.tencent.com/) platform without modifying any configuration
|
|
182
|
+
| Milestone | Status |
|
|
183
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
|
|
184
|
+
| Support combination of any server-side framework with any frontend framework. (Serverless/Midway/NestJS) + (React17/React18/Vue2/Vue3) | 🚀 |
|
|
185
|
+
| Smoothest [vite](https://vite-design.surge.sh/) [support](http://doc.ssr-fc.com/docs/features$vite) | 🚀 |
|
|
186
|
+
| Minimal and elegant server-side rendering implementation | 🚀 |
|
|
187
|
+
| Support [pre-rendering](http://doc.ssr-fc.com/docs/features$ssg) capability | 🚀 |
|
|
188
|
+
| Optimized production code bundle size for Serverless scenarios with strict code package size limitations | 🚀 |
|
|
189
|
+
| Support both conventional frontend routing and declarative frontend routing | 🚀 |
|
|
190
|
+
| Abandon traditional template engines, all page elements unified using frontend components as DSL | 🚀 |
|
|
191
|
+
| Support four rendering modes simultaneously, providing one-click degradation from server-side rendering to client-side rendering | 🚀 |
|
|
192
|
+
| Unify data fetching methods for different frameworks on server and client sides, achieving high reusability | 🚀 |
|
|
193
|
+
| Type-friendly, fully embrace TypeScript | 🚀 |
|
|
194
|
+
| Support seamless integration with [antd](https://github.com/ant-design/ant-design) [vant](https://vant-contrib.gitee.io/vant/#/) without modifying any configuration | 🚀 |
|
|
195
|
+
| Support using less as CSS preprocessor | 🚀 |
|
|
196
|
+
| Seamless [usage](http://doc.ssr-fc.com/docs/features$faq#%E4%B8%8E%20micro-app%20%E7%BB%93%E5%90%88%E4%BD%BF%E7%94%A8) in micro-frontend scenarios | 🚀 |
|
|
197
|
+
| Support using context or [valtio](https://github.com/pmndrs/valtio) for minimalist [data management](http://doc.ssr-fc.com/docs/features$communication#React%20%E5%9C%BA%E6%99%AF) solutions, abandoning traditional redux/dva data management solutions | 🚀 |
|
|
198
|
+
| Vue3 scenarios provide [Pinia](https://pinia.vuejs.org/introduction.html#basic-example) and [Provide/Inject](http://doc.ssr-fc.com/docs/features$communication#Vue%20%E5%9C%BA%E6%99%AF%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88) to replace `Vuex` for cross-component communication | 🚀 |
|
|
199
|
+
| Support creation and usage on Alibaba Cloud [platform](https://zhuanlan.zhihu.com/p/139210473) | 🚀 |
|
|
200
|
+
| ssr deploy one-click deployment to [Alibaba Cloud](https://www.aliyun.com/) platform | 🚀 |
|
|
201
|
+
| ssr deploy --tencent one-click deployment to [Tencent Cloud](https://cloud.tencent.com/) platform without modifying any configuration | 🚀 |
|
|
202
202
|
|
|
203
203
|
## Solution Comparison
|
|
204
204
|
|
|
@@ -214,15 +214,15 @@ Although the technology stacks are different, the development philosophy is cons
|
|
|
214
214
|
|
|
215
215
|
Note: In `Midway.js` and `Nest.js` scenarios, we have implemented one-click deployment to `Serverless` platforms. However, the underlying implementations differ slightly. For more detailed introduction, please read the [Serverless](http://doc.ssr-fc.com/docs/features$serverless) chapter. If you need to extensively use capabilities provided by `Serverless` platforms, we recommend creating `Midway.js` type applications. We strongly recommend reading our [official documentation](http://doc.ssr-fc.com/) for more detailed understanding.
|
|
216
216
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
217
|
+
- [nestjs-react-ssr](https://github.com/zhangyuang/ssr/tree/dev/example/nestjs-react-ssr)
|
|
218
|
+
- [nestjs-react18-ssr](https://github.com/zhangyuang/ssr/tree/dev/example/nestjs-react18-ssr)
|
|
219
|
+
- [nestjs-vue-ssr](https://github.com/zhangyuang/ssr/tree/dev/example/nestjs-vue-ssr)
|
|
220
|
+
- [nestjs-vue3-ssr](https://github.com/zhangyuang/ssr/tree/dev/example/nestjs-vue3-ssr)
|
|
221
|
+
- [nestjs-vue3-ssr-pinia](https://github.com/zhangyuang/nestjs-vue3-ssr-pinia)
|
|
222
|
+
- [midway-react-ssr](https://github.com/zhangyuang/ssr/tree/dev/example/midway-react-ssr)
|
|
223
|
+
- [midway-react18-ssr](https://github.com/zhangyuang/ssr/tree/dev/example/midway-react18-ssr)
|
|
224
|
+
- [midway-vue-ssr](https://github.com/zhangyuang/ssr/tree/dev/example/midway-vue-ssr)
|
|
225
|
+
- [midway-vue3-ssr](https://github.com/zhangyuang/ssr/tree/dev/example/midway-vue3-ssr)
|
|
226
226
|
|
|
227
227
|
Developers can create different types of applications according to their actual technology stack needs to get started quickly.
|
|
228
228
|
|
|
@@ -247,21 +247,21 @@ $ yarn start:vite # start in vite mode, equivalent to npx ssr start --tools vite
|
|
|
247
247
|
Preview application details deployed to Alibaba Cloud/Tencent Cloud services through Serverless one-click deployment by visiting the following links.
|
|
248
248
|
Use queryParams `csr=true` to degrade SSR server-side rendering mode to CSR client-side rendering mode with one click, or configure through `config.js`.
|
|
249
249
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
250
|
+
- http://ssr-fc.com/ React SSR application deployed to Alibaba Cloud
|
|
251
|
+
- http://ssr-fc.com?csr=true React SSR application deployed to Alibaba Cloud, accessed in CSR mode
|
|
252
|
+
- http://tx.ssr-fc.com React SSR application deployed to Tencent Cloud
|
|
253
|
+
- http://tx.ssr-fc.com?csr=true React SSR application deployed to Tencent Cloud, accessed in CSR mode
|
|
254
|
+
- http://vue.ssr-fc.com Vue SSR application deployed to Alibaba Cloud
|
|
255
|
+
- http://vue3.ssr-fc.com Vue3 SSR application deployed to Alibaba Cloud
|
|
256
|
+
- http://vue.ssr-fc.com?csr=true Vue SSR application deployed to Alibaba Cloud, accessed in CSR mode
|
|
257
|
+
- http://vue3.ssr-fc.com?csr=true Vue3 SSR application deployed to Alibaba Cloud, accessed in CSR mode
|
|
258
258
|
|
|
259
259
|
## Ecosystem
|
|
260
260
|
|
|
261
261
|
| Project | Status | Description |
|
|
262
262
|
| ------------------- | ------------------------------------------------ | ----------------------------------------------------------------------- |
|
|
263
263
|
| [ssr] | [![ssr-status]][ssr] | cli for ssr framework |
|
|
264
|
-
| [ssr-core]
|
|
264
|
+
| [ssr-core] | [![ssr-core-status]][ssr-core] | core render for all framwork |
|
|
265
265
|
| [ssr-plugin-midway] | [![ssr-plugin-midway-status]][ssr-plugin-midway] | provide start and build fetature by [midway@2.0](https://midwayjs.org/) |
|
|
266
266
|
| [ssr-plugin-nestjs] | [![ssr-plugin-nestjs-status]][ssr-plugin-nestjs] | provide start and build feature by [NestJS](https://docs.nestjs.com/) |
|
|
267
267
|
| [ssr-plugin-react] | [![ssr-plugin-react-status]][ssr-plugin-react] | develop react application only be used in development |
|
|
@@ -285,7 +285,6 @@ Use queryParams `csr=true` to degrade SSR server-side rendering mode to CSR clie
|
|
|
285
285
|
[ssr-plugin-vue3-status]: https://img.shields.io/npm/v/ssr-plugin-vue3.svg
|
|
286
286
|
[ssr-webpack-status]: https://img.shields.io/npm/v/ssr-webpack.svg
|
|
287
287
|
[ssr-types-status]: https://img.shields.io/npm/v/ssr-types.svg
|
|
288
|
-
|
|
289
288
|
[ssr]: https://github.com/zhangyuang/ssr/tree/dev/packages/cli
|
|
290
289
|
[ssr-core]: https://github.com/zhangyuang/ssr/tree/dev/packages/core
|
|
291
290
|
[ssr-hoc-react]: https://github.com/zhangyuang/ssr/tree/dev/packages/hoc-react
|
|
@@ -321,6 +320,7 @@ Although we have tried our best to check the application, there may still be omi
|
|
|
321
320
|
## Project Donation
|
|
322
321
|
|
|
323
322
|
If this project can help you, we hope to receive your donation ☕️ to contribute to the open source community.
|
|
323
|
+
|
|
324
324
|
<div style="display:flex">
|
|
325
325
|
<img src="https://doc.ssr-fc.com/images/wepay.jpg" width="150">
|
|
326
326
|
<img src="https://doc.ssr-fc.com/images/alipay.jpg" width="150">
|
|
@@ -346,7 +346,7 @@ SUM: 164 471 195 4927
|
|
|
346
346
|
|
|
347
347
|
## Frontend Development Manual
|
|
348
348
|
|
|
349
|
-
[How to Build a Comfortable and Efficient Frontend Development Environment](http://fe.ssr-fc.com/)
|
|
349
|
+
[How to Build a Comfortable and Efficient Frontend Development Environment](http://fe.ssr-fc.com/)
|
|
350
350
|
|
|
351
351
|
## Project Star Growth Trend
|
|
352
352
|
|
package/cjs/entry/context.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IProps } from
|
|
1
|
+
import { IProps } from "ssr-types";
|
|
2
2
|
export declare function AppContext(props: IProps): import("react").FunctionComponentElement<import("react").ProviderProps<import("ssr-types").IContext<any>>>;
|
|
3
3
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/entry/context.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAoC,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/entry/context.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAoC,MAAM,WAAW,CAAC;AA2BrE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,8GAiBvC"}
|
package/cjs/entry/context.js
CHANGED
|
@@ -6,12 +6,12 @@ const create_1 = require("./create");
|
|
|
6
6
|
const { reducer, state } = create_1.Routes;
|
|
7
7
|
const userState = state !== null && state !== void 0 ? state : {};
|
|
8
8
|
const userReducer = reducer !== null && reducer !== void 0 ? reducer : function () { };
|
|
9
|
-
const isDev = process.env.NODE_ENV !==
|
|
9
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
10
10
|
function defaultReducer(state, action) {
|
|
11
11
|
switch (action.type) {
|
|
12
|
-
case
|
|
12
|
+
case "updateContext":
|
|
13
13
|
if (isDev) {
|
|
14
|
-
console.log(
|
|
14
|
+
console.log("[SSR:updateContext]: dispatch updateContext with action");
|
|
15
15
|
console.log(action);
|
|
16
16
|
}
|
|
17
17
|
return { ...state, ...action.payload };
|
|
@@ -26,8 +26,8 @@ function AppContext(props) {
|
|
|
26
26
|
return (0, react_1.createElement)(props.context.Provider, {
|
|
27
27
|
value: {
|
|
28
28
|
state,
|
|
29
|
-
dispatch
|
|
30
|
-
}
|
|
29
|
+
dispatch,
|
|
30
|
+
},
|
|
31
31
|
}, props.children);
|
|
32
32
|
}
|
|
33
33
|
//# sourceMappingURL=context.js.map
|
package/cjs/entry/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/entry/context.tsx"],"names":[],"mappings":";;AA4BA,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/entry/context.tsx"],"names":[],"mappings":";;AA4BA,gCAiBC;AA7CD,iCAAkD;AAElD,qCAAkC;AAElC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,eAAyB,CAAC;AAErD,MAAM,SAAS,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC;AAC9B,MAAM,WAAW,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,cAAa,CAAC,CAAC;AAE9C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;AAIpD,SAAS,cAAc,CAAC,KAAU,EAAE,MAAc;IAChD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,eAAe;YAClB,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAC;gBACvE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACtB,CAAC;YACD,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAC3C,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,KAAU,EAAE,MAAW;IAC7C,OAAO,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACrE,CAAC;AAED,SAAgB,UAAU,CAAC,KAAa;IACtC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAChC,EAAE,EACF,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,EACf,aAAa,CAAC,CAAC,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAC9D,CAAC;IACF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,kBAAU,EAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IACnE,OAAO,IAAA,qBAAa,EAClB,KAAK,CAAC,OAAO,CAAC,QAAQ,EACtB;QACE,KAAK,EAAE;YACL,KAAK;YACL,QAAQ;SACT;KACF,EACD,KAAK,CAAC,QAAe,CACtB,CAAC;AACJ,CAAC"}
|
package/cjs/entry/create.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IContext, ReactRoutesType } from
|
|
1
|
+
import type { IContext, ReactRoutesType } from "ssr-types";
|
|
2
2
|
export declare const Routes: ReactRoutesType;
|
|
3
3
|
export declare const ssrCreateContext: () => import("react").Context<IContext<any>>;
|
|
4
4
|
export declare function createStore(): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/entry/create.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/entry/create.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE3D,eAAO,MAAM,MAAM,EAAiD,eAAe,CAAC;AACpF,eAAO,MAAM,gBAAgB,8CAQ5B,CAAC;AAEF,wBAAgB,WAAW,QAW1B"}
|
package/cjs/entry/create.js
CHANGED
|
@@ -11,7 +11,7 @@ const valtio_1 = require("valtio");
|
|
|
11
11
|
exports.Routes = (0, ssr_common_utils_1.combineRoutes)(declareRoutes, ManualRoutes);
|
|
12
12
|
const ssrCreateContext = () => {
|
|
13
13
|
const STORE_CONTEXT = (0, react_1.createContext)({
|
|
14
|
-
state: {}
|
|
14
|
+
state: {},
|
|
15
15
|
});
|
|
16
16
|
if (__isBrowser__) {
|
|
17
17
|
window.STORE_CONTEXT = STORE_CONTEXT;
|
package/cjs/entry/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/entry/create.ts"],"names":[],"mappings":";;;AAmBA,kCAWC;AA9BD,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/entry/create.ts"],"names":[],"mappings":";;;AAmBA,kCAWC;AA9BD,2DAA2D;AAC3D,yDAAyD;AACzD,iCAAsC;AACtC,uDAAiD;AACjD,iDAA0C;AAC1C,mCAA+B;AAGlB,QAAA,MAAM,GAAG,IAAA,gCAAa,EAAC,aAAa,EAAE,YAAY,CAAoB,CAAC;AAC7E,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,aAAa,GAAG,IAAA,qBAAa,EAAW;QAC5C,KAAK,EAAE,EAAE;KACV,CAAC,CAAC;IACH,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,CAAC,aAAa,GAAG,aAAa,CAAC;IACvC,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AARW,QAAA,gBAAgB,oBAQ3B;AAEF,SAAgB,WAAW;;IACzB,MAAM,EAAE,KAAK,EAAE,GAAG,cAAM,CAAC;IACzB,MAAM,aAAa,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,IAAA,yBAAS,EAAC,KAAK,CAAC,CAAC,CAAC;IACtE,IAAI,aAAa,EAAE,CAAC;QAClB,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;YAChC,IAAI,aAAa,KAAI,MAAA,MAAM,CAAC,eAAe,0CAAG,GAAG,CAAC,CAAA,EAAE,CAAC;gBACnD,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react17-client-entry.d.ts","sourceRoot":"","sources":["../../src/entry/react17-client-entry.tsx"],"names":[],"mappings":"AAWA,QAAA,MAAM,YAAY,QAAa,OAAO,CAAC,IAAI,CAyD1C,
|
|
1
|
+
{"version":3,"file":"react17-client-entry.d.ts","sourceRoot":"","sources":["../../src/entry/react17-client-entry.tsx"],"names":[],"mappings":"AAWA,QAAA,MAAM,YAAY,QAAa,OAAO,CAAC,IAAI,CAyD1C,CAAC;AAIF,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -20,11 +20,11 @@ const clientRender = async () => {
|
|
|
20
20
|
(0, ssr_common_utils_1.setStore)(store !== null && store !== void 0 ? store : {});
|
|
21
21
|
const baseName = (0, ssr_common_utils_1.isMicro)() ? window.clientPrefix : window.prefix;
|
|
22
22
|
const routes = await (0, ssr_common_utils_1.preloadComponent)(FeRoutes, baseName);
|
|
23
|
-
const container = document.querySelector((_a = window.ssrDevInfo.rootId) !== null && _a !== void 0 ? _a :
|
|
23
|
+
const container = document.querySelector((_a = window.ssrDevInfo.rootId) !== null && _a !== void 0 ? _a : "#app");
|
|
24
24
|
const ele = (0, react_1.createElement)(
|
|
25
25
|
//@ts-ignore
|
|
26
26
|
react_router_dom_1.BrowserRouter, {
|
|
27
|
-
basename: baseName
|
|
27
|
+
basename: baseName,
|
|
28
28
|
}, (0, react_1.createElement)(context_1.AppContext, {
|
|
29
29
|
context,
|
|
30
30
|
children: (0, react_1.createElement)(react_router_dom_1.Switch, null, (0, react_1.createElement)(IApp, null, (0, react_1.createElement)(react_router_dom_1.Switch, null, routes.map((item) => {
|
|
@@ -38,14 +38,13 @@ const clientRender = async () => {
|
|
|
38
38
|
path: path,
|
|
39
39
|
render: (props) => (0, react_1.createElement)(WrappedComponent, {
|
|
40
40
|
...props,
|
|
41
|
-
key: props.history.location.key
|
|
42
|
-
})
|
|
41
|
+
key: props.history.location.key,
|
|
42
|
+
}),
|
|
43
43
|
});
|
|
44
|
-
}))))
|
|
44
|
+
})))),
|
|
45
45
|
}));
|
|
46
|
-
react_dom_1.default[window.__USE_SSR__ ?
|
|
46
|
+
react_dom_1.default[window.__USE_SSR__ ? "hydrate" : "render"](ele, container);
|
|
47
47
|
if (!window.__USE_VITE__) {
|
|
48
|
-
;
|
|
49
48
|
(_c = (_b = module === null || module === void 0 ? void 0 : module.hot) === null || _b === void 0 ? void 0 : _b.accept) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
50
49
|
}
|
|
51
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react17-client-entry.js","sourceRoot":"","sources":["../../src/entry/react17-client-entry.tsx"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"react17-client-entry.js","sourceRoot":"","sources":["../../src/entry/react17-client-entry.tsx"],"names":[],"mappings":";;;AACA,yCAAiC;AACjC,iCAAsC;AACtC,uDAAgE;AAChE,uDAAwF;AACxF,iDAA8C;AAC9C,qCAAiE;AACjE,uCAAuC;AAEvC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,eAAM,CAAC;AAE9C,MAAM,YAAY,GAAG,KAAK,IAAmB,EAAE;;IAC7C,MAAM,IAAI,GACR,GAAG,aAAH,GAAG,cAAH,GAAG,GACH,UAAU,KAAkB;QAC1B,OAAO,KAAK,CAAC,QAAS,CAAC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EAAE,IAAI;gBACV,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAChB,IAAA,qBAAa,EAAC,gBAAgB,EAAE;oBAC9B,GAAG,KAAK;oBACR,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG;iBAChC,CAAC;aACL,CAAC,CAAC;QACL,CAAC,CAAC,CACH,CACF,CACF;KACF,CAAC,CACH,CAAC;IAEF,mBAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAEpE,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QACzB,MAAA,MAAC,MAAc,aAAd,MAAM,uBAAN,MAAM,CAAU,GAAG,0CAAE,MAAM,kDAAI,CAAC;IACnC,CAAC;AACH,CAAC,CAAC;AAIO,oCAAY;AAFrB,YAAY,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react18-client-entry.d.ts","sourceRoot":"","sources":["../../src/entry/react18-client-entry.tsx"],"names":[],"mappings":"AAYA,QAAA,MAAM,YAAY,QAAa,OAAO,CAAC,IAAI,CA6D1C,
|
|
1
|
+
{"version":3,"file":"react18-client-entry.d.ts","sourceRoot":"","sources":["../../src/entry/react18-client-entry.tsx"],"names":[],"mappings":"AAYA,QAAA,MAAM,YAAY,QAAa,OAAO,CAAC,IAAI,CA6D1C,CAAC;AAIF,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -21,11 +21,11 @@ const clientRender = async () => {
|
|
|
21
21
|
(0, ssr_common_utils_1.setStore)(store !== null && store !== void 0 ? store : {});
|
|
22
22
|
const baseName = (0, ssr_common_utils_1.isMicro)() ? window.clientPrefix : window.prefix;
|
|
23
23
|
const routes = await (0, ssr_common_utils_1.preloadComponent)(FeRoutes, baseName);
|
|
24
|
-
const container = document.querySelector((_a = window.ssrDevInfo.rootId) !== null && _a !== void 0 ? _a :
|
|
24
|
+
const container = document.querySelector((_a = window.ssrDevInfo.rootId) !== null && _a !== void 0 ? _a : "#app");
|
|
25
25
|
const ele = (0, react_1.createElement)(
|
|
26
26
|
//@ts-ignore
|
|
27
27
|
react_router_dom_1.BrowserRouter, {
|
|
28
|
-
basename: baseName
|
|
28
|
+
basename: baseName,
|
|
29
29
|
}, (0, react_1.createElement)(context_1.AppContext, {
|
|
30
30
|
context,
|
|
31
31
|
children: (0, react_1.createElement)(react_router_dom_1.Switch, null, (0, react_1.createElement)(IApp, null, (0, react_1.createElement)(react_router_dom_1.Switch, null, routes.map((item) => {
|
|
@@ -39,13 +39,12 @@ const clientRender = async () => {
|
|
|
39
39
|
path: path,
|
|
40
40
|
render: (props) => (0, react_1.createElement)(WrappedComponent, {
|
|
41
41
|
...props,
|
|
42
|
-
key: props.history.location.key
|
|
43
|
-
})
|
|
42
|
+
key: props.history.location.key,
|
|
43
|
+
}),
|
|
44
44
|
});
|
|
45
|
-
}))))
|
|
45
|
+
})))),
|
|
46
46
|
}));
|
|
47
47
|
if (window.__USE_SSR__) {
|
|
48
|
-
;
|
|
49
48
|
client_1.hydrateRoot(container, ele);
|
|
50
49
|
}
|
|
51
50
|
else {
|
|
@@ -53,7 +52,6 @@ const clientRender = async () => {
|
|
|
53
52
|
root.render(ele);
|
|
54
53
|
}
|
|
55
54
|
if (!window.__USE_VITE__) {
|
|
56
|
-
;
|
|
57
55
|
(_c = (_b = module === null || module === void 0 ? void 0 : module.hot) === null || _b === void 0 ? void 0 : _b.accept) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
58
56
|
}
|
|
59
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react18-client-entry.js","sourceRoot":"","sources":["../../src/entry/react18-client-entry.tsx"],"names":[],"mappings":";;;AAGA,YAAY;AACZ,
|
|
1
|
+
{"version":3,"file":"react18-client-entry.js","sourceRoot":"","sources":["../../src/entry/react18-client-entry.tsx"],"names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AAC,CAAC,IAAI,EAAE,EAAE;YAClB,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;YACxC,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC;YACxB,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC;YACpC,MAAM,gBAAgB,GAAG,IAAA,6BAAa,EAAC,SAAS,CAAC,CAAC;YAClD,OAAO,IAAA,qBAAa,EAAC,wBAAK,EAAE;gBAC1B,KAAK,EAAE,IAAI;gBACX,GAAG,EAAE,IAAI;gBACT,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAChB,IAAA,qBAAa,EAAC,gBAAgB,EAAE;oBAC9B,GAAG,KAAK;oBACR,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG;iBAChC,CAAC;aACL,CAAC,CAAC;QACL,CAAC,CAAC,CACH,CACF,CACF;KACF,CAAC,CACH,CAAC;IACF,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACtB,oBAAkC,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACtD,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAI,mBAAgC,CAAC,SAAS,CAAC,CAAC;QAC1D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QACzB,MAAA,MAAC,MAAc,aAAd,MAAM,uBAAN,MAAM,CAAU,GAAG,0CAAE,MAAM,kDAAI,CAAC;IACnC,CAAC;AACH,CAAC,CAAC;AAIO,oCAAY;AAFrB,YAAY,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ISSRContext, IConfig } from
|
|
2
|
-
import { Routes } from
|
|
1
|
+
import { ISSRContext, IConfig } from "ssr-types";
|
|
2
|
+
import { Routes } from "./create";
|
|
3
3
|
declare const serverRender: (ctx: ISSRContext, config: IConfig) => Promise<string | import("stream").Readable | NodeJS.ReadableStream | import("ssr-types").PipeableStream | {
|
|
4
4
|
html: string;
|
|
5
5
|
teleportsContext: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-entry.d.ts","sourceRoot":"","sources":["../../src/entry/server-entry.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAmD,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"server-entry.d.ts","sourceRoot":"","sources":["../../src/entry/server-entry.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAmD,MAAM,WAAW,CAAC;AAGlG,OAAO,EAAE,MAAM,EAAiC,MAAM,UAAU,CAAC;AAOjE,QAAA,MAAM,YAAY,GAAU,KAAK,WAAW,EAAE,QAAQ,OAAO;;;EA2K5D,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -15,7 +15,7 @@ const { FeRoutes, layoutFetch, state, Layout } = create_1.Routes;
|
|
|
15
15
|
const serverRender = async (ctx, config) => {
|
|
16
16
|
var _a;
|
|
17
17
|
const context = (0, create_1.ssrCreateContext)();
|
|
18
|
-
const { mode, parallelFetch, prefix, isVite, isDev, clientPrefix, onReady, onError, stream, rootId, hashRouter, streamHighWaterMark } = config;
|
|
18
|
+
const { mode, parallelFetch, prefix, isVite, isDev, clientPrefix, onReady, onError, stream, rootId, hashRouter, streamHighWaterMark, } = config;
|
|
19
19
|
const rawPath = (_a = ctx.request.path) !== null && _a !== void 0 ? _a : ctx.request.url;
|
|
20
20
|
const path = (0, ssr_common_utils_1.normalizePath)(rawPath, prefix);
|
|
21
21
|
const routeItem = (0, ssr_common_utils_1.findRoute)(FeRoutes, path);
|
|
@@ -30,8 +30,8 @@ const serverRender = async (ctx, config) => {
|
|
|
30
30
|
? [
|
|
31
31
|
React.createElement("script", { src: "/@vite/client", type: "module", key: "vite-client" }),
|
|
32
32
|
React.createElement("script", { key: "vite-react-refresh", type: "module", dangerouslySetInnerHTML: {
|
|
33
|
-
__html: ssr_common_utils_1.reactRefreshFragment
|
|
34
|
-
} })
|
|
33
|
+
__html: ssr_common_utils_1.reactRefreshFragment,
|
|
34
|
+
} }),
|
|
35
35
|
]
|
|
36
36
|
: dynamicCssOrder
|
|
37
37
|
.map((css) => manifest[css])
|
|
@@ -41,33 +41,33 @@ const serverRender = async (ctx, config) => {
|
|
|
41
41
|
: dynamicJsOrder
|
|
42
42
|
.map((js) => manifest[js])
|
|
43
43
|
.filter(Boolean)
|
|
44
|
-
.map((js) => React.createElement("link", { href: js, as: "script", rel: isVite ?
|
|
44
|
+
.map((js) => (React.createElement("link", { href: js, as: "script", rel: isVite ? "modulepreload" : "preload", key: js }))));
|
|
45
45
|
const injectScript = [
|
|
46
46
|
...(isVite
|
|
47
47
|
? [
|
|
48
48
|
React.createElement("script", { key: "viteWindowInit", dangerouslySetInnerHTML: {
|
|
49
|
-
__html:
|
|
50
|
-
} })
|
|
49
|
+
__html: "window.__USE_VITE__=true",
|
|
50
|
+
} }),
|
|
51
51
|
]
|
|
52
52
|
: []),
|
|
53
53
|
...(isVite && isDev
|
|
54
54
|
? [
|
|
55
|
-
React.createElement("script", { type: "module", src: `/node_modules/ssr-plugin-react/esm/entry/${(0, ssr_common_utils_1.getClientEntry)()}.js`, key: "vite-react-entry" })
|
|
55
|
+
React.createElement("script", { type: "module", src: `/node_modules/ssr-plugin-react/esm/entry/${(0, ssr_common_utils_1.getClientEntry)()}.js`, key: "vite-react-entry" }),
|
|
56
56
|
]
|
|
57
57
|
: []),
|
|
58
58
|
...dynamicJsOrder
|
|
59
59
|
.map((js) => manifest[js])
|
|
60
60
|
.filter(Boolean)
|
|
61
|
-
.map((item) => React.createElement("script", { key: item, src: item, type: isVite ?
|
|
61
|
+
.map((item) => (React.createElement("script", { key: item, src: item, type: isVite ? "module" : "text/javascript" }))),
|
|
62
62
|
];
|
|
63
63
|
const staticList = {
|
|
64
64
|
injectCss,
|
|
65
|
-
injectScript
|
|
65
|
+
injectScript,
|
|
66
66
|
};
|
|
67
|
-
const isCsr = !!(mode ===
|
|
67
|
+
const isCsr = !!(mode === "csr" || ((_a = ctx.request.query) === null || _a === void 0 ? void 0 : _a.csr));
|
|
68
68
|
const Component = isCsr
|
|
69
69
|
? React.Fragment
|
|
70
|
-
: component.name ===
|
|
70
|
+
: component.name === "dynamicComponent"
|
|
71
71
|
? (await component()).default
|
|
72
72
|
: component;
|
|
73
73
|
if (isCsr) {
|
|
@@ -78,25 +78,29 @@ const serverRender = async (ctx, config) => {
|
|
|
78
78
|
const currentFetch = fetch ? (await fetch()).default : null;
|
|
79
79
|
const lF = layoutFetch ? layoutFetch({ ctx }) : Promise.resolve({});
|
|
80
80
|
const CF = currentFetch ? currentFetch({ ctx }) : Promise.resolve({});
|
|
81
|
-
[layoutFetchData, fetchData] = parallelFetch
|
|
81
|
+
[layoutFetchData, fetchData] = parallelFetch
|
|
82
|
+
? await Promise.all([lF, CF])
|
|
83
|
+
: [await lF, await CF];
|
|
82
84
|
}
|
|
83
|
-
const combineData = isCsr
|
|
84
|
-
|
|
85
|
+
const combineData = isCsr
|
|
86
|
+
? null
|
|
87
|
+
: Object.assign({}, state !== null && state !== void 0 ? state : {}, layoutFetchData !== null && layoutFetchData !== void 0 ? layoutFetchData : {}, fetchData !== null && fetchData !== void 0 ? fetchData : {});
|
|
88
|
+
const ssrDevInfo = { manifest: isDev ? manifest : "", rootId };
|
|
85
89
|
const innerHTML = (0, ssr_common_utils_1.splitPageInfo)({
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
"window.__USE_SSR__": !isCsr,
|
|
91
|
+
"window.__INITIAL_DATA__": isCsr ? {} : (0, ssr_serialize_javascript_1.serialize)(combineData),
|
|
92
|
+
"window.__USE_VITE__": isVite,
|
|
93
|
+
"window.prefix": `"${prefix}"`,
|
|
94
|
+
"window.clientPrefix": `"${clientPrefix !== null && clientPrefix !== void 0 ? clientPrefix : ""}"`,
|
|
95
|
+
"window.ssrDevInfo": JSON.stringify(ssrDevInfo),
|
|
96
|
+
"window.hashRouter": Boolean(hashRouter),
|
|
97
|
+
"window.__VALTIO_DATA__": isCsr ? {} : (0, ssr_serialize_javascript_1.serialize)((0, ssr_common_utils_1.useStore)()),
|
|
94
98
|
});
|
|
95
99
|
const injectState = React.createElement("script", { dangerouslySetInnerHTML: { __html: innerHTML } });
|
|
96
100
|
// with jsx type error, use createElement here
|
|
97
101
|
const ele = (0, react_1.createElement)(react_router_dom_1.StaticRouter, {
|
|
98
102
|
location: ctx.request.url,
|
|
99
|
-
basename: prefix ===
|
|
103
|
+
basename: prefix === "/" ? undefined : prefix,
|
|
100
104
|
}, (0, react_1.createElement)(context_1.AppContext, {
|
|
101
105
|
context: context,
|
|
102
106
|
initialState: combineData,
|
|
@@ -104,8 +108,8 @@ const serverRender = async (ctx, config) => {
|
|
|
104
108
|
ctx: ctx,
|
|
105
109
|
config: config,
|
|
106
110
|
staticList: staticList,
|
|
107
|
-
injectState: injectState
|
|
108
|
-
}, (0, react_1.createElement)(Component, null))
|
|
111
|
+
injectState: injectState,
|
|
112
|
+
}, (0, react_1.createElement)(Component, null)),
|
|
109
113
|
}));
|
|
110
114
|
// for ctx.body will loose asynclocalstorage context, consume stream in advance like vue2/3
|
|
111
115
|
if ((0, ssr_common_utils_1.isReact18)()) {
|
|
@@ -113,7 +117,7 @@ const serverRender = async (ctx, config) => {
|
|
|
113
117
|
? ReactDOMServer
|
|
114
118
|
.renderToPipeableStream(ele, {
|
|
115
119
|
onAllReady: onReady,
|
|
116
|
-
onError: onError
|
|
120
|
+
onError: onError,
|
|
117
121
|
})
|
|
118
122
|
.pipe(new stream_1.PassThrough({ highWaterMark: streamHighWaterMark }))
|
|
119
123
|
: ReactDOMServer.renderToString(ele);
|
|
@@ -127,7 +131,7 @@ const serverRender = async (ctx, config) => {
|
|
|
127
131
|
return await ssr_common_utils_1.localStorageWrapper.run({
|
|
128
132
|
context: context,
|
|
129
133
|
ctx,
|
|
130
|
-
store: (0, create_1.createStore)()
|
|
134
|
+
store: (0, create_1.createStore)(),
|
|
131
135
|
}, fn);
|
|
132
136
|
};
|
|
133
137
|
exports.serverRender = serverRender;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-entry.js","sourceRoot":"","sources":["../../src/entry/server-entry.tsx"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"server-entry.js","sourceRoot":"","sources":["../../src/entry/server-entry.tsx"],"names":[],"mappings":";;;AACA,mCAAqC;AACrC,+BAA+B;AAC/B,iCAAsC;AACtC,mDAAmD;AACnD,uDAAgD;AAChD,uDAc0B;AAE1B,uEAAqD;AACrD,uCAAuC;AACvC,qCAAiE;AAoL1C,uFApLd,eAAM,OAoLc;AAlL7B,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,eAAM,CAAC;AAKxD,MAAM,YAAY,GAAG,KAAK,EAAE,GAAgB,EAAE,MAAe,EAAE,EAAE;;IAC/D,MAAM,OAAO,GAAG,IAAA,yBAAgB,GAAE,CAAC;IACnC,MAAM,EACJ,IAAI,EACJ,aAAa,EACb,MAAM,EACN,MAAM,EACN,KAAK,EACL,YAAY,EACZ,OAAO,EACP,OAAO,EACP,MAAM,EACN,MAAM,EACN,UAAU,EACV,mBAAmB,GACpB,GAAG,MAAM,CAAC;IACX,MAAM,OAAO,GAAG,MAAA,GAAG,CAAC,OAAO,CAAC,IAAI,mCAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;IACpD,MAAM,IAAI,GAAG,IAAA,gCAAa,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5C,MAAM,SAAS,GAAG,IAAA,4BAAS,EAA6B,QAAQ,EAAE,IAAI,CAAC,CAAC;IACxE,IAAA,6BAAU,EAAC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