ssr-plugin-react 6.1.24 → 6.1.31

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,84 @@
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.31](https://github.com/zhangyuang/ssr/compare/v6.1.30...v6.1.31) (2021-12-17)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * node12 vite ssr optimize ([941a405](https://github.com/zhangyuang/ssr/commit/941a40507303606859ecd08a8594010929c4aaaa))
12
+
13
+
14
+
15
+
16
+
17
+ ## [6.1.30](https://github.com/zhangyuang/ssr/compare/v6.1.29...v6.1.30) (2021-12-17)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * node12 vite ssr optimize ([88fb3c9](https://github.com/zhangyuang/ssr/commit/88fb3c935bdc7aa05d44f682e0e14f7ed09be8c9))
23
+
24
+
25
+
26
+
27
+
28
+ ## [6.1.29](https://github.com/zhangyuang/ssr/compare/v6.1.28...v6.1.29) (2021-12-17)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * vite in server side optimize deps ([b9af6f4](https://github.com/zhangyuang/ssr/commit/b9af6f4de403af9b2909d82c5dde8bd161d98397))
34
+ * vite optimize ([f690358](https://github.com/zhangyuang/ssr/commit/f6903589bfd317b464aecb17db5acaca336dda31))
35
+
36
+
37
+ ### Features
38
+
39
+ * support common plugin in vite ([6a0a3ab](https://github.com/zhangyuang/ssr/commit/6a0a3ab0e6b7a43179053a02342db303f40cfbd6))
40
+ * support optionalchaining when node version less than 14 ([3b4bc90](https://github.com/zhangyuang/ssr/commit/3b4bc9044df5826bc7c9810bca4d8ccb0c6ad4fd))
41
+
42
+
43
+
44
+
45
+
46
+ ## [6.1.28](https://github.com/zhangyuang/ssr/compare/v6.1.25...v6.1.28) (2021-12-16)
47
+
48
+
49
+ ### Bug Fixes
50
+
51
+ * alias ([0417457](https://github.com/zhangyuang/ssr/commit/0417457959a8159f045b18d0cd801ef10f1c68c3))
52
+
53
+
54
+
55
+
56
+
57
+ ## [6.1.27](https://github.com/zhangyuang/ssr/compare/v6.1.26...v6.1.27) (2021-12-16)
58
+
59
+ **Note:** Version bump only for package ssr-plugin-react
60
+
61
+
62
+
63
+
64
+
65
+ ## [6.1.26](https://github.com/zhangyuang/ssr/compare/v6.1.25...v6.1.26) (2021-12-16)
66
+
67
+ **Note:** Version bump only for package ssr-plugin-react
68
+
69
+
70
+
71
+
72
+
73
+ ## [6.1.25](https://github.com/zhangyuang/ssr/compare/v6.1.24...v6.1.25) (2021-12-16)
74
+
75
+
76
+ ### Features
77
+
78
+ * add vite test ([#148](https://github.com/zhangyuang/ssr/issues/148)) ([efce102](https://github.com/zhangyuang/ssr/commit/efce102ebe1be25c1275712042b1ee0e7b088568))
79
+
80
+
81
+
82
+
83
+
6
84
  ## [6.1.24](https://github.com/zhangyuang/ssr/compare/v6.1.23...v6.1.24) (2021-12-13)
7
85
 
8
86
  **Note:** Version bump only for package ssr-plugin-react
package/README.md CHANGED
@@ -53,22 +53,28 @@
53
53
  </b></td>
54
54
  <td align="center"><a target="_blank" href="https://yulebao.alibaba.com/"><img src="https://gw.alicdn.com/tfs/TB1CmlIIFT7gK0jSZFpXXaTkpXa-190-46.png" width="100px;"/><br><sub><b>阿里影业娱乐宝
55
55
  </b></sub></a></td>
56
- <td align="center"><a target="_blank" href="https://campaign.vmate.com/vrbollywood"><img src="https://img.alicdn.com/tfs/TB17p6Vhbj1gK0jSZFOXXc7GpXa-512-512.png" width="100px;" alt="vmate 积分商城"/><br />
57
- <a target="_blank" href="https://job.alibaba.com/zhaopin/position_detail.htm?trace=qrcode_share&positionCode=GP524819"><sub><b>Vmate短视频
58
- </b></a></td>
59
- <td align="center"><a target="_blank" href="https://enjoysales.paat.com/"><img src="https://img.alicdn.com/tfs/TB1Ma0BiEY1gK0jSZFMXXaWcVXa-836-836.png" width="100px;" alt="火炽星原CRM"/><br />
60
- <a target="_blank" href="https://enjoysales.paat.com/"><sub><b>火炽星原CRM
61
- </b></a></td>
62
56
  <td align="center"><a href="https://www.niuniuda.com/mall" target="_blank"><img src="https://img.alicdn.com/tfs/TB1df_8pBr0gK0jSZFnXXbRRXXa-160-60.png" width="100px;" alt="牛牛搭"/><br />
63
57
  <a href="https://www.niuniuda.com/mall" target="_blank"><sub><b>牛牛搭
64
58
  </b></a></td>
59
+ <td align="center"><a href="https://www.gszq.com/" target="_blank"><img src="https://www.gszq.com/static/media/icon-slogan.4d1c7974.png
60
+ " width="100px;" alt="国盛证券"/><br />
61
+ <a href="https://www.gszq.com/" target="_bvlank"><sub><b>国盛证券
62
+ </b></a></td>
63
+ <td align="center"><a href="https://m.isle.org.cn" target="_blank"><img src="https://res.wx.qq.com/op_res/qzBjcpT1AZDopDDkEJfj5gKFADotYHTgD33lz9xvZUIj7VJaIR_8HE4lfOxwaiYBgi4V2xXm0xLmAcdQxF4IrQ" width="100px;" alt="三易科技"/><br />
64
+ <a href="https://m.isle.org.cn" target="_bvlank"><sub><b>三易科技
65
+ </b></a></td>
65
66
  <td align="center"><a href="https://help.seewo.com/" target="_blank"><img src="https://img.alicdn.com/tfs/TB11Xo3q4v1gK0jSZFFXXb0sXXa-350-55.png" width="100px;" alt="cvte"/><br /><a href="https://help.seewo.com/" target="_blank"><sub><b>希沃帮助中心
66
67
  </b></a></td>
67
68
  <td align="center"><a href="https://wecard.qq.com/index/" target="_blank"><img src="https://img.alicdn.com/tfs/TB1pTZGrFT7gK0jSZFpXXaTkpXa-164-164.jpg" width="100px;" alt="腾讯微卡"/><br />
68
69
  <a href="https://wecard.qq.com/index/" target="_blank"><sub><b>腾讯微卡
69
70
  </b></a></td>
70
- <td align="center"><a href="https://www.myweimai.com/#sectionOne" target="_blank"><img src="https://img.alicdn.com/tfs/TB16i3VrQT2gK0jSZPcXXcKkpXa-400-400.jpg" width="100px;" alt="微脉"/><br />
71
- <a href="https://www.myweimai.com/#sectionOne" target="_bvlank"><sub><b>微脉
71
+ <td align="center" style="height: 100px"><a href="https://www.habisummercamp.com/" target="_blank"><img src="https://res.wx.qq.com/op_res/XXUpF56bDue53vZadoCSPSnqKF3bZqPOQnqsPa_ngEARa0OUIW22pX7eKsftPb6pc5ny62cR_wXM4g5xJ7G3DQ
72
+ " width="200px;margin: 20px 0" alt="Happy"/><br />
73
+ <a href="https://www.habisummercamp.com/" target="_bvlank"><b>HappyPC
74
+ </b></a></td>
75
+ <td align="center" style="height: 100px"><a href="https://m.habisummercamp.com/" target="_blank"><img src="https://res.wx.qq.com/op_res/XXUpF56bDue53vZadoCSPSnqKF3bZqPOQnqsPa_ngEARa0OUIW22pX7eKsftPb6pc5ny62cR_wXM4g5xJ7G3DQ
76
+ " width="200px;margin: 20px 0" alt="Happy"/><br />
77
+ <a href="https://m.habisummercamp.com/" target="_bvlank"><b>HappyMobile
72
78
  </b></a></td>
73
79
  </tr>
74
80
  <tr>
@@ -82,21 +88,9 @@
82
88
  </b></sub></a></td>
83
89
  <td align="center"><a target="_blank" href="http://tx.ssr-fc.com/"><img src="http://s0.60logo.com/uploads/items/images/soft/180126/tengxunyun.svg" width="100px;"/><br><sub><b>部署于腾讯云示例应用
84
90
  </b></sub></a></td>
85
- <td align="center"><a href="https://www.gszq.com/" target="_blank"><img src="https://www.gszq.com/static/media/icon-slogan.4d1c7974.png
86
- " width="100px;" alt="国盛证券"/><br />
87
- <a href="https://www.gszq.com/" target="_bvlank"><sub><b>国盛证券
88
- </b></a></td>
89
- <td align="center"><a href="https://m.isle.org.cn" target="_blank"><img src="https://res.wx.qq.com/op_res/qzBjcpT1AZDopDDkEJfj5gKFADotYHTgD33lz9xvZUIj7VJaIR_8HE4lfOxwaiYBgi4V2xXm0xLmAcdQxF4IrQ" width="100px;" alt="三易科技"/><br />
90
- <a href="https://m.isle.org.cn" target="_bvlank"><sub><b>三易科技
91
- </b></a></td>
92
- <td align="center"><a href="https://www.66tools.com/" target="_blank"><img src="https://cdn.66tools.com/extension/chrome_qrcode_avatar.png" width="100px;" alt="极速二维码"/><br />
93
- <a href="https://www.66tools.com/" target="_bvlank"><sub><b>极速二维码
94
- </b></a></td>
95
91
  <td align="center"><a href="https://www.100.com/" target="_blank"><img src="https://oss.bs2dl.100.com/hippo/config/f13ee98cfca7ce13888752c1261081b44bd356fd.png" width="100px;" alt="100教育"/><br />
96
92
  <a href="https://www.100.com/" target="_bvlank"><sub><b>100教育
97
93
  </b></a></td>
98
- </tr>
99
- <tr>
100
94
  <td align="center" style="height: 100px"><a href="https://m.film.qq.com/x/tva-vip-center/" target="_blank"><img src="https://res.wx.qq.com/op_res/x7sWI9AfUK1QwH0EDhKp4e_bGWxYOQ_1RlZqBFy9JntJzaE4aRzNhVgmxLNloAFpSQ-mBr9X9pux3QlV9QHHvQ" width="200px;margin: 20px 0" alt="腾讯视频"/><br />
101
95
  <a href="https://m.film.qq.com/x/tva-vip-center/" target="_bvlank"><b>腾讯视频
102
96
  </b></a></td>
@@ -106,17 +100,23 @@
106
100
  <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
101
  <a href="https://jiawu.dewu.com" target="_bvlank"><b>得物
108
102
  </b></a></td>
109
- <td align="center" style="height: 100px"><a href="https://www.habisummercamp.com/" target="_blank"><img src="https://res.wx.qq.com/op_res/XXUpF56bDue53vZadoCSPSnqKF3bZqPOQnqsPa_ngEARa0OUIW22pX7eKsftPb6pc5ny62cR_wXM4g5xJ7G3DQ
110
- " width="200px;margin: 20px 0" alt="Happy"/><br />
111
- <a href="https://www.habisummercamp.com/" target="_bvlank"><b>HappyPC
103
+ <td align="center"><a href="https://www.myweimai.com/#sectionOne" target="_blank"><img src="https://img.alicdn.com/tfs/TB16i3VrQT2gK0jSZPcXXcKkpXa-400-400.jpg" width="100px;" alt="微脉"/><br />
104
+ <a href="https://www.myweimai.com/#sectionOne" target="_bvlank"><sub><b>微脉
112
105
  </b></a></td>
113
- <td align="center" style="height: 100px"><a href="https://m.habisummercamp.com/" target="_blank"><img src="https://res.wx.qq.com/op_res/XXUpF56bDue53vZadoCSPSnqKF3bZqPOQnqsPa_ngEARa0OUIW22pX7eKsftPb6pc5ny62cR_wXM4g5xJ7G3DQ
114
- " width="200px;margin: 20px 0" alt="Happy"/><br />
115
- <a href="https://m.habisummercamp.com/" target="_bvlank"><b>HappyMobile
106
+ </tr>
107
+ <tr>
108
+ <td align="center"><a target="_blank" href="https://campaign.vmate.com/vrbollywood"><img src="https://img.alicdn.com/tfs/TB17p6Vhbj1gK0jSZFOXXc7GpXa-512-512.png" width="100px;" alt="vmate 积分商城"/><br />
109
+ <a target="_blank" href="https://job.alibaba.com/zhaopin/position_detail.htm?trace=qrcode_share&positionCode=GP524819"><sub><b>Vmate短视频
110
+ </b></a></td>
111
+ <td align="center"><a target="_blank" href="https://enjoysales.paat.com/"><img src="https://img.alicdn.com/tfs/TB1Ma0BiEY1gK0jSZFMXXaWcVXa-836-836.png" width="100px;" alt="火炽星原CRM"/><br />
112
+ <a target="_blank" href="https://enjoysales.paat.com/"><sub><b>火炽星原CRM
116
113
  </b></a></td>
117
114
  <td align="center" style="height: 100px"><a href="https://www.paixin.com/" target="_blank"><img src="https://www.paixin.com/favicon.ico" width="200px;margin: 20px 0" alt="Happy"/><br />
118
115
  <a href="https://www.paixin.com/" target="_bvlank"><b>拍信创意
119
116
  </b></a></td>
117
+ <td align="center"><a href="https://www.66tools.com/" target="_blank"><img src="https://cdn.66tools.com/extension/chrome_qrcode_avatar.png" width="100px;" alt="极速二维码"/><br />
118
+ <a href="https://www.66tools.com/" target="_bvlank"><sub><b>极速二维码
119
+ </b></a></td>
120
120
  </tr>
121
121
  </table>
122
122
 
@@ -72,12 +72,6 @@ const getBaseConfig = (chain, isServer) => {
72
72
  .end()
73
73
  .alias
74
74
  .end();
75
- chain.resolve.alias
76
- .set('@', (0, ssr_server_utils_1.getFeDir)())
77
- .set('_build', (0, path_1.join)((0, ssr_server_utils_1.getCwd)(), './build'))
78
- .set('react', loadModule('react')) // 用cwd的路径alias,否则可能会出现多个react实例
79
- .set('react-router', loadModule('react-router'))
80
- .set('react-router-dom', loadModule('react-router-dom'));
81
75
  alias && Object.keys(alias).forEach(item => {
82
76
  chain.resolve.alias
83
77
  .set(item, alias[item]);
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;
2
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.clientConfig = exports.serverConfig = exports.viteStart = exports.viteBuild = void 0;
5
5
  const ssr_server_utils_1 = require("ssr-server-utils");
6
6
  const plugin_react_1 = require("@vitejs/plugin-react");
7
7
  const vite_plugin_style_import_1 = require("vite-plugin-style-import");
8
8
  const build = require('vite').build;
9
- const { getOutput, reactServerEntry, reactClientEntry, viteConfig } = (0, ssr_server_utils_1.loadConfig)();
9
+ const { getOutput, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev } = (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/],
@@ -23,15 +23,23 @@ const serverConfig = {
23
23
  plugins: [
24
24
  (0, plugin_react_1.default)({
25
25
  ...(_b = (_a = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _a === void 0 ? void 0 : _a.server) === null || _b === void 0 ? void 0 : _b.defaultPluginOptions,
26
- jsxRuntime: 'classic'
26
+ jsxRuntime: 'classic',
27
+ babel: !supportOptinalChaining && {
28
+ plugins: [
29
+ '@babel/plugin-proposal-optional-chaining',
30
+ '@babel/plugin-proposal-nullish-coalescing-operator'
31
+ ]
32
+ }
27
33
  }),
28
- (_d = (_c = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _c === void 0 ? void 0 : _c.server) === null || _d === void 0 ? void 0 : _d.extraPlugin,
34
+ (_d = (_c = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _c === void 0 ? void 0 : _c.common) === null || _d === void 0 ? void 0 : _d.extraPlugin,
35
+ (_f = (_e = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _e === void 0 ? void 0 : _e.server) === null || _f === void 0 ? void 0 : _f.extraPlugin,
29
36
  (0, vite_plugin_style_import_1.default)(styleImportConfig)
30
37
  ],
31
38
  build: {
32
39
  ssr: reactServerEntry,
33
40
  outDir: serverOutPut,
34
41
  rollupOptions: {
42
+ input: isDev ? reactClientEntry : '',
35
43
  output: {
36
44
  entryFileNames: 'Page.server.js'
37
45
  }
@@ -39,7 +47,7 @@ const serverConfig = {
39
47
  },
40
48
  define: {
41
49
  __isBrowser__: false,
42
- ...(_f = (_e = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _e === void 0 ? void 0 : _e.server) === null || _f === void 0 ? void 0 : _f.define
50
+ ...(_h = (_g = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _g === void 0 ? void 0 : _g.server) === null || _h === void 0 ? void 0 : _h.define
43
51
  }
44
52
  };
45
53
  exports.serverConfig = serverConfig;
@@ -50,10 +58,11 @@ const clientConfig = {
50
58
  },
51
59
  plugins: [
52
60
  (0, plugin_react_1.default)({
53
- ...(_h = (_g = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _g === void 0 ? void 0 : _g.client) === null || _h === void 0 ? void 0 : _h.defaultPluginOptions,
61
+ ...(_k = (_j = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _j === void 0 ? void 0 : _j.client) === null || _k === void 0 ? void 0 : _k.defaultPluginOptions,
54
62
  jsxRuntime: 'classic'
55
63
  }),
56
- (_k = (_j = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _j === void 0 ? void 0 : _j.client) === null || _k === void 0 ? void 0 : _k.extraPlugin,
64
+ (_m = (_l = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _l === void 0 ? void 0 : _l.common) === null || _m === void 0 ? void 0 : _m.extraPlugin,
65
+ (_p = (_o = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _o === void 0 ? void 0 : _o.client) === null || _p === void 0 ? void 0 : _p.extraPlugin,
57
66
  (0, vite_plugin_style_import_1.default)(styleImportConfig)
58
67
  ],
59
68
  build: {
@@ -67,7 +76,7 @@ const clientConfig = {
67
76
  },
68
77
  define: {
69
78
  __isBrowser__: true,
70
- ...(_m = (_l = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _l === void 0 ? void 0 : _l.client) === null || _m === void 0 ? void 0 : _m.define
79
+ ...(_r = (_q = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _q === void 0 ? void 0 : _q.client) === null || _r === void 0 ? void 0 : _r.define
71
80
  }
72
81
  };
73
82
  exports.clientConfig = clientConfig;
@@ -1,5 +1,5 @@
1
1
  import { join } from 'path';
2
- import { getFeDir, getCwd, loadConfig, getLocalNodeModules, setStyle, addImageChain } from 'ssr-server-utils';
2
+ import { getCwd, loadConfig, getLocalNodeModules, setStyle, addImageChain } from 'ssr-server-utils';
3
3
  import * as webpack from 'webpack';
4
4
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5
5
  const WebpackBar = require('webpackbar');
@@ -69,12 +69,6 @@ const getBaseConfig = (chain, isServer) => {
69
69
  .end()
70
70
  .alias
71
71
  .end();
72
- chain.resolve.alias
73
- .set('@', getFeDir())
74
- .set('_build', join(getCwd(), './build'))
75
- .set('react', loadModule('react')) // 用cwd的路径alias,否则可能会出现多个react实例
76
- .set('react-router', loadModule('react-router'))
77
- .set('react-router-dom', loadModule('react-router-dom'));
78
72
  alias && Object.keys(alias).forEach(item => {
79
73
  chain.resolve.alias
80
74
  .set(item, alias[item]);
package/esm/tools/vite.js CHANGED
@@ -1,9 +1,9 @@
1
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
2
2
  import { loadConfig, chunkNamePlugin, rollupOutputOptions, manifestPlugin, commonConfig } from 'ssr-server-utils';
3
3
  import react from '@vitejs/plugin-react';
4
4
  import styleImport, { AndDesignVueResolve, VantResolve, ElementPlusResolve, NutuiResolve, AntdResolve } from 'vite-plugin-style-import';
5
5
  const build = require('vite').build;
6
- const { getOutput, reactServerEntry, reactClientEntry, viteConfig } = loadConfig();
6
+ const { getOutput, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev } = loadConfig();
7
7
  const { clientOutPut, serverOutPut } = getOutput();
8
8
  const styleImportConfig = {
9
9
  include: ['**/*.vue', '**/*.ts', '**/*.js', '**/*.tsx', '**/*.jsx', /chunkName/],
@@ -20,15 +20,23 @@ const serverConfig = {
20
20
  plugins: [
21
21
  react({
22
22
  ...(_b = (_a = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _a === void 0 ? void 0 : _a.server) === null || _b === void 0 ? void 0 : _b.defaultPluginOptions,
23
- jsxRuntime: 'classic'
23
+ jsxRuntime: 'classic',
24
+ babel: !supportOptinalChaining && {
25
+ plugins: [
26
+ '@babel/plugin-proposal-optional-chaining',
27
+ '@babel/plugin-proposal-nullish-coalescing-operator'
28
+ ]
29
+ }
24
30
  }),
25
- (_d = (_c = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _c === void 0 ? void 0 : _c.server) === null || _d === void 0 ? void 0 : _d.extraPlugin,
31
+ (_d = (_c = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _c === void 0 ? void 0 : _c.common) === null || _d === void 0 ? void 0 : _d.extraPlugin,
32
+ (_f = (_e = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _e === void 0 ? void 0 : _e.server) === null || _f === void 0 ? void 0 : _f.extraPlugin,
26
33
  styleImport(styleImportConfig)
27
34
  ],
28
35
  build: {
29
36
  ssr: reactServerEntry,
30
37
  outDir: serverOutPut,
31
38
  rollupOptions: {
39
+ input: isDev ? reactClientEntry : '',
32
40
  output: {
33
41
  entryFileNames: 'Page.server.js'
34
42
  }
@@ -36,7 +44,7 @@ const serverConfig = {
36
44
  },
37
45
  define: {
38
46
  __isBrowser__: false,
39
- ...(_f = (_e = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _e === void 0 ? void 0 : _e.server) === null || _f === void 0 ? void 0 : _f.define
47
+ ...(_h = (_g = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _g === void 0 ? void 0 : _g.server) === null || _h === void 0 ? void 0 : _h.define
40
48
  }
41
49
  };
42
50
  const clientConfig = {
@@ -46,10 +54,11 @@ const clientConfig = {
46
54
  },
47
55
  plugins: [
48
56
  react({
49
- ...(_h = (_g = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _g === void 0 ? void 0 : _g.client) === null || _h === void 0 ? void 0 : _h.defaultPluginOptions,
57
+ ...(_k = (_j = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _j === void 0 ? void 0 : _j.client) === null || _k === void 0 ? void 0 : _k.defaultPluginOptions,
50
58
  jsxRuntime: 'classic'
51
59
  }),
52
- (_k = (_j = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _j === void 0 ? void 0 : _j.client) === null || _k === void 0 ? void 0 : _k.extraPlugin,
60
+ (_m = (_l = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _l === void 0 ? void 0 : _l.common) === null || _m === void 0 ? void 0 : _m.extraPlugin,
61
+ (_p = (_o = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _o === void 0 ? void 0 : _o.client) === null || _p === void 0 ? void 0 : _p.extraPlugin,
53
62
  styleImport(styleImportConfig)
54
63
  ],
55
64
  build: {
@@ -63,7 +72,7 @@ const clientConfig = {
63
72
  },
64
73
  define: {
65
74
  __isBrowser__: true,
66
- ...(_m = (_l = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _l === void 0 ? void 0 : _l.client) === null || _m === void 0 ? void 0 : _m.define
75
+ ...(_r = (_q = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _q === void 0 ? void 0 : _q.client) === null || _r === void 0 ? void 0 : _r.define
67
76
  }
68
77
  };
69
78
  const viteStart = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssr-plugin-react",
3
- "version": "6.1.24",
3
+ "version": "6.1.31",
4
4
  "description": "plugin-react for ssr",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -30,6 +30,8 @@
30
30
  "homepage": "https://github.com/zhangyuang/ssr#readme",
31
31
  "dependencies": {
32
32
  "@babel/core": "^7.0.0",
33
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.5",
34
+ "@babel/plugin-proposal-optional-chaining": "^7.16.5",
33
35
  "@babel/plugin-transform-runtime": "^7.9.6",
34
36
  "@babel/preset-env": "^7.5.5",
35
37
  "@vitejs/plugin-react": "^1.0.0",
@@ -54,13 +56,13 @@
54
56
  "postcss-safe-parser": "4.0.1",
55
57
  "react-dev-utils": "^11.0.4",
56
58
  "serialize-javascript": "^6.0.0",
57
- "ssr-client-utils": "^6.1.24",
58
- "ssr-hoc-react": "^6.1.24",
59
- "ssr-server-utils": "^6.1.24",
60
- "ssr-webpack": "^6.1.24",
59
+ "ssr-client-utils": "^6.1.29",
60
+ "ssr-hoc-react": "^6.1.29",
61
+ "ssr-server-utils": "^6.1.29",
62
+ "ssr-webpack": "^6.1.29",
61
63
  "terser-webpack-plugin": "^2.3.5",
62
64
  "url-loader": "^4.1.1",
63
- "vite": "^2.7.0-beta.10",
65
+ "vite": "^2.7.0",
64
66
  "vite-plugin-style-import": "^1.4.0",
65
67
  "webpack-bundle-analyzer": "^3.6.1",
66
68
  "webpack-chain": "^6.4.0",
@@ -72,7 +74,7 @@
72
74
  "@types/react-dom": "^17.0.0",
73
75
  "@types/react-router-dom": "^5.1.3",
74
76
  "@types/webpack": "^4.41.10",
75
- "ssr-types-react": "^6.1.24"
77
+ "ssr-types-react": "^6.1.29"
76
78
  },
77
- "gitHead": "1db2fdc29361d4f74c49c3fad8de5fbaa8e19b58"
79
+ "gitHead": "e238c458fc4312003e20a33151f28aa70cfa1a1f"
78
80
  }
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { join } from 'path'
3
3
  import { Mode } from 'ssr-types'
4
- import { getFeDir, getCwd, loadConfig, getLocalNodeModules, setStyle, addImageChain } from 'ssr-server-utils'
4
+ import { getCwd, loadConfig, getLocalNodeModules, setStyle, addImageChain } from 'ssr-server-utils'
5
5
  import * as WebpackChain from 'webpack-chain'
6
6
  import * as webpack from 'webpack'
7
7
 
@@ -75,12 +75,6 @@ const getBaseConfig = (chain: WebpackChain, isServer: boolean) => {
75
75
  .end()
76
76
  .alias
77
77
  .end()
78
- chain.resolve.alias
79
- .set('@', getFeDir())
80
- .set('_build', join(getCwd(), './build'))
81
- .set('react', loadModule('react')) // 用cwd的路径alias,否则可能会出现多个react实例
82
- .set('react-router', loadModule('react-router'))
83
- .set('react-router-dom', loadModule('react-router-dom'))
84
78
 
85
79
  alias && Object.keys(alias).forEach(item => {
86
80
  chain.resolve.alias
package/src/tools/vite.ts CHANGED
@@ -10,7 +10,8 @@ import styleImport, {
10
10
  } from 'vite-plugin-style-import'
11
11
 
12
12
  const build: typeof BuildType = require('vite').build
13
- const { getOutput, reactServerEntry, reactClientEntry, viteConfig } = loadConfig()
13
+ const { getOutput, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev } = loadConfig()
14
+
14
15
  const { clientOutPut, serverOutPut } = getOutput()
15
16
  const styleImportConfig = {
16
17
  include: ['**/*.vue', '**/*.ts', '**/*.js', '**/*.tsx', '**/*.jsx', /chunkName/],
@@ -19,23 +20,31 @@ const styleImportConfig = {
19
20
  VantResolve(),
20
21
  ElementPlusResolve(),
21
22
  NutuiResolve(),
22
- AntdResolve()]
23
+ AntdResolve()
24
+ ]
23
25
  }
24
26
  const serverConfig: UserConfig = {
25
27
  ...commonConfig(),
26
28
  plugins: [
27
29
  react({
28
30
  ...viteConfig?.()?.server?.defaultPluginOptions,
29
- jsxRuntime: 'classic'
31
+ jsxRuntime: 'classic',
32
+ babel: !supportOptinalChaining && {
33
+ plugins: [
34
+ '@babel/plugin-proposal-optional-chaining',
35
+ '@babel/plugin-proposal-nullish-coalescing-operator'
36
+ ]
37
+ }
30
38
  }),
39
+ viteConfig?.()?.common?.extraPlugin,
31
40
  viteConfig?.()?.server?.extraPlugin,
32
41
  styleImport(styleImportConfig)
33
-
34
42
  ],
35
43
  build: {
36
44
  ssr: reactServerEntry,
37
45
  outDir: serverOutPut,
38
46
  rollupOptions: {
47
+ input: isDev ? reactClientEntry : '',
39
48
  output: {
40
49
  entryFileNames: 'Page.server.js'
41
50
  }
@@ -57,6 +66,7 @@ const clientConfig: UserConfig = {
57
66
  ...viteConfig?.()?.client?.defaultPluginOptions,
58
67
  jsxRuntime: 'classic'
59
68
  }),
69
+ viteConfig?.()?.common?.extraPlugin,
60
70
  viteConfig?.()?.client?.extraPlugin,
61
71
  styleImport(styleImportConfig)
62
72
  ],