ssr-plugin-react 6.1.62 → 6.1.67
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 +49 -0
- package/README.md +2 -2
- 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/cjs/tools/vite.js +3 -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/esm/tools/vite.js +3 -3
- 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 +28 -0
- package/src/entry/server-entry.tsx +1 -2
- package/src/tools/vite.ts +5 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,55 @@
|
|
|
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.67](https://github.com/zhangyuang/ssr/compare/v6.1.66...v6.1.67) (2022-02-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* transform route.ts by esbuild ([1719168](https://github.com/zhangyuang/ssr/commit/17191687db5dc6805b5bbcf5dcd8f80d8d29bbde))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [6.1.66](https://github.com/zhangyuang/ssr/compare/v6.1.65...v6.1.66) (2022-02-18)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* create-router ([ee9c3fa](https://github.com/zhangyuang/ssr/commit/ee9c3fa5fe14f8e324edcf5da64bf1dd8e041891))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [6.1.65](https://github.com/zhangyuang/ssr/compare/v6.1.62...v6.1.65) (2022-02-17)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* support combine declareRouter with manualRouter ([c2b5482](https://github.com/zhangyuang/ssr/commit/c2b548284f8683c266e6e858d6a9eb91cb72bc50))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [6.1.64](https://github.com/zhangyuang/ssr/compare/v6.1.63...v6.1.64) (2022-02-15)
|
|
40
|
+
|
|
41
|
+
**Note:** Version bump only for package ssr-plugin-react
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## [6.1.63](https://github.com/zhangyuang/ssr/compare/v6.1.62...v6.1.63) (2022-02-15)
|
|
48
|
+
|
|
49
|
+
**Note:** Version bump only for package ssr-plugin-react
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
6
55
|
## [6.1.62](https://github.com/zhangyuang/ssr/compare/v6.1.61...v6.1.62) (2022-02-15)
|
|
7
56
|
|
|
8
57
|
**Note:** Version bump only for package ssr-plugin-react
|
package/README.md
CHANGED
|
@@ -188,7 +188,7 @@ $ npm run build # 资源构建,等价于 npx ssr build
|
|
|
188
188
|
$ npm run start:vite # 以 vite 模式启动,等价于 npx ssr start --vite
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
-

|
|
192
192
|
|
|
193
193
|
## 线上案例
|
|
194
194
|
|
|
@@ -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,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-declare-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;
|
package/cjs/tools/vite.js
CHANGED
|
@@ -42,12 +42,12 @@ const serverConfig = {
|
|
|
42
42
|
build: {
|
|
43
43
|
ssr: reactServerEntry,
|
|
44
44
|
outDir: serverOutPut,
|
|
45
|
-
rollupOptions:
|
|
46
|
-
|
|
45
|
+
rollupOptions: {
|
|
46
|
+
input: isDev ? reactClientEntry : reactServerEntry,
|
|
47
47
|
output: {
|
|
48
48
|
entryFileNames: 'Page.server.js'
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|
|
51
51
|
},
|
|
52
52
|
define: {
|
|
53
53
|
__isBrowser__: false,
|
|
@@ -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-declare-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/esm/tools/vite.js
CHANGED
|
@@ -39,12 +39,12 @@ const serverConfig = {
|
|
|
39
39
|
build: {
|
|
40
40
|
ssr: reactServerEntry,
|
|
41
41
|
outDir: serverOutPut,
|
|
42
|
-
rollupOptions:
|
|
43
|
-
|
|
42
|
+
rollupOptions: {
|
|
43
|
+
input: isDev ? reactClientEntry : reactServerEntry,
|
|
44
44
|
output: {
|
|
45
45
|
entryFileNames: 'Page.server.js'
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
48
|
},
|
|
49
49
|
define: {
|
|
50
50
|
__isBrowser__: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssr-plugin-react",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.67",
|
|
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.67",
|
|
61
|
+
"ssr-webpack": "^6.1.67",
|
|
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": "ff46d4ed1b0c5bb4b0557d91c564bc360cfa051e"
|
|
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-declare-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
|
package/src/tools/vite.ts
CHANGED
|
@@ -40,14 +40,12 @@ const serverConfig: UserConfig = {
|
|
|
40
40
|
build: {
|
|
41
41
|
ssr: reactServerEntry,
|
|
42
42
|
outDir: serverOutPut,
|
|
43
|
-
rollupOptions:
|
|
44
|
-
isDev ?
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
entryFileNames: 'Page.server.js'
|
|
48
|
-
}
|
|
43
|
+
rollupOptions: {
|
|
44
|
+
input: isDev ? reactClientEntry : reactServerEntry, // setting prebundle list by client-entry in dev
|
|
45
|
+
output: {
|
|
46
|
+
entryFileNames: 'Page.server.js'
|
|
49
47
|
}
|
|
50
|
-
|
|
48
|
+
}
|
|
51
49
|
},
|
|
52
50
|
define: {
|
|
53
51
|
__isBrowser__: false,
|