@modern-js/plugin-ssg 2.69.4 → 3.0.0-alpha.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.
Files changed (52) hide show
  1. package/dist/cjs/index.js +130 -156
  2. package/dist/cjs/libs/make.js +69 -62
  3. package/dist/cjs/libs/output.js +50 -44
  4. package/dist/cjs/libs/replace.js +68 -64
  5. package/dist/cjs/libs/util.js +200 -182
  6. package/dist/cjs/server/consts.js +33 -25
  7. package/dist/cjs/server/index.js +137 -92
  8. package/dist/cjs/server/prerender.js +72 -68
  9. package/dist/cjs/types.js +17 -15
  10. package/dist/esm/index.mjs +89 -0
  11. package/dist/esm/libs/make.mjs +31 -0
  12. package/dist/esm/libs/output.mjs +11 -0
  13. package/dist/esm/libs/replace.mjs +28 -0
  14. package/dist/esm/libs/util.mjs +147 -0
  15. package/dist/esm/server/consts.mjs +2 -0
  16. package/dist/esm/server/index.mjs +97 -0
  17. package/dist/esm/server/prerender.mjs +30 -0
  18. package/dist/esm-node/index.mjs +89 -0
  19. package/dist/esm-node/libs/make.mjs +31 -0
  20. package/dist/esm-node/libs/output.mjs +11 -0
  21. package/dist/esm-node/libs/replace.mjs +28 -0
  22. package/dist/esm-node/libs/util.mjs +147 -0
  23. package/dist/esm-node/server/consts.mjs +2 -0
  24. package/dist/esm-node/server/index.mjs +97 -0
  25. package/dist/esm-node/server/prerender.mjs +30 -0
  26. package/dist/types/libs/util.d.ts +1 -1
  27. package/dist/types/server/index.d.ts +2 -2
  28. package/package.json +27 -29
  29. package/rslib.config.mts +4 -0
  30. package/rstest.config.ts +7 -0
  31. package/dist/cjs/server/process.js +0 -108
  32. package/dist/esm/index.js +0 -163
  33. package/dist/esm/libs/make.js +0 -36
  34. package/dist/esm/libs/output.js +0 -15
  35. package/dist/esm/libs/replace.js +0 -41
  36. package/dist/esm/libs/util.js +0 -210
  37. package/dist/esm/server/consts.js +0 -4
  38. package/dist/esm/server/index.js +0 -66
  39. package/dist/esm/server/prerender.js +0 -46
  40. package/dist/esm/server/process.js +0 -263
  41. package/dist/esm-node/index.js +0 -128
  42. package/dist/esm-node/libs/make.js +0 -37
  43. package/dist/esm-node/libs/output.js +0 -15
  44. package/dist/esm-node/libs/replace.js +0 -36
  45. package/dist/esm-node/libs/util.js +0 -161
  46. package/dist/esm-node/server/consts.js +0 -4
  47. package/dist/esm-node/server/index.js +0 -62
  48. package/dist/esm-node/server/prerender.js +0 -37
  49. package/dist/esm-node/server/process.js +0 -85
  50. package/dist/types/server/process.d.ts +0 -1
  51. /package/dist/esm/{types.js → types.mjs} +0 -0
  52. /package/dist/esm-node/{types.js → types.mjs} +0 -0
@@ -1,71 +1,75 @@
1
1
  "use strict";
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 });
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
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ replaceRoute: ()=>replaceRoute,
37
+ exist: ()=>exist
33
38
  });
34
- module.exports = __toCommonJS(replace_exports);
35
- var import_normalize_path = __toESM(require("normalize-path"));
39
+ const external_normalize_path_namespaceObject = require("normalize-path");
40
+ var external_normalize_path_default = /*#__PURE__*/ __webpack_require__.n(external_normalize_path_namespaceObject);
36
41
  function exist(route, pageRoutes) {
37
- return pageRoutes.slice().findIndex((pageRoute) => {
38
- const urlEqual = (0, import_normalize_path.default)(pageRoute.urlPath) === (0, import_normalize_path.default)(route.urlPath);
39
- const entryEqual = pageRoute.entryName === route.entryName;
40
- if (urlEqual && entryEqual) {
41
- return true;
42
- }
43
- return false;
44
- });
42
+ return pageRoutes.slice().findIndex((pageRoute)=>{
43
+ const urlEqual = external_normalize_path_default()(pageRoute.urlPath) === external_normalize_path_default()(route.urlPath);
44
+ const entryEqual = pageRoute.entryName === route.entryName;
45
+ if (urlEqual && entryEqual) return true;
46
+ return false;
47
+ });
45
48
  }
