ssr-plugin-react 6.1.17 → 6.1.18

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,17 @@
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.18](https://github.com/zhangyuang/ssr/compare/v6.1.17...v6.1.18) (2021-12-07)
7
+
8
+
9
+ ### Features
10
+
11
+ * add viteConfig ([ee86006](https://github.com/zhangyuang/ssr/commit/ee8600688b832b36089128e18f63a4cc8d630a25))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [6.1.17](https://github.com/zhangyuang/ssr/compare/v6.1.15...v6.1.17) (2021-12-07)
7
18
 
8
19
 
package/cjs/tools/vite.js CHANGED
@@ -1,17 +1,20 @@
1
1
  "use strict";
2
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.clientConfig = exports.serverConfig = exports.viteStart = exports.viteBuild = void 0;
4
5
  const ssr_server_utils_1 = require("ssr-server-utils");
5
6
  const plugin_react_1 = require("@vitejs/plugin-react");
6
7
  const build = require('vite').build;
7
- const { getOutput, reactServerEntry, reactClientEntry } = (0, ssr_server_utils_1.loadConfig)();
8
+ const { getOutput, reactServerEntry, reactClientEntry, viteConfig } = (0, ssr_server_utils_1.loadConfig)();
8
9
  const { clientOutPut, serverOutPut } = getOutput();
9
10
  const serverConfig = {
10
11
  ...(0, ssr_server_utils_1.commonConfig)(),
11
12
  plugins: [
12
13
  (0, plugin_react_1.default)({
14
+ ...(_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,
13
15
  jsxRuntime: 'classic'
14
- })
16
+ }),
17
+ (_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
15
18
  ],
16
19
  build: {
17
20
  ssr: reactServerEntry,
@@ -23,7 +26,8 @@ const serverConfig = {
23
26
  }
24
27
  },
25
28
  define: {
26
- __isBrowser__: false
29
+ __isBrowser__: false,
30
+ ...(_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
27
31
  }
28
32
  };
29
33
  exports.serverConfig = serverConfig;
@@ -34,8 +38,10 @@ const clientConfig = {
34
38
  },
35
39
  plugins: [
36
40
  (0, plugin_react_1.default)({
41
+ ...(_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,
37
42
  jsxRuntime: 'classic'
38
- })
43
+ }),
44
+ (_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
39
45
  ],
40
46
  build: {
41
47
  ssrManifest: true,
@@ -47,7 +53,8 @@ const clientConfig = {
47
53
  }
48
54
  },
49
55
  define: {
50
- __isBrowser__: true
56
+ __isBrowser__: true,
57
+ ...(_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
51
58
  }
52
59
  };
53
60
  exports.clientConfig = clientConfig;
package/esm/tools/vite.js CHANGED
@@ -1,14 +1,17 @@
1
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1
2
  import { loadConfig, chunkNamePlugin, output, manifestPlugin, commonConfig } from 'ssr-server-utils';
2
3
  import react from '@vitejs/plugin-react';
3
4
  const build = require('vite').build;
4
- const { getOutput, reactServerEntry, reactClientEntry } = loadConfig();
5
+ const { getOutput, reactServerEntry, reactClientEntry, viteConfig } = loadConfig();
5
6
  const { clientOutPut, serverOutPut } = getOutput();
6
7
  const serverConfig = {
7
8
  ...commonConfig(),
8
9
  plugins: [
9
10
  react({
11
+ ...(_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,
10
12
  jsxRuntime: 'classic'
11
- })
13
+ }),
14
+ (_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
12
15
  ],
13
16
  build: {
14
17
  ssr: reactServerEntry,
@@ -20,7 +23,8 @@ const serverConfig = {
20
23
  }
21
24
  },
22
25
  define: {
23
- __isBrowser__: false
26
+ __isBrowser__: false,
27
+ ...(_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
24
28
  }
25
29
  };
26
30
  const clientConfig = {
@@ -30,8 +34,10 @@ const clientConfig = {
30
34
  },
31
35
  plugins: [
32
36
  react({
37
+ ...(_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,
33
38
  jsxRuntime: 'classic'
34
- })
39
+ }),
40
+ (_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
35
41
  ],
36
42
  build: {
37
43
  ssrManifest: true,
@@ -43,7 +49,8 @@ const clientConfig = {
43
49
  }
44
50
  },
45
51
  define: {
46
- __isBrowser__: true
52
+ __isBrowser__: true,
53
+ ...(_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
47
54
  }
48
55
  };
49
56
  const viteStart = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssr-plugin-react",
3
- "version": "6.1.17",
3
+ "version": "6.1.18",
4
4
  "description": "plugin-react for ssr",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -54,10 +54,10 @@
54
54
  "postcss-safe-parser": "4.0.1",
55
55
  "react-dev-utils": "^11.0.4",
56
56
  "serialize-javascript": "^6.0.0",
57
- "ssr-client-utils": "^6.1.15",
58
- "ssr-hoc-react": "^6.1.15",
59
- "ssr-server-utils": "^6.1.17",
60
- "ssr-webpack": "^6.1.17",
57
+ "ssr-client-utils": "^6.1.18",
58
+ "ssr-hoc-react": "^6.1.18",
59
+ "ssr-server-utils": "^6.1.18",
60
+ "ssr-webpack": "^6.1.18",
61
61
  "terser-webpack-plugin": "^2.3.5",
62
62
  "url-loader": "^4.1.1",
63
63
  "vite": "^2.7.0-beta.10",
@@ -71,7 +71,7 @@
71
71
  "@types/react-dom": "^17.0.0",
72
72
  "@types/react-router-dom": "^5.1.3",
73
73
  "@types/webpack": "^4.41.10",
74
- "ssr-types-react": "^6.1.15"
74
+ "ssr-types-react": "^6.1.18"
75
75
  },
76
- "gitHead": "4026213163a642c15c240f186178798e68aa78ce"
76
+ "gitHead": "7033461bb5347024123b67a2cb53a98dc2cf99c1"
77
77
  }
@@ -23,7 +23,7 @@ const getServerWebpack = (chain: WebpackChain) => {
23
23
  const modulesDir = [join(cwd, './node_modules')]
24
24
  modulesDir.push(getLocalNodeModules())
25
25
  chain.externals(nodeExternals({
26
- whitelist: [/\.(css|less|sass|scss)$/, /antd.*?(style)/].concat(whiteList || []),
26
+ whitelist: [/\.(css|less|sass|scss)$/, /antd.*?(style)/].concat(whiteList as RegExp[] || []),
27
27
  // externals Dir contains example/xxx/node_modules ssr/node_modules
28
28
  modulesDir
29
29
  }))
package/src/tools/vite.ts CHANGED
@@ -2,15 +2,17 @@ import type { build as BuildType, UserConfig } from 'vite'
2
2
  import { loadConfig, chunkNamePlugin, output, manifestPlugin, commonConfig } from 'ssr-server-utils'
3
3
  import react from '@vitejs/plugin-react'
4
4
  const build: typeof BuildType = require('vite').build
5
- const { getOutput, reactServerEntry, reactClientEntry } = loadConfig()
5
+ const { getOutput, reactServerEntry, reactClientEntry, viteConfig } = loadConfig()
6
6
  const { clientOutPut, serverOutPut } = getOutput()
7
7
 
8
8
  const serverConfig: UserConfig = {
9
9
  ...commonConfig(),
10
10
  plugins: [
11
11
  react({
12
+ ...viteConfig?.()?.server?.defaultPluginOptions,
12
13
  jsxRuntime: 'classic'
13
- })
14
+ }),
15
+ viteConfig?.()?.server?.extraPlugin
14
16
  ],
15
17
  build: {
16
18
  ssr: reactServerEntry,
@@ -22,7 +24,8 @@ const serverConfig: UserConfig = {
22
24
  }
23
25
  },
24
26
  define: {
25
- __isBrowser__: false
27
+ __isBrowser__: false,
28
+ ...viteConfig?.()?.server?.define
26
29
  }
27
30
  }
28
31
 
@@ -33,8 +36,10 @@ const clientConfig: UserConfig = {
33
36
  },
34
37
  plugins: [
35
38
  react({
39
+ ...viteConfig?.()?.client?.defaultPluginOptions,
36
40
  jsxRuntime: 'classic'
37
- })
41
+ }),
42
+ viteConfig?.()?.client?.extraPlugin
38
43
  ],
39
44
  build: {
40
45
  ssrManifest: true,
@@ -46,7 +51,8 @@ const clientConfig: UserConfig = {
46
51
  }
47
52
  },
48
53
  define: {
49
- __isBrowser__: true
54
+ __isBrowser__: true,
55
+ ...viteConfig?.()?.client?.define
50
56
  }
51
57
  }
52
58
  const viteStart = async () => {