@modern-js/plugin-ssg 2.15.0 → 2.17.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 -0
- package/dist/cjs/index.js +62 -95
- package/dist/cjs/libs/make.js +34 -48
- package/dist/cjs/libs/output.js +18 -41
- package/dist/cjs/libs/replace.js +24 -41
- package/dist/cjs/libs/util.js +48 -72
- package/dist/cjs/server/consts.js +7 -25
- package/dist/cjs/server/index.js +67 -90
- package/dist/cjs/server/prerender.js +20 -41
- package/dist/cjs/server/process.js +22 -45
- package/dist/cjs/types.js +4 -15
- package/dist/esm/index.js +316 -309
- package/dist/esm/libs/make.js +70 -71
- package/dist/esm/libs/output.js +9 -10
- package/dist/esm/libs/replace.js +113 -100
- package/dist/esm/libs/util.js +211 -210
- package/dist/esm/server/consts.js +1 -2
- package/dist/esm/server/index.js +56 -57
- package/dist/esm/server/prerender.js +85 -86
- package/dist/esm/server/process.js +220 -213
- package/dist/esm/types.js +1 -1
- package/dist/esm-node/index.js +29 -51
- package/dist/esm-node/libs/make.js +14 -14
- package/dist/esm-node/libs/output.js +1 -4
- package/dist/esm-node/libs/replace.js +8 -11
- package/dist/esm-node/libs/util.js +26 -41
- package/dist/esm-node/server/consts.js +1 -4
- package/dist/esm-node/server/index.js +49 -52
- package/dist/esm-node/server/prerender.js +4 -5
- package/dist/esm-node/server/process.js +3 -13
- package/dist/esm-node/types.js +1 -0
- package/package.json +12 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @modern-js/plugin-ssg
|
|
2
2
|
|
|
3
|
+
## 2.17.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @modern-js/utils@2.17.0
|
|
8
|
+
|
|
9
|
+
## 2.16.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 4e876ab: chore: package.json include the monorepo-relative directory
|
|
14
|
+
|
|
15
|
+
chore: 在 package.json 中声明 monorepo 的子路径
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [5954330]
|
|
18
|
+
- Updated dependencies [7596520]
|
|
19
|
+
- Updated dependencies [4e876ab]
|
|
20
|
+
- @modern-js/utils@2.16.0
|
|
21
|
+
|
|
3
22
|
## 2.15.0
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,57 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => _default
|
|
31
8
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
9
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
10
|
+
const _utils = require("@modern-js/utils");
|
|
11
|
+
const _reactrouterdom = require("react-router-dom");
|
|
12
|
+
const _util = require("./libs/util");
|
|
13
|
+
const _server = require("./server");
|
|
14
|
+
const _output = require("./libs/output");
|
|
15
|
+
const _replace = require("./libs/replace");
|
|
16
|
+
const _make = require("./libs/make");
|
|
17
|
+
function _interop_require_default(obj) {
|
|
18
|
+
return obj && obj.__esModule ? obj : {
|
|
19
|
+
default: obj
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const _default = () => ({
|
|
42
23
|
name: "@modern-js/plugin-ssg",
|
|
43
|
-
pre: [
|
|
24
|
+
pre: [
|
|
25
|
+
"@modern-js/plugin-server",
|
|
26
|
+
"@modern-js/plugin-bff"
|
|
27
|
+
],
|
|
44
28
|
setup: (api) => {
|
|
45
29
|
const agreedRouteMap = {};
|
|
46
30
|
return {
|
|
47
31
|
validateSchema() {
|
|
48
|
-
return
|
|
32
|
+
return _utils.PLUGIN_SCHEMAS["@modern-js/plugin-ssg"];
|
|
49
33
|
},
|
|
50
34
|
modifyFileSystemRoutes({ entrypoint, routes }) {
|
|
51
35
|
const { entryName } = entrypoint;
|
|
52
|
-
const flattedRoutes = (0,
|
|
36
|
+
const flattedRoutes = (0, _util.flattenRoutes)(routes);
|
|
53
37
|
agreedRouteMap[entryName] = flattedRoutes;
|
|
54
|
-
return {
|
|
38
|
+
return {
|
|
39
|
+
entrypoint,
|
|
40
|
+
routes
|
|
41
|
+
};
|
|
55
42
|
},
|
|
56
43
|
async afterBuild() {
|
|
57
44
|
const resolvedConfig = api.useResolvedConfigContext();
|
|
@@ -60,19 +47,14 @@ var src_default = () => ({
|
|
|
60
47
|
const { output, server } = resolvedConfig;
|
|
61
48
|
const { ssg, distPath: { root: outputPath } = {} } = output;
|
|
62
49
|
const ssgOptions = (Array.isArray(ssg) ? ssg.pop() : ssg) || true;
|
|
63
|
-
const buildDir =
|
|
64
|
-
const routes = (0,
|
|
50
|
+
const buildDir = _path.default.join(appDirectory, outputPath);
|
|
51
|
+
const routes = (0, _util.readJSONSpec)(buildDir);
|
|
65
52
|
const pageRoutes = routes.filter((route) => !route.isApi);
|
|
66
53
|
const apiRoutes = routes.filter((route) => route.isApi);
|
|
67
54
|
if (pageRoutes.length === 0) {
|
|
68
55
|
return;
|
|
69
56
|
}
|
|
70
|
-
const intermediateOptions = (0,
|
|
71
|
-
ssgOptions,
|
|
72
|
-
entrypoints,
|
|
73
|
-
pageRoutes,
|
|
74
|
-
server
|
|
75
|
-
);
|
|
57
|
+
const intermediateOptions = (0, _util.standardOptions)(ssgOptions, entrypoints, pageRoutes, server);
|
|
76
58
|
if (!intermediateOptions) {
|
|
77
59
|
return;
|
|
78
60
|
}
|
|
@@ -86,11 +68,14 @@ var src_default = () => ({
|
|
|
86
68
|
return;
|
|
87
69
|
}
|
|
88
70
|
if (entryOptions === true) {
|
|
89
|
-
ssgRoutes.push({
|
|
71
|
+
ssgRoutes.push({
|
|
72
|
+
...pageRoute,
|
|
73
|
+
output: entryPath
|
|
74
|
+
});
|
|
90
75
|
} else if (entryOptions.routes && entryOptions.routes.length > 0) {
|
|
91
76
|
const { routes: enrtyRoutes, headers } = entryOptions;
|
|
92
77
|
enrtyRoutes.forEach((route) => {
|
|
93
|
-
ssgRoutes.push((0,
|
|
78
|
+
ssgRoutes.push((0, _make.makeRoute)(pageRoute, route, headers));
|
|
94
79
|
});
|
|
95
80
|
}
|
|
96
81
|
} else {
|
|
@@ -98,35 +83,32 @@ var src_default = () => ({
|
|
|
98
83
|
return;
|
|
99
84
|
}
|
|
100
85
|
if (entryOptions === true) {
|
|
101
|
-
entryOptions = {
|
|
86
|
+
entryOptions = {
|
|
87
|
+
preventDefault: [],
|
|
88
|
+
routes: [],
|
|
89
|
+
headers: {}
|
|
90
|
+
};
|
|
102
91
|
}
|
|
103
|
-
const {
|
|
104
|
-
preventDefault = [],
|
|
105
|
-
routes: userRoutes = [],
|
|
106
|
-
headers
|
|
107
|
-
} = entryOptions;
|
|
92
|
+
const { preventDefault = [], routes: userRoutes = [], headers } = entryOptions;
|
|
108
93
|
if (userRoutes.length > 0) {
|
|
109
94
|
userRoutes.forEach((route) => {
|
|
110
95
|
if (typeof route === "string") {
|
|
111
|
-
ssgRoutes.push((0,
|
|
96
|
+
ssgRoutes.push((0, _make.makeRoute)(pageRoute, route, headers));
|
|
112
97
|
} else if (Array.isArray(route.params)) {
|
|
113
98
|
route.params.forEach((param) => {
|
|
114
|
-
ssgRoutes.push(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
headers
|
|
119
|
-
)
|
|
120
|
-
);
|
|
99
|
+
ssgRoutes.push((0, _make.makeRoute)(pageRoute, {
|
|
100
|
+
...route,
|
|
101
|
+
url: (0, _reactrouterdom.generatePath)(route.url, param)
|
|
102
|
+
}, headers));
|
|
121
103
|
});
|
|
122
104
|
} else {
|
|
123
|
-
ssgRoutes.push((0,
|
|
105
|
+
ssgRoutes.push((0, _make.makeRoute)(pageRoute, route, headers));
|
|
124
106
|
}
|
|
125
107
|
});
|
|
126
108
|
} else {
|
|
127
109
|
agreedRoutes.filter((route) => !preventDefault.includes(route.path)).forEach((route) => {
|
|
128
|
-
if (!(0,
|
|
129
|
-
ssgRoutes.push((0,
|
|
110
|
+
if (!(0, _util.isDynamicUrl)(route.path)) {
|
|
111
|
+
ssgRoutes.push((0, _make.makeRoute)(pageRoute, route.path, headers));
|
|
130
112
|
}
|
|
131
113
|
});
|
|
132
114
|
}
|
|
@@ -137,36 +119,21 @@ var src_default = () => ({
|
|
|
137
119
|
}
|
|
138
120
|
ssgRoutes.forEach((ssgRoute) => {
|
|
139
121
|
if (ssgRoute.isSSR) {
|
|
140
|
-
const isOriginRoute = pageRoutes.some(
|
|
141
|
-
(pageRoute) => pageRoute.urlPath === ssgRoute.urlPath && pageRoute.entryName === ssgRoute.entryName
|
|
142
|
-
);
|
|
122
|
+
const isOriginRoute = pageRoutes.some((pageRoute) => pageRoute.urlPath === ssgRoute.urlPath && pageRoute.entryName === ssgRoute.entryName);
|
|
143
123
|
if (isOriginRoute) {
|
|
144
|
-
throw new Error(
|
|
145
|
-
`ssg can not using with ssr,url - ${ssgRoute.urlPath}, entry - ${ssgRoute.entryName} `
|
|
146
|
-
);
|
|
124
|
+
throw new Error(`ssg can not using with ssr,url - ${ssgRoute.urlPath}, entry - ${ssgRoute.entryName} `);
|
|
147
125
|
}
|
|
148
|
-
|
|
149
|
-
`new ssg route ${ssgRoute.urlPath} is using ssr now,maybe from parent route ${ssgRoute.entryName},close ssr`
|
|
150
|
-
);
|
|
126
|
+
_utils.logger.warn(`new ssg route ${ssgRoute.urlPath} is using ssr now,maybe from parent route ${ssgRoute.entryName},close ssr`);
|
|
151
127
|
}
|
|
152
128
|
ssgRoute.isSSR = false;
|
|
153
|
-
ssgRoute.output = (0,
|
|
129
|
+
ssgRoute.output = (0, _util.formatOutput)(ssgRoute.output);
|
|
154
130
|
});
|
|
155
|
-
const htmlAry = await (0,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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");
|
|
131
|
+
const htmlAry = await (0, _server.createServer)(api, ssgRoutes, pageRoutes, apiRoutes, resolvedConfig, appDirectory);
|
|
132
|
+
(0, _output.writeHtmlFile)(htmlAry, ssgRoutes, buildDir);
|
|
133
|
+
(0, _replace.replaceRoute)(ssgRoutes, pageRoutes);
|
|
134
|
+
(0, _util.writeJSONSpec)(buildDir, pageRoutes.concat(apiRoutes));
|
|
135
|
+
_utils.logger.info("ssg Compiled successfully");
|
|
167
136
|
}
|
|
168
137
|
};
|
|
169
138
|
}
|
|
170
139
|
});
|
|
171
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
172
|
-
0 && (module.exports = {});
|
package/dist/cjs/libs/make.js
CHANGED
|
@@ -1,67 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 make_exports = {};
|
|
29
|
-
__export(make_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
30
13
|
makeRender: () => makeRender,
|
|
31
14
|
makeRoute: () => makeRoute
|
|
32
15
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
16
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
17
|
+
const _normalizepath = /* @__PURE__ */ _interop_require_default(require("normalize-path"));
|
|
18
|
+
function _interop_require_default(obj) {
|
|
19
|
+
return obj && obj.__esModule ? obj : {
|
|
20
|
+
default: obj
|
|
21
|
+
};
|
|
22
|
+
}
|
|
36
23
|
function makeRender(ssgRoutes, render, port) {
|
|
37
|
-
return ssgRoutes.map(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
24
|
+
return ssgRoutes.map((ssgRoute) => render({
|
|
25
|
+
url: ssgRoute.urlPath,
|
|
26
|
+
headers: {
|
|
27
|
+
host: `localhost:${port}`,
|
|
28
|
+
...ssgRoute.headers
|
|
29
|
+
},
|
|
30
|
+
connection: {}
|
|
31
|
+
}));
|
|
44
32
|
}
|
|
45
33
|
function makeRoute(baseRoute, route, headers = {}) {
|
|
46
34
|
const { urlPath, entryPath } = baseRoute;
|
|
47
35
|
if (typeof route === "string") {
|
|
48
36
|
return {
|
|
49
37
|
...baseRoute,
|
|
50
|
-
urlPath: (0,
|
|
38
|
+
urlPath: (0, _normalizepath.default)(`${urlPath}${route}`) || "/",
|
|
51
39
|
headers,
|
|
52
|
-
output:
|
|
40
|
+
output: _path.default.join(entryPath, `..${route === "/" ? "" : route}`)
|
|
53
41
|
};
|
|
54
42
|
} else {
|
|
55
43
|
return {
|
|
56
44
|
...baseRoute,
|
|
57
|
-
urlPath: (0,
|
|
58
|
-
headers: {
|
|
59
|
-
|
|
45
|
+
urlPath: (0, _normalizepath.default)(`${urlPath}${route.url}`) || "/",
|
|
46
|
+
headers: {
|
|
47
|
+
...headers,
|
|
48
|
+
...route.headers
|
|
49
|
+
},
|
|
50
|
+
output: route.output ? _path.default.normalize(route.output) : _path.default.join(entryPath, `..${route.url === "/" ? "" : route.url}`)
|
|
60
51
|
};
|
|
61
52
|
}
|
|
62
53
|
}
|
|
63
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
-
0 && (module.exports = {
|
|
65
|
-
makeRender,
|
|
66
|
-
makeRoute
|
|
67
|
-
});
|
package/dist/cjs/libs/output.js
CHANGED
|
@@ -1,48 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 output_exports = {};
|
|
29
|
-
__export(output_exports, {
|
|
30
|
-
writeHtmlFile: () => writeHtmlFile
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
31
4
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
5
|
+
Object.defineProperty(exports, "writeHtmlFile", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => writeHtmlFile
|
|
8
|
+
});
|
|
9
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
10
|
+
const _utils = require("@modern-js/utils");
|
|
11
|
+
function _interop_require_default(obj) {
|
|
12
|
+
return obj && obj.__esModule ? obj : {
|
|
13
|
+
default: obj
|
|
14
|
+
};
|
|
15
|
+
}
|
|
35
16
|
function writeHtmlFile(htmlAry, ssgRoutes, baseDir) {
|
|
36
17
|
htmlAry.forEach((html, index) => {
|
|
37
18
|
const ssgRoute = ssgRoutes[index];
|
|
38
|
-
const filepath =
|
|
39
|
-
if (!
|
|
40
|
-
|
|
19
|
+
const filepath = _path.default.join(baseDir, ssgRoute.output);
|
|
20
|
+
if (!_utils.fs.existsSync(_path.default.dirname(filepath))) {
|
|
21
|
+
_utils.fs.ensureDirSync(_path.default.dirname(filepath));
|
|
41
22
|
}
|
|
42
|
-
|
|
23
|
+
_utils.fs.writeFileSync(filepath, html);
|
|
43
24
|
});
|
|
44
25
|
}
|
|
45
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
-
0 && (module.exports = {
|
|
47
|
-
writeHtmlFile
|
|
48
|
-
});
|
package/dist/cjs/libs/replace.js
CHANGED
|
@@ -1,40 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 replace_exports = {};
|
|
29
|
-
__export(replace_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
30
13
|
exist: () => exist,
|
|
31
14
|
replaceRoute: () => replaceRoute
|
|
32
15
|
});
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
const _normalizepath = /* @__PURE__ */ _interop_require_default(require("normalize-path"));
|
|
17
|
+
function _interop_require_default(obj) {
|
|
18
|
+
return obj && obj.__esModule ? obj : {
|
|
19
|
+
default: obj
|
|
20
|
+
};
|
|
21
|
+
}
|
|
35
22
|
function exist(route, pageRoutes) {
|
|
36
23
|
return pageRoutes.slice().findIndex((pageRoute) => {
|
|
37
|
-
const urlEqual = (0,
|
|
24
|
+
const urlEqual = (0, _normalizepath.default)(pageRoute.urlPath) === (0, _normalizepath.default)(route.urlPath);
|
|
38
25
|
const entryEqual = pageRoute.entryName === route.entryName;
|
|
39
26
|
if (urlEqual && entryEqual) {
|
|
40
27
|
return true;
|
|
@@ -45,16 +32,17 @@ function exist(route, pageRoutes) {
|
|
|
45
32
|
function replaceRoute(ssgRoutes, pageRoutes) {
|
|
46
33
|
const cleanSsgRoutes = ssgRoutes.map((ssgRoute) => {
|
|
47
34
|
const { output, headers, ...cleanSsgRoute } = ssgRoute;
|
|
48
|
-
return Object.assign(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
35
|
+
return Object.assign(cleanSsgRoute, output ? {
|
|
36
|
+
entryPath: output
|
|
37
|
+
} : {});
|
|
52
38
|
});
|
|
53
39
|
const freshRoutes = [];
|
|
54
40
|
cleanSsgRoutes.forEach((ssgRoute) => {
|
|
55
41
|
const index = exist(ssgRoute, pageRoutes);
|
|
56
42
|
if (index < 0) {
|
|
57
|
-
freshRoutes.push({
|
|
43
|
+
freshRoutes.push({
|
|
44
|
+
...ssgRoute
|
|
45
|
+
});
|
|
58
46
|
} else {
|
|
59
47
|
pageRoutes[index].entryPath = ssgRoute.entryPath;
|
|
60
48
|
}
|
|
@@ -62,8 +50,3 @@ function replaceRoute(ssgRoutes, pageRoutes) {
|
|
|
62
50
|
pageRoutes.push(...freshRoutes);
|
|
63
51
|
return pageRoutes;
|
|
64
52
|
}
|
|
65
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
-
0 && (module.exports = {
|
|
67
|
-
exist,
|
|
68
|
-
replaceRoute
|
|
69
|
-
});
|