46
49
  function replaceRoute(ssgRoutes, pageRoutes) {
47
- const cleanSsgRoutes = ssgRoutes.map((ssgRoute) => {
48
- const { output, headers, ...cleanSsgRoute } = ssgRoute;
49
- return Object.assign(cleanSsgRoute, output ? {
50
- entryPath: output
51
- } : {});
52
- });
53
- const freshRoutes = [];
54
- cleanSsgRoutes.forEach((ssgRoute) => {
55
- const index = exist(ssgRoute, pageRoutes);
56
- if (index < 0) {
57
- freshRoutes.push({
58
- ...ssgRoute
59
- });
60
- } else {
61
- pageRoutes[index].entryPath = ssgRoute.entryPath;
62
- }
63
- });
64
- pageRoutes.push(...freshRoutes);
65
- return pageRoutes;
50
+ const cleanSsgRoutes = ssgRoutes.map((ssgRoute)=>{
51
+ const { output, headers, ...cleanSsgRoute } = ssgRoute;
52
+ return Object.assign(cleanSsgRoute, output ? {
53
+ entryPath: output
54
+ } : {});
55
+ });
56
+ const freshRoutes = [];
57
+ cleanSsgRoutes.forEach((ssgRoute)=>{
58
+ const index = exist(ssgRoute, pageRoutes);
59
+ if (index < 0) freshRoutes.push({
60
+ ...ssgRoute
61
+ });
62
+ else pageRoutes[index].entryPath = ssgRoute.entryPath;
63
+ });
64
+ pageRoutes.push(...freshRoutes);
65
+ return pageRoutes;
66
66
  }
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
69
- exist,
70
- replaceRoute
67
+ exports.exist = __webpack_exports__.exist;
68
+ exports.replaceRoute = __webpack_exports__.replaceRoute;
69
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
70
+ "exist",
71
+ "replaceRoute"
72
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
73
+ Object.defineProperty(exports, '__esModule', {
74
+ value: true
71
75
  });
@@ -1,206 +1,224 @@
1
1
  "use strict";
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 });
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
- chunkArray: () => chunkArray,
32
- flattenRoutes: () => flattenRoutes,
33
- formatOutput: () => formatOutput,
34
- formatPath: () => formatPath,
35
- getOutput: () => getOutput,
36
- getUrlPrefix: () => getUrlPrefix,
37
- isDynamicUrl: () => isDynamicUrl,
38
- openRouteSSR: () => openRouteSSR,
39
- readJSONSpec: () => readJSONSpec,
40
- replaceWithAlias: () => replaceWithAlias,
41
- standardOptions: () => standardOptions,
42
- writeJSONSpec: () => writeJSONSpec
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ chunkArray: ()=>chunkArray,
37
+ readJSONSpec: ()=>readJSONSpec,
38
+ replaceWithAlias: ()=>replaceWithAlias,
39
+ writeJSONSpec: ()=>writeJSONSpec,
40
+ openRouteSSR: ()=>openRouteSSR,
41
+ getOutput: ()=>getOutput,
42
+ standardOptions: ()=>standardOptions,
43
+ isDynamicUrl: ()=>isDynamicUrl,
44
+ formatOutput: ()=>formatOutput,
45
+ getUrlPrefix: ()=>getUrlPrefix,
46
+ flattenRoutes: ()=>flattenRoutes,
47
+ formatPath: ()=>formatPath
43
48
  });
44
- module.exports = __toCommonJS(util_exports);
45
- var import_path = __toESM(require("path"));
46
- var import_utils = require("@modern-js/utils");
49
+ const external_path_namespaceObject = require("path");
50
+ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
51
+ const utils_namespaceObject = require("@modern-js/utils");
47
52
  function formatOutput(filename) {
48
- const outputPath = import_path.default.extname(filename) ? filename : `${filename}/index.html`;
49
- return outputPath;
53
+ const outputPath = external_path_default().extname(filename) ? filename : `${filename}/index.html`;
54
+ return outputPath;
50
55
  }
51
56
  function formatPath(str) {
52
- let addr = str;
53
- if (!addr || typeof addr !== "string") {
57
+ let addr = str;
58
+ if (!addr || 'string' != typeof addr) return addr;
59
+ if (addr.startsWith('.')) addr = addr.slice(1);
60
+ if (!addr.startsWith('/')) addr = `/${addr}`;
61
+ if (addr.endsWith('/') && '/' !== addr) addr = addr.slice(0, addr.length - 1);
54
62
  return addr;
55
- }
56
- if (addr.startsWith(".")) {
57
- addr = addr.slice(1);
58
- }
59
- if (!addr.startsWith("/")) {
60
- addr = `/${addr}`;
61
- }
62
- if (addr.endsWith("/") && addr !== "/") {
63
- addr = addr.slice(0, addr.length - 1);
64
- }
65
- return addr;
66
63
  }
