@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.
package/dist/cjs/index.js CHANGED
@@ -1,31 +1,45 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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) => {
6
9
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- ssgPlugin: function() {
14
- return ssgPlugin;
15
- },
16
- default: function() {
17
- return _default;
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 });
18
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 src_exports = {};
30
+ __export(src_exports, {
31
+ default: () => src_default,
32
+ ssgPlugin: () => ssgPlugin
19
33
  });
20
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
21
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
22
- const _utils = require("@modern-js/utils");
23
- const _reactrouterdom = require("react-router-dom");
24
- const _util = require("./libs/util");
25
- const _server = require("./server");
26
- const _output = require("./libs/output");
27
- const _replace = require("./libs/replace");
28
- const _make = require("./libs/make");
34
+ module.exports = __toCommonJS(src_exports);
35
+ var import_path = __toESM(require("path"));
36
+ var import_utils = require("@modern-js/utils");
37
+ var import_react_router_dom = require("react-router-dom");
38
+ var import_util = require("./libs/util");
39
+ var import_server = require("./server");
40
+ var import_output = require("./libs/output");
41
+ var import_replace = require("./libs/replace");
42
+ var import_make = require("./libs/make");
29
43
  const ssgPlugin = () => ({
30
44
  name: "@modern-js/plugin-ssg",
31
45
  pre: [
@@ -57,7 +71,7 @@ const ssgPlugin = () => ({
57
71
  },
58
72
  modifyFileSystemRoutes({ entrypoint, routes }) {
59
73
  const { entryName } = entrypoint;
60
- const flattedRoutes = (0, _util.flattenRoutes)(routes);
74
+ const flattedRoutes = (0, import_util.flattenRoutes)(routes);
61
75
  agreedRouteMap[entryName] = flattedRoutes;
62
76
  return {
63
77
  entrypoint,
@@ -71,14 +85,14 @@ const ssgPlugin = () => ({
71
85
  const { output, server } = resolvedConfig;
72
86
  const { ssg, distPath: { root: outputPath } = {} } = output;
73
87
  const ssgOptions = (Array.isArray(ssg) ? ssg.pop() : ssg) || true;
74
- const buildDir = _path.default.join(appDirectory, outputPath);
75
- const routes = (0, _util.readJSONSpec)(buildDir);
88
+ const buildDir = import_path.default.join(appDirectory, outputPath);
89
+ const routes = (0, import_util.readJSONSpec)(buildDir);
76
90
  const pageRoutes = routes.filter((route) => !route.isApi);
77
91
  const apiRoutes = routes.filter((route) => route.isApi);
78
92
  if (pageRoutes.length === 0) {
79
93
  return;
80
94
  }
81
- const intermediateOptions = (0, _util.standardOptions)(ssgOptions, entrypoints, pageRoutes, server);
95
+ const intermediateOptions = (0, import_util.standardOptions)(ssgOptions, entrypoints, pageRoutes, server);
82
96
  if (!intermediateOptions) {
83
97
  return;
84
98
  }
@@ -99,7 +113,7 @@ const ssgPlugin = () => ({
99
113
  } else if (entryOptions.routes && entryOptions.routes.length > 0) {
100
114
  const { routes: enrtyRoutes, headers } = entryOptions;
101
115
  enrtyRoutes.forEach((route) => {
102
- ssgRoutes.push((0, _make.makeRoute)(pageRoute, route, headers));
116
+ ssgRoutes.push((0, import_make.makeRoute)(pageRoute, route, headers));
103
117
  });
104
118
  }
105
119
  } else {
@@ -117,22 +131,22 @@ const ssgPlugin = () => ({
117
131
  if (userRoutes.length > 0) {
118
132
  userRoutes.forEach((route) => {
119
133
  if (typeof route === "string") {
120
- ssgRoutes.push((0, _make.makeRoute)(pageRoute, route, headers));
134
+ ssgRoutes.push((0, import_make.makeRoute)(pageRoute, route, headers));
121
135
  } else if (Array.isArray(route.params)) {
122
136
  route.params.forEach((param) => {
123
- ssgRoutes.push((0, _make.makeRoute)(pageRoute, {
137
+ ssgRoutes.push((0, import_make.makeRoute)(pageRoute, {
124
138
  ...route,
125
- url: (0, _reactrouterdom.generatePath)(route.url, param)
139
+ url: (0, import_react_router_dom.generatePath)(route.url, param)
126
140
  }, headers));
127
141
  });
128
142
  } else {
129
- ssgRoutes.push((0, _make.makeRoute)(pageRoute, route, headers));
143
+ ssgRoutes.push((0, import_make.makeRoute)(pageRoute, route, headers));
130
144
  }
131
145
  });
132
146
  } else {
133
147
  agreedRoutes.filter((route) => !preventDefault.includes(route.path)).forEach((route) => {
134
- if (!(0, _util.isDynamicUrl)(route.path)) {
135
- ssgRoutes.push((0, _make.makeRoute)(pageRoute, route.path, headers));
148
+ if (!(0, import_util.isDynamicUrl)(route.path)) {
149
+ ssgRoutes.push((0, import_make.makeRoute)(pageRoute, route.path, headers));
136
150
  }
137
151
  });
138
152
  }
@@ -147,18 +161,22 @@ const ssgPlugin = () => ({
147
161
  if (isOriginRoute) {
148
162
  throw new Error(`ssg can not using with ssr,url - ${ssgRoute.urlPath}, entry - ${ssgRoute.entryName} `);
149
163
  }
150
- _utils.logger.warn(`new ssg route ${ssgRoute.urlPath} is using ssr now,maybe from parent route ${ssgRoute.entryName},close ssr`);
164
+ import_utils.logger.warn(`new ssg route ${ssgRoute.urlPath} is using ssr now,maybe from parent route ${ssgRoute.entryName},close ssr`);
151
165
  }
152
166
  ssgRoute.isSSR = false;
153
- ssgRoute.output = (0, _util.formatOutput)(ssgRoute.output);
167
+ ssgRoute.output = (0, import_util.formatOutput)(ssgRoute.output);
154
168
  });
155
- const htmlAry = await (0, _server.createServer)(api, ssgRoutes, pageRoutes, apiRoutes, resolvedConfig, appDirectory);
156
- (0, _output.writeHtmlFile)(htmlAry, ssgRoutes, buildDir);
157
- (0, _replace.replaceRoute)(ssgRoutes, pageRoutes);
158
- (0, _util.writeJSONSpec)(buildDir, pageRoutes.concat(apiRoutes));
159
- _utils.logger.info("ssg Compiled successfully");
169
+ const htmlAry = await (0, import_server.createServer)(api, ssgRoutes, pageRoutes, apiRoutes, resolvedConfig, appDirectory);
170
+ (0, import_output.writeHtmlFile)(htmlAry, ssgRoutes, buildDir);
171
+ (0, import_replace.replaceRoute)(ssgRoutes, pageRoutes);
172
+ (0, import_util.writeJSONSpec)(buildDir, pageRoutes.concat(apiRoutes));
173
+ import_utils.logger.info("ssg Compiled successfully");
160
174
  }
161
175
  };
162
176
  }
163
177
  });
164
- const _default = ssgPlugin;
178
+ var src_default = ssgPlugin;
179
+ // Annotate the CommonJS export names for ESM import in node:
180
+ 0 && (module.exports = {
181
+ ssgPlugin
182
+ });
@@ -1,25 +1,39 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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) => {
6
9
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- makeRender: function() {
14
- return makeRender;
15
- },
16
- makeRoute: function() {
17
- return makeRoute;
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 });
18
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 make_exports = {};
30
+ __export(make_exports, {
31
+ makeRender: () => makeRender,
32
+ makeRoute: () => makeRoute
19
33
  });
20
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
21
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
22
- const _normalizepath = /* @__PURE__ */ _interop_require_default._(require("normalize-path"));
34
+ module.exports = __toCommonJS(make_exports);
35
+ var import_path = __toESM(require("path"));
36
+ var import_normalize_path = __toESM(require("normalize-path"));
23
37
  function makeRender(ssgRoutes, render, port) {
24
38
  return ssgRoutes.map((ssgRoute) => render({
25
39
  url: ssgRoute.urlPath,
@@ -35,19 +49,24 @@ function makeRoute(baseRoute, route, headers = {}) {
35
49
  if (typeof route === "string") {
36
50
  return {
37
51
  ...baseRoute,
38
- urlPath: (0, _normalizepath.default)(`${urlPath}${route}`) || "/",
52
+ urlPath: (0, import_normalize_path.default)(`${urlPath}${route}`) || "/",
39
53
  headers,
40
- output: _path.default.join(entryPath, `..${route === "/" ? "" : route}`)
54
+ output: import_path.default.join(entryPath, `..${route === "/" ? "" : route}`)
41
55
  };
42
56
  } else {
43
57
  return {
44
58
  ...baseRoute,
45
- urlPath: (0, _normalizepath.default)(`${urlPath}${route.url}`) || "/",
59
+ urlPath: (0, import_normalize_path.default)(`${urlPath}${route.url}`) || "/",
46
60
  headers: {
47
61
  ...headers,
48
62
  ...route.headers
49
63
  },
50
- output: route.output ? _path.default.normalize(route.output) : _path.default.join(entryPath, `..${route.url === "/" ? "" : route.url}`)
64
+ output: route.output ? import_path.default.normalize(route.output) : import_path.default.join(entryPath, `..${route.url === "/" ? "" : route.url}`)
51
65
  };
52
66
  }
53
67
  }
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ makeRender,
71
+ makeRoute
72
+ });
@@ -1,23 +1,49 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "writeHtmlFile", {
6
- enumerable: true,
7
- get: function() {
8
- return writeHtmlFile;
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 output_exports = {};
30
+ __export(output_exports, {
31
+ writeHtmlFile: () => writeHtmlFile
10
32
  });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
13
- const _utils = require("@modern-js/utils");
33
+ module.exports = __toCommonJS(output_exports);
34
+ var import_path = __toESM(require("path"));
35
+ var import_utils = require("@modern-js/utils");
14
36
  function writeHtmlFile(htmlAry, ssgRoutes, baseDir) {
15
37
  htmlAry.forEach((html, index) => {
16
38
  const ssgRoute = ssgRoutes[index];
17
- const filepath = _path.default.join(baseDir, ssgRoute.output);
18
- if (!_utils.fs.existsSync(_path.default.dirname(filepath))) {
19
- _utils.fs.ensureDirSync(_path.default.dirname(filepath));
39
+ const filepath = import_path.default.join(baseDir, ssgRoute.output);
40
+ if (!import_utils.fs.existsSync(import_path.default.dirname(filepath))) {
41
+ import_utils.fs.ensureDirSync(import_path.default.dirname(filepath));
20
42
  }
21
- _utils.fs.writeFileSync(filepath, html);
43
+ import_utils.fs.writeFileSync(filepath, html);
22
44
  });
23
45
  }
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ writeHtmlFile
49
+ });
@@ -1,27 +1,41 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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) => {
6
9
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- exist: function() {
14
- return exist;
15
- },
16
- replaceRoute: function() {
17
- return replaceRoute;
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 });
18
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 replace_exports = {};
30
+ __export(replace_exports, {
31
+ exist: () => exist,
32
+ replaceRoute: () => replaceRoute
19
33
  });
20
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
21
- const _normalizepath = /* @__PURE__ */ _interop_require_default._(require("normalize-path"));
34
+ module.exports = __toCommonJS(replace_exports);
35
+ var import_normalize_path = __toESM(require("normalize-path"));
22
36
  function exist(route, pageRoutes) {
23
37
  return pageRoutes.slice().findIndex((pageRoute) => {
24
- const urlEqual = (0, _normalizepath.default)(pageRoute.urlPath) === (0, _normalizepath.default)(route.urlPath);
38
+ const urlEqual = (0, import_normalize_path.default)(pageRoute.urlPath) === (0, import_normalize_path.default)(route.urlPath);
25
39
  const entryEqual = pageRoute.entryName === route.entryName;
26
40
  if (urlEqual && entryEqual) {
27
41
  return true;
@@ -50,3 +64,8 @@ function replaceRoute(ssgRoutes, pageRoutes) {
50
64
  pageRoutes.push(...freshRoutes);
51
65
  return pageRoutes;
52
66
  }
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ exist,
70
+ replaceRoute
71
+ });
@@ -1,54 +1,50 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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) => {
6
9
  for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- formatOutput: function() {
14
- return formatOutput;
15
- },
16
- formatPath: function() {
17
- return formatPath;
18
- },
19
- isDynamicUrl: function() {
20
- return isDynamicUrl;
21
- },
22
- getUrlPrefix: function() {
23
- return getUrlPrefix;
24
- },
25
- getOutput: function() {
26
- return getOutput;
27
- },
28
- readJSONSpec: function() {
29
- return readJSONSpec;
30
- },
31
- writeJSONSpec: function() {
32
- return writeJSONSpec;
33
- },
34
- replaceWithAlias: function() {
35
- return replaceWithAlias;
36
- },
37
- standardOptions: function() {
38
- return standardOptions;
39
- },
40
- openRouteSSR: function() {
41
- return openRouteSSR;
42
- },
43
- flattenRoutes: function() {
44
- return flattenRoutes;
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 });
45
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 util_exports = {};
30
+ __export(util_exports, {
31
+ flattenRoutes: () => flattenRoutes,
32
+ formatOutput: () => formatOutput,
33
+ formatPath: () => formatPath,
34
+ getOutput: () => getOutput,
35
+ getUrlPrefix: () => getUrlPrefix,
36
+ isDynamicUrl: () => isDynamicUrl,
37
+ openRouteSSR: () => openRouteSSR,
38
+ readJSONSpec: () => readJSONSpec,
39
+ replaceWithAlias: () => replaceWithAlias,
40
+ standardOptions: () => standardOptions,
41
+ writeJSONSpec: () => writeJSONSpec
46
42
  });
47
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
48
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
49
- const _utils = require("@modern-js/utils");
43
+ module.exports = __toCommonJS(util_exports);
44
+ var import_path = __toESM(require("path"));
45
+ var import_utils = require("@modern-js/utils");
50
46
  function formatOutput(filename) {
51
- const outputPath = _path.default.extname(filename) ? filename : `${filename}/index.html`;
47
+ const outputPath = import_path.default.extname(filename) ? filename : `${filename}/index.html`;
52
48
  return outputPath;
53
49
  }
54
50
  function formatPath(str) {
@@ -101,20 +97,20 @@ function getOutput(route, base, agreed) {
101
97
  throw new Error(`routing must provide output when calling createPage(), check ${route.urlPath}`);
102
98
  }
103
99
  const readJSONSpec = (dir) => {
104
- const routeJSONPath = _path.default.join(dir, _utils.ROUTE_SPEC_FILE);
100
+ const routeJSONPath = import_path.default.join(dir, import_utils.ROUTE_SPEC_FILE);
105
101
  const routeJSON = require(routeJSONPath);
106
102
  const { routes } = routeJSON;
107
103
  return routes;
108
104
  };
109
105
  const writeJSONSpec = (dir, routes) => {
110
- const routeJSONPath = _path.default.join(dir, _utils.ROUTE_SPEC_FILE);
111
- _utils.fs.writeJSONSync(routeJSONPath, {
106
+ const routeJSONPath = import_path.default.join(dir, import_utils.ROUTE_SPEC_FILE);
107
+ import_utils.fs.writeJSONSync(routeJSONPath, {
112
108
  routes
113
109
  }, {
114
110
  spaces: 2
115
111
  });
116
112
  };
117
- const replaceWithAlias = (base, filePath, alias) => _path.default.posix.join(alias, _path.default.posix.relative(base, filePath));
113
+ const replaceWithAlias = (base, filePath, alias) => import_path.default.posix.join(alias, import_path.default.posix.relative(base, filePath));
118
114
  const standardOptions = (ssgOptions, entrypoints, routes, server) => {
119
115
  if (ssgOptions === false) {
120
116
  return false;
@@ -125,7 +121,7 @@ const standardOptions = (ssgOptions, entrypoints, routes, server) => {
125
121
  return opt;
126
122
  }, {});
127
123
  } else if (typeof ssgOptions === "object") {
128
- const isSingle = (0, _utils.isSingleEntry)(entrypoints);
124
+ const isSingle = (0, import_utils.isSingleEntry)(entrypoints);
129
125
  if (isSingle && typeof ssgOptions.main === "undefined") {
130
126
  return {
131
127
  main: ssgOptions
@@ -158,25 +154,25 @@ const standardOptions = (ssgOptions, entrypoints, routes, server) => {
158
154
  const openRouteSSR = (routes, entries = []) => routes.map((ssgRoute) => ({
159
155
  ...ssgRoute,
160
156
  isSSR: entries.includes(ssgRoute.entryName),
161
- bundle: `${_utils.SERVER_BUNDLE_DIRECTORY}/${ssgRoute.entryName}.js`
157
+ bundle: `${import_utils.SERVER_BUNDLE_DIRECTORY}/${ssgRoute.entryName}.js`
162
158
  }));
163
159
  const flattenRoutes = (routes) => {
164
160
  const parents = [];
165
161
  const newRoutes = [];
166
162
  const traverseRoute = (route) => {
167
163
  const parent = parents[parents.length - 1];
168
- let path = parent ? `${parent.path}/${route.path || ""}`.replace(/\/+/g, "/") : route.path || "";
169
- path = path.replace(/\/$/, "");
170
- if (route._component && (path !== "/" || path === "/" && !parent)) {
164
+ let path2 = parent ? `${parent.path}/${route.path || ""}`.replace(/\/+/g, "/") : route.path || "";
165
+ path2 = path2.replace(/\/$/, "");
166
+ if (route._component && (path2 !== "/" || path2 === "/" && !parent)) {
171
167
  newRoutes.push({
172
168
  ...route,
173
- path
169
+ path: path2
174
170
  });
175
171
  }
176
172
  if (route.children) {
177
173
  parents.push({
178
174
  ...route,
179
- path
175
+ path: path2
180
176
  });
181
177
  route.children.forEach(traverseRoute);
182
178
  parents.pop();
@@ -185,3 +181,17 @@ const flattenRoutes = (routes) => {
185
181
  routes.forEach(traverseRoute);
186
182
  return newRoutes;
187
183
  };
184
+ // Annotate the CommonJS export names for ESM import in node:
185
+ 0 && (module.exports = {
186
+ flattenRoutes,
187
+ formatOutput,
188
+ formatPath,
189
+ getOutput,
190
+ getUrlPrefix,
191
+ isDynamicUrl,
192
+ openRouteSSR,
193
+ readJSONSpec,
194
+ replaceWithAlias,
195
+ standardOptions,
196
+ writeJSONSpec
197
+ });
@@ -1,11 +1,28 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "CLOSE_SIGN", {
6
- enumerable: true,
7
- get: function() {
8
- return CLOSE_SIGN;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var consts_exports = {};
20
+ __export(consts_exports, {
21
+ CLOSE_SIGN: () => CLOSE_SIGN
10
22
  });
23
+ module.exports = __toCommonJS(consts_exports);
11
24
  const CLOSE_SIGN = "modern_close_server";
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ CLOSE_SIGN
28
+ });