ssr-plugin-react 6.1.64 → 6.1.65
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 +11 -0
- package/README.md +1 -1
- 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 +29 -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 +26 -0
- package/esm/entry/server-entry.js +1 -2
- package/package.json +5 -5
- package/src/entry/client-entry.tsx +1 -2
- package/src/entry/context.tsx +1 -2
- package/src/entry/create-router.ts +31 -0
- package/src/entry/server-entry.tsx +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.65](https://github.com/zhangyuang/ssr/compare/v6.1.62...v6.1.65) (2022-02-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* support combine declareRouter with manualRouter ([c2b5482](https://github.com/zhangyuang/ssr/commit/c2b548284f8683c266e6e858d6a9eb91cb72bc50))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [6.1.64](https://github.com/zhangyuang/ssr/compare/v6.1.63...v6.1.64) (2022-02-15)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package ssr-plugin-react
|
package/README.md
CHANGED
|
@@ -271,7 +271,7 @@ $ npm run start:vite # 以 vite 模式启动,等价于 npx ssr start --vite
|
|
|
271
271
|
|
|
272
272
|
<div style="display:flex">
|
|
273
273
|
<!-- <img src="https://res.wx.qq.com/op_res/7F1t4Z8yCHWilehbcFGjAj0yVn0URMiWBGVJa-TVu_eqw5IwUXA2kPYBnfX6YRHy0FVBB-yC6l0IEL02QTJkLg" width="300"> -->
|
|
274
|
-
<img src="https://res.wx.qq.com/op_res/
|
|
274
|
+
<img src="https://res.wx.qq.com/op_res/yEMBkta89JhlC9RlNrTqXHshV4a6Wa-tBIBMZe9PjLoOJgtnLYjHQ4TQttfqJ4iYbqhSTEA4YI6TBWkO76-chA" width="300">
|
|
275
275
|
</div>
|
|
276
276
|
|
|
277
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,29 @@
|
|
|
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 => {
|
|
18
|
+
const found = ManualRoutesWithType.FeRoutes.find(e => e.path === route.path);
|
|
19
|
+
return found !== null && found !== void 0 ? found : route;
|
|
20
|
+
});
|
|
21
|
+
declareRoutesWithType.FeRoutes.forEach(route => {
|
|
22
|
+
// 补充声明式路由新增的配置
|
|
23
|
+
const found = combineRoutes.find(e => e.path === route.path);
|
|
24
|
+
if (!found) {
|
|
25
|
+
combineRoutes.push(route);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
Routes.FeRoutes = combineRoutes;
|
|
29
|
+
}
|
|
@@ -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,26 @@
|
|
|
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 => {
|
|
14
|
+
const found = ManualRoutesWithType.FeRoutes.find(e => e.path === route.path);
|
|
15
|
+
return found !== null && found !== void 0 ? found : route;
|
|
16
|
+
});
|
|
17
|
+
declareRoutesWithType.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 { 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.65",
|
|
4
4
|
"description": "plugin-react for ssr",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"react-dev-utils": "^11.0.4",
|
|
57
57
|
"serialize-javascript": "^6.0.0",
|
|
58
58
|
"ssr-client-utils": "^6.1.62",
|
|
59
|
-
"ssr-hoc-react": "^6.1.
|
|
60
|
-
"ssr-server-utils": "^6.1.
|
|
61
|
-
"ssr-webpack": "^6.1.
|
|
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",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"concurrently": "^5.1.0",
|
|
77
77
|
"ssr-types-react": "^6.1.62"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "21a0f367b85a4aaab35fc35465ee62facaf2ff16"
|
|
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,31 @@
|
|
|
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 => {
|
|
17
|
+
const found = ManualRoutesWithType.FeRoutes.find(e => e.path === route.path)
|
|
18
|
+
return found ?? route
|
|
19
|
+
})
|
|
20
|
+
declareRoutesWithType.FeRoutes.forEach(route => {
|
|
21
|
+
// 补充声明式路由新增的配置
|
|
22
|
+
const found = combineRoutes.find(e => e.path === route.path)
|
|
23
|
+
if (!found) {
|
|
24
|
+
combineRoutes.push(route)
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
Routes.FeRoutes = combineRoutes
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
Routes
|
|
31
|
+
}
|
|
@@ -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
|