@modern-js/plugin-ssg 2.5.0 → 2.7.0

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
@@ -1,5 +1,34 @@
1
1
  # @modern-js/plugin-ssg
2
2
 
3
+ ## 2.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - dcad887024: feat: support deferred data for streaming ssr
8
+ feat: 流式渲染支持 deferred data
9
+
10
+ ### Patch Changes
11
+
12
+ - 0de9e61292: fix: ssg error reporting inaccuracy problem
13
+
14
+ fix: 修复 ssg 报错不准确的问题
15
+
16
+ - Updated dependencies [0f15fc597c]
17
+ - Updated dependencies [dcad887024]
18
+ - Updated dependencies [a4672f7c16]
19
+ - Updated dependencies [7fff9020e1]
20
+ - Updated dependencies [84bfb439b8]
21
+ - @modern-js/utils@2.7.0
22
+
23
+ ## 2.6.0
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [e1f799e]
28
+ - Updated dependencies [7915ab3]
29
+ - Updated dependencies [0fe658a]
30
+ - @modern-js/utils@2.6.0
31
+
3
32
  ## 2.5.0
4
33
 
5
34
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -32,6 +36,7 @@ var import_utils = require("@modern-js/utils");
32
36
  var import_util = require("../libs/util");
33
37
  var import_consts = require("./consts");
34
38
  const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) => new Promise((resolve, reject) => {
39
+ var _a, _b;
35
40
  const entries = ssgRoutes.map((route) => route.entryName);
36
41
  const backup = (0, import_util.openRouteSSR)(pageRoutes, entries);
37
42
  const total = backup.concat(apiRoutes);
@@ -65,7 +70,7 @@ const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirecto
65
70
  resolve(htmlAry);
66
71
  }
67
72
  });