67
64
  function isDynamicUrl(url) {
68
- return url.includes(":");
65
+ return url.includes(':') || url.endsWith('*');
69
66
  }
70
67
  function getUrlPrefix(route, baseUrl) {
71
- let base = "";
72
- if (Array.isArray(baseUrl)) {
73
- const filters = baseUrl.filter((url) => route.urlPath.includes(url));
74
- if (filters.length > 1) {
75
- const matched = filters.sort((a, b) => a.length - b.length)[0];
76
- if (!matched) {
77
- throw new Error("");
78
- }
79
- base = matched;
80
- }
81
- } else {
82
- base = baseUrl;
83
- }
84
- base = base === "/" ? "" : base;
85
- const entryName = route.entryName === "main" ? "" : route.entryName;
86
- const prefix = `${base}/${entryName}`;
87
- return prefix.endsWith("/") ? prefix.slice(0, -1) : prefix;
68
+ let base = '';
69
+ if (Array.isArray(baseUrl)) {
70
+ const filters = baseUrl.filter((url)=>route.urlPath.includes(url));
71
+ if (filters.length > 1) {
72
+ const matched = filters.sort((a, b)=>a.length - b.length)[0];
73
+ if (!matched) throw new Error('');
74
+ base = matched;
75
+ }
76
+ } else base = baseUrl;
77
+ base = '/' === base ? '' : base;
78
+ const entryName = 'main' === route.entryName ? '' : route.entryName;
79
+ const prefix = `${base}/${entryName}`;
80
+ return prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;
88
81
  }
89
82
  function getOutput(route, base, agreed) {
90
- const { output } = route;
91
- if (output) {
92
- return output;
93
- }
94
- if (agreed) {
95
- const urlWithoutBase = route.urlPath.replace(base, "");
96
- return urlWithoutBase.startsWith("/") ? urlWithoutBase.slice(1) : urlWithoutBase;
97
- }
98
- throw new Error(`routing must provide output when calling createPage(), check ${route.urlPath}`);
83
+ const { output } = route;
84
+ if (output) return output;
85
+ if (agreed) {
86
+ const urlWithoutBase = route.urlPath.replace(base, '');
87
+ return urlWithoutBase.startsWith('/') ? urlWithoutBase.slice(1) : urlWithoutBase;
88
+ }
89
+ throw new Error(`routing must provide output when calling createPage(), check ${route.urlPath}`);
99
90
  }
