ssr-plugin-react 6.1.30 → 6.1.36

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.36](https://github.com/zhangyuang/ssr/compare/v6.1.35...v6.1.36) (2021-12-30)
7
+
8
+ **Note:** Version bump only for package ssr-plugin-react
9
+
10
+
11
+
12
+
13
+
14
+ ## [6.1.35](https://github.com/zhangyuang/ssr/compare/v6.1.34...v6.1.35) (2021-12-30)
15
+
16
+ **Note:** Version bump only for package ssr-plugin-react
17
+
18
+
19
+
20
+
21
+
22
+ ## [6.1.34](https://github.com/zhangyuang/ssr/compare/v6.1.33...v6.1.34) (2021-12-29)
23
+
24
+
25
+ ### Features
26
+
27
+ * support dynamic css preload in vite mode ([3979b42](https://github.com/zhangyuang/ssr/commit/3979b4236c3fdcc0312987f86783f8485892276e))
28
+
29
+
30
+
31
+
32
+
33
+ ## [6.1.31](https://github.com/zhangyuang/ssr/compare/v6.1.30...v6.1.31) (2021-12-17)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * node12 vite ssr optimize ([941a405](https://github.com/zhangyuang/ssr/commit/941a40507303606859ecd08a8594010929c4aaaa))
39
+
40
+
41
+
42
+
43
+
6
44
  ## [6.1.30](https://github.com/zhangyuang/ssr/compare/v6.1.29...v6.1.30) (2021-12-17)
7
45
 
8
46
 
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/i1X1OIr2VfQ9MLcvsFOCyN4UWghSc85u64U8OeXxQWKrpdXvpnhe-gms1sUgtRr_QOHZPqanJ2G_lNzuN00ZvQ" width="300">
276
+ <img src="https://res.wx.qq.com/op_res/QHEy-aukLNwJhw1OYtAnYlslZscEeZ8SyyTcolA3wSnHM-wpfwLJYbzQMtfEeD44sN9tAYryDJQkmWSlElMJkw" width="300">
277
277
  </div>
278
278
 
279
279
  ## 前端开发手册
@@ -4,7 +4,7 @@ exports.serverRender = void 0;
4
4
  const React = require("react");
5
5
  const react_router_dom_1 = require("react-router-dom");
6
6
  const ssr_server_utils_1 = require("ssr-server-utils");
7
- //@ts-expect-error
7
+ // @ts-expect-error
8
8
  const serializeWrap = require("serialize-javascript");
9
9
  // @ts-expect-error
10
10
  const Routes = require("_build/ssr-temporary-routes");
@@ -32,7 +32,8 @@ const serverRender = async (ctx, config) => {
32
32
  let dynamicCssOrder = cssOrder;
33
33
  if (dynamic) {
34
34
  dynamicCssOrder = cssOrder.concat([`${routeItem.webpackChunkName}.css`]);
35
- if (!isVite) {
35
+ if (!isVite || (isVite && !isDev)) {
36
+ // call it when webpack mode or vite prod mode
36
37
  dynamicCssOrder = await (0, ssr_server_utils_1.addAsyncChunk)(dynamicCssOrder, routeItem.webpackChunkName);
37
38
  }
38
39
  }
package/cjs/tools/vite.js CHANGED
@@ -6,7 +6,7 @@ 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 } = (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/],
@@ -20,10 +20,6 @@ const styleImportConfig = {
20
20
  };
21
21
  const serverConfig = {
22
22
  ...(0, ssr_server_utils_1.commonConfig)(),
23
- optimizeDeps: {
24
- include: ['path-to-regexp', 'react-dom'],
25
- exclude: ['ssr-server-utils']
26
- },
27
23
  plugins: [
28
24
  (0, plugin_react_1.default)({
29
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,
@@ -43,6 +39,7 @@ const serverConfig = {
43
39
  ssr: reactServerEntry,
44
40
  outDir: serverOutPut,
45
41
  rollupOptions: {
42
+ input: isDev ? reactClientEntry : '',
46
43
  output: {
47
44
  entryFileNames: 'Page.server.js'
48
45
  }
@@ -74,7 +71,7 @@ const clientConfig = {
74
71
  rollupOptions: {
75
72
  input: reactClientEntry,
76
73
  output: ssr_server_utils_1.rollupOutputOptions,
77
- plugins: [(0, ssr_server_utils_1.chunkNamePlugin)(), (0, ssr_server_utils_1.manifestPlugin)()]
74
+ plugins: [(0, ssr_server_utils_1.chunkNamePlugin)(), (0, ssr_server_utils_1.asyncOptimizeChunkPlugin)(), (0, ssr_server_utils_1.manifestPlugin)()]
78
75
  }
79
76
  },
80
77
  define: {
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { StaticRouter } from 'react-router-dom';
3
3
  import { findRoute, getManifest, logGreen, normalizePath, addAsyncChunk } from 'ssr-server-utils';
4
- //@ts-expect-error
4
+ // @ts-expect-error
5
5
  import * as serializeWrap from 'serialize-javascript';
6
6
  // @ts-expect-error
7
7
  import * as Routes from '_build/ssr-temporary-routes';
@@ -29,7 +29,8 @@ const serverRender = async (ctx, config) => {
29
29
  let dynamicCssOrder = cssOrder;
30
30
  if (dynamic) {
31
31
  dynamicCssOrder = cssOrder.concat([`${routeItem.webpackChunkName}.css`]);
32
- if (!isVite) {
32
+ if (!isVite || (isVite && !isDev)) {
33
+ // call it when webpack mode or vite prod mode
33
34
  dynamicCssOrder = await addAsyncChunk(dynamicCssOrder, routeItem.webpackChunkName);
34
35
  }
35
36
  }
package/esm/tools/vite.js CHANGED
@@ -1,9 +1,9 @@
1
1
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
2
- import { loadConfig, chunkNamePlugin, rollupOutputOptions, manifestPlugin, commonConfig } from 'ssr-server-utils';
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 } = 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/],
@@ -17,10 +17,6 @@ const styleImportConfig = {
17
17
  };
18
18
  const serverConfig = {
19
19
  ...commonConfig(),
20
- optimizeDeps: {
21
- include: ['path-to-regexp', 'react-dom'],
22
- exclude: ['ssr-server-utils']
23
- },
24
20
  plugins: [
25
21
  react({
26
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,
@@ -40,6 +36,7 @@ const serverConfig = {
40
36
  ssr: reactServerEntry,
41
37
  outDir: serverOutPut,
42
38
  rollupOptions: {
39
+ input: isDev ? reactClientEntry : '',
43
40
  output: {
44
41
  entryFileNames: 'Page.server.js'
45
42
  }
@@ -70,7 +67,7 @@ const clientConfig = {
70
67
  rollupOptions: {
71
68
  input: reactClientEntry,
72
69
  output: rollupOutputOptions,
73
- plugins: [chunkNamePlugin(), manifestPlugin()]
70
+ plugins: [chunkNamePlugin(), asyncOptimizeChunkPlugin(), manifestPlugin()]
74
71
  }
75
72
  },
76
73
  define: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssr-plugin-react",
3
- "version": "6.1.30",
3
+ "version": "6.1.36",
4
4
  "description": "plugin-react for ssr",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -58,8 +58,8 @@
58
58
  "serialize-javascript": "^6.0.0",
59
59
  "ssr-client-utils": "^6.1.29",
60
60
  "ssr-hoc-react": "^6.1.29",
61
- "ssr-server-utils": "^6.1.29",
62
- "ssr-webpack": "^6.1.29",
61
+ "ssr-server-utils": "^6.1.36",
62
+ "ssr-webpack": "^6.1.36",
63
63
  "terser-webpack-plugin": "^2.3.5",
64
64
  "url-loader": "^4.1.1",
65
65
  "vite": "^2.7.0",
@@ -76,5 +76,5 @@
76
76
  "@types/webpack": "^4.41.10",
77
77
  "ssr-types-react": "^6.1.29"
78
78
  },
79
- "gitHead": "880fd2d12752666a1d89dd37f30bf1fef801b0b2"
79
+ "gitHead": "1383b509801fc3912fe8a498a10ffe78040a29f5"
80
80
  }
@@ -2,7 +2,7 @@ import * as React from 'react'
2
2
  import { StaticRouter } from 'react-router-dom'
3
3
  import { findRoute, getManifest, logGreen, normalizePath, addAsyncChunk } from 'ssr-server-utils'
4
4
  import { ISSRContext, IConfig, ReactRoutesType, ReactESMFeRouteItem } from 'ssr-types-react'
5
- //@ts-expect-error
5
+ // @ts-expect-error
6
6
  import * as serializeWrap from 'serialize-javascript'
7
7
  // @ts-expect-error
8
8
  import * as Routes from '_build/ssr-temporary-routes'
@@ -34,7 +34,8 @@ const serverRender = async (ctx: ISSRContext, config: IConfig): Promise<React.Re
34
34
 
35
35
  if (dynamic) {
36
36
  dynamicCssOrder = cssOrder.concat([`${routeItem.webpackChunkName}.css`])
37
- if (!isVite) {
37
+ if (!isVite || (isVite && !isDev)) {
38
+ // call it when webpack mode or vite prod mode
38
39
  dynamicCssOrder = await addAsyncChunk(dynamicCssOrder, routeItem.webpackChunkName)
39
40
  }
40
41
  }
package/src/tools/vite.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { build as BuildType, UserConfig } from 'vite'
2
- import { loadConfig, chunkNamePlugin, rollupOutputOptions, manifestPlugin, commonConfig } from 'ssr-server-utils'
2
+ import { loadConfig, chunkNamePlugin, rollupOutputOptions, manifestPlugin, commonConfig, asyncOptimizeChunkPlugin } from 'ssr-server-utils'
3
3
  import react from '@vitejs/plugin-react'
4
4
  import styleImport, {
5
5
  AndDesignVueResolve,
@@ -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 } = loadConfig()
13
+ const { getOutput, reactServerEntry, reactClientEntry, viteConfig, supportOptinalChaining, isDev } = loadConfig()
14
14
 
15
15
  const { clientOutPut, serverOutPut } = getOutput()
16
16
  const styleImportConfig = {
@@ -25,10 +25,6 @@ const styleImportConfig = {
25
25
  }
26
26
  const serverConfig: UserConfig = {
27
27
  ...commonConfig(),
28
- optimizeDeps: {
29
- include: ['path-to-regexp', 'react-dom'],
30
- exclude: ['ssr-server-utils']
31
- },
32
28
  plugins: [
33
29
  react({
34
30
  ...viteConfig?.()?.server?.defaultPluginOptions,
@@ -48,6 +44,7 @@ const serverConfig: UserConfig = {
48
44
  ssr: reactServerEntry,
49
45
  outDir: serverOutPut,
50
46
  rollupOptions: {
47
+ input: isDev ? reactClientEntry : '',
51
48
  output: {
52
49
  entryFileNames: 'Page.server.js'
53
50
  }
@@ -79,7 +76,7 @@ const clientConfig: UserConfig = {
79
76
  rollupOptions: {
80
77
  input: reactClientEntry,
81
78
  output: rollupOutputOptions,
82
- plugins: [chunkNamePlugin(), manifestPlugin()]
79
+ plugins: [chunkNamePlugin(), asyncOptimizeChunkPlugin(), manifestPlugin()]
83
80
  }
84
81
  },
85
82
  define: {