68
- cp.stderr.on("data", (chunk) => {
73
+ (_a = cp.stderr) == null ? void 0 : _a.on("data", (chunk) => {
69
74
  const str = chunk.toString();
70
75
  if (str.includes("Error")) {
71
76
  import_utils.logger.error(str);
@@ -75,7 +80,7 @@ const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirecto
75
80
  import_utils.logger.info(str.replace(/[^\S\n]+/g, " "));
76
81
  }
77
82
  });
78
- cp.stdout.on("data", (chunk) => {
83
+ (_b = cp.stdout) == null ? void 0 : _b.on("data", (chunk) => {
79
84
  const str = chunk.toString();
80
85
  if (str.includes("Error")) {
81
86
  import_utils.logger.error(str);
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -13,6 +13,10 @@ var __copyProps = (to, from, except, desc) => {
13
13
  return to;
14
14
  };
15
15
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
16
20
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
17
21
  mod
18
22
  ));
@@ -68,6 +72,6 @@ process.on("message", async (chunk) => {
68
72
  });
69
73
  } catch (e) {
70
74
  modernServer == null ? void 0 : modernServer.close();
71
- throw e;
75
+ process.stderr.write(e instanceof Error ? e.stack : e.toString());
72
76
  }
73
77
  });
@@ -5,6 +5,7 @@ import { openRouteSSR } from "../libs/util";
5
5
  import { CLOSE_SIGN } from "./consts";
6
6
  var createServer = function(api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) {
7
7
  return new Promise(function(resolve, reject) {
8
+ var _cp_stderr, _cp_stdout;
8
9
  var entries = ssgRoutes.map(function(route) {
9
10
  return route.entryName;
10
11
  });
@@ -38,7 +39,7 @@ var createServer = function(api, ssgRoutes, pageRoutes, apiRoutes, options, appD
38
39
  resolve(htmlAry);
39
40
  }
40
41
  });
41
- cp.stderr.on("data", function(chunk) {
42
+ (_cp_stderr = cp.stderr) === null || _cp_stderr === void 0 ? void 0 : _cp_stderr.on("data", function(chunk) {
42
43
  var str = chunk.toString();
43
44
  if (str.includes("Error")) {
44
45
  logger.error(str);
@@ -48,7 +49,7 @@ var createServer = function(api, ssgRoutes, pageRoutes, apiRoutes, options, appD
48
49
  logger.info(str.replace(/[^\S\n]+/g, " "));
49
50
  }
50
51
  });
51
- cp.stdout.on("data", function(chunk) {
52
+ (_cp_stdout = cp.stdout) === null || _cp_stdout === void 0 ? void 0 : _cp_stdout.on("data", function(chunk) {
52
53
  var str = chunk.toString();
53
54
  if (str.includes("Error")) {
54
55
  logger.error(str);
@@ -27,6 +27,13 @@ function _asyncToGenerator(fn) {
27
27
  });
28
28
  };
29
29
  }
30
+ function _instanceof(left, right) {
31
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
32
+ return !!right[Symbol.hasInstance](left);
33
+ } else {
34
+ return left instanceof right;
35
+ }
36
+ }
30
37
  var __generator = this && this.__generator || function(thisArg, body) {
31
38
  var f, y, t, g, _ = {
32
39
  label: 0,
@@ -212,7 +219,11 @@ process.on("message", function() {
212
219
  case 4:
213
220
  e = _state.sent();
214
221
  modernServer === null || modernServer === void 0 ? void 0 : modernServer.close();
215
- throw e;
222
+ process.stderr.write(_instanceof(e, Error) ? e.stack : e.toString());
223
+ return [
224
+ 3,
225
+ 5
226
+ ];
216
227
  case 5:
217
228
  return [
218
229
  2
@@ -4,6 +4,7 @@ import { logger } from "@modern-js/utils";
4
4
  import { openRouteSSR } from "../libs/util";
5
5
  import { CLOSE_SIGN } from "./consts";
6
6
  const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) => new Promise((resolve, reject) => {
7
+ var _a, _b;
7
8
  const entries = ssgRoutes.map((route) => route.entryName);
8
9
  const backup = openRouteSSR(pageRoutes, entries);
9
10
  const total = backup.concat(apiRoutes);
@@ -37,7 +38,7 @@ const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirecto
37
38
  resolve(htmlAry);
38
39
  }
39
40
  });
40
- cp.stderr.on("data", (chunk) => {
41
+ (_a = cp.stderr) == null ? void 0 : _a.on("data", (chunk) => {
41
42
  const str = chunk.toString();
42
43
  if (str.includes("Error")) {
43
44
  logger.error(str);
@@ -47,7 +48,7 @@ const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirecto
47
48
  logger.info(str.replace(/[^\S\n]+/g, " "));
48
49
  }
49
50
  });
50
- cp.stdout.on("data", (chunk) => {
51
+ (_b = cp.stdout) == null ? void 0 : _b.on("data", (chunk) => {
51
52
  const str = chunk.toString();
52
53
  if (str.includes("Error")) {
53
54
  logger.error(str);
@@ -50,6 +50,6 @@ process.on("message", async (chunk) => {
50
50
  });
51
51
  } catch (e) {
52
52
  modernServer == null ? void 0 : modernServer.close();
53
- throw e;
53
+ process.stderr.write(e instanceof Error ? e.stack : e.toString());
54
54
  }
55
55
  });
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.5.0",
14
+ "version": "2.7.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/cjs/index.js",
@@ -57,7 +57,7 @@
57
57
  "node-mocks-http": "^1.10.1",
58
58
  "normalize-path": "^3.0.0",
59
59
  "portfinder": "^1.0.28",
60
- "@modern-js/utils": "2.5.0"
60
+ "@modern-js/utils": "2.7.0"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "react-router-dom": ">=5.1.2"
@@ -72,13 +72,13 @@
72
72
  "@types/node": "^14",
73
73
  "jest": "^27",
74
74
  "react": "^18",
75
- "react-router-dom": "^6.6.0",
75
+ "react-router-dom": "^6.8.1",
76
76
  "typescript": "^4",
77
- "@modern-js/app-tools": "2.5.0",
78
- "@modern-js/prod-server": "2.5.0",
79
- "@modern-js/types": "2.5.0",
80
- "@scripts/build": "2.5.0",
81
- "@scripts/jest-config": "2.5.0"
77
+ "@modern-js/app-tools": "2.7.0",
78
+ "@modern-js/prod-server": "2.7.0",
79
+ "@modern-js/types": "2.7.0",
80
+ "@scripts/jest-config": "2.7.0",
81
+ "@scripts/build": "2.7.0"
82
82
  },
83
83
  "sideEffects": false,
84
84
  "publishConfig": {