100
- const readJSONSpec = (dir) => {
101
- const routeJSONPath = import_path.default.join(dir, import_utils.ROUTE_SPEC_FILE);
102
- const routeJSON = require(routeJSONPath);
103
- const { routes } = routeJSON;
104
- return routes;
91
+ const readJSONSpec = (dir)=>{
92
+ const routeJSONPath = external_path_default().join(dir, utils_namespaceObject.ROUTE_SPEC_FILE);
93
+ const routeJSON = require(routeJSONPath);
94
+ const { routes } = routeJSON;
95
+ return routes;
105
96
  };
106
- const writeJSONSpec = (dir, routes) => {
107
- const routeJSONPath = import_path.default.join(dir, import_utils.ROUTE_SPEC_FILE);
108
- import_utils.fs.writeJSONSync(routeJSONPath, {
109
- routes
110
- }, {
111
- spaces: 2
112
- });
97
+ const writeJSONSpec = (dir, routes)=>{
98
+ const routeJSONPath = external_path_default().join(dir, utils_namespaceObject.ROUTE_SPEC_FILE);
99
+ utils_namespaceObject.fs.writeJSONSync(routeJSONPath, {
100
+ routes
101
+ }, {
102
+ spaces: 2
103
+ });
113
104
  };
114
- const replaceWithAlias = (base, filePath, alias) => import_path.default.posix.join(alias, import_path.default.posix.relative(base, filePath));
115
- const standardOptions = (ssgOptions, entrypoints, routes, server) => {
116
- if (ssgOptions === false) {
117
- return false;
118
- }
119
- if (ssgOptions === true) {
120
- return entrypoints.reduce((opt, entry) => {
121
- opt[entry.entryName] = ssgOptions;
122
- return opt;
105
+ const replaceWithAlias = (base, filePath, alias)=>external_path_default().posix.join(alias, external_path_default().posix.relative(base, filePath));
106
+ const standardOptions = (ssgOptions, entrypoints, routes, server, ssgByEntries)=>{
107
+ if (ssgByEntries && Object.keys(ssgByEntries).length > 0) {
108
+ const result = {};
109
+ Object.keys(ssgByEntries).forEach((key)=>{
110
+ const val = ssgByEntries[key];
111
+ if ('function' != typeof val) result[key] = val;
112
+ });
113
+ for (const entry of entrypoints){
114
+ const { entryName } = entry;
115
+ const configured = ssgByEntries[entryName];
116
+ if ('function' == typeof configured) {
117
+ const routesForEntry = routes.filter((r)=>r.entryName === entryName);
118
+ if (Array.isArray(server?.baseUrl)) for (const url of server.baseUrl)routesForEntry.filter((r)=>'string' == typeof r.urlPath && r.urlPath.startsWith(url)).forEach((r)=>{
119
+ result[r.urlPath] = configured(entryName, {
120
+ baseUrl: url
121
+ });
122
+ });
123
+ else result[entryName] = configured(entryName, {
124
+ baseUrl: server?.baseUrl
125
+ });
126
+ } else if (void 0 !== configured) result[entryName] = configured;
127
+ }
128
+ return result;
129
+ }
130
+ if (false === ssgOptions) return false;
131
+ if (true === ssgOptions) return entrypoints.reduce((opt, entry)=>{
132
+ opt[entry.entryName] = ssgOptions;
133
+ return opt;
123
134
  }, {});
124
- } else if (typeof ssgOptions === "object") {
125
- const isSingle = (0, import_utils.isSingleEntry)(entrypoints);
126
- if (isSingle && typeof ssgOptions.main === "undefined") {
127
- return {
128
- main: ssgOptions
129
- };
130
- } else {
131
- return ssgOptions;
135
+ if ('object' == typeof ssgOptions) {
136
+ const isSingle = (0, utils_namespaceObject.isSingleEntry)(entrypoints);
137
+ if (isSingle) return {
138
+ main: ssgOptions
139
+ };
140
+ return entrypoints.reduce((opt, entry)=>{
141
+ opt[entry.entryName] = ssgOptions;
142
+ return opt;
143
+ }, {});
132
144
  }
133
- } else if (typeof ssgOptions === "function") {
134
- const intermediateOptions = {};
135
- for (const entrypoint of entrypoints) {
136
- const { entryName } = entrypoint;
137
- if (Array.isArray(server === null || server === void 0 ? void 0 : server.baseUrl)) {
138
- for (const url of server.baseUrl) {
139
- const matchUrl = entryName === "main" ? url : `${url}/${entryName}`;
140
- const route = routes.find((route2) => route2.urlPath === matchUrl);
141
- intermediateOptions[route === null || route === void 0 ? void 0 : route.urlPath] = ssgOptions(entryName, {
142
- baseUrl: url
143
- });
145
+ if ('function' == typeof ssgOptions) {
146
+ const intermediateOptions = {};
147
+ for (const entrypoint of entrypoints){
148
+ const { entryName } = entrypoint;
149
+ const routesForEntry = routes.filter((r)=>r.entryName === entryName);
150
+ if (Array.isArray(server?.baseUrl)) for (const url of server.baseUrl)routesForEntry.filter((r)=>'string' == typeof r.urlPath && r.urlPath.startsWith(url)).forEach((r)=>{
151
+ intermediateOptions[r.urlPath] = ssgOptions(entryName, {
152
+ baseUrl: url
153
+ });
154
+ });
155
+ else intermediateOptions[entryName] = ssgOptions(entryName, {
156
+ baseUrl: server?.baseUrl
157
+ });
144
158
  }
145
- } else {
146
- intermediateOptions[entryName] = ssgOptions(entryName, {
147
- baseUrl: server === null || server === void 0 ? void 0 : server.baseUrl
148
- });
149
- }
159
+ return intermediateOptions;
150
160
  }
151
- return intermediateOptions;
152
- }
153
- return false;
161
+ return false;
154
162
  };
155
- const openRouteSSR = (routes, entries = []) => routes.map((ssgRoute) => ({
156
- ...ssgRoute,
157
- isSSR: entries.includes(ssgRoute.entryName),
158
- bundle: `${import_utils.SERVER_BUNDLE_DIRECTORY}/${ssgRoute.entryName}.js`
159
- }));
160
- const flattenRoutes = (routes) => {
161
- const parents = [];
162
- const newRoutes = [];
163
- const traverseRoute = (route) => {
164
- const parent = parents[parents.length - 1];
165
- let path2 = parent ? `${parent.path}/${route.path || ""}`.replace(/\/+/g, "/") : route.path || "";
166
- path2 = path2.replace(/\/$/, "");
167
- if (route._component && (path2 !== "/" || path2 === "/" && !parent)) {
168
- newRoutes.push({
169
- ...route,
170
- path: path2
171
- });
172
- }
173
- if (route.children) {
174
- parents.push({
175
- ...route,
176
- path: path2
177
- });
178
- route.children.forEach(traverseRoute);
179
- parents.pop();
180
- }
181
- };
182
- routes.forEach(traverseRoute);
183
- return newRoutes;
163
+ const openRouteSSR = (routes, entries = [])=>routes.map((ssgRoute)=>({
164
+ ...ssgRoute,
165
+ isSSR: entries.includes(ssgRoute.entryName),
166
+ bundle: `${utils_namespaceObject.SERVER_BUNDLE_DIRECTORY}/${ssgRoute.entryName}.js`
167
+ }));
168
+ const flattenRoutes = (routes)=>{
169
+ const parents = [];
170
+ const newRoutes = [];
171
+ const traverseRoute = (route)=>{
172
+ const parent = parents[parents.length - 1];
173
+ let path = parent ? `${parent.path}/${route.path || ''}`.replace(/\/+/g, '/') : route.path || '';
174
+ path = path.replace(/\/$/, '');
175
+ if (route._component && ('/' !== path || '/' === path && !parent)) newRoutes.push({
176
+ ...route,
177
+ path
178
+ });
179
+ if (route.children) {
180
+ parents.push({
181
+ ...route,
182
+ path
183
+ });
184
+ route.children.forEach(traverseRoute);
185
+ parents.pop();
186
+ }
187
+ };
188
+ routes.forEach(traverseRoute);
189
+ return newRoutes;
184
190
  };
185
191
  function chunkArray(arr, size) {
186
- const result = [];
187
- for (let i = 0; i < arr.length; i += size) {
188
- result.push(arr.slice(i, i + size));
189
- }
190
- return result;
192
+ const result = [];
193
+ for(let i = 0; i < arr.length; i += size)result.push(arr.slice(i, i + size));
194
+ return result;
191
195
  }
192
- // Annotate the CommonJS export names for ESM import in node:
193
- 0 && (module.exports = {
194
- chunkArray,
195
- flattenRoutes,
196
- formatOutput,
197
- formatPath,
198
- getOutput,
199
- getUrlPrefix,
200
- isDynamicUrl,
201
- openRouteSSR,
202
- readJSONSpec,
203
- replaceWithAlias,
204
- standardOptions,
205
- writeJSONSpec
196
+ exports.chunkArray = __webpack_exports__.chunkArray;
197
+ exports.flattenRoutes = __webpack_exports__.flattenRoutes;
198
+ exports.formatOutput = __webpack_exports__.formatOutput;
199
+ exports.formatPath = __webpack_exports__.formatPath;
200
+ exports.getOutput = __webpack_exports__.getOutput;
201
+ exports.getUrlPrefix = __webpack_exports__.getUrlPrefix;
202
+ exports.isDynamicUrl = __webpack_exports__.isDynamicUrl;
203
+ exports.openRouteSSR = __webpack_exports__.openRouteSSR;
204
+ exports.readJSONSpec = __webpack_exports__.readJSONSpec;
205
+ exports.replaceWithAlias = __webpack_exports__.replaceWithAlias;
206
+ exports.standardOptions = __webpack_exports__.standardOptions;
207
+ exports.writeJSONSpec = __webpack_exports__.writeJSONSpec;
208
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
209
+ "chunkArray",
210
+ "flattenRoutes",
211
+ "formatOutput",
212
+ "formatPath",
213
+ "getOutput",
214
+ "getUrlPrefix",
215
+ "isDynamicUrl",
216
+ "openRouteSSR",
217
+ "readJSONSpec",
218
+ "replaceWithAlias",
219
+ "standardOptions",
220
+ "writeJSONSpec"
221
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
222
+ Object.defineProperty(exports, '__esModule', {
223
+ value: true
206
224
  });
@@ -1,28 +1,36 @@
1
1
  "use strict";
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 });
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
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ CLOSE_SIGN: ()=>CLOSE_SIGN
22
28
  });
23
- module.exports = __toCommonJS(consts_exports);
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
29
+ const CLOSE_SIGN = 'modern_close_server';
30
+ exports.CLOSE_SIGN = __webpack_exports__.CLOSE_SIGN;
31
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
32
+ "CLOSE_SIGN"
33
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
34
+ Object.defineProperty(exports, '__esModule', {
35
+ value: true
28
36
  });