ssr-plugin-react 6.1.42 → 6.1.48

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,79 @@
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.48](https://github.com/zhangyuang/ssr/compare/v6.1.47...v6.1.48) (2022-01-13)
7
+
8
+ **Note:** Version bump only for package ssr-plugin-react
9
+
10
+
11
+
12
+
13
+
14
+ ## [6.1.47](https://github.com/zhangyuang/ssr/compare/v6.1.47-alpha.1...v6.1.47) (2022-01-13)
15
+
16
+ **Note:** Version bump only for package ssr-plugin-react
17
+
18
+
19
+
20
+
21
+
22
+ ## [6.1.47-alpha.1](https://github.com/zhangyuang/ssr/compare/v6.1.47-alpha.0...v6.1.47-alpha.1) (2022-01-13)
23
+
24
+
25
+ ### Features
26
+
27
+ * support babelOptions ([2cd9139](https://github.com/zhangyuang/ssr/commit/2cd91398bed61fe4def651d1846ad438c517f78b))
28
+
29
+
30
+
31
+
32
+
33
+ ## [6.1.47-alpha.0](https://github.com/zhangyuang/ssr/compare/v6.1.46...v6.1.47-alpha.0) (2022-01-13)
34
+
35
+
36
+ ### Features
37
+
38
+ * support babelOptions ([8847197](https://github.com/zhangyuang/ssr/commit/8847197ff8065b40a883c37f107ee8eae8d32ba9))
39
+
40
+
41
+
42
+
43
+
44
+ ## [6.1.46](https://github.com/zhangyuang/ssr/compare/v6.1.45...v6.1.46) (2022-01-07)
45
+
46
+ **Note:** Version bump only for package ssr-plugin-react
47
+
48
+
49
+
50
+
51
+
52
+ ## [6.1.45](https://github.com/zhangyuang/ssr/compare/v6.1.44...v6.1.45) (2022-01-06)
53
+
54
+ **Note:** Version bump only for package ssr-plugin-react
55
+
56
+
57
+
58
+
59
+
60
+ ## [6.1.44](https://github.com/zhangyuang/ssr/compare/v6.1.42...v6.1.44) (2022-01-05)
61
+
62
+
63
+ ### Bug Fixes
64
+
65
+ * manualChunks ([663295c](https://github.com/zhangyuang/ssr/commit/663295c17693550301ac5a71ee78f68d3d11ecfa))
66
+
67
+
68
+
69
+
70
+
71
+ ## [6.1.43](https://github.com/zhangyuang/ssr/compare/v6.1.42...v6.1.43) (2022-01-05)
72
+
73
+ **Note:** Version bump only for package ssr-plugin-react
74
+
75
+
76
+
77
+
78
+
6
79
  ## [6.1.42](https://github.com/zhangyuang/ssr/compare/v6.1.41...v6.1.42) (2022-01-05)
7
80
 
8
81
 
package/README.md CHANGED
@@ -273,7 +273,7 @@ $ npm run start:vite # 以 vite 模式启动,等价于 npx ssr start --vite
273
273
 
274
274
  <div style="display:flex">
275
275
  <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/QHEy-aukLNwJhw1OYtAnYlslZscEeZ8SyyTcolA3wSnHM-wpfwLJYbzQMtfEeD44sN9tAYryDJQkmWSlElMJkw" width="300">
276
+ <img src="https://res.wx.qq.com/op_res/7SpflSUP3RJ5InL7FkN0-9JeTj18T_lvqJXXHLNNpY_owTyqtgVH8qMqjk4w7S6YeDWZmUP-N_4vLLAUCdySTA" width="300">
277
277
  </div>
278
278
 
279
279
  ## 前端开发手册
@@ -8,6 +8,8 @@ const MiniCssExtractPlugin = require((0, ssr_server_utils_1.loadModuleFromFramew
8
8
  const WebpackBar = require('webpackbar');
9
9
  const loadModule = ssr_server_utils_1.loadModuleFromFramework;
10
10
  const addBabelLoader = (chain, envOptions) => {
11
+ var _a, _b;
12
+ const { babelOptions } = (0, ssr_server_utils_1.loadConfig)();
11
13
  chain.use('babel-loader')
12
14
  .loader(loadModule('babel-loader'))
13
15
  .options({
@@ -19,7 +21,8 @@ const addBabelLoader = (chain, envOptions) => {
19
21
  loadModule('@babel/preset-env'),
20
22
  envOptions
21
23
  ],
22
- [loadModule('babel-preset-react-app'), { flow: false, typescript: true }]
24
+ [loadModule('babel-preset-react-app'), { flow: false, typescript: true }],
25
+ ...(_a = babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.presets) !== null && _a !== void 0 ? _a : []
23
26
  ],
24
27
  plugins: [
25
28
  [loadModule('@babel/plugin-transform-runtime'), {
@@ -36,7 +39,8 @@ const addBabelLoader = (chain, envOptions) => {
36
39
  }, 'antd'
37
40
  ],
38
41
  [loadModule('@babel/plugin-proposal-private-methods'), { loose: true }],
39
- [loadModule('@babel/plugin-proposal-private-property-in-object'), { loose: true }]
42
+ [loadModule('@babel/plugin-proposal-private-property-in-object'), { loose: true }],
43
+ ...(_b = babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.plugins) !== null && _b !== void 0 ? _b : []
40
44
  ]
41
45
  })
42
46
  .end();
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, _p, _q, _r;
2
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
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, supportOptinalChaining, isDev, define } = (0, ssr_server_utils_1.loadConfig)();
9
+ const { getOutput, 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/],
@@ -24,15 +24,19 @@ const serverConfig = {
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
26
  jsxRuntime: 'classic',
27
- babel: !supportOptinalChaining && {
27
+ babel: {
28
+ ...babelOptions,
28
29
  plugins: [
29
- '@babel/plugin-proposal-optional-chaining',
30
- '@babel/plugin-proposal-nullish-coalescing-operator'
30
+ ...(_c = babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.plugins) !== null && _c !== void 0 ? _c : [],
31
+ ...!supportOptinalChaining ? [
32
+ '@babel/plugin-proposal-optional-chaining',
33
+ '@babel/plugin-proposal-nullish-coalescing-operator'
34
+ ] : []
31
35
  ]
32
36
  }
33
37
  }),
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,
38
+ (_e = (_d = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _d === void 0 ? void 0 : _d.common) === null || _e === void 0 ? void 0 : _e.extraPlugin,
39
+ (_g = (_f = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _f === void 0 ? void 0 : _f.server) === null || _g === void 0 ? void 0 : _g.extraPlugin,
36
40
  (0, vite_plugin_style_import_1.default)(styleImportConfig)
37
41
  ],
38
42
  build: {
@@ -47,7 +51,7 @@ const serverConfig = {
47
51
  },
48
52
  define: {
49
53
  __isBrowser__: false,
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,
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,
51
55
  ...define === null || define === void 0 ? void 0 : define.server,
52
56
  ...define === null || define === void 0 ? void 0 : define.base
53
57
  }
@@ -60,11 +64,12 @@ const clientConfig = {
60
64
  },
61
65
  plugins: [
62
66
  (0, plugin_react_1.default)({
63
- ...(_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,
64
- jsxRuntime: 'classic'
67
+ ...(_l = (_k = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _k === void 0 ? void 0 : _k.client) === null || _l === void 0 ? void 0 : _l.defaultPluginOptions,
68
+ jsxRuntime: 'classic',
69
+ ...babelOptions
65
70
  }),
66
- (_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,
67
- (_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,
71
+ (_o = (_m = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _m === void 0 ? void 0 : _m.common) === null || _o === void 0 ? void 0 : _o.extraPlugin,
72
+ (_q = (_p = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _p === void 0 ? void 0 : _p.client) === null || _q === void 0 ? void 0 : _q.extraPlugin,
68
73
  (0, vite_plugin_style_import_1.default)(styleImportConfig)
69
74
  ],
70
75
  build: {
@@ -78,7 +83,7 @@ const clientConfig = {
78
83
  },
79
84
  define: {
80
85
  __isBrowser__: true,
81
- ...(_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,
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,
82
87
  ...define === null || define === void 0 ? void 0 : define.client,
83
88
  ...define === null || define === void 0 ? void 0 : define.base
84
89
  }
@@ -5,6 +5,8 @@ const MiniCssExtractPlugin = require(loadModuleFromFramework('mini-css-extract-p
5
5
  const WebpackBar = require('webpackbar');
6
6
  const loadModule = loadModuleFromFramework;
7
7
  const addBabelLoader = (chain, envOptions) => {
8
+ var _a, _b;
9
+ const { babelOptions } = loadConfig();
8
10
  chain.use('babel-loader')
9
11
  .loader(loadModule('babel-loader'))
10
12
  .options({
@@ -16,7 +18,8 @@ const addBabelLoader = (chain, envOptions) => {
16
18
  loadModule('@babel/preset-env'),
17
19
  envOptions
18
20
  ],
19
- [loadModule('babel-preset-react-app'), { flow: false, typescript: true }]
21
+ [loadModule('babel-preset-react-app'), { flow: false, typescript: true }],
22
+ ...(_a = babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.presets) !== null && _a !== void 0 ? _a : []
20
23
  ],
21
24
  plugins: [
22
25
  [loadModule('@babel/plugin-transform-runtime'), {
@@ -33,7 +36,8 @@ const addBabelLoader = (chain, envOptions) => {
33
36
  }, 'antd'
34
37
  ],
35
38
  [loadModule('@babel/plugin-proposal-private-methods'), { loose: true }],
36
- [loadModule('@babel/plugin-proposal-private-property-in-object'), { loose: true }]
39
+ [loadModule('@babel/plugin-proposal-private-property-in-object'), { loose: true }],
40
+ ...(_b = babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.plugins) !== null && _b !== void 0 ? _b : []
37
41
  ]
38
42
  })
39
43
  .end();
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, _p, _q, _r;
1
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
2
2
  import { loadConfig, chunkNamePlugin, rollupOutputOptions, manifestPlugin, commonConfig, asyncOptimizeChunkPlugin } 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, supportOptinalChaining, isDev, define } = loadConfig();
6
+ const { getOutput, 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/],
@@ -21,15 +21,19 @@ const serverConfig = {
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
23
  jsxRuntime: 'classic',
24
- babel: !supportOptinalChaining && {
24
+ babel: {
25
+ ...babelOptions,
25
26
  plugins: [
26
- '@babel/plugin-proposal-optional-chaining',
27
- '@babel/plugin-proposal-nullish-coalescing-operator'
27
+ ...(_c = babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.plugins) !== null && _c !== void 0 ? _c : [],
28
+ ...!supportOptinalChaining ? [
29
+ '@babel/plugin-proposal-optional-chaining',
30
+ '@babel/plugin-proposal-nullish-coalescing-operator'
31
+ ] : []
28
32
  ]
29
33
  }
30
34
  }),
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,
35
+ (_e = (_d = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _d === void 0 ? void 0 : _d.common) === null || _e === void 0 ? void 0 : _e.extraPlugin,
36
+ (_g = (_f = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _f === void 0 ? void 0 : _f.server) === null || _g === void 0 ? void 0 : _g.extraPlugin,
33
37
  styleImport(styleImportConfig)
34
38
  ],
35
39
  build: {
@@ -44,7 +48,7 @@ const serverConfig = {
44
48
  },
45
49
  define: {
46
50
  __isBrowser__: false,
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,
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,
48
52
  ...define === null || define === void 0 ? void 0 : define.server,
49
53
  ...define === null || define === void 0 ? void 0 : define.base
50
54
  }
@@ -56,11 +60,12 @@ const clientConfig = {
56
60
  },
57
61
  plugins: [
58
62
  react({
59
- ...(_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,
60
- jsxRuntime: 'classic'
63
+ ...(_l = (_k = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _k === void 0 ? void 0 : _k.client) === null || _l === void 0 ? void 0 : _l.defaultPluginOptions,
64
+ jsxRuntime: 'classic',
65
+ ...babelOptions
61
66
  }),
62
- (_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,
63
- (_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,
67
+ (_o = (_m = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _m === void 0 ? void 0 : _m.common) === null || _o === void 0 ? void 0 : _o.extraPlugin,
68
+ (_q = (_p = viteConfig === null || viteConfig === void 0 ? void 0 : viteConfig()) === null || _p === void 0 ? void 0 : _p.client) === null || _q === void 0 ? void 0 : _q.extraPlugin,
64
69
  styleImport(styleImportConfig)
65
70
  ],
66
71
  build: {
@@ -74,7 +79,7 @@ const clientConfig = {
74
79
  },
75
80
  define: {
76
81
  __isBrowser__: true,
77
- ...(_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,
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,
78
83
  ...define === null || define === void 0 ? void 0 : define.client,
79
84
  ...define === null || define === void 0 ? void 0 : define.base
80
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssr-plugin-react",
3
- "version": "6.1.42",
3
+ "version": "6.1.48",
4
4
  "description": "plugin-react for ssr",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -38,7 +38,6 @@
38
38
  "babel-loader": "8.0.4",
39
39
  "babel-plugin-import": "^1.13.0",
40
40
  "babel-preset-react-app": "^9.0.2",
41
- "concurrently": "^5.1.0",
42
41
  "core-js": "^3.6.4",
43
42
  "css-hot-loader": "^1.4.4",
44
43
  "css-loader": "^5.2.7",
@@ -56,10 +55,10 @@
56
55
  "postcss-safe-parser": "4.0.1",
57
56
  "react-dev-utils": "^11.0.4",
58
57
  "serialize-javascript": "^6.0.0",
59
- "ssr-client-utils": "^6.1.42",
60
- "ssr-hoc-react": "^6.1.42",
61
- "ssr-server-utils": "^6.1.42",
62
- "ssr-webpack": "^6.1.42",
58
+ "ssr-client-utils": "^6.1.48",
59
+ "ssr-hoc-react": "^6.1.48",
60
+ "ssr-server-utils": "^6.1.48",
61
+ "ssr-webpack": "^6.1.48",
63
62
  "terser-webpack-plugin": "^2.3.5",
64
63
  "url-loader": "^4.1.1",
65
64
  "vite": "^2.7.0",
@@ -74,7 +73,8 @@
74
73
  "@types/react-dom": "^17.0.0",
75
74
  "@types/react-router-dom": "^5.1.3",
76
75
  "@types/webpack": "^4.41.10",
77
- "ssr-types-react": "^6.1.42"
76
+ "concurrently": "^5.1.0",
77
+ "ssr-types-react": "^6.1.48"
78
78
  },
79
- "gitHead": "3426bffd013456e7b72ba73f1f04a9a73855bc27"
79
+ "gitHead": "104b30653d5e3860cda1a4ed321a432306e5832d"
80
80
  }
@@ -10,6 +10,7 @@ const WebpackBar = require('webpackbar')
10
10
  const loadModule = loadModuleFromFramework
11
11
 
12
12
  const addBabelLoader = (chain: WebpackChain.Rule<WebpackChain.Module>, envOptions: any) => {
13
+ const { babelOptions } = loadConfig()
13
14
  chain.use('babel-loader')
14
15
  .loader(loadModule('babel-loader'))
15
16
  .options({
@@ -21,7 +22,8 @@ const addBabelLoader = (chain: WebpackChain.Rule<WebpackChain.Module>, envOption
21
22
  loadModule('@babel/preset-env'),
22
23
  envOptions
23
24
  ],
24
- [loadModule('babel-preset-react-app'), { flow: false, typescript: true }]
25
+ [loadModule('babel-preset-react-app'), { flow: false, typescript: true }],
26
+ ...babelOptions?.presets ?? []
25
27
  ],
26
28
  plugins: [
27
29
  [loadModule('@babel/plugin-transform-runtime'), {
@@ -38,7 +40,8 @@ const addBabelLoader = (chain: WebpackChain.Rule<WebpackChain.Module>, envOption
38
40
  }, 'antd'
39
41
  ],
40
42
  [loadModule('@babel/plugin-proposal-private-methods'), { loose: true }],
41
- [loadModule('@babel/plugin-proposal-private-property-in-object'), { loose: true }]
43
+ [loadModule('@babel/plugin-proposal-private-property-in-object'), { loose: true }],
44
+ ...babelOptions?.plugins ?? []
42
45
  ]
43
46
  })
44
47
  .end()
package/src/tools/vite.ts CHANGED
@@ -10,7 +10,7 @@ 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, supportOptinalChaining, isDev, define } = loadConfig()
13
+ const { getOutput, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev, define, babelOptions } = loadConfig()
14
14
 
15
15
  const { clientOutPut, serverOutPut } = getOutput()
16
16
  const styleImportConfig = {
@@ -29,10 +29,14 @@ const serverConfig: UserConfig = {
29
29
  react({
30
30
  ...viteConfig?.()?.server?.defaultPluginOptions,
31
31
  jsxRuntime: 'classic',
32
- babel: !supportOptinalChaining && {
32
+ babel: {
33
+ ...babelOptions,
33
34
  plugins: [
34
- '@babel/plugin-proposal-optional-chaining',
35
- '@babel/plugin-proposal-nullish-coalescing-operator'
35
+ ...babelOptions?.plugins ?? [],
36
+ ...!supportOptinalChaining ? [
37
+ '@babel/plugin-proposal-optional-chaining',
38
+ '@babel/plugin-proposal-nullish-coalescing-operator'
39
+ ] : []
36
40
  ]
37
41
  }
38
42
  }),
@@ -66,7 +70,8 @@ const clientConfig: UserConfig = {
66
70
  plugins: [
67
71
  react({
68
72
  ...viteConfig?.()?.client?.defaultPluginOptions,
69
- jsxRuntime: 'classic'
73
+ jsxRuntime: 'classic',
74
+ ...babelOptions
70
75
  }),
71
76
  viteConfig?.()?.common?.extraPlugin,
72
77
  viteConfig?.()?.client?.extraPlugin,