ssr-plugin-react 6.1.59 → 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 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.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
+
17
+ ## [6.1.64](https://github.com/zhangyuang/ssr/compare/v6.1.63...v6.1.64) (2022-02-15)
18
+
19
+ **Note:** Version bump only for package ssr-plugin-react
20
+
21
+
22
+
23
+
24
+
25
+ ## [6.1.63](https://github.com/zhangyuang/ssr/compare/v6.1.62...v6.1.63) (2022-02-15)
26
+
27
+ **Note:** Version bump only for package ssr-plugin-react
28
+
29
+
30
+
31
+
32
+
33
+ ## [6.1.62](https://github.com/zhangyuang/ssr/compare/v6.1.61...v6.1.62) (2022-02-15)
34
+
35
+ **Note:** Version bump only for package ssr-plugin-react
36
+
37
+
38
+
39
+
40
+
41
+ ## [6.1.60](https://github.com/zhangyuang/ssr/compare/v6.1.59...v6.1.60) (2022-02-09)
42
+
43
+
44
+ ### Bug Fixes
45
+
46
+ * vite production inputOptions ([573b219](https://github.com/zhangyuang/ssr/commit/573b2193b2aef17a814abf8c0d8f53d6f7ba7719))
47
+
48
+
49
+
50
+
51
+
6
52
  ## [6.1.59](https://github.com/zhangyuang/ssr/compare/v6.1.58...v6.1.59) (2022-02-08)
7
53
 
8
54
  **Note:** Version bump only for package ssr-plugin-react
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/UQMlAGgJt38dZ0iX_udYYLvwceEOo5w6OAcZ5XodX_aMSZ_cpvCtpbfQaLGkPnDMoK0Rnbhgr7FjpQ8YUjaX-Q" width="300">
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
- // @ts-expect-error
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) {
@@ -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
- // @ts-expect-error
9
- const Routes = require("_build/ssr-temporary-routes");
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,3 @@
1
+ import { ReactRoutesType } from 'ssr-types-react';
2
+ declare const Routes: ReactRoutesType;
3
+ export { Routes };
@@ -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 { FeRoutes, layoutFetch, PrefixRouterBase, state } = Routes;
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
- input: isDev ? reactClientEntry : '',
45
+ rollupOptions: Object.assign(isDev ? { input: reactClientEntry } : {}, // setting prebundle list by client-entry in dev
46
+ {
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
- // @ts-expect-error
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 () => {
@@ -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
- // @ts-expect-error
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,3 @@
1
+ import { ReactRoutesType } from 'ssr-types-react';
2
+ declare const Routes: ReactRoutesType;
3
+ export { Routes };
@@ -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/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
- input: isDev ? reactClientEntry : '',
42
+ rollupOptions: Object.assign(isDev ? { input: reactClientEntry } : {}, // setting prebundle list by client-entry in dev
43
+ {
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.59",
3
+ "version": "6.1.65",
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.58",
59
- "ssr-hoc-react": "^6.1.58",
60
- "ssr-server-utils": "^6.1.59",
61
- "ssr-webpack": "^6.1.59",
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.58"
77
+ "ssr-types-react": "^6.1.62"
78
78
  },
79
- "gitHead": "0522f203047ff136e651958834684251d5fe36e5"
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
- // @ts-expect-error
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
@@ -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
- // @ts-expect-error
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
package/src/tools/vite.ts CHANGED
@@ -40,12 +40,14 @@ const serverConfig: UserConfig = {
40
40
  build: {
41
41
  ssr: reactServerEntry,
42
42
  outDir: serverOutPut,
43
- rollupOptions: {
44
- input: isDev ? reactClientEntry : '',
45
- output: {
46
- entryFileNames: 'Page.server.js'
43
+ rollupOptions: Object.assign(
44
+ isDev ? { input: reactClientEntry } : {}, // setting prebundle list by client-entry in dev
45
+ {
46
+ output: {
47
+ entryFileNames: 'Page.server.js'
48
+ }
47
49
  }
48
- }
50
+ )
49
51
  },
50
52
  define: {
51
53
  __isBrowser__: false,