@modern-js/plugin-ssg 2.15.0 → 2.17.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.
@@ -1,49 +1,36 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
8
6
  for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
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.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var util_exports = {};
29
- __export(util_exports, {
30
- flattenRoutes: () => flattenRoutes,
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
31
13
  formatOutput: () => formatOutput,
32
14
  formatPath: () => formatPath,
33
- getOutput: () => getOutput,
34
- getUrlPrefix: () => getUrlPrefix,
35
15
  isDynamicUrl: () => isDynamicUrl,
36
- openRouteSSR: () => openRouteSSR,
16
+ getUrlPrefix: () => getUrlPrefix,
17
+ getOutput: () => getOutput,
37
18
  readJSONSpec: () => readJSONSpec,
19
+ writeJSONSpec: () => writeJSONSpec,
38
20
  replaceWithAlias: () => replaceWithAlias,
39
21
  standardOptions: () => standardOptions,
40
- writeJSONSpec: () => writeJSONSpec
22
+ openRouteSSR: () => openRouteSSR,
23
+ flattenRoutes: () => flattenRoutes
41
24
  });
42
- module.exports = __toCommonJS(util_exports);
43
- var import_path = __toESM(require("path"));
44
- var import_utils = require("@modern-js/utils");
25
+ const _path = /* @__PURE__ */ _interop_require_default(require("path"));
26
+ const _utils = require("@modern-js/utils");
27
+ function _interop_require_default(obj) {
28
+ return obj && obj.__esModule ? obj : {
29
+ default: obj
30
+ };
31
+ }
45
32
  function formatOutput(filename) {
46
- const outputPath = import_path.default.extname(filename) ? filename : `${filename}/index.html`;
33
+ const outputPath = _path.default.extname(filename) ? filename : `${filename}/index.html`;
47
34
  return outputPath;
48
35
  }
49
36
  function formatPath(str) {
@@ -93,21 +80,23 @@ function getOutput(route, base, agreed) {
93
80
  const urlWithoutBase = route.urlPath.replace(base, "");
94
81
  return urlWithoutBase.startsWith("/") ? urlWithoutBase.slice(1) : urlWithoutBase;
95
82
  }
96
- throw new Error(
97
- `routing must provide output when calling createPage(), check ${route.urlPath}`
98
- );
83
+ throw new Error(`routing must provide output when calling createPage(), check ${route.urlPath}`);
99
84
  }
100
85
  const readJSONSpec = (dir) => {
101
- const routeJSONPath = import_path.default.join(dir, import_utils.ROUTE_SPEC_FILE);
86
+ const routeJSONPath = _path.default.join(dir, _utils.ROUTE_SPEC_FILE);
102
87
  const routeJSON = require(routeJSONPath);
103
88
  const { routes } = routeJSON;
104
89
  return routes;
105
90
  };
106
91
  const writeJSONSpec = (dir, routes) => {
107
- const routeJSONPath = import_path.default.join(dir, import_utils.ROUTE_SPEC_FILE);
108
- import_utils.fs.writeJSONSync(routeJSONPath, { routes }, { spaces: 2 });
92
+ const routeJSONPath = _path.default.join(dir, _utils.ROUTE_SPEC_FILE);
93
+ _utils.fs.writeJSONSync(routeJSONPath, {
94
+ routes
95
+ }, {
96
+ spaces: 2
97
+ });
109
98
  };
