ssr-plugin-react 6.1.68 → 6.1.71
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 +34 -0
- package/README.md +4 -3
- package/cjs/config/index.js +5 -1
- package/cjs/entry/server-entry.js +1 -1
- package/cjs/index.js +5 -1
- package/cjs/tools/vite.js +6 -7
- package/esm/entry/server-entry.js +1 -1
- package/esm/tools/vite.js +6 -7
- package/package.json +14 -13
- package/src/entry/server-entry.tsx +1 -2
- package/src/tools/vite.ts +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,40 @@
|
|
|
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.71](https://github.com/zhangyuang/ssr/compare/v6.1.70...v6.1.71) (2022-03-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* support base config ([6c3cb6e](https://github.com/zhangyuang/ssr/commit/6c3cb6e58ce21dc81c0e7690c9652e8445e0b693))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [6.1.70](https://github.com/zhangyuang/ssr/compare/v6.1.68...v6.1.70) (2022-03-15)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* inject prefix to browser ([3f568cc](https://github.com/zhangyuang/ssr/commit/3f568cc6f15182ffe5fc3e58e1bffebcc4eb7a18))
|
|
23
|
+
* upgrade postcss to 8.0 ([70707e8](https://github.com/zhangyuang/ssr/commit/70707e8b297c2c7f77bb3344a907f1421bce0104))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## [6.1.69](https://github.com/zhangyuang/ssr/compare/v6.1.68...v6.1.69) (2022-03-08)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
* upgrade postcss to 8.0 ([70707e8](https://github.com/zhangyuang/ssr/commit/70707e8b297c2c7f77bb3344a907f1421bce0104))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
6
40
|
## [6.1.68](https://github.com/zhangyuang/ssr/compare/v6.1.67...v6.1.68) (2022-03-04)
|
|
7
41
|
|
|
8
42
|
**Note:** Version bump only for package ssr-plugin-react
|
package/README.md
CHANGED
|
@@ -266,12 +266,13 @@ $ npm run start:vite # 以 vite 模式启动,等价于 npx ssr start --vite
|
|
|
266
266
|
|
|
267
267
|
## 答疑群
|
|
268
268
|
|
|
269
|
-
虽然我们已经尽力检查了一遍应用,但仍有可能有疏漏的地方,如果你在使用过程中发现任何问题或者建议,欢迎提[issue](https://github.com/zhangyuang/ssr/issues)或者[PR](https://github.com/zhangyuang/ssr/pulls)
|
|
270
|
-
|
|
269
|
+
虽然我们已经尽力检查了一遍应用,但仍有可能有疏漏的地方,如果你在使用过程中发现任何问题或者建议,欢迎提[issue](https://github.com/zhangyuang/ssr/issues)或者[PR](https://github.com/zhangyuang/ssr/pulls)
|
|
270
|
+
|
|
271
|
+
`注: 由于微信交流群人数限制,进群请添加私人二维码并备注进入 ssr 交流群,由于是私人微信,拉群后将会自行删除好友,敬请谅解。我们更加鼓励通过 issue 和 discussion 来交流问题`
|
|
271
272
|
|
|
272
273
|
<div style="display:flex">
|
|
273
274
|
<!-- <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/
|
|
275
|
+
<img src="https://res.wx.qq.com/op_res/Nv12X2und927FEOvJ5iflzX-WBW07GSC22kumTCiShZnudKpG0jMuRs70ecHQb3Hy1QjjaASNzyOuMgHr43Wpw" width="300">
|
|
275
276
|
</div>
|
|
276
277
|
|
|
277
278
|
## 前端开发手册
|
package/cjs/config/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -96,7 +96,7 @@ const serverRender = async (ctx, config) => {
|
|
|
96
96
|
}
|
|
97
97
|
const combineData = isCsr ? null : Object.assign(state !== null && state !== void 0 ? state : {}, layoutFetchData !== null && layoutFetchData !== void 0 ? layoutFetchData : {}, fetchData !== null && fetchData !== void 0 ? fetchData : {});
|
|
98
98
|
const injectState = isCsr ? null : React.createElement("script", { dangerouslySetInnerHTML: {
|
|
99
|
-
__html: `window.__USE_SSR__=true; window.__INITIAL_DATA__ =${serialize(combineData)}`
|
|
99
|
+
__html: `window.__USE_SSR__=true; window.__INITIAL_DATA__ =${serialize(combineData)}; ${base && `window.prefix="${base}"`}`
|
|
100
100
|
} });
|
|
101
101
|
return (React.createElement(react_router_dom_1.StaticRouter, { location: ctx.request.url },
|
|
102
102
|
React.createElement(create_context_1.STORE_CONTEXT.Provider, { value: { state: combineData } },
|
package/cjs/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/cjs/tools/vite.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o
|
|
2
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.clientConfig = exports.serverConfig = exports.viteStart = exports.viteBuild = void 0;
|
|
5
5
|
const vite_1 = require("vite");
|
|
6
6
|
const ssr_server_utils_1 = require("ssr-server-utils");
|
|
7
7
|
const plugin_react_1 = require("@vitejs/plugin-react");
|
|
8
8
|
const vite_plugin_style_import_1 = require("vite-plugin-style-import");
|
|
9
|
-
const { getOutput, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev, define, babelOptions } = (0, ssr_server_utils_1.loadConfig)();
|
|
9
|
+
const { getOutput, prefix, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev, define, babelOptions } = (0, ssr_server_utils_1.loadConfig)();
|
|
10
10
|
const { clientOutPut, serverOutPut } = getOutput();
|
|
11
11
|
const styleImportConfig = {
|
|
12
12
|
include: ['**/*.vue', '**/*.ts', '**/*.js', '**/*.tsx', '**/*.jsx', /chunkName/],
|
|
@@ -51,7 +51,6 @@ const serverConfig = {
|
|
|
51
51
|
},
|
|
52
52
|
define: {
|
|
53
53
|
__isBrowser__: false,
|
|
54
|
-
...(_j = (_h = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _h === void 0 ? void 0 : _h.server) === null || _j === void 0 ? void 0 : _j.define,
|
|
55
54
|
...define === null || define === void 0 ? void 0 : define.server,
|
|
56
55
|
...define === null || define === void 0 ? void 0 : define.base
|
|
57
56
|
}
|
|
@@ -59,17 +58,18 @@ const serverConfig = {
|
|
|
59
58
|
exports.serverConfig = serverConfig;
|
|
60
59
|
const clientConfig = {
|
|
61
60
|
...(0, ssr_server_utils_1.commonConfig)(),
|
|
61
|
+
base: isDev ? '/' : prefix,
|
|
62
62
|
esbuild: {
|
|
63
63
|
keepNames: true
|
|
64
64
|
},
|
|
65
65
|
plugins: [
|
|
66
66
|
(0, plugin_react_1.default)({
|
|
67
|
-
...(
|
|
67
|
+
...(_j = (_h = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _h === void 0 ? void 0 : _h.client) === null || _j === void 0 ? void 0 : _j.defaultPluginOptions,
|
|
68
68
|
jsxRuntime: 'classic',
|
|
69
69
|
...babelOptions
|
|
70
70
|
}),
|
|
71
|
-
(
|
|
72
|
-
(
|
|
71
|
+
(_l = (_k = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _k === void 0 ? void 0 : _k.common) === null || _l === void 0 ? void 0 : _l.extraPlugin,
|
|
72
|
+
(_o = (_m = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _m === void 0 ? void 0 : _m.client) === null || _o === void 0 ? void 0 : _o.extraPlugin,
|
|
73
73
|
(0, vite_plugin_style_import_1.default)(styleImportConfig)
|
|
74
74
|
],
|
|
75
75
|
build: {
|
|
@@ -83,7 +83,6 @@ const clientConfig = {
|
|
|
83
83
|
},
|
|
84
84
|
define: {
|
|
85
85
|
__isBrowser__: true,
|
|
86
|
-
...(_s = (_r = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _r === void 0 ? void 0 : _r.client) === null || _s === void 0 ? void 0 : _s.define,
|
|
87
86
|
...define === null || define === void 0 ? void 0 : define.client,
|
|
88
87
|
...define === null || define === void 0 ? void 0 : define.base
|
|
89
88
|
}
|
|
@@ -93,7 +93,7 @@ const serverRender = async (ctx, config) => {
|
|
|
93
93
|
}
|
|
94
94
|
const combineData = isCsr ? null : Object.assign(state !== null && state !== void 0 ? state : {}, layoutFetchData !== null && layoutFetchData !== void 0 ? layoutFetchData : {}, fetchData !== null && fetchData !== void 0 ? fetchData : {});
|
|
95
95
|
const injectState = isCsr ? null : React.createElement("script", { dangerouslySetInnerHTML: {
|
|
96
|
-
__html: `window.__USE_SSR__=true; window.__INITIAL_DATA__ =${serialize(combineData)}`
|
|
96
|
+
__html: `window.__USE_SSR__=true; window.__INITIAL_DATA__ =${serialize(combineData)}; ${base && `window.prefix="${base}"`}`
|
|
97
97
|
} });
|
|
98
98
|
return (React.createElement(StaticRouter, { location: ctx.request.url },
|
|
99
99
|
React.createElement(Context.Provider, { value: { state: combineData } },
|
package/esm/tools/vite.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o
|
|
1
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
2
2
|
import { build } from 'vite';
|
|
3
3
|
import { loadConfig, chunkNamePlugin, rollupOutputOptions, manifestPlugin, commonConfig, asyncOptimizeChunkPlugin } from 'ssr-server-utils';
|
|
4
4
|
import react from '@vitejs/plugin-react';
|
|
5
5
|
import styleImport, { AndDesignVueResolve, VantResolve, ElementPlusResolve, NutuiResolve, AntdResolve } from 'vite-plugin-style-import';
|
|
6
|
-
const { getOutput, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev, define, babelOptions } = loadConfig();
|
|
6
|
+
const { getOutput, prefix, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev, define, babelOptions } = loadConfig();
|
|
7
7
|
const { clientOutPut, serverOutPut } = getOutput();
|
|
8
8
|
const styleImportConfig = {
|
|
9
9
|
include: ['**/*.vue', '**/*.ts', '**/*.js', '**/*.tsx', '**/*.jsx', /chunkName/],
|
|
@@ -48,24 +48,24 @@ const serverConfig = {
|
|
|
48
48
|
},
|
|
49
49
|
define: {
|
|
50
50
|
__isBrowser__: false,
|
|
51
|
-
...(_j = (_h = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _h === void 0 ? void 0 : _h.server) === null || _j === void 0 ? void 0 : _j.define,
|
|
52
51
|
...define === null || define === void 0 ? void 0 : define.server,
|
|
53
52
|
...define === null || define === void 0 ? void 0 : define.base
|
|
54
53
|
}
|
|
55
54
|
};
|
|
56
55
|
const clientConfig = {
|
|
57
56
|
...commonConfig(),
|
|
57
|
+
base: isDev ? '/' : prefix,
|
|
58
58
|
esbuild: {
|
|
59
59
|
keepNames: true
|
|
60
60
|
},
|
|
61
61
|
plugins: [
|
|
62
62
|
react({
|
|
63
|
-
...(
|
|
63
|
+
...(_j = (_h = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _h === void 0 ? void 0 : _h.client) === null || _j === void 0 ? void 0 : _j.defaultPluginOptions,
|
|
64
64
|
jsxRuntime: 'classic',
|
|
65
65
|
...babelOptions
|
|
66
66
|
}),
|
|
67
|
-
(
|
|
68
|
-
(
|
|
67
|
+
(_l = (_k = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _k === void 0 ? void 0 : _k.common) === null || _l === void 0 ? void 0 : _l.extraPlugin,
|
|
68
|
+
(_o = (_m = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _m === void 0 ? void 0 : _m.client) === null || _o === void 0 ? void 0 : _o.extraPlugin,
|
|
69
69
|
styleImport(styleImportConfig)
|
|
70
70
|
],
|
|
71
71
|
build: {
|
|
@@ -79,7 +79,6 @@ const clientConfig = {
|
|
|
79
79
|
},
|
|
80
80
|
define: {
|
|
81
81
|
__isBrowser__: true,
|
|
82
|
-
...(_s = (_r = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _r === void 0 ? void 0 : _r.client) === null || _s === void 0 ? void 0 : _s.define,
|
|
83
82
|
...define === null || define === void 0 ? void 0 : define.client,
|
|
84
83
|
...define === null || define === void 0 ? void 0 : define.base
|
|
85
84
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssr-plugin-react",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.71",
|
|
4
4
|
"description": "plugin-react for ssr",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -46,19 +46,20 @@
|
|
|
46
46
|
"less": "^4.1.1",
|
|
47
47
|
"less-loader": "^7.3.0",
|
|
48
48
|
"mini-css-extract-plugin": "^1.0.0",
|
|
49
|
-
"optimize-css-assets-webpack-plugin": "
|
|
50
|
-
"postcss
|
|
51
|
-
"postcss-
|
|
49
|
+
"optimize-css-assets-webpack-plugin": "^6.0.0",
|
|
50
|
+
"postcss": "^8.0.0",
|
|
51
|
+
"postcss-discard-comments": "^5.0.0",
|
|
52
|
+
"postcss-flexbugs-fixes": "^5.0.0",
|
|
52
53
|
"postcss-loader": "^4.0.0",
|
|
53
|
-
"postcss-modules": "^
|
|
54
|
-
"postcss-preset-env": "^
|
|
55
|
-
"postcss-safe-parser": "
|
|
54
|
+
"postcss-modules": "^4.0.0",
|
|
55
|
+
"postcss-preset-env": "^7.0.0",
|
|
56
|
+
"postcss-safe-parser": "^6.0.0",
|
|
56
57
|
"react-dev-utils": "^11.0.4",
|
|
57
58
|
"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.
|
|
59
|
+
"ssr-client-utils": "^6.1.71",
|
|
60
|
+
"ssr-hoc-react": "^6.1.71",
|
|
61
|
+
"ssr-server-utils": "^6.1.71",
|
|
62
|
+
"ssr-webpack": "^6.1.71",
|
|
62
63
|
"terser-webpack-plugin": "^2.3.5",
|
|
63
64
|
"url-loader": "^4.1.1",
|
|
64
65
|
"vite": "^2.7.0",
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
"@types/react-router-dom": "^5.1.3",
|
|
75
76
|
"@types/webpack": "^4.41.10",
|
|
76
77
|
"concurrently": "^5.1.0",
|
|
77
|
-
"ssr-types-react": "^6.1.
|
|
78
|
+
"ssr-types-react": "^6.1.71"
|
|
78
79
|
},
|
|
79
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "d153ade08a8ed0376c7d18dd914b12a6e02c9f1c"
|
|
80
81
|
}
|
|
@@ -102,9 +102,8 @@ const serverRender = async (ctx: ISSRContext, config: IConfig): Promise<React.Re
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
const combineData = isCsr ? null : Object.assign(state ?? {}, layoutFetchData ?? {}, fetchData ?? {})
|
|
105
|
-
|
|
106
105
|
const injectState = isCsr ? null : <script dangerouslySetInnerHTML={{
|
|
107
|
-
__html: `window.__USE_SSR__=true; window.__INITIAL_DATA__ =${serialize(combineData)}`
|
|
106
|
+
__html: `window.__USE_SSR__=true; window.__INITIAL_DATA__ =${serialize(combineData)}; ${base && `window.prefix="${base}"`}`
|
|
108
107
|
}} />
|
|
109
108
|
|
|
110
109
|
return (
|
package/src/tools/vite.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { loadConfig, chunkNamePlugin, rollupOutputOptions, manifestPlugin, commo
|
|
|
3
3
|
import react from '@vitejs/plugin-react'
|
|
4
4
|
import styleImport, { AndDesignVueResolve, VantResolve, ElementPlusResolve, NutuiResolve, AntdResolve } from 'vite-plugin-style-import'
|
|
5
5
|
|
|
6
|
-
const { getOutput, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev, define, babelOptions } = loadConfig()
|
|
6
|
+
const { getOutput, prefix, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev, define, babelOptions } = loadConfig()
|
|
7
7
|
|
|
8
8
|
const { clientOutPut, serverOutPut } = getOutput()
|
|
9
9
|
const styleImportConfig = {
|
|
@@ -49,7 +49,6 @@ const serverConfig: UserConfig = {
|
|
|
49
49
|
},
|
|
50
50
|
define: {
|
|
51
51
|
__isBrowser__: false,
|
|
52
|
-
...viteConfig?.()?.server?.define,
|
|
53
52
|
...define?.server,
|
|
54
53
|
...define?.base
|
|
55
54
|
}
|
|
@@ -57,6 +56,7 @@ const serverConfig: UserConfig = {
|
|
|
57
56
|
|
|
58
57
|
const clientConfig: UserConfig = {
|
|
59
58
|
...commonConfig(),
|
|
59
|
+
base: isDev ? '/' : prefix,
|
|
60
60
|
esbuild: {
|
|
61
61
|
keepNames: true
|
|
62
62
|
},
|
|
@@ -81,7 +81,6 @@ const clientConfig: UserConfig = {
|
|
|
81
81
|
},
|
|
82
82
|
define: {
|
|
83
83
|
__isBrowser__: true,
|
|
84
|
-
...viteConfig?.()?.client?.define,
|
|
85
84
|
...define?.client,
|
|
86
85
|
...define?.base
|
|
87
86
|
}
|