ssr-plugin-react 6.1.60 → 6.1.66
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 +46 -0
- package/README.md +2 -4
- package/cjs/entry/client-entry.js +2 -3
- package/cjs/entry/context.js +2 -3
- package/cjs/entry/create-router.d.ts +3 -0
- package/cjs/entry/create-router.js +26 -0
- package/cjs/entry/server-entry.js +2 -3
- package/esm/entry/client-entry.js +1 -2
- package/esm/entry/context.js +1 -2
- package/esm/entry/create-router.d.ts +3 -0
- package/esm/entry/create-router.js +23 -0
- package/esm/entry/server-entry.js +1 -2
- package/package.json +7 -7
- package/src/entry/client-entry.tsx +1 -2
- package/src/entry/context.tsx +1 -2
- package/src/entry/create-router.ts +28 -0
- package/src/entry/server-entry.tsx +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,52 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [6.1.66](https://github.com/zhangyuang/ssr/compare/v6.1.65...v6.1.66) (2022-02-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* create-router ([ee9c3fa](https://github.com/zhangyuang/ssr/commit/ee9c3fa5fe14f8e324edcf5da64bf1dd8e041891))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [6.1.65](https://github.com/zhangyuang/ssr/compare/v6.1.62...v6.1.65) (2022-02-17)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* support combine declareRouter with manualRouter ([c2b5482](https://github.com/zhangyuang/ssr/commit/c2b548284f8683c266e6e858d6a9eb91cb72bc50))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [6.1.64](https://github.com/zhangyuang/ssr/compare/v6.1.63...v6.1.64) (2022-02-15)
|
|
29
|
+
|
|
30
|
+
**Note:** Version bump only for package ssr-plugin-react
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## [6.1.63](https://github.com/zhangyuang/ssr/compare/v6.1.62...v6.1.63) (2022-02-15)
|
|
37
|
+
|
|
38
|
+
**Note:** Version bump only for package ssr-plugin-react
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## [6.1.62](https://github.com/zhangyuang/ssr/compare/v6.1.61...v6.1.62) (2022-02-15)
|
|
45
|
+
|
|
46
|
+
**Note:** Version bump only for package ssr-plugin-react
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
6
52
|
## [6.1.60](https://github.com/zhangyuang/ssr/compare/v6.1.59...v6.1.60) (2022-02-09)
|
|
7
53
|
|
|
8
54
|
|
package/README.md
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
<a href="https://github.com/zhangyuang/ssr/actions" target="_blank"><img src="https://github.com/zhangyuang/ssr/workflows/CI/badge.svg" alt="githubActions" />
|
|
17
17
|
<a href="https://www.cypress.io/" target="_blank"><img src="https://img.shields.io/badge/cypress-dashboard-brightgreen.svg" alt="cypress" />
|
|
18
18
|
<a href="https://npmcharts.com/compare/ssr" target="_blank"><img src="https://img.shields.io/npm/dm/ssr" alt="download" />
|
|
19
|
-
<a href="https://github.com/zhangyuang/ssr" target="_blank"><img src="https://img.shields.io/tokei/lines/github/zhangyuang/ssr-lines?color=4dc71f" alt="Node" />
|
|
20
19
|
<a href="https://github.com/zhangyuang/ssr" target="_blank"><img src="https://img.shields.io/badge/node-%3E=12-green.svg?color=4dc71f" alt="Node" ></a>
|
|
21
20
|
<a href="https://github.com/zhangyuang/ssr" target="_blank"><img src="https://img.shields.io/github/stars/zhangyuang/ssr.svg?color=4dc71f" alt="Node" ></a>
|
|
22
21
|
</div>
|
|
@@ -41,7 +40,6 @@
|
|
|
41
40
|
- 可能会改动技术栈,如从 `Vue2` 升级为 `Vue3`,从 `Vue3` 降级为 `Vue2` 或 `React/Vue` 互相切换
|
|
42
41
|
- 需要在服务端渲染场景下开箱即用使用 `antd` `vant` 等流行 `ui` 库
|
|
43
42
|
- 需要能够同时支持 `Webpack`, `Vite` 两种开发工具,以便同时得到快速的启动速度 `HMR` 速度以及稳定的生产环境代码
|
|
44
|
-
|
|
45
43
|
## 哪些应用在使用
|
|
46
44
|
|
|
47
45
|
正在使用这个项目的公司(应用), 如果您正在使用但名单中没有列出来的话请提 [issue](https://github.com/zhangyuang/ssr/issues),欢迎推广分享,我们将随时提供技术支持
|
|
@@ -127,7 +125,7 @@
|
|
|
127
125
|
- 🧲 插件驱动:基于插件架构,用户更加专注于业务逻辑;
|
|
128
126
|
- 💯 Serverless优先:一键发布到各种Serverless平台,也支持传统Web Server,比如Egg、Midway、Nest等。
|
|
129
127
|
- 🛡 高可用场景,可无缝从SSR降级到CSR,最佳容灾方案。
|
|
130
|
-
- 😄 功能丰富,构建工具支持 Webpack/Vite
|
|
128
|
+
- 😄 功能丰富,构建工具支持 Webpack/Vite,全新的 `Vue3 Script Setup` 支持
|
|
131
129
|
|
|
132
130
|
## 已实现的功能
|
|
133
131
|
|
|
@@ -273,7 +271,7 @@ $ npm run start:vite # 以 vite 模式启动,等价于 npx ssr start --vite
|
|
|
273
271
|
|
|
274
272
|
<div style="display:flex">
|
|
275
273
|
<!-- <img src="https://res.wx.qq.com/op_res/7F1t4Z8yCHWilehbcFGjAj0yVn0URMiWBGVJa-TVu_eqw5IwUXA2kPYBnfX6YRHy0FVBB-yC6l0IEL02QTJkLg" width="300"> -->
|
|
276
|
-
<img src="https://res.wx.qq.com/op_res/
|
|
274
|
+
<img src="https://res.wx.qq.com/op_res/yEMBkta89JhlC9RlNrTqXHshV4a6Wa-tBIBMZe9PjLoOJgtnLYjHQ4TQttfqJ4iYbqhSTEA4YI6TBWkO76-chA" width="300">
|
|
277
275
|
</div>
|
|
278
276
|
|
|
279
277
|
## 前端开发手册
|
|
@@ -6,10 +6,9 @@ const ReactDOM = require("react-dom");
|
|
|
6
6
|
const react_router_dom_1 = require("react-router-dom");
|
|
7
7
|
const ssr_client_utils_1 = require("ssr-client-utils");
|
|
8
8
|
const ssr_hoc_react_1 = require("ssr-hoc-react");
|
|
9
|
-
|
|
10
|
-
const Routes = require("_build/ssr-temporary-routes");
|
|
9
|
+
const create_router_1 = require("./create-router");
|
|
11
10
|
const context_1 = require("./context");
|
|
12
|
-
const { FeRoutes, layoutFetch, App, PrefixRouterBase } = Routes;
|
|
11
|
+
const { FeRoutes, layoutFetch, App, PrefixRouterBase } = create_router_1.Routes;
|
|
13
12
|
const clientRender = async () => {
|
|
14
13
|
var _a, _b, _c;
|
|
15
14
|
const IApp = App !== null && App !== void 0 ? App : function (props) {
|
package/cjs/entry/context.js
CHANGED
|
@@ -5,9 +5,8 @@ const React = require("react");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
// @ts-expect-error
|
|
7
7
|
const create_context_1 = require("_build/create-context");
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const { reducer, state } = Routes;
|
|
8
|
+
const create_router_1 = require("./create-router");
|
|
9
|
+
const { reducer, state } = create_router_1.Routes;
|
|
11
10
|
const userState = state !== null && state !== void 0 ? state : {};
|
|
12
11
|
const userReducer = reducer !== null && reducer !== void 0 ? reducer : function () { };
|
|
13
12
|
const isDev = process.env.NODE_ENV !== 'production';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Routes = void 0;
|
|
4
|
+
// @ts-expect-error
|
|
5
|
+
const declareRoutes = require("_build/ssr-temporary-routes");
|
|
6
|
+
// @ts-expect-error
|
|
7
|
+
const ManualRoutes = require("_build/ssr-manual-routes");
|
|
8
|
+
const declareRoutesWithType = declareRoutes;
|
|
9
|
+
const ManualRoutesWithType = ManualRoutes;
|
|
10
|
+
const Routes = {
|
|
11
|
+
...declareRoutes,
|
|
12
|
+
...ManualRoutesWithType
|
|
13
|
+
};
|
|
14
|
+
exports.Routes = Routes;
|
|
15
|
+
if (ManualRoutesWithType.FeRoutes) {
|
|
16
|
+
// 声明式路由覆盖约定式路由同名path
|
|
17
|
+
const combineRoutes = declareRoutesWithType.FeRoutes.map(route => { var _a; return (_a = ManualRoutesWithType.FeRoutes.find(e => e.path === route.path)) !== null && _a !== void 0 ? _a : route; });
|
|
18
|
+
ManualRoutesWithType.FeRoutes.forEach(route => {
|
|
19
|
+
// 补充声明式路由新增的配置
|
|
20
|
+
const found = combineRoutes.find(e => e.path === route.path);
|
|
21
|
+
if (!found) {
|
|
22
|
+
combineRoutes.push(route);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Routes.FeRoutes = combineRoutes;
|
|
26
|
+
}
|
|
@@ -7,12 +7,11 @@ const ssr_server_utils_1 = require("ssr-server-utils");
|
|
|
7
7
|
// @ts-expect-error
|
|
8
8
|
const serializeWrap = require("serialize-javascript");
|
|
9
9
|
// @ts-expect-error
|
|
10
|
-
const Routes = require("_build/ssr-temporary-routes");
|
|
11
|
-
// @ts-expect-error
|
|
12
10
|
const create_context_1 = require("_build/create-context");
|
|
13
11
|
// @ts-expect-error
|
|
14
12
|
const index_tsx_1 = require("@/components/layout/index.tsx");
|
|
15
|
-
const
|
|
13
|
+
const create_router_1 = require("./create-router");
|
|
14
|
+
const { FeRoutes, layoutFetch, PrefixRouterBase, state } = create_router_1.Routes;
|
|
16
15
|
const serialize = serializeWrap.default || serializeWrap;
|
|
17
16
|
const serverRender = async (ctx, config) => {
|
|
18
17
|
var _a;
|
|
@@ -3,8 +3,7 @@ import * as ReactDOM from 'react-dom';
|
|
|
3
3
|
import { BrowserRouter, Route, Switch } from 'react-router-dom';
|
|
4
4
|
import { preloadComponent } from 'ssr-client-utils';
|
|
5
5
|
import { wrapComponent } from 'ssr-hoc-react';
|
|
6
|
-
|
|
7
|
-
import * as Routes from '_build/ssr-temporary-routes';
|
|
6
|
+
import { Routes } from './create-router';
|
|
8
7
|
import { AppContext } from './context';
|
|
9
8
|
const { FeRoutes, layoutFetch, App, PrefixRouterBase } = Routes;
|
|
10
9
|
const clientRender = async () => {
|
package/esm/entry/context.js
CHANGED
|
@@ -2,8 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { useReducer } from 'react';
|
|
3
3
|
// @ts-expect-error
|
|
4
4
|
import { STORE_CONTEXT } from '_build/create-context';
|
|
5
|
-
|
|
6
|
-
import * as Routes from '_build/ssr-temporary-routes';
|
|
5
|
+
import { Routes } from './create-router';
|
|
7
6
|
const { reducer, state } = Routes;
|
|
8
7
|
const userState = state !== null && state !== void 0 ? state : {};
|
|
9
8
|
const userReducer = reducer !== null && reducer !== void 0 ? reducer : function () { };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// @ts-expect-error
|
|
2
|
+
import * as declareRoutes from '_build/ssr-temporary-routes';
|
|
3
|
+
// @ts-expect-error
|
|
4
|
+
import * as ManualRoutes from '_build/ssr-manual-routes';
|
|
5
|
+
const declareRoutesWithType = declareRoutes;
|
|
6
|
+
const ManualRoutesWithType = ManualRoutes;
|
|
7
|
+
const Routes = {
|
|
8
|
+
...declareRoutes,
|
|
9
|
+
...ManualRoutesWithType
|
|
10
|
+
};
|
|
11
|
+
if (ManualRoutesWithType.FeRoutes) {
|
|
12
|
+
// 声明式路由覆盖约定式路由同名path
|
|
13
|
+
const combineRoutes = declareRoutesWithType.FeRoutes.map(route => { var _a; return (_a = ManualRoutesWithType.FeRoutes.find(e => e.path === route.path)) !== null && _a !== void 0 ? _a : route; });
|
|
14
|
+
ManualRoutesWithType.FeRoutes.forEach(route => {
|
|
15
|
+
// 补充声明式路由新增的配置
|
|
16
|
+
const found = combineRoutes.find(e => e.path === route.path);
|
|
17
|
+
if (!found) {
|
|
18
|
+
combineRoutes.push(route);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
Routes.FeRoutes = combineRoutes;
|
|
22
|
+
}
|
|
23
|
+
export { Routes };
|
|
@@ -4,11 +4,10 @@ import { findRoute, getManifest, logGreen, normalizePath, addAsyncChunk } from '
|
|
|
4
4
|
// @ts-expect-error
|
|
5
5
|
import * as serializeWrap from 'serialize-javascript';
|
|
6
6
|
// @ts-expect-error
|
|
7
|
-
import * as Routes from '_build/ssr-temporary-routes';
|
|
8
|
-
// @ts-expect-error
|
|
9
7
|
import { STORE_CONTEXT as Context } from '_build/create-context';
|
|
10
8
|
// @ts-expect-error
|
|
11
9
|
import Layout from '@/components/layout/index.tsx';
|
|
10
|
+
import { Routes } from './create-router';
|
|
12
11
|
const { FeRoutes, layoutFetch, PrefixRouterBase, state } = Routes;
|
|
13
12
|
const serialize = serializeWrap.default || serializeWrap;
|
|
14
13
|
const serverRender = async (ctx, config) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssr-plugin-react",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.66",
|
|
4
4
|
"description": "plugin-react for ssr",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"postcss-safe-parser": "4.0.1",
|
|
56
56
|
"react-dev-utils": "^11.0.4",
|
|
57
57
|
"serialize-javascript": "^6.0.0",
|
|
58
|
-
"ssr-client-utils": "^6.1.
|
|
59
|
-
"ssr-hoc-react": "^6.1.
|
|
60
|
-
"ssr-server-utils": "^6.1.
|
|
61
|
-
"ssr-webpack": "^6.1.
|
|
58
|
+
"ssr-client-utils": "^6.1.62",
|
|
59
|
+
"ssr-hoc-react": "^6.1.65",
|
|
60
|
+
"ssr-server-utils": "^6.1.65",
|
|
61
|
+
"ssr-webpack": "^6.1.65",
|
|
62
62
|
"terser-webpack-plugin": "^2.3.5",
|
|
63
63
|
"url-loader": "^4.1.1",
|
|
64
64
|
"vite": "^2.7.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@types/react-router-dom": "^5.1.3",
|
|
75
75
|
"@types/webpack": "^4.41.10",
|
|
76
76
|
"concurrently": "^5.1.0",
|
|
77
|
-
"ssr-types-react": "^6.1.
|
|
77
|
+
"ssr-types-react": "^6.1.62"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "820d4b06b19190d48dc0bf29b11a40732f6ba40b"
|
|
80
80
|
}
|
|
@@ -4,8 +4,7 @@ import { BrowserRouter, Route, Switch } from 'react-router-dom'
|
|
|
4
4
|
import { preloadComponent } from 'ssr-client-utils'
|
|
5
5
|
import { wrapComponent } from 'ssr-hoc-react'
|
|
6
6
|
import { IWindow, LayoutProps, ReactESMFeRouteItem, ReactRoutesType } from 'ssr-types-react'
|
|
7
|
-
|
|
8
|
-
import * as Routes from '_build/ssr-temporary-routes'
|
|
7
|
+
import { Routes } from './create-router'
|
|
9
8
|
import { AppContext } from './context'
|
|
10
9
|
|
|
11
10
|
const { FeRoutes, layoutFetch, App, PrefixRouterBase } = Routes as ReactRoutesType
|
package/src/entry/context.tsx
CHANGED
|
@@ -4,8 +4,7 @@ import { IProps, Action, IWindow, ReactRoutesType } from 'ssr-types-react'
|
|
|
4
4
|
|
|
5
5
|
// @ts-expect-error
|
|
6
6
|
import { STORE_CONTEXT } from '_build/create-context'
|
|
7
|
-
|
|
8
|
-
import * as Routes from '_build/ssr-temporary-routes'
|
|
7
|
+
import { Routes } from './create-router'
|
|
9
8
|
|
|
10
9
|
const { reducer, state } = Routes as ReactRoutesType
|
|
11
10
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// @ts-expect-error
|
|
2
|
+
import * as declareRoutes from '_build/ssr-temporary-routes'
|
|
3
|
+
// @ts-expect-error
|
|
4
|
+
import * as ManualRoutes from '_build/ssr-manual-routes'
|
|
5
|
+
import { ReactRoutesType } from 'ssr-types-react'
|
|
6
|
+
|
|
7
|
+
const declareRoutesWithType = declareRoutes as ReactRoutesType
|
|
8
|
+
const ManualRoutesWithType = ManualRoutes as ReactRoutesType
|
|
9
|
+
|
|
10
|
+
const Routes: ReactRoutesType = {
|
|
11
|
+
...declareRoutes,
|
|
12
|
+
...ManualRoutesWithType
|
|
13
|
+
}
|
|
14
|
+
if (ManualRoutesWithType.FeRoutes) {
|
|
15
|
+
// 声明式路由覆盖约定式路由同名path
|
|
16
|
+
const combineRoutes = declareRoutesWithType.FeRoutes.map(route => ManualRoutesWithType.FeRoutes.find(e => e.path === route.path) ?? route)
|
|
17
|
+
ManualRoutesWithType.FeRoutes.forEach(route => {
|
|
18
|
+
// 补充声明式路由新增的配置
|
|
19
|
+
const found = combineRoutes.find(e => e.path === route.path)
|
|
20
|
+
if (!found) {
|
|
21
|
+
combineRoutes.push(route)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
Routes.FeRoutes = combineRoutes
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
Routes
|
|
28
|
+
}
|
|
@@ -5,11 +5,10 @@ import { ISSRContext, IConfig, ReactRoutesType, ReactESMFeRouteItem } from 'ssr-
|
|
|
5
5
|
// @ts-expect-error
|
|
6
6
|
import * as serializeWrap from 'serialize-javascript'
|
|
7
7
|
// @ts-expect-error
|
|
8
|
-
import * as Routes from '_build/ssr-temporary-routes'
|
|
9
|
-
// @ts-expect-error
|
|
10
8
|
import { STORE_CONTEXT as Context } from '_build/create-context'
|
|
11
9
|
// @ts-expect-error
|
|
12
10
|
import Layout from '@/components/layout/index.tsx'
|
|
11
|
+
import { Routes } from './create-router'
|
|
13
12
|
|
|
14
13
|
const { FeRoutes, layoutFetch, PrefixRouterBase, state } = Routes as ReactRoutesType
|
|
15
14
|
const serialize = serializeWrap.default || serializeWrap
|