ssr-plugin-react 6.1.3 → 6.1.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 CHANGED
@@ -3,6 +3,44 @@
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.7](https://github.com/ykfe/ssr/compare/ssr-plugin-react@6.1.6...ssr-plugin-react@6.1.7) (2021-11-22)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * restore staicRouter ([1150a6c](https://github.com/ykfe/ssr/commit/1150a6c4e4fe17d4416e35d619f8aac10837a7b8))
12
+
13
+
14
+
15
+
16
+
17
+ ## [6.1.6](https://github.com/ykfe/ssr/compare/ssr-plugin-react@6.1.5...ssr-plugin-react@6.1.6) (2021-11-19)
18
+
19
+ **Note:** Version bump only for package ssr-plugin-react
20
+
21
+
22
+
23
+
24
+
25
+ ## [6.1.5](https://github.com/ykfe/ssr/compare/ssr-plugin-react@6.1.4...ssr-plugin-react@6.1.5) (2021-11-18)
26
+
27
+ **Note:** Version bump only for package ssr-plugin-react
28
+
29
+
30
+
31
+
32
+
33
+ ## [6.1.4](https://github.com/ykfe/ssr/compare/ssr-plugin-react@6.1.3...ssr-plugin-react@6.1.4) (2021-11-17)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ *  boolean GENERATE_SOURCEMAP ([#133](https://github.com/ykfe/ssr/issues/133)) ([dbaeed8](https://github.com/ykfe/ssr/commit/dbaeed8efcf3d232c5754b2cfd6f3a664596610c))
39
+
40
+
41
+
42
+
43
+
6
44
  ## [6.1.3](https://github.com/ykfe/ssr/compare/ssr-plugin-react@6.1.2...ssr-plugin-react@6.1.3) (2021-11-07)
7
45
 
8
46
  **Note:** Version bump only for package ssr-plugin-react
package/README.md CHANGED
@@ -103,6 +103,9 @@
103
103
  <td align="center" style="height: 100px"><a href="https://blog.dreamer2q.wang/" target="_blank"><img src="https://res.wx.qq.com/op_res/MxxGgjPFRiTgjiReUefs2aMce-SgNvxxTB9U87YYhcOu6KPw9er7r2Lc0ne-b90nFstTUpc8REDwpxfUreKV1g" width="200px;margin: 20px 0" alt="Dream2qBlog"/><br />
104
104
  <a href="https://blog.dreamer2q.wang/" target="_bvlank"><b>个人博客
105
105
  </b></a></td>
106
+ <td align="center" style="height: 100px"><a href="https://jiawu.dewu.com" target="_blank"><img src="https://cdn.poizon.com/node-common/31116a45953ad8b468c6c832036aac88.png" width="200px;margin: 20px 0" alt="Dream2qBlog"/><br />
107
+ <a href="https://jiawu.dewu.com" target="_bvlank"><b>得物
108
+ </b></a></td>
106
109
  </tr>
107
110
  </table>
108
111
 
@@ -259,7 +262,7 @@ $ npm run start:vite # 以 vite 模式启动,等价于 npx ssr start --vite
259
262
 
260
263
  <div style="display:flex">
261
264
  <img src="https://res.wx.qq.com/op_res/7F1t4Z8yCHWilehbcFGjAj0yVn0URMiWBGVJa-TVu_eqw5IwUXA2kPYBnfX6YRHy0FVBB-yC6l0IEL02QTJkLg" width="300">
262
- <img src="https://res.wx.qq.com/op_res/5ApFtMe8Bx0buRwIkD2USbwyyXNEVYR_KkOmGri9hv9NV8PhpfWTD0lPlZwPM1MeKVrPnCouEAdP0R_do_CNqQ" width="300">
265
+ <img src="https://res.wx.qq.com/op_res/LKApEGZg8dfVdons6UrO3dU1NRHcIes4wn3WQqHI60FOyMB5VlhYWiPiZjB-NlijbCZTX4Za4-isfAQSMK58pw" width="300">
263
266
  </div>
264
267
 
265
268
  ## 前端开发手册
@@ -13,7 +13,7 @@ const loadModule = require.resolve;
13
13
  let asyncChunkMap = {};
14
14
  const getClientWebpack = (chain) => {
15
15
  const { isDev, chunkName, getOutput, cwd, useHash, chainClientConfig } = (0, ssr_server_utils_1.loadConfig)();
16
- const shouldUseSourceMap = isDev || process.env.GENERATE_SOURCEMAP;
16
+ const shouldUseSourceMap = isDev || Boolean(process.env.GENERATE_SOURCEMAP);
17
17
  const publicPath = (0, ssr_server_utils_1.getOutputPublicPath)();
18
18
  (0, base_1.getBaseConfig)(chain, false);
19
19
  chain.devtool(isDev ? 'cheap-module-source-map' : (shouldUseSourceMap ? 'source-map' : false));
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.serverRender = void 0;
4
4
  const React = require("react");
5
+ const react_router_dom_1 = require("react-router-dom");
5
6
  const ssr_server_utils_1 = require("ssr-server-utils");
6
7
  const serialize = require("serialize-javascript");
7
8
  // @ts-expect-error
@@ -96,7 +97,8 @@ const serverRender = async (ctx, config) => {
96
97
  const injectState = isCsr ? null : React.createElement("script", { dangerouslySetInnerHTML: {
97
98
  __html: `window.__USE_SSR__=true; window.__INITIAL_DATA__ =${serialize(combineData)}`
98
99
  } });
99
- return (React.createElement(create_context_1.STORE_CONTEXT.Provider, { value: { state: combineData } },
100
- React.createElement(index_tsx_1.default, { ctx: ctx, config: config, staticList: staticList, injectState: injectState }, isCsr ? React.createElement(React.Fragment, null) : React.createElement(Component, null))));
100
+ return (React.createElement(react_router_dom_1.StaticRouter, null,
101
+ React.createElement(create_context_1.STORE_CONTEXT.Provider, { value: { state: combineData } },
102
+ React.createElement(index_tsx_1.default, { ctx: ctx, config: config, staticList: staticList, injectState: injectState }, isCsr ? React.createElement(React.Fragment, null) : React.createElement(Component, null)))));
101
103
  };
102
104
  exports.serverRender = serverRender;
@@ -10,7 +10,7 @@ const loadModule = require.resolve;
10
10
  let asyncChunkMap = {};
11
11
  const getClientWebpack = (chain) => {
12
12
  const { isDev, chunkName, getOutput, cwd, useHash, chainClientConfig } = loadConfig();
13
- const shouldUseSourceMap = isDev || process.env.GENERATE_SOURCEMAP;
13
+ const shouldUseSourceMap = isDev || Boolean(process.env.GENERATE_SOURCEMAP);
14
14
  const publicPath = getOutputPublicPath();
15
15
  getBaseConfig(chain, false);
16
16
  chain.devtool(isDev ? 'cheap-module-source-map' : (shouldUseSourceMap ? 'source-map' : false));
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { StaticRouter } from 'react-router-dom';
2
3
  import { findRoute, getManifest, logGreen, normalizePath, addAsyncChunk } from 'ssr-server-utils';
3
4
  import * as serialize from 'serialize-javascript';
4
5
  // @ts-expect-error
@@ -93,7 +94,8 @@ const serverRender = async (ctx, config) => {
93
94
  const injectState = isCsr ? null : React.createElement("script", { dangerouslySetInnerHTML: {
94
95
  __html: `window.__USE_SSR__=true; window.__INITIAL_DATA__ =${serialize(combineData)}`
95
96
  } });
96
- return (React.createElement(Context.Provider, { value: { state: combineData } },
97
- React.createElement(Layout, { ctx: ctx, config: config, staticList: staticList, injectState: injectState }, isCsr ? React.createElement(React.Fragment, null) : React.createElement(Component, null))));
97
+ return (React.createElement(StaticRouter, null,
98
+ React.createElement(Context.Provider, { value: { state: combineData } },
99
+ React.createElement(Layout, { ctx: ctx, config: config, staticList: staticList, injectState: injectState }, isCsr ? React.createElement(React.Fragment, null) : React.createElement(Component, null)))));
98
100
  };
99
101
  export { serverRender };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssr-plugin-react",
3
- "version": "6.1.3",
3
+ "version": "6.1.7",
4
4
  "description": "plugin-react for ssr",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -53,10 +53,10 @@
53
53
  "postcss-safe-parser": "4.0.1",
54
54
  "react-dev-utils": "^11.0.4",
55
55
  "serialize-javascript": "^3.0.0",
56
- "ssr-client-utils": "^5.6.37",
57
- "ssr-hoc-react": "^6.0.3",
58
- "ssr-server-utils": "^5.7.6",
59
- "ssr-webpack": "^5.7.5",
56
+ "ssr-client-utils": "^5.6.39",
57
+ "ssr-hoc-react": "^6.0.6",
58
+ "ssr-server-utils": "^5.7.8",
59
+ "ssr-webpack": "^5.7.7",
60
60
  "terser-webpack-plugin": "^2.3.5",
61
61
  "url-loader": "^4.1.1",
62
62
  "webpack-bundle-analyzer": "^3.6.1",
@@ -70,7 +70,7 @@
70
70
  "@types/react-router-dom": "^5.1.3",
71
71
  "@types/serialize-javascript": "^1.5.0",
72
72
  "@types/webpack": "^4.41.10",
73
- "ssr-types-react": "^6.0.3"
73
+ "ssr-types-react": "^6.0.5"
74
74
  },
75
- "gitHead": "c6832ec680e252bff73ab1721cb49dbdbf67e52a"
75
+ "gitHead": "f48f8edfcbf902c4035694bcadac421046d13c52"
76
76
  }
@@ -13,7 +13,7 @@ let asyncChunkMap: Record<string, string> = {}
13
13
 
14
14
  const getClientWebpack = (chain: WebpackChain) => {
15
15
  const { isDev, chunkName, getOutput, cwd, useHash, chainClientConfig } = loadConfig()
16
- const shouldUseSourceMap = isDev || process.env.GENERATE_SOURCEMAP
16
+ const shouldUseSourceMap = isDev || Boolean(process.env.GENERATE_SOURCEMAP)
17
17
  const publicPath = getOutputPublicPath()
18
18
  getBaseConfig(chain, false)
19
19
  chain.devtool(isDev ? 'cheap-module-source-map' : (shouldUseSourceMap ? 'source-map' : false))
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react'
2
+ import { StaticRouter } from 'react-router-dom'
2
3
  import { findRoute, getManifest, logGreen, normalizePath, addAsyncChunk } from 'ssr-server-utils'
3
4
  import { ISSRContext, IGlobal, IConfig, ReactRoutesType, ReactESMFeRouteItem } from 'ssr-types-react'
4
5
  import * as serialize from 'serialize-javascript'
@@ -109,11 +110,13 @@ const serverRender = async (ctx: ISSRContext, config: IConfig): Promise<React.Re
109
110
  }} />
110
111
 
111
112
  return (
112
- <Context.Provider value={{ state: combineData }}>
113
- <Layout ctx={ctx} config={config} staticList={staticList} injectState={injectState}>
114
- {isCsr ? <></> : <Component />}
115
- </Layout>
116
- </Context.Provider>
113
+ <StaticRouter>
114
+ <Context.Provider value={{ state: combineData }}>
115
+ <Layout ctx={ctx} config={config} staticList={staticList} injectState={injectState}>
116
+ {isCsr ? <></> : <Component />}
117
+ </Layout>
118
+ </Context.Provider>
119
+ </StaticRouter>
117
120
  )
118
121
  }
119
122