@modern-js/plugin-ssg 2.4.0 → 2.5.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 +15 -0
- package/dist/cjs/index.js +168 -0
- package/dist/{js/node → cjs}/libs/make.js +8 -23
- package/dist/{js/node → cjs}/libs/output.js +0 -0
- package/dist/{js/node → cjs}/libs/replace.js +2 -28
- package/dist/{js/node → cjs}/libs/util.js +8 -22
- package/dist/{js/node → cjs}/server/consts.js +0 -0
- package/dist/{js/node → cjs}/server/index.js +0 -0
- package/dist/{js/node → cjs}/server/prerender.js +3 -19
- package/dist/{js/node → cjs}/server/process.js +7 -27
- package/dist/{js/node → cjs}/types.js +0 -0
- package/dist/{js/treeshaking → esm}/index.js +3 -3
- 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/esm-node/index.js +148 -0
- package/dist/esm-node/libs/make.js +33 -0
- package/dist/{js/modern → esm-node}/libs/output.js +0 -0
- package/dist/esm-node/libs/replace.js +35 -0
- package/dist/{js/modern → esm-node}/libs/util.js +8 -24
- package/dist/{js/modern → esm-node}/server/consts.js +0 -0
- package/dist/{js/modern → esm-node}/server/index.js +0 -0
- package/dist/esm-node/server/prerender.js +35 -0
- package/dist/esm-node/server/process.js +55 -0
- package/dist/{js/modern → esm-node}/types.js +0 -0
- package/dist/types/libs/util.d.ts +1 -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
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import path from "path";
|
|
21
|
-
import normalize from "normalize-path";
|
|
22
|
-
function makeRender(ssgRoutes, render, port) {
|
|
23
|
-
return ssgRoutes.map(
|
|
24
|
-
(ssgRoute) => render({
|
|
25
|
-
url: ssgRoute.urlPath,
|
|
26
|
-
headers: __spreadValues({ host: `localhost:${port}` }, ssgRoute.headers),
|
|
27
|
-
connection: {}
|
|
28
|
-
})
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
function makeRoute(baseRoute, route, headers = {}) {
|
|
32
|
-
const { urlPath, entryPath } = baseRoute;
|
|
33
|
-
if (typeof route === "string") {
|
|
34
|
-
return __spreadProps(__spreadValues({}, baseRoute), {
|
|
35
|
-
urlPath: normalize(`${urlPath}${route}`) || "/",
|
|
36
|
-
headers,
|
|
37
|
-
output: path.join(entryPath, `..${route === "/" ? "" : route}`)
|
|
38
|
-
});
|
|
39
|
-
} else {
|
|
40
|
-
return __spreadProps(__spreadValues({}, baseRoute), {
|
|
41
|
-
urlPath: normalize(`${urlPath}${route.url}`) || "/",
|
|
42
|
-
headers: __spreadValues(__spreadValues({}, headers), route.headers),
|
|
43
|
-
output: route.output ? path.normalize(route.output) : path.join(entryPath, `..${route.url === "/" ? "" : route.url}`)
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
makeRender,
|
|
49
|
-
makeRoute
|
|
50
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
var __objRest = (source, exclude) => {
|
|
18
|
-
var target = {};
|
|
19
|
-
for (var prop in source)
|
|
20
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
-
target[prop] = source[prop];
|
|
22
|
-
if (source != null && __getOwnPropSymbols)
|
|
23
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
-
target[prop] = source[prop];
|
|
26
|
-
}
|
|
27
|
-
return target;
|
|
28
|
-
};
|
|
29
|
-
import normalize from "normalize-path";
|
|
30
|
-
function exist(route, pageRoutes) {
|
|
31
|
-
return pageRoutes.slice().findIndex((pageRoute) => {
|
|
32
|
-
const urlEqual = normalize(pageRoute.urlPath) === normalize(route.urlPath);
|
|
33
|
-
const entryEqual = pageRoute.entryName === route.entryName;
|
|
34
|
-
if (urlEqual && entryEqual) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
return false;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
function replaceRoute(ssgRoutes, pageRoutes) {
|
|
41
|
-
const cleanSsgRoutes = ssgRoutes.map((ssgRoute) => {
|
|
42
|
-
const _a = ssgRoute, { output, headers } = _a, cleanSsgRoute = __objRest(_a, ["output", "headers"]);
|
|
43
|
-
return Object.assign(
|
|
44
|
-
cleanSsgRoute,
|
|
45
|
-
output ? { entryPath: output } : {}
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
const freshRoutes = [];
|
|
49
|
-
cleanSsgRoutes.forEach((ssgRoute) => {
|
|
50
|
-
const index = exist(ssgRoute, pageRoutes);
|
|
51
|
-
if (index < 0) {
|
|
52
|
-
freshRoutes.push(__spreadValues({}, ssgRoute));
|
|
53
|
-
} else {
|
|
54
|
-
pageRoutes[index].entryPath = ssgRoute.entryPath;
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
pageRoutes.push(...freshRoutes);
|
|
58
|
-
return pageRoutes;
|
|
59
|
-
}
|
|
60
|
-
export {
|
|
61
|
-
exist,
|
|
62
|
-
replaceRoute
|
|
63
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import EventEmitter from "events";
|
|
21
|
-
import { Readable } from "stream";
|
|
22
|
-
import httpMocks from "node-mocks-http";
|
|
23
|
-
const compile = (requestHandler) => (options, extend = {}) => new Promise((resolve, reject) => {
|
|
24
|
-
const req = httpMocks.createRequest(__spreadProps(__spreadValues({}, options), {
|
|
25
|
-
eventEmitter: Readable
|
|
26
|
-
}));
|
|
27
|
-
const res = httpMocks.createResponse({ eventEmitter: EventEmitter });
|
|
28
|
-
Object.assign(req, extend);
|
|
29
|
-
const proxyRes = new Proxy(res, {
|
|
30
|
-
get(obj, prop) {
|
|
31
|
-
if (typeof prop === "symbol" && !obj[prop]) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
return obj[prop];
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
res.on("finish", () => {
|
|
38
|
-
if (res.statusCode !== 200) {
|
|
39
|
-
reject(new Error(res.statusMessage));
|
|
40
|
-
} else {
|
|
41
|
-
resolve(res._getData());
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
res.on("error", (e) => reject(e));
|
|
45
|
-
try {
|
|
46
|
-
requestHandler(req, proxyRes);
|
|
47
|
-
} catch (e) {
|
|
48
|
-
reject(e);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
export {
|
|
52
|
-
compile
|
|
53
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
-
};
|
|
5
|
-
var __async = (__this, __arguments, generator) => {
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
var fulfilled = (value) => {
|
|
8
|
-
try {
|
|
9
|
-
step(generator.next(value));
|
|
10
|
-
} catch (e) {
|
|
11
|
-
reject(e);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
var rejected = (value) => {
|
|
15
|
-
try {
|
|
16
|
-
step(generator.throw(value));
|
|
17
|
-
} catch (e) {
|
|
18
|
-
reject(e);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
22
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
import server from "@modern-js/prod-server";
|
|
26
|
-
import portfinder from "portfinder";
|
|
27
|
-
import { makeRender } from "../libs/make";
|
|
28
|
-
import { compile as createRender } from "./prerender";
|
|
29
|
-
import { CLOSE_SIGN } from "./consts";
|
|
30
|
-
var require_process = __commonJS({
|
|
31
|
-
"src/server/process.ts"(exports) {
|
|
32
|
-
process.on("message", (chunk) => __async(exports, null, function* () {
|
|
33
|
-
if (chunk === CLOSE_SIGN) {
|
|
34
|
-
process.exit();
|
|
35
|
-
}
|
|
36
|
-
const context = JSON.parse(chunk);
|
|
37
|
-
const {
|
|
38
|
-
routes,
|
|
39
|
-
renderRoutes,
|
|
40
|
-
options,
|
|
41
|
-
appDirectory,
|
|
42
|
-
plugins
|
|
43
|
-
} = context;
|
|
44
|
-
let modernServer = null;
|
|
45
|
-
try {
|
|
46
|
-
const { server: serverOptions } = options;
|
|
47
|
-
const defaultPort = Number(process.env.PORT) || serverOptions.port;
|
|
48
|
-
portfinder.basePort = defaultPort;
|
|
49
|
-
const port = yield portfinder.getPortPromise();
|
|
50
|
-
modernServer = yield server({
|
|
51
|
-
pwd: appDirectory,
|
|
52
|
-
config: options,
|
|
53
|
-
routes,
|
|
54
|
-
staticGenerate: true,
|
|
55
|
-
internalPlugins: plugins
|
|
56
|
-
});
|
|
57
|
-
modernServer.listen(port, (err) => __async(exports, null, function* () {
|
|
58
|
-
if (err) {
|
|
59
|
-
throw err;
|
|
60
|
-
}
|
|
61
|
-
if (!modernServer) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const render = createRender(modernServer.getRequestHandler());
|
|
65
|
-
const renderPromiseAry = makeRender(
|
|
66
|
-
renderRoutes,
|
|
67
|
-
render,
|
|
68
|
-
port
|
|
69
|
-
);
|
|
70
|
-
const htmlAry = yield Promise.all(renderPromiseAry);
|
|
71
|
-
htmlAry.forEach((html) => {
|
|
72
|
-
process.send(html);
|
|
73
|
-
process.send(null);
|
|
74
|
-
});
|
|
75
|
-
modernServer.close();
|
|
76
|
-
}));
|
|
77
|
-
} catch (e) {
|
|
78
|
-
modernServer == null ? void 0 : modernServer.close();
|
|
79
|
-
throw e;
|
|
80
|
-
}
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
export default require_process();
|
package/dist/js/node/index.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
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
|
-
var __export = (target, all) => {
|
|
25
|
-
for (var name in all)
|
|
26
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
-
};
|
|
28
|
-
var __copyProps = (to, from, except, desc) => {
|
|
29
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
-
for (let key of __getOwnPropNames(from))
|
|
31
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
-
}
|
|
34
|
-
return to;
|
|
35
|
-
};
|
|
36
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
|
-
mod
|
|
39
|
-
));
|
|
40
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
41
|
-
var __async = (__this, __arguments, generator) => {
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
var fulfilled = (value) => {
|
|
44
|
-
try {
|
|
45
|
-
step(generator.next(value));
|
|
46
|
-
} catch (e) {
|
|
47
|
-
reject(e);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
var rejected = (value) => {
|
|
51
|
-
try {
|
|
52
|
-
step(generator.throw(value));
|
|
53
|
-
} catch (e) {
|
|
54
|
-
reject(e);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
58
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
var src_exports = {};
|
|
62
|
-
__export(src_exports, {
|
|
63
|
-
default: () => src_default
|
|
64
|
-
});
|
|
65
|
-
module.exports = __toCommonJS(src_exports);
|
|
66
|
-
var import_path = __toESM(require("path"));
|
|
67
|
-
var import_utils = require("@modern-js/utils");
|
|
68
|
-
var import_react_router_dom = require("react-router-dom");
|
|
69
|
-
var import_util = require("./libs/util");
|
|
70
|
-
var import_server = require("./server");
|
|
71
|
-
var import_output = require("./libs/output");
|
|
72
|
-
var import_replace = require("./libs/replace");
|
|
73
|
-
var import_make = require("./libs/make");
|
|
74
|
-
var src_default = () => ({
|
|
75
|
-
name: "@modern-js/plugin-ssg",
|
|
76
|
-
pre: ["@modern-js/plugin-server", "@modern-js/plugin-bff"],
|
|
77
|
-
setup: (api) => {
|
|
78
|
-
const agreedRouteMap = {};
|
|
79
|
-
return {
|
|
80
|
-
validateSchema() {
|
|
81
|
-
return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-ssg"];
|
|
82
|
-
},
|
|
83
|
-
modifyFileSystemRoutes({ entrypoint, routes }) {
|
|
84
|
-
const { entryName } = entrypoint;
|
|
85
|
-
const flattedRoutes = (0, import_util.flattenRoutes)(routes);
|
|
86
|
-
agreedRouteMap[entryName] = flattedRoutes;
|
|
87
|
-
return { entrypoint, routes };
|
|
88
|
-
},
|
|
89
|
-
afterBuild() {
|
|
90
|
-
return __async(this, null, function* () {
|
|
91
|
-
const resolvedConfig = api.useResolvedConfigContext();
|
|
92
|
-
const appContext = api.useAppContext();
|
|
93
|
-
const { appDirectory, entrypoints } = appContext;
|
|
94
|
-
const { output, server } = resolvedConfig;
|
|
95
|
-
const { ssg, distPath: { root: outputPath } = {} } = output;
|
|
96
|
-
const ssgOptions = (Array.isArray(ssg) ? ssg.pop() : ssg) || true;
|
|
97
|
-
const buildDir = import_path.default.join(appDirectory, outputPath);
|
|
98
|
-
const routes = (0, import_util.readJSONSpec)(buildDir);
|
|
99
|
-
const pageRoutes = routes.filter((route) => !route.isApi);
|
|
100
|
-
const apiRoutes = routes.filter((route) => route.isApi);
|
|
101
|
-
if (pageRoutes.length === 0) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const intermediateOptions = (0, import_util.standardOptions)(
|
|
105
|
-
ssgOptions,
|
|
106
|
-
entrypoints,
|
|
107
|
-
pageRoutes,
|
|
108
|
-
server
|
|
109
|
-
);
|
|
110
|
-
if (!intermediateOptions) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const ssgRoutes = [];
|
|
114
|
-
pageRoutes.forEach((pageRoute) => {
|
|
115
|
-
const { entryName, entryPath } = pageRoute;
|
|
116
|
-
const agreedRoutes = agreedRouteMap[entryName];
|
|
117
|
-
let entryOptions = intermediateOptions[entryName] || intermediateOptions[pageRoute.urlPath];
|
|
118
|
-
if (!agreedRoutes) {
|
|
119
|
-
if (!entryOptions) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (entryOptions === true) {
|
|
123
|
-
ssgRoutes.push(__spreadProps(__spreadValues({}, pageRoute), { output: entryPath }));
|
|
124
|
-
} else if (entryOptions.routes && entryOptions.routes.length > 0) {
|
|
125
|
-
const { routes: enrtyRoutes, headers } = entryOptions;
|
|
126
|
-
enrtyRoutes.forEach((route) => {
|
|
127
|
-
ssgRoutes.push((0, import_make.makeRoute)(pageRoute, route, headers));
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
} else {
|
|
131
|
-
if (!entryOptions) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (entryOptions === true) {
|
|
135
|
-
entryOptions = { preventDefault: [], routes: [], headers: {} };
|
|
136
|
-
}
|
|
137
|
-
const {
|
|
138
|
-
preventDefault = [],
|
|
139
|
-
routes: userRoutes = [],
|
|
140
|
-
headers
|
|
141
|
-
} = entryOptions;
|
|
142
|
-
if (userRoutes.length > 0) {
|
|
143
|
-
userRoutes.forEach((route) => {
|
|
144
|
-
if (typeof route === "string") {
|
|
145
|
-
ssgRoutes.push((0, import_make.makeRoute)(pageRoute, route, headers));
|
|
146
|
-
} else if (Array.isArray(route.params)) {
|
|
147
|
-
route.params.forEach((param) => {
|
|
148
|
-
ssgRoutes.push(
|
|
149
|
-
(0, import_make.makeRoute)(
|
|
150
|
-
pageRoute,
|
|
151
|
-
__spreadProps(__spreadValues({}, route), { url: (0, import_react_router_dom.generatePath)(route.url, param) }),
|
|
152
|
-
headers
|
|
153
|
-
)
|
|
154
|
-
);
|
|
155
|
-
});
|
|
156
|
-
} else {
|
|
157
|
-
ssgRoutes.push((0, import_make.makeRoute)(pageRoute, route, headers));
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
} else {
|
|
161
|
-
agreedRoutes.filter((route) => !preventDefault.includes(route.path)).forEach((route) => {
|
|
162
|
-
if (!(0, import_util.isDynamicUrl)(route.path)) {
|
|
163
|
-
ssgRoutes.push((0, import_make.makeRoute)(pageRoute, route.path, headers));
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
if (ssgRoutes.length === 0) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
ssgRoutes.forEach((ssgRoute) => {
|
|
173
|
-
if (ssgRoute.isSSR) {
|
|
174
|
-
const isOriginRoute = pageRoutes.some(
|
|
175
|
-
(pageRoute) => pageRoute.urlPath === ssgRoute.urlPath && pageRoute.entryName === ssgRoute.entryName
|
|
176
|
-
);
|
|
177
|
-
if (isOriginRoute) {
|
|
178
|
-
throw new Error(
|
|
179
|
-
`ssg can not using with ssr,url - ${ssgRoute.urlPath}, entry - ${ssgRoute.entryName} `
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
import_utils.logger.warn(
|
|
183
|
-
`new ssg route ${ssgRoute.urlPath} is using ssr now,maybe from parent route ${ssgRoute.entryName},close ssr`
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
ssgRoute.isSSR = false;
|
|
187
|
-
ssgRoute.output = (0, import_util.formatOutput)(ssgRoute.output);
|
|
188
|
-
});
|
|
189
|
-
const htmlAry = yield (0, import_server.createServer)(
|
|
190
|
-
api,
|
|
191
|
-
ssgRoutes,
|
|
192
|
-
pageRoutes,
|
|
193
|
-
apiRoutes,
|
|
194
|
-
resolvedConfig,
|
|
195
|
-
appDirectory
|
|
196
|
-
);
|
|
197
|
-
(0, import_output.writeHtmlFile)(htmlAry, ssgRoutes, buildDir);
|
|
198
|
-
(0, import_replace.replaceRoute)(ssgRoutes, pageRoutes);
|
|
199
|
-
(0, import_util.writeJSONSpec)(buildDir, pageRoutes.concat(apiRoutes));
|
|
200
|
-
import_utils.logger.info("ssg Compiled successfully");
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
207
|
-
0 && (module.exports = {});
|