110
- const replaceWithAlias = (base, filePath, alias) => import_path.default.posix.join(alias, import_path.default.posix.relative(base, filePath));
99
+ const replaceWithAlias = (base, filePath, alias) => _path.default.posix.join(alias, _path.default.posix.relative(base, filePath));
111
100
  const standardOptions = (ssgOptions, entrypoints, routes, server) => {
112
101
  if (ssgOptions === false) {
113
102
  return false;
@@ -118,9 +107,11 @@ const standardOptions = (ssgOptions, entrypoints, routes, server) => {
118
107
  return opt;
119
108
  }, {});
120
109
  } else if (typeof ssgOptions === "object") {
121
- const isSingle = (0, import_utils.isSingleEntry)(entrypoints);
110
+ const isSingle = (0, _utils.isSingleEntry)(entrypoints);
122
111
  if (isSingle && typeof ssgOptions.main === "undefined") {
123
- return { main: ssgOptions };
112
+ return {
113
+ main: ssgOptions
114
+ };
124
115
  } else {
125
116
  return ssgOptions;
126
117
  }
@@ -128,18 +119,17 @@ const standardOptions = (ssgOptions, entrypoints, routes, server) => {
128
119
  const intermediateOptions = {};
129
120
  for (const entrypoint of entrypoints) {
130
121
  const { entryName } = entrypoint;
131
- if (Array.isArray(server == null ? void 0 : server.baseUrl)) {
122
+ if (Array.isArray(server === null || server === void 0 ? void 0 : server.baseUrl)) {
132
123
  for (const url of server.baseUrl) {
133
124
  const matchUrl = entryName === "main" ? url : `${url}/${entryName}`;
134
125
  const route = routes.find((route2) => route2.urlPath === matchUrl);
135
- intermediateOptions[route == null ? void 0 : route.urlPath] = ssgOptions(
136
- entryName,
137
- { baseUrl: url }
138
- );
126
+ intermediateOptions[route === null || route === void 0 ? void 0 : route.urlPath] = ssgOptions(entryName, {
127
+ baseUrl: url
128
+ });
139
129
  }
140
130
  } else {
141
131
  intermediateOptions[entryName] = ssgOptions(entryName, {
142
- baseUrl: server == null ? void 0 : server.baseUrl
132
+ baseUrl: server === null || server === void 0 ? void 0 : server.baseUrl
143
133
  });
144
134
  }
145
135
  }
@@ -150,25 +140,25 @@ const standardOptions = (ssgOptions, entrypoints, routes, server) => {
150
140
  const openRouteSSR = (routes, entries = []) => routes.map((ssgRoute) => ({
151
141
  ...ssgRoute,
152
142
  isSSR: entries.includes(ssgRoute.entryName),
153
- bundle: `${import_utils.SERVER_BUNDLE_DIRECTORY}/${ssgRoute.entryName}.js`
143
+ bundle: `${_utils.SERVER_BUNDLE_DIRECTORY}/${ssgRoute.entryName}.js`
154
144
  }));
155
145
  const flattenRoutes = (routes) => {
156
146
  const parents = [];
157
147
  const newRoutes = [];
158
148
  const traverseRoute = (route) => {
159
149
  const parent = parents[parents.length - 1];
160
- let path2 = parent ? `${parent.path}/${route.path || ""}`.replace(/\/+/g, "/") : route.path || "";
161
- path2 = path2.replace(/\/$/, "");
162
- if (route._component && (path2 !== "/" || path2 === "/" && !parent)) {
150
+ let path = parent ? `${parent.path}/${route.path || ""}`.replace(/\/+/g, "/") : route.path || "";
151
+ path = path.replace(/\/$/, "");
152
+ if (route._component && (path !== "/" || path === "/" && !parent)) {
163
153
  newRoutes.push({
164
154
  ...route,
165
- path: path2
155
+ path
166
156
  });
167
157
  }
168
158
  if (route.children) {
169
159
  parents.push({
170
160
  ...route,
171
- path: path2
161
+ path
172
162
  });
173
163
  route.children.forEach(traverseRoute);
174
164
  parents.pop();
@@ -177,17 +167,3 @@ const flattenRoutes = (routes) => {
177
167
  routes.forEach(traverseRoute);
178
168
  return newRoutes;
179
169
  };
180
- // Annotate the CommonJS export names for ESM import in node:
181
- 0 && (module.exports = {
182
- flattenRoutes,
183
- formatOutput,
184
- formatPath,
185
- getOutput,
186
- getUrlPrefix,
187
- isDynamicUrl,
188
- openRouteSSR,
189
- readJSONSpec,
190
- replaceWithAlias,
191
- standardOptions,
192
- writeJSONSpec
193
- });
@@ -1,27 +1,9 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var consts_exports = {};
19
- __export(consts_exports, {
20
- CLOSE_SIGN: () => CLOSE_SIGN
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
21
4
  });
22
- module.exports = __toCommonJS(consts_exports);
23
- const CLOSE_SIGN = "modern_close_server";
24
- // Annotate the CommonJS export names for ESM import in node:
25
- 0 && (module.exports = {
26
- CLOSE_SIGN
5
+ Object.defineProperty(exports, "CLOSE_SIGN", {
6
+ enumerable: true,
7
+ get: () => CLOSE_SIGN
27
8
  });
9
+ const CLOSE_SIGN = "modern_close_server";
@@ -1,97 +1,74 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
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.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var server_exports = {};
29
- __export(server_exports, {
30
- createServer: () => createServer
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
31
4
  });
32
- module.exports = __toCommonJS(server_exports);
33
- var import_child_process = __toESM(require("child_process"));
34
- var import_path = __toESM(require("path"));
35
- var import_utils = require("@modern-js/utils");
36
- var import_util = require("../libs/util");
37
- var import_consts = require("./consts");
38
- const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) => new Promise((resolve, reject) => {
39
- var _a, _b;
40
- const entries = ssgRoutes.map((route) => route.entryName);
41
- const backup = (0, import_util.openRouteSSR)(pageRoutes, entries);
42
- const total = backup.concat(apiRoutes);
43
- const cp = import_child_process.default.fork(import_path.default.join(__dirname, "process"), {
44
- cwd: appDirectory,
45
- silent: true
46
- });
47
- const appContext = api.useAppContext();
48
- const plugins = appContext.serverInternalPlugins;
49
- cp.send(
50
- JSON.stringify({
5
+ Object.defineProperty(exports, "createServer", {
6
+ enumerable: true,
7
+ get: () => createServer
8
+ });
9
+ const _child_process = /* @__PURE__ */ _interop_require_default(require("child_process"));
10
+ const _path = /* @__PURE__ */ _interop_require_default(require("path"));
11
+ const _utils = require("@modern-js/utils");
12
+ const _util = require("../libs/util");
13
+ const _consts = require("./consts");
14
+ function _interop_require_default(obj) {
15
+ return obj && obj.__esModule ? obj : {
16
+ default: obj
17
+ };
18
+ }
19
+ const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) => {
20
+ return new Promise((resolve, reject) => {
21
+ var _cp_stderr, _cp_stdout;
22
+ const entries = ssgRoutes.map((route) => route.entryName);
23
+ const backup = (0, _util.openRouteSSR)(pageRoutes, entries);
24
+ const total = backup.concat(apiRoutes);
25
+ const cp = _child_process.default.fork(_path.default.join(__dirname, "process"), {
26
+ cwd: appDirectory,
27
+ silent: true
28
+ });
29
+ const appContext = api.useAppContext();
30
+ const plugins = appContext.serverInternalPlugins;
31
+ cp.send(JSON.stringify({
51
32
  options,
52
33
  renderRoutes: ssgRoutes,
53
34
  routes: total,
54
35
  appDirectory,
55
36
  plugins
56
- })
57
- );
58
- const htmlChunks = [];
59
- const htmlAry = [];
60
- cp.on("message", (chunk) => {
61
- if (chunk !== null) {
62
- htmlChunks.push(chunk);
63
- } else {
64
- const html = htmlChunks.join("");
65
- htmlAry.push(html);
66
- htmlChunks.length = 0;
67
- }
68
- if (htmlAry.length === ssgRoutes.length) {
69
- cp.send(import_consts.CLOSE_SIGN);
70
- resolve(htmlAry);
71
- }
72
- });
73
- (_a = cp.stderr) == null ? void 0 : _a.on("data", (chunk) => {
74
- const str = chunk.toString();
75
- if (str.includes("Error")) {
76
- import_utils.logger.error(str);
77
- reject(new Error("ssg render failed"));
78
- cp.kill("SIGKILL");
79
- } else {
80
- import_utils.logger.info(str.replace(/[^\S\n]+/g, " "));
81
- }
37
+ }));
38
+ const htmlChunks = [];
39
+ const htmlAry = [];
40
+ cp.on("message", (chunk) => {
41
+ if (chunk !== null) {
42
+ htmlChunks.push(chunk);
43
+ } else {
44
+ const html = htmlChunks.join("");
45
+ htmlAry.push(html);
46
+ htmlChunks.length = 0;
47
+ }
48
+ if (htmlAry.length === ssgRoutes.length) {
49
+ cp.send(_consts.CLOSE_SIGN);
50
+ resolve(htmlAry);
51
+ }
52
+ });
53
+ (_cp_stderr = cp.stderr) === null || _cp_stderr === void 0 ? void 0 : _cp_stderr.on("data", (chunk) => {
54
+ const str = chunk.toString();
55
+ if (str.includes("Error")) {
56
+ _utils.logger.error(str);
57
+ reject(new Error("ssg render failed"));
58
+ cp.kill("SIGKILL");
59
+ } else {
60
+ _utils.logger.info(str.replace(/[^\S\n]+/g, " "));
61
+ }
62
+ });
63
+ (_cp_stdout = cp.stdout) === null || _cp_stdout === void 0 ? void 0 : _cp_stdout.on("data", (chunk) => {
64
+ const str = chunk.toString();
65
+ if (str.includes("Error")) {
66
+ _utils.logger.error(str);
67
+ reject(new Error("ssg render failed"));
68
+ cp.kill("SIGKILL");
69
+ } else {
70
+ _utils.logger.info(str.replace(/[^\S\n]+/g, " "));
71
+ }
72
+ });
82
73
  });
83
- (_b = cp.stdout) == null ? void 0 : _b.on("data", (chunk) => {
84
- const str = chunk.toString();
85
- if (str.includes("Error")) {
86
- import_utils.logger.error(str);
87
- reject(new Error("ssg render failed"));
88
- cp.kill("SIGKILL");
89
- } else {
90
- import_utils.logger.info(str.replace(/[^\S\n]+/g, " "));
91
- }
92
- });
93
- });
94
- // Annotate the CommonJS export names for ESM import in node:
95
- 0 && (module.exports = {
96
- createServer
97
- });
74
+ };
@@ -1,44 +1,27 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
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.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var prerender_exports = {};
29
- __export(prerender_exports, {
30
- compile: () => compile
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "compile", {
6
+ enumerable: true,
7
+ get: () => compile
31
8
  });
32
- module.exports = __toCommonJS(prerender_exports);
33
- var import_events = __toESM(require("events"));
34
- var import_stream = require("stream");
35
- var import_node_mocks_http = __toESM(require("node-mocks-http"));
9
+ const _events = /* @__PURE__ */ _interop_require_default(require("events"));
10
+ const _stream = require("stream");
11
+ const _nodemockshttp = /* @__PURE__ */ _interop_require_default(require("node-mocks-http"));
12
+ function _interop_require_default(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
36
17
  const compile = (requestHandler) => (options, extend = {}) => new Promise((resolve, reject) => {
37
- const req = import_node_mocks_http.default.createRequest({
18
+ const req = _nodemockshttp.default.createRequest({
38
19
  ...options,
39
- eventEmitter: import_stream.Readable
20
+ eventEmitter: _stream.Readable
21
+ });
22
+ const res = _nodemockshttp.default.createResponse({
23
+ eventEmitter: _events.default
40
24
  });
41
- const res = import_node_mocks_http.default.createResponse({ eventEmitter: import_events.default });
42
25
  Object.assign(req, extend);
43
26
  const proxyRes = new Proxy(res, {
44
27
  get(obj, prop) {
@@ -62,7 +45,3 @@ const compile = (requestHandler) => (options, extend = {}) => new Promise((resol
62
45
  reject(e);
63
46
  }
64
47
  });
65
- // Annotate the CommonJS export names for ESM import in node:
66
- 0 && (module.exports = {
67
- compile
68
- });
@@ -1,49 +1,30 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from === "object" || typeof from === "function") {
9
- for (let key of __getOwnPropNames(from))
10
- if (!__hasOwnProp.call(to, key) && key !== except)
11
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- }
13
- return to;
14
- };
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.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
23
- var import_prod_server = __toESM(require("@modern-js/prod-server"));
24
- var import_portfinder = __toESM(require("portfinder"));
25
- var import_make = require("../libs/make");
26
- var import_prerender = require("./prerender");
27
- var import_consts = require("./consts");
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _prodserver = /* @__PURE__ */ _interop_require_default(require("@modern-js/prod-server"));
6
+ const _portfinder = /* @__PURE__ */ _interop_require_default(require("portfinder"));
7
+ const _make = require("../libs/make");
8
+ const _prerender = require("./prerender");
9
+ const _consts = require("./consts");
10
+ function _interop_require_default(obj) {
11
+ return obj && obj.__esModule ? obj : {
12
+ default: obj
13
+ };
14
+ }
28
15
  process.on("message", async (chunk) => {
29
- if (chunk === import_consts.CLOSE_SIGN) {
16
+ if (chunk === _consts.CLOSE_SIGN) {
30
17
  process.exit();
31
18
  }
32
19
  const context = JSON.parse(chunk);
33
- const {
34
- routes,
35
- renderRoutes,
36
- options,
37
- appDirectory,
38
- plugins
39
- } = context;
20
+ const { routes, renderRoutes, options, appDirectory, plugins } = context;
40
21
  let modernServer = null;
41
22
  try {
42
23
  const { server: serverOptions } = options;
43
24
  const defaultPort = Number(process.env.PORT) || serverOptions.port;
44
- import_portfinder.default.basePort = defaultPort;
45
- const port = await import_portfinder.default.getPortPromise();
46
- modernServer = await (0, import_prod_server.default)({
25
+ _portfinder.default.basePort = defaultPort;
26
+ const port = await _portfinder.default.getPortPromise();
27
+ modernServer = await (0, _prodserver.default)({
47
28
  pwd: appDirectory,
48
29
  config: options,
49
30
  routes,
@@ -57,12 +38,8 @@ process.on("message", async (chunk) => {
57
38
  if (!modernServer) {
58
39
  return;
59
40
  }
60
- const render = (0, import_prerender.compile)(modernServer.getRequestHandler());
61
- const renderPromiseAry = (0, import_make.makeRender)(
62
- renderRoutes,
63
- render,
64
- port
65
- );
41
+ const render = (0, _prerender.compile)(modernServer.getRequestHandler());
42
+ const renderPromiseAry = (0, _make.makeRender)(renderRoutes, render, port);
66
43
  const htmlAry = await Promise.all(renderPromiseAry);
67
44
  htmlAry.forEach((html) => {
68
45
  process.send(html);
@@ -71,7 +48,7 @@ process.on("message", async (chunk) => {
71
48
  modernServer.close();
72
49
  });
73
50
  } catch (e) {
74
- modernServer == null ? void 0 : modernServer.close();
51
+ modernServer === null || modernServer === void 0 ? void 0 : modernServer.close();
75
52
  process.stderr.write(e instanceof Error ? e.stack : e.toString());
76
53
  }
77
54
  });
package/dist/cjs/types.js CHANGED
@@ -1,15 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var types_exports = {};
15
- module.exports = __toCommonJS(types_exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });