@modern-js/plugin-ssg 2.35.1 → 2.37.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,25 +1,47 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "createServer", {
6
- enumerable: true,
7
- get: function() {
8
- return createServer;
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
17
  }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var server_exports = {};
30
+ __export(server_exports, {
31
+ createServer: () => createServer
10
32
  });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _child_process = /* @__PURE__ */ _interop_require_default._(require("child_process"));
13
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
14
- const _utils = require("@modern-js/utils");
15
- const _util = require("../libs/util");
16
- const _consts = require("./consts");
33
+ module.exports = __toCommonJS(server_exports);
34
+ var import_child_process = __toESM(require("child_process"));
35
+ var import_path = __toESM(require("path"));
36
+ var import_utils = require("@modern-js/utils");
37
+ var import_util = require("../libs/util");
38
+ var import_consts = require("./consts");
17
39
  const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) => new Promise((resolve, reject) => {
18
40
  var _cp_stderr, _cp_stdout;
19
41
  const entries = ssgRoutes.map((route) => route.entryName);
20
- const backup = (0, _util.openRouteSSR)(pageRoutes, entries);
42
+ const backup = (0, import_util.openRouteSSR)(pageRoutes, entries);
21
43
  const total = backup.concat(apiRoutes);
22
- const cp = _child_process.default.fork(_path.default.join(__dirname, "process"), {
44
+ const cp = import_child_process.default.fork(import_path.default.join(__dirname, "process"), {
23
45
  cwd: appDirectory,
24
46
  silent: true
25
47
  });
@@ -43,28 +65,32 @@ const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirecto
43
65
  htmlChunks.length = 0;
44
66
  }
45
67
  if (htmlAry.length === ssgRoutes.length) {
46
- cp.send(_consts.CLOSE_SIGN);
68
+ cp.send(import_consts.CLOSE_SIGN);
47
69
  resolve(htmlAry);
48
70
  }
49
71
  });
50
72
  (_cp_stderr = cp.stderr) === null || _cp_stderr === void 0 ? void 0 : _cp_stderr.on("data", (chunk) => {
51
73
  const str = chunk.toString();
52
74
  if (str.includes("Error")) {
53
- _utils.logger.error(str);
75
+ import_utils.logger.error(str);
54
76
  reject(new Error("ssg render failed"));
55
77
  cp.kill("SIGKILL");
56
78
  } else {
57
- _utils.logger.info(str.replace(/[^\S\n]+/g, " "));
79
+ import_utils.logger.info(str.replace(/[^\S\n]+/g, " "));
58
80
  }
59
81
  });
60
82
  (_cp_stdout = cp.stdout) === null || _cp_stdout === void 0 ? void 0 : _cp_stdout.on("data", (chunk) => {
61
83
  const str = chunk.toString();
62
84
  if (str.includes("Error")) {
63
- _utils.logger.error(str);
85
+ import_utils.logger.error(str);
64
86
  reject(new Error("ssg render failed"));
65
87
  cp.kill("SIGKILL");
66
88
  } else {
67
- _utils.logger.info(str.replace(/[^\S\n]+/g, " "));
89
+ import_utils.logger.info(str.replace(/[^\S\n]+/g, " "));
68
90
  }
69
91
  });
70
92
  });
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ createServer
96
+ });
@@ -1,24 +1,46 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "compile", {
6
- enumerable: true,
7
- get: function() {
8
- return compile;
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
17
  }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var prerender_exports = {};
30
+ __export(prerender_exports, {
31
+ compile: () => compile
10
32
  });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _events = /* @__PURE__ */ _interop_require_default._(require("events"));
13
- const _stream = require("stream");
14
- const _nodemockshttp = /* @__PURE__ */ _interop_require_default._(require("node-mocks-http"));
33
+ module.exports = __toCommonJS(prerender_exports);
34
+ var import_events = __toESM(require("events"));
35
+ var import_stream = require("stream");
36
+ var import_node_mocks_http = __toESM(require("node-mocks-http"));
15
37
  const compile = (requestHandler) => (options, extend = {}) => new Promise((resolve, reject) => {
16
- const req = _nodemockshttp.default.createRequest({
38
+ const req = import_node_mocks_http.default.createRequest({
17
39
  ...options,
18
- eventEmitter: _stream.Readable
40
+ eventEmitter: import_stream.Readable
19
41
  });
20
- const res = _nodemockshttp.default.createResponse({
21
- eventEmitter: _events.default
42
+ const res = import_node_mocks_http.default.createResponse({
43
+ eventEmitter: import_events.default
22
44
  });
23
45
  Object.assign(req, extend);
24
46
  const proxyRes = new Proxy(res, {
@@ -43,3 +65,7 @@ const compile = (requestHandler) => (options, extend = {}) => new Promise((resol
43
65
  reject(e);
44
66
  }
45
67
  });
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ compile
71
+ });
@@ -1,15 +1,33 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
6
- const _prodserver = /* @__PURE__ */ _interop_require_default._(require("@modern-js/prod-server"));
7
- const _portfinder = /* @__PURE__ */ _interop_require_default._(require("portfinder"));
8
- const _make = require("../libs/make");
9
- const _prerender = require("./prerender");
10
- const _consts = require("./consts");
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var import_prod_server = __toESM(require("@modern-js/prod-server"));
25
+ var import_portfinder = __toESM(require("portfinder"));
26
+ var import_make = require("../libs/make");
27
+ var import_prerender = require("./prerender");
28
+ var import_consts = require("./consts");
11
29
  process.on("message", async (chunk) => {
12
- if (chunk === _consts.CLOSE_SIGN) {
30
+ if (chunk === import_consts.CLOSE_SIGN) {
13
31
  process.exit();
14
32
  }
15
33
  const context = JSON.parse(chunk);
@@ -18,9 +36,9 @@ process.on("message", async (chunk) => {
18
36
  try {
19
37
  const { server: serverOptions } = options;
20
38
  const defaultPort = Number(process.env.PORT) || serverOptions.port;
21
- _portfinder.default.basePort = defaultPort;
22
- const port = await _portfinder.default.getPortPromise();
23
- modernServer = await (0, _prodserver.default)({
39
+ import_portfinder.default.basePort = defaultPort;
40
+ const port = await import_portfinder.default.getPortPromise();
41
+ modernServer = await (0, import_prod_server.default)({
24
42
  pwd: appDirectory,
25
43
  config: options,
26
44
  routes,
@@ -34,8 +52,8 @@ process.on("message", async (chunk) => {
34
52
  if (!modernServer) {
35
53
  return;
36
54
  }
37
- const render = (0, _prerender.compile)(modernServer.getRequestHandler());
38
- const renderPromiseAry = (0, _make.makeRender)(renderRoutes, render, port);
55
+ const render = (0, import_prerender.compile)(modernServer.getRequestHandler());
56
+ const renderPromiseAry = (0, import_make.makeRender)(renderRoutes, render, port);
39
57
  const htmlAry = await Promise.all(renderPromiseAry);
40
58
  htmlAry.forEach((html) => {
41
59
  process.send(html);
package/dist/cjs/types.js CHANGED
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
package/dist/esm/index.js CHANGED
@@ -10,7 +10,7 @@ import { createServer } from "./server";
10
10
  import { writeHtmlFile } from "./libs/output";
11
11
  import { replaceRoute } from "./libs/replace";
12
12
  import { makeRoute } from "./libs/make";
13
- export var ssgPlugin = function() {
13
+ var ssgPlugin = function() {
14
14
  return {
15
15
  name: "@modern-js/plugin-ssg",
16
16
  pre: [
@@ -46,8 +46,8 @@ export var ssgPlugin = function() {
46
46
  var flattedRoutes = flattenRoutes(routes);
47
47
  agreedRouteMap[entryName] = flattedRoutes;
48
48
  return {
49
- entrypoint: entrypoint,
50
- routes: routes
49
+ entrypoint,
50
+ routes
51
51
  };
52
52
  },
53
53
  afterBuild: function afterBuild() {
@@ -176,4 +176,8 @@ export var ssgPlugin = function() {
176
176
  }
177
177
  };
178
178
  };
179
- export default ssgPlugin;
179
+ var src_default = ssgPlugin;
180
+ export {
181
+ src_default as default,
182
+ ssgPlugin
183
+ };
@@ -2,7 +2,7 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
2
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
3
3
  import path from "path";
4
4
  import normalize from "normalize-path";
5
- export function makeRender(ssgRoutes, render, port) {
5
+ function makeRender(ssgRoutes, render, port) {
6
6
  return ssgRoutes.map(function(ssgRoute) {
7
7
  return render({
8
8
  url: ssgRoute.urlPath,
@@ -13,13 +13,13 @@ export function makeRender(ssgRoutes, render, port) {
13
13
  });
14
14
  });
15
15
  }
16
- export function makeRoute(baseRoute, route) {
16
+ function makeRoute(baseRoute, route) {
17
17
  var headers = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
18
18
  var urlPath = baseRoute.urlPath, entryPath = baseRoute.entryPath;
19
19
  if (typeof route === "string") {
20
20
  return _object_spread_props(_object_spread({}, baseRoute), {
21
21
  urlPath: normalize("".concat(urlPath).concat(route)) || "/",
22
- headers: headers,
22
+ headers,
23
23
  output: path.join(entryPath, "..".concat(route === "/" ? "" : route))
24
24
  });
25
25
  } else {
@@ -30,3 +30,7 @@ export function makeRoute(baseRoute, route) {
30
30
  });
31
31
  }
32
32
  }
33
+ export {
34
+ makeRender,
35
+ makeRoute
36
+ };
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import { fs } from "@modern-js/utils";
3
- export function writeHtmlFile(htmlAry, ssgRoutes, baseDir) {
3
+ function writeHtmlFile(htmlAry, ssgRoutes, baseDir) {
4
4
  htmlAry.forEach(function(html, index) {
5
5
  var ssgRoute = ssgRoutes[index];
6
6
  var filepath = path.join(baseDir, ssgRoute.output);
@@ -10,3 +10,6 @@ export function writeHtmlFile(htmlAry, ssgRoutes, baseDir) {
10
10
  fs.writeFileSync(filepath, html);
11
11
  });
12
12
  }
13
+ export {
14
+ writeHtmlFile
15
+ };
@@ -2,7 +2,7 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
2
  import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
3
3
  import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
4
4
  import normalize from "normalize-path";
5
- export function exist(route, pageRoutes) {
5
+ function exist(route, pageRoutes) {
6
6
  return pageRoutes.slice().findIndex(function(pageRoute) {
7
7
  var urlEqual = normalize(pageRoute.urlPath) === normalize(route.urlPath);
8
8
  var entryEqual = pageRoute.entryName === route.entryName;
@@ -12,7 +12,7 @@ export function exist(route, pageRoutes) {
12
12
  return false;
13
13
  });
14
14
  }
15
- export function replaceRoute(ssgRoutes, pageRoutes) {
15
+ function replaceRoute(ssgRoutes, pageRoutes) {
16
16
  var _pageRoutes;
17
17
  var cleanSsgRoutes = ssgRoutes.map(function(ssgRoute) {
18
18
  var output = ssgRoute.output, headers = ssgRoute.headers, cleanSsgRoute = _object_without_properties(ssgRoute, [
@@ -35,3 +35,7 @@ export function replaceRoute(ssgRoutes, pageRoutes) {
35
35
  (_pageRoutes = pageRoutes).push.apply(_pageRoutes, _to_consumable_array(freshRoutes));
36
36
  return pageRoutes;
37
37
  }
38
+ export {
39
+ exist,
40
+ replaceRoute
41
+ };
@@ -2,11 +2,11 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
2
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
3
3
  import path from "path";
4
4
  import { ROUTE_SPEC_FILE, fs, isSingleEntry, SERVER_BUNDLE_DIRECTORY } from "@modern-js/utils";
5
- export function formatOutput(filename) {
5
+ function formatOutput(filename) {
6
6
  var outputPath = path.extname(filename) ? filename : "".concat(filename, "/index.html");
7
7
  return outputPath;
8
8
  }
9
- export function formatPath(str) {
9
+ function formatPath(str) {
10
10
  var addr = str;
11
11
  if (!addr || typeof addr !== "string") {
12
12
  return addr;
@@ -22,10 +22,10 @@ export function formatPath(str) {
22
22
  }
23
23
  return addr;
24
24
  }
25
- export function isDynamicUrl(url) {
25
+ function isDynamicUrl(url) {
26
26
  return url.includes(":");
27
27
  }
28
- export function getUrlPrefix(route, baseUrl) {
28
+ function getUrlPrefix(route, baseUrl) {
29
29
  var base = "";
30
30
  if (Array.isArray(baseUrl)) {
31
31
  var filters = baseUrl.filter(function(url) {
@@ -48,7 +48,7 @@ export function getUrlPrefix(route, baseUrl) {
48
48
  var prefix = "".concat(base, "/").concat(entryName);
49
49
  return prefix.endsWith("/") ? prefix.slice(0, -1) : prefix;
50
50
  }
51
- export function getOutput(route, base, agreed) {
51
+ function getOutput(route, base, agreed) {
52
52
  var output = route.output;
53
53
  if (output) {
54
54
  return output;
@@ -59,24 +59,24 @@ export function getOutput(route, base, agreed) {
59
59
  }
60
60
  throw new Error("routing must provide output when calling createPage(), check ".concat(route.urlPath));
61
61
  }
62
- export var readJSONSpec = function(dir) {
62
+ var readJSONSpec = function(dir) {
63
63
  var routeJSONPath = path.join(dir, ROUTE_SPEC_FILE);
64
64
  var routeJSON = require(routeJSONPath);
65
65
  var routes = routeJSON.routes;
66
66
  return routes;
67
67
  };
68
- export var writeJSONSpec = function(dir, routes) {
68
+ var writeJSONSpec = function(dir, routes) {
69
69
  var routeJSONPath = path.join(dir, ROUTE_SPEC_FILE);
70
70
  fs.writeJSONSync(routeJSONPath, {
71
- routes: routes
71
+ routes
72
72
  }, {
73
73
  spaces: 2
74
74
  });
75
75
  };
76
- export var replaceWithAlias = function(base, filePath, alias) {
76
+ var replaceWithAlias = function(base, filePath, alias) {
77
77
  return path.posix.join(alias, path.posix.relative(base, filePath));
78
78
  };
79
- export var standardOptions = function(ssgOptions, entrypoints, routes, server) {
79
+ var standardOptions = function(ssgOptions, entrypoints, routes, server) {
80
80
  if (ssgOptions === false) {
81
81
  return false;
82
82
  }
@@ -156,7 +156,7 @@ export var standardOptions = function(ssgOptions, entrypoints, routes, server) {
156
156
  }
157
157
  return false;
158
158
  };
159
- export var openRouteSSR = function(routes) {
159
+ var openRouteSSR = function(routes) {
160
160
  var entries = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
161
161
  return routes.map(function(ssgRoute) {
162
162
  return _object_spread_props(_object_spread({}, ssgRoute), {
@@ -165,7 +165,7 @@ export var openRouteSSR = function(routes) {
165
165
  });
166
166
  });
167
167
  };
168
- export var flattenRoutes = function(routes) {
168
+ var flattenRoutes = function(routes) {
169
169
  var parents = [];
170
170
  var newRoutes = [];
171
171
  var traverseRoute = function(route) {
@@ -188,3 +188,16 @@ export var flattenRoutes = function(routes) {
188
188
  routes.forEach(traverseRoute);
189
189
  return newRoutes;
190
190
  };
191
+ export {
192
+ flattenRoutes,
193
+ formatOutput,
194
+ formatPath,
195
+ getOutput,
196
+ getUrlPrefix,
197
+ isDynamicUrl,
198
+ openRouteSSR,
199
+ readJSONSpec,
200
+ replaceWithAlias,
201
+ standardOptions,
202
+ writeJSONSpec
203
+ };
@@ -1 +1,4 @@
1
- export var CLOSE_SIGN = "modern_close_server";
1
+ var CLOSE_SIGN = "modern_close_server";
2
+ export {
3
+ CLOSE_SIGN
4
+ };
@@ -3,7 +3,7 @@ import path from "path";
3
3
  import { logger } from "@modern-js/utils";
4
4
  import { openRouteSSR } from "../libs/util";
5
5
  import { CLOSE_SIGN } from "./consts";
6
- export var createServer = function(api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) {
6
+ var createServer = function(api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) {
7
7
  return new Promise(function(resolve, reject) {
8
8
  var _cp_stderr, _cp_stdout;
9
9
  var entries = ssgRoutes.map(function(route) {
@@ -18,11 +18,11 @@ export var createServer = function(api, ssgRoutes, pageRoutes, apiRoutes, option
18
18
  var appContext = api.useAppContext();
19
19
  var plugins = appContext.serverInternalPlugins;
20
20
  cp.send(JSON.stringify({
21
- options: options,
21
+ options,
22
22
  renderRoutes: ssgRoutes,
23
23
  routes: total,
24
- appDirectory: appDirectory,
25
- plugins: plugins
24
+ appDirectory,
25
+ plugins
26
26
  }));
27
27
  var htmlChunks = [];
28
28
  var htmlAry = [];
@@ -61,3 +61,6 @@ export var createServer = function(api, ssgRoutes, pageRoutes, apiRoutes, option
61
61
  });
62
62
  });
63
63
  };
64
+ export {
65
+ createServer
66
+ };
@@ -4,7 +4,7 @@ import { _ as _type_of } from "@swc/helpers/_/_type_of";
4
4
  import EventEmitter from "events";
5
5
  import { Readable } from "stream";
6
6
  import httpMocks from "node-mocks-http";
7
- export var compile = function(requestHandler) {
7
+ var compile = function(requestHandler) {
8
8
  return function(options) {
9
9
  var extend = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
10
10
  return new Promise(function(resolve, reject) {
@@ -41,3 +41,6 @@ export var compile = function(requestHandler) {
41
41
  });
42
42
  };
43
43
  };
44
+ export {
45
+ compile
46
+ };
@@ -40,7 +40,7 @@ process.on("message", function() {
40
40
  server({
41
41
  pwd: appDirectory,
42
42
  config: options,
43
- routes: routes,
43
+ routes,
44
44
  staticGenerate: true,
45
45
  internalPlugins: plugins
46
46
  })
package/dist/esm/types.js CHANGED
@@ -1 +0,0 @@
1
- export {};
@@ -6,7 +6,7 @@ import { createServer } from "./server";
6
6
  import { writeHtmlFile } from "./libs/output";
7
7
  import { replaceRoute } from "./libs/replace";
8
8
  import { makeRoute } from "./libs/make";
9
- export const ssgPlugin = () => ({
9
+ const ssgPlugin = () => ({
10
10
  name: "@modern-js/plugin-ssg",
11
11
  pre: [
12
12
  "@modern-js/plugin-server",
@@ -141,4 +141,8 @@ export const ssgPlugin = () => ({
141
141
  };
142
142
  }
143
143
  });
144
- export default ssgPlugin;
144
+ var src_default = ssgPlugin;
145
+ export {
146
+ src_default as default,
147
+ ssgPlugin
148
+ };
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import normalize from "normalize-path";
3
- export function makeRender(ssgRoutes, render, port) {
3
+ function makeRender(ssgRoutes, render, port) {
4
4
  return ssgRoutes.map((ssgRoute) => render({
5
5
  url: ssgRoute.urlPath,
6
6
  headers: {
@@ -10,7 +10,7 @@ export function makeRender(ssgRoutes, render, port) {
10
10
  connection: {}
11
11
  }));
12
12
  }
13
- export function makeRoute(baseRoute, route, headers = {}) {
13
+ function makeRoute(baseRoute, route, headers = {}) {
14
14
  const { urlPath, entryPath } = baseRoute;
15
15
  if (typeof route === "string") {
16
16
  return {
@@ -31,3 +31,7 @@ export function makeRoute(baseRoute, route, headers = {}) {
31
31
  };
32
32
  }
33
33
  }
34
+ export {
35
+ makeRender,
36
+ makeRoute
37
+ };
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import { fs } from "@modern-js/utils";
3
- export function writeHtmlFile(htmlAry, ssgRoutes, baseDir) {
3
+ function writeHtmlFile(htmlAry, ssgRoutes, baseDir) {
4
4
  htmlAry.forEach((html, index) => {
5
5
  const ssgRoute = ssgRoutes[index];
6
6
  const filepath = path.join(baseDir, ssgRoute.output);
@@ -10,3 +10,6 @@ export function writeHtmlFile(htmlAry, ssgRoutes, baseDir) {
10
10
  fs.writeFileSync(filepath, html);
11
11
  });
12
12
  }
13
+ export {
14
+ writeHtmlFile
15
+ };
@@ -1,5 +1,5 @@
1
1
  import normalize from "normalize-path";
2
- export function exist(route, pageRoutes) {
2
+ function exist(route, pageRoutes) {
3
3
  return pageRoutes.slice().findIndex((pageRoute) => {
4
4
  const urlEqual = normalize(pageRoute.urlPath) === normalize(route.urlPath);
5
5
  const entryEqual = pageRoute.entryName === route.entryName;
@@ -9,7 +9,7 @@ export function exist(route, pageRoutes) {
9
9
  return false;
10
10
  });
11
11
  }
12
- export function replaceRoute(ssgRoutes, pageRoutes) {
12
+ function replaceRoute(ssgRoutes, pageRoutes) {
13
13
  const cleanSsgRoutes = ssgRoutes.map((ssgRoute) => {
14
14
  const { output, headers, ...cleanSsgRoute } = ssgRoute;
15
15
  return Object.assign(cleanSsgRoute, output ? {
@@ -30,3 +30,7 @@ export function replaceRoute(ssgRoutes, pageRoutes) {
30
30
  pageRoutes.push(...freshRoutes);
31
31
  return pageRoutes;
32
32
  }
33
+ export {
34
+ exist,
35
+ replaceRoute
36
+ };