@modern-js/plugin-ssg 2.4.1-beta.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -2
- package/dist/cjs/index.js +172 -0
- package/dist/{js/node → cjs}/libs/make.js +12 -23
- package/dist/{js/node → cjs}/libs/output.js +4 -0
- package/dist/{js/node → cjs}/libs/replace.js +6 -28
- package/dist/{js/node → cjs}/libs/util.js +12 -22
- package/dist/{js/node → cjs}/server/index.js +4 -0
- package/dist/{js/node → cjs}/server/prerender.js +7 -19
- package/dist/{js/node → cjs}/server/process.js +11 -27
- package/dist/esm-node/index.js +148 -0
- package/dist/esm-node/libs/make.js +33 -0
- package/dist/esm-node/libs/replace.js +35 -0
- package/dist/{js/modern → esm-node}/libs/util.js +8 -24
- package/dist/esm-node/server/prerender.js +35 -0
- package/dist/esm-node/server/process.js +55 -0
- package/package.json +18 -19
- package/dist/js/modern/index.js +0 -189
- package/dist/js/modern/libs/make.js +0 -50
- package/dist/js/modern/libs/replace.js +0 -63
- package/dist/js/modern/server/prerender.js +0 -53
- package/dist/js/modern/server/process.js +0 -84
- package/dist/js/node/index.js +0 -207
- /package/dist/{js/node → cjs}/server/consts.js +0 -0
- /package/dist/{js/node → cjs}/types.js +0 -0
- /package/dist/{js/treeshaking → esm}/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/libs/make.js +0 -0
- /package/dist/{js/treeshaking → esm}/libs/output.js +0 -0
- /package/dist/{js/treeshaking → esm}/libs/replace.js +0 -0
- /package/dist/{js/treeshaking → esm}/libs/util.js +0 -0
- /package/dist/{js/treeshaking → esm}/server/consts.js +0 -0
- /package/dist/{js/treeshaking → esm}/server/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/server/prerender.js +0 -0
- /package/dist/{js/treeshaking → esm}/server/process.js +0 -0
- /package/dist/{js/treeshaking → esm}/types.js +0 -0
- /package/dist/{js/modern → esm-node}/libs/output.js +0 -0
- /package/dist/{js/modern → esm-node}/server/consts.js +0 -0
- /package/dist/{js/modern → esm-node}/server/index.js +0 -0
- /package/dist/{js/modern → esm-node}/types.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
# @modern-js/plugin-ssg
|
|
2
2
|
|
|
3
|
-
## 2.
|
|
3
|
+
## 2.6.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- Updated dependencies [e1f799e]
|
|
8
|
+
- Updated dependencies [7915ab3]
|
|
9
|
+
- Updated dependencies [0fe658a]
|
|
10
|
+
- @modern-js/utils@2.6.0
|
|
11
|
+
|
|
12
|
+
## 2.5.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 89ca6cc: refactor: merge build-config into scripts/build
|
|
17
|
+
|
|
18
|
+
refactor: 把 build-config 合并进 scripts/build
|
|
19
|
+
|
|
20
|
+
- 30614fa: chore: modify package.json entry fields and build config
|
|
21
|
+
chore: 更改 package.json entry 字段以及构建配置
|
|
22
|
+
- Updated dependencies [30614fa]
|
|
23
|
+
- Updated dependencies [1b0ce87]
|
|
7
24
|
- Updated dependencies [11c053b]
|
|
8
|
-
- @modern-js/utils@2.
|
|
25
|
+
- @modern-js/utils@2.5.0
|
|
9
26
|
|
|
10
27
|
## 2.4.0
|
|
11
28
|
|
|
@@ -0,0 +1,172 @@
|
|
|
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 src_exports = {};
|
|
29
|
+
__export(src_exports, {
|
|
30
|
+
default: () => src_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
33
|
+
var import_path = __toESM(require("path"));
|
|
34
|
+
var import_utils = require("@modern-js/utils");
|
|
35
|
+
var import_react_router_dom = require("react-router-dom");
|
|
36
|
+
var import_util = require("./libs/util");
|
|
37
|
+
var import_server = require("./server");
|
|
38
|
+
var import_output = require("./libs/output");
|
|
39
|
+
var import_replace = require("./libs/replace");
|
|
40
|
+
var import_make = require("./libs/make");
|
|
41
|
+
var src_default = () => ({
|
|
42
|
+
name: "@modern-js/plugin-ssg",
|
|
43
|
+
pre: ["@modern-js/plugin-server", "@modern-js/plugin-bff"],
|
|
44
|
+
setup: (api) => {
|
|
45
|
+
const agreedRouteMap = {};
|
|
46
|
+
return {
|
|
47
|
+
validateSchema() {
|
|
48
|
+
return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-ssg"];
|
|
49
|
+
},
|
|
50
|
+
modifyFileSystemRoutes({ entrypoint, routes }) {
|
|
51
|
+
const { entryName } = entrypoint;
|
|
52
|
+
const flattedRoutes = (0, import_util.flattenRoutes)(routes);
|
|
53
|
+
agreedRouteMap[entryName] = flattedRoutes;
|
|
54
|
+
return { entrypoint, routes };
|
|
55
|
+
},
|
|
56
|
+
async afterBuild() {
|
|
57
|
+
const resolvedConfig = api.useResolvedConfigContext();
|
|
58
|
+
const appContext = api.useAppContext();
|
|
59
|
+
const { appDirectory, entrypoints } = appContext;
|
|
60
|
+
const { output, server } = resolvedConfig;
|
|
61
|
+
const { ssg, distPath: { root: outputPath } = {} } = output;
|
|
62
|
+
const ssgOptions = (Array.isArray(ssg) ? ssg.pop() : ssg) || true;
|
|
63
|
+
const buildDir = import_path.default.join(appDirectory, outputPath);
|
|
64
|
+
const routes = (0, import_util.readJSONSpec)(buildDir);
|
|
65
|
+
const pageRoutes = routes.filter((route) => !route.isApi);
|
|
66
|
+
const apiRoutes = routes.filter((route) => route.isApi);
|
|
67
|
+
if (pageRoutes.length === 0) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const intermediateOptions = (0, import_util.standardOptions)(
|
|
71
|
+
ssgOptions,
|
|
72
|
+
entrypoints,
|
|
73
|
+
pageRoutes,
|
|
74
|
+
server
|
|
75
|
+
);
|
|
76
|
+
if (!intermediateOptions) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const ssgRoutes = [];
|
|
80
|
+
pageRoutes.forEach((pageRoute) => {
|
|
81
|
+
const { entryName, entryPath } = pageRoute;
|
|
82
|
+
const agreedRoutes = agreedRouteMap[entryName];
|
|
83
|
+
let entryOptions = intermediateOptions[entryName] || intermediateOptions[pageRoute.urlPath];
|
|
84
|
+
if (!agreedRoutes) {
|
|
85
|
+
if (!entryOptions) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (entryOptions === true) {
|
|
89
|
+
ssgRoutes.push({ ...pageRoute, output: entryPath });
|
|
90
|
+
} else if (entryOptions.routes && entryOptions.routes.length > 0) {
|
|
91
|
+
const { routes: enrtyRoutes, headers } = entryOptions;
|
|
92
|
+
enrtyRoutes.forEach((route) => {
|
|
93
|
+
ssgRoutes.push((0, import_make.makeRoute)(pageRoute, route, headers));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
if (!entryOptions) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (entryOptions === true) {
|
|
101
|
+
entryOptions = { preventDefault: [], routes: [], headers: {} };
|
|
102
|
+
}
|
|
103
|
+
const {
|
|
104
|
+
preventDefault = [],
|
|
105
|
+
routes: userRoutes = [],
|
|
106
|
+
headers
|
|
107
|
+
} = entryOptions;
|
|
108
|
+
if (userRoutes.length > 0) {
|
|
109
|
+
userRoutes.forEach((route) => {
|
|
110
|
+
if (typeof route === "string") {
|
|
111
|
+
ssgRoutes.push((0, import_make.makeRoute)(pageRoute, route, headers));
|
|
112
|
+
} else if (Array.isArray(route.params)) {
|
|
113
|
+
route.params.forEach((param) => {
|
|
114
|
+
ssgRoutes.push(
|
|
115
|
+
(0, import_make.makeRoute)(
|
|
116
|
+
pageRoute,
|
|
117
|
+
{ ...route, url: (0, import_react_router_dom.generatePath)(route.url, param) },
|
|
118
|
+
headers
|
|
119
|
+
)
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
} else {
|
|
123
|
+
ssgRoutes.push((0, import_make.makeRoute)(pageRoute, route, headers));
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
agreedRoutes.filter((route) => !preventDefault.includes(route.path)).forEach((route) => {
|
|
128
|
+
if (!(0, import_util.isDynamicUrl)(route.path)) {
|
|
129
|
+
ssgRoutes.push((0, import_make.makeRoute)(pageRoute, route.path, headers));
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
if (ssgRoutes.length === 0) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
ssgRoutes.forEach((ssgRoute) => {
|
|
139
|
+
if (ssgRoute.isSSR) {
|
|
140
|
+
const isOriginRoute = pageRoutes.some(
|
|
141
|
+
(pageRoute) => pageRoute.urlPath === ssgRoute.urlPath && pageRoute.entryName === ssgRoute.entryName
|
|
142
|
+
);
|
|
143
|
+
if (isOriginRoute) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
`ssg can not using with ssr,url - ${ssgRoute.urlPath}, entry - ${ssgRoute.entryName} `
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
import_utils.logger.warn(
|
|
149
|
+
`new ssg route ${ssgRoute.urlPath} is using ssr now,maybe from parent route ${ssgRoute.entryName},close ssr`
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
ssgRoute.isSSR = false;
|
|
153
|
+
ssgRoute.output = (0, import_util.formatOutput)(ssgRoute.output);
|
|
154
|
+
});
|
|
155
|
+
const htmlAry = await (0, import_server.createServer)(
|
|
156
|
+
api,
|
|
157
|
+
ssgRoutes,
|
|
158
|
+
pageRoutes,
|
|
159
|
+
apiRoutes,
|
|
160
|
+
resolvedConfig,
|
|
161
|
+
appDirectory
|
|
162
|
+
);
|
|
163
|
+
(0, import_output.writeHtmlFile)(htmlAry, ssgRoutes, buildDir);
|
|
164
|
+
(0, import_replace.replaceRoute)(ssgRoutes, pageRoutes);
|
|
165
|
+
(0, import_util.writeJSONSpec)(buildDir, pageRoutes.concat(apiRoutes));
|
|
166
|
+
import_utils.logger.info("ssg Compiled successfully");
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
172
|
+
0 && (module.exports = {});
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
7
|
var __export = (target, all) => {
|
|
25
8
|
for (var name in all)
|
|
26
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -34,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
17
|
return to;
|
|
35
18
|
};
|
|
36
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.
|
|
37
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
25
|
mod
|
|
39
26
|
));
|
|
@@ -50,7 +37,7 @@ function makeRender(ssgRoutes, render, port) {
|
|
|
50
37
|
return ssgRoutes.map(
|
|
51
38
|
(ssgRoute) => render({
|
|
52
39
|
url: ssgRoute.urlPath,
|
|
53
|
-
headers:
|
|
40
|
+
headers: { host: `localhost:${port}`, ...ssgRoute.headers },
|
|
54
41
|
connection: {}
|
|
55
42
|
})
|
|
56
43
|
);
|
|
@@ -58,17 +45,19 @@ function makeRender(ssgRoutes, render, port) {
|
|
|
58
45
|
function makeRoute(baseRoute, route, headers = {}) {
|
|
59
46
|
const { urlPath, entryPath } = baseRoute;
|
|
60
47
|
if (typeof route === "string") {
|
|
61
|
-
return
|
|
48
|
+
return {
|
|
49
|
+
...baseRoute,
|
|
62
50
|
urlPath: (0, import_normalize_path.default)(`${urlPath}${route}`) || "/",
|
|
63
51
|
headers,
|
|
64
52
|
output: import_path.default.join(entryPath, `..${route === "/" ? "" : route}`)
|
|
65
|
-
}
|
|
53
|
+
};
|
|
66
54
|
} else {
|
|
67
|
-
return
|
|
55
|
+
return {
|
|
56
|
+
...baseRoute,
|
|
68
57
|
urlPath: (0, import_normalize_path.default)(`${urlPath}${route.url}`) || "/",
|
|
69
|
-
headers:
|
|
58
|
+
headers: { ...headers, ...route.headers },
|
|
70
59
|
output: route.output ? import_path.default.normalize(route.output) : import_path.default.join(entryPath, `..${route.url === "/" ? "" : route.url}`)
|
|
71
|
-
}
|
|
60
|
+
};
|
|
72
61
|
}
|
|
73
62
|
}
|
|
74
63
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -2,34 +2,8 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __objRest = (source, exclude) => {
|
|
22
|
-
var target = {};
|
|
23
|
-
for (var prop in source)
|
|
24
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
-
target[prop] = source[prop];
|
|
26
|
-
if (source != null && __getOwnPropSymbols)
|
|
27
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
}
|
|
31
|
-
return target;
|
|
32
|
-
};
|
|
33
7
|
var __export = (target, all) => {
|
|
34
8
|
for (var name in all)
|
|
35
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -43,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
43
17
|
return to;
|
|
44
18
|
};
|
|
45
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.
|
|
46
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
47
25
|
mod
|
|
48
26
|
));
|
|
@@ -66,7 +44,7 @@ function exist(route, pageRoutes) {
|
|
|
66
44
|
}
|
|
67
45
|
function replaceRoute(ssgRoutes, pageRoutes) {
|
|
68
46
|
const cleanSsgRoutes = ssgRoutes.map((ssgRoute) => {
|
|
69
|
-
const
|
|
47
|
+
const { output, headers, ...cleanSsgRoute } = ssgRoute;
|
|
70
48
|
return Object.assign(
|
|
71
49
|
cleanSsgRoute,
|
|
72
50
|
output ? { entryPath: output } : {}
|
|
@@ -76,7 +54,7 @@ function replaceRoute(ssgRoutes, pageRoutes) {
|
|
|
76
54
|
cleanSsgRoutes.forEach((ssgRoute) => {
|
|
77
55
|
const index = exist(ssgRoute, pageRoutes);
|
|
78
56
|
if (index < 0) {
|
|
79
|
-
freshRoutes.push(
|
|
57
|
+
freshRoutes.push({ ...ssgRoute });
|
|
80
58
|
} else {
|
|
81
59
|
pageRoutes[index].entryPath = ssgRoute.entryPath;
|
|
82
60
|
}
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
7
|
var __export = (target, all) => {
|
|
25
8
|
for (var name in all)
|
|
26
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -34,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
17
|
return to;
|
|
35
18
|
};
|
|
36
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.
|
|
37
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
25
|
mod
|
|
39
26
|
));
|
|
@@ -160,7 +147,8 @@ const standardOptions = (ssgOptions, entrypoints, routes, server) => {
|
|
|
160
147
|
}
|
|
161
148
|
return false;
|
|
162
149
|
};
|
|
163
|
-
const openRouteSSR = (routes, entries = []) => routes.map((ssgRoute) =>
|
|
150
|
+
const openRouteSSR = (routes, entries = []) => routes.map((ssgRoute) => ({
|
|
151
|
+
...ssgRoute,
|
|
164
152
|
isSSR: entries.includes(ssgRoute.entryName),
|
|
165
153
|
bundle: `${import_utils.SERVER_BUNDLE_DIRECTORY}/${ssgRoute.entryName}.js`
|
|
166
154
|
}));
|
|
@@ -172,14 +160,16 @@ const flattenRoutes = (routes) => {
|
|
|
172
160
|
let path2 = parent ? `${parent.path}/${route.path || ""}`.replace(/\/+/g, "/") : route.path || "";
|
|
173
161
|
path2 = path2.replace(/\/$/, "");
|
|
174
162
|
if (route._component && (path2 !== "/" || path2 === "/" && !parent)) {
|
|
175
|
-
newRoutes.push(
|
|
163
|
+
newRoutes.push({
|
|
164
|
+
...route,
|
|
176
165
|
path: path2
|
|
177
|
-
})
|
|
166
|
+
});
|
|
178
167
|
}
|
|
179
168
|
if (route.children) {
|
|
180
|
-
parents.push(
|
|
169
|
+
parents.push({
|
|
170
|
+
...route,
|
|
181
171
|
path: path2
|
|
182
|
-
})
|
|
172
|
+
});
|
|
183
173
|
route.children.forEach(traverseRoute);
|
|
184
174
|
parents.pop();
|
|
185
175
|
}
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
7
|
var __export = (target, all) => {
|
|
25
8
|
for (var name in all)
|
|
26
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -34,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
17
|
return to;
|
|
35
18
|
};
|
|
36
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.
|
|
37
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
25
|
mod
|
|
39
26
|
));
|
|
@@ -47,9 +34,10 @@ var import_events = __toESM(require("events"));
|
|
|
47
34
|
var import_stream = require("stream");
|
|
48
35
|
var import_node_mocks_http = __toESM(require("node-mocks-http"));
|
|
49
36
|
const compile = (requestHandler) => (options, extend = {}) => new Promise((resolve, reject) => {
|
|
50
|
-
const req = import_node_mocks_http.default.createRequest(
|
|
37
|
+
const req = import_node_mocks_http.default.createRequest({
|
|
38
|
+
...options,
|
|
51
39
|
eventEmitter: import_stream.Readable
|
|
52
|
-
})
|
|
40
|
+
});
|
|
53
41
|
const res = import_node_mocks_http.default.createResponse({ eventEmitter: import_events.default });
|
|
54
42
|
Object.assign(req, extend);
|
|
55
43
|
const proxyRes = new Proxy(res, {
|
|
@@ -13,35 +13,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
13
|
return to;
|
|
14
14
|
};
|
|
15
15
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
16
20
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
17
21
|
mod
|
|
18
22
|
));
|
|
19
|
-
var __async = (__this, __arguments, generator) => {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
var fulfilled = (value) => {
|
|
22
|
-
try {
|
|
23
|
-
step(generator.next(value));
|
|
24
|
-
} catch (e) {
|
|
25
|
-
reject(e);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var rejected = (value) => {
|
|
29
|
-
try {
|
|
30
|
-
step(generator.throw(value));
|
|
31
|
-
} catch (e) {
|
|
32
|
-
reject(e);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
36
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
23
|
var import_prod_server = __toESM(require("@modern-js/prod-server"));
|
|
40
24
|
var import_portfinder = __toESM(require("portfinder"));
|
|
41
25
|
var import_make = require("../libs/make");
|
|
42
26
|
var import_prerender = require("./prerender");
|
|
43
27
|
var import_consts = require("./consts");
|
|
44
|
-
process.on("message", (chunk) =>
|
|
28
|
+
process.on("message", async (chunk) => {
|
|
45
29
|
if (chunk === import_consts.CLOSE_SIGN) {
|
|
46
30
|
process.exit();
|
|
47
31
|
}
|
|
@@ -58,15 +42,15 @@ process.on("message", (chunk) => __async(exports, null, function* () {
|
|
|
58
42
|
const { server: serverOptions } = options;
|
|
59
43
|
const defaultPort = Number(process.env.PORT) || serverOptions.port;
|
|
60
44
|
import_portfinder.default.basePort = defaultPort;
|
|
61
|
-
const port =
|
|
62
|
-
modernServer =
|
|
45
|
+
const port = await import_portfinder.default.getPortPromise();
|
|
46
|
+
modernServer = await (0, import_prod_server.default)({
|
|
63
47
|
pwd: appDirectory,
|
|
64
48
|
config: options,
|
|
65
49
|
routes,
|
|
66
50
|
staticGenerate: true,
|
|
67
51
|
internalPlugins: plugins
|
|
68
52
|
});
|
|
69
|
-
modernServer.listen(port, (err) =>
|
|
53
|
+
modernServer.listen(port, async (err) => {
|
|
70
54
|
if (err) {
|
|
71
55
|
throw err;
|
|
72
56
|
}
|
|
@@ -79,15 +63,15 @@ process.on("message", (chunk) => __async(exports, null, function* () {
|
|
|
79
63
|
render,
|
|
80
64
|
port
|
|
81
65
|
);
|
|
82
|
-
const htmlAry =
|
|
66
|
+
const htmlAry = await Promise.all(renderPromiseAry);
|
|
83
67
|
htmlAry.forEach((html) => {
|
|
84
68
|
process.send(html);
|
|
85
69
|
process.send(null);
|
|
86
70
|
});
|
|
87
71
|
modernServer.close();
|
|
88
|
-
})
|
|
72
|
+
});
|
|
89
73
|
} catch (e) {
|
|
90
74
|
modernServer == null ? void 0 : modernServer.close();
|
|
91
75
|
throw e;
|
|
92
76
|
}
|
|
93
|
-
})
|
|
77
|
+
});
|