@modern-js/plugin-ssg 1.2.15 → 1.16.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 +39 -0
- package/dist/js/modern/index.js +4 -3
- package/dist/js/modern/libs/util.js +16 -4
- package/dist/js/node/index.js +4 -3
- package/dist/js/node/libs/util.js +16 -4
- package/dist/types/libs/util.d.ts +3 -1
- package/package.json +7 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @modern-js/plugin-ssg
|
|
2
2
|
|
|
3
|
+
## 1.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1100dd58c: chore: support react 18
|
|
8
|
+
|
|
9
|
+
chore: 支持 React 18
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [641592f52]
|
|
14
|
+
- Updated dependencies [3904b30a5]
|
|
15
|
+
- Updated dependencies [1100dd58c]
|
|
16
|
+
- Updated dependencies [e04e6e76a]
|
|
17
|
+
- Updated dependencies [81c66e4a4]
|
|
18
|
+
- Updated dependencies [2c305b6f5]
|
|
19
|
+
- @modern-js/utils@1.16.0
|
|
20
|
+
|
|
21
|
+
## 1.15.0
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [8658a78]
|
|
26
|
+
- Updated dependencies [05d4a4f]
|
|
27
|
+
- Updated dependencies [ad05af9]
|
|
28
|
+
- Updated dependencies [5d53d1c]
|
|
29
|
+
- Updated dependencies [37cd159]
|
|
30
|
+
- @modern-js/utils@1.15.0
|
|
31
|
+
|
|
32
|
+
## 1.2.16
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- 5876e63: fix: the SSG callback is called once for each baseUrl, when a user configures multiple baseUrl.
|
|
37
|
+
fix: 当用户配置了多个 baseUrl 时,将会为每个 baseUrl 调用一次 SSG 回调函数。
|
|
38
|
+
- Updated dependencies [4fc801f]
|
|
39
|
+
- Updated dependencies [c8614b8]
|
|
40
|
+
- @modern-js/utils@1.8.0
|
|
41
|
+
|
|
3
42
|
## 1.2.15
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
package/dist/js/modern/index.js
CHANGED
|
@@ -43,7 +43,8 @@ export default (() => ({
|
|
|
43
43
|
entrypoints
|
|
44
44
|
} = appContext;
|
|
45
45
|
const {
|
|
46
|
-
output
|
|
46
|
+
output,
|
|
47
|
+
server
|
|
47
48
|
} = resolvedConfig;
|
|
48
49
|
const {
|
|
49
50
|
ssg,
|
|
@@ -65,7 +66,7 @@ export default (() => ({
|
|
|
65
66
|
return;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
const intermediateOptions = standardOptions(ssgOptions, entrypoints);
|
|
69
|
+
const intermediateOptions = standardOptions(ssgOptions, entrypoints, pageRoutes, server);
|
|
69
70
|
|
|
70
71
|
if (!intermediateOptions) {
|
|
71
72
|
return;
|
|
@@ -79,7 +80,7 @@ export default (() => ({
|
|
|
79
80
|
entryPath
|
|
80
81
|
} = pageRoute;
|
|
81
82
|
const agreedRoutes = agreedRouteMap[entryName];
|
|
82
|
-
let entryOptions = intermediateOptions[entryName];
|
|
83
|
+
let entryOptions = intermediateOptions[entryName] || intermediateOptions[pageRoute.urlPath];
|
|
83
84
|
|
|
84
85
|
if (!agreedRoutes) {
|
|
85
86
|
// default behavior for non-agreed route
|
|
@@ -95,7 +95,7 @@ export const writeJSONSpec = (dir, routes) => {
|
|
|
95
95
|
});
|
|
96
96
|
};
|
|
97
97
|
export const replaceWithAlias = (base, filePath, alias) => path.posix.join(alias, path.posix.relative(base, filePath));
|
|
98
|
-
export const standardOptions = (ssgOptions, entrypoints) => {
|
|
98
|
+
export const standardOptions = (ssgOptions, entrypoints, routes, server) => {
|
|
99
99
|
if (ssgOptions === false) {
|
|
100
100
|
return false;
|
|
101
101
|
}
|
|
@@ -121,9 +121,21 @@ export const standardOptions = (ssgOptions, entrypoints) => {
|
|
|
121
121
|
for (const entrypoint of entrypoints) {
|
|
122
122
|
const {
|
|
123
123
|
entryName
|
|
124
|
-
} = entrypoint; //
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
} = entrypoint; // TODO: may be async function
|
|
125
|
+
|
|
126
|
+
if (Array.isArray(server === null || server === void 0 ? void 0 : server.baseUrl)) {
|
|
127
|
+
for (const url of server.baseUrl) {
|
|
128
|
+
const matchUrl = entryName === 'main' ? url : `${url}/${entryName}`;
|
|
129
|
+
const route = routes.find(route => route.urlPath === matchUrl);
|
|
130
|
+
intermediateOptions[route === null || route === void 0 ? void 0 : route.urlPath] = ssgOptions(entryName, {
|
|
131
|
+
baseUrl: url
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
intermediateOptions[entryName] = ssgOptions(entryName, {
|
|
136
|
+
baseUrl: server === null || server === void 0 ? void 0 : server.baseUrl
|
|
137
|
+
});
|
|
138
|
+
}
|
|
127
139
|
}
|
|
128
140
|
|
|
129
141
|
return intermediateOptions;
|
package/dist/js/node/index.js
CHANGED
|
@@ -60,7 +60,8 @@ var _default = () => ({
|
|
|
60
60
|
entrypoints
|
|
61
61
|
} = appContext;
|
|
62
62
|
const {
|
|
63
|
-
output
|
|
63
|
+
output,
|
|
64
|
+
server
|
|
64
65
|
} = resolvedConfig;
|
|
65
66
|
const {
|
|
66
67
|
ssg,
|
|
@@ -83,7 +84,7 @@ var _default = () => ({
|
|
|
83
84
|
return;
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
const intermediateOptions = (0, _util.standardOptions)(ssgOptions, entrypoints);
|
|
87
|
+
const intermediateOptions = (0, _util.standardOptions)(ssgOptions, entrypoints, pageRoutes, server);
|
|
87
88
|
|
|
88
89
|
if (!intermediateOptions) {
|
|
89
90
|
return;
|
|
@@ -97,7 +98,7 @@ var _default = () => ({
|
|
|
97
98
|
entryPath
|
|
98
99
|
} = pageRoute;
|
|
99
100
|
const agreedRoutes = agreedRouteMap[entryName];
|
|
100
|
-
let entryOptions = intermediateOptions[entryName];
|
|
101
|
+
let entryOptions = intermediateOptions[entryName] || intermediateOptions[pageRoute.urlPath];
|
|
101
102
|
|
|
102
103
|
if (!agreedRoutes) {
|
|
103
104
|
// default behavior for non-agreed route
|
|
@@ -126,7 +126,7 @@ const replaceWithAlias = (base, filePath, alias) => _path.default.posix.join(ali
|
|
|
126
126
|
|
|
127
127
|
exports.replaceWithAlias = replaceWithAlias;
|
|
128
128
|
|
|
129
|
-
const standardOptions = (ssgOptions, entrypoints) => {
|
|
129
|
+
const standardOptions = (ssgOptions, entrypoints, routes, server) => {
|
|
130
130
|
if (ssgOptions === false) {
|
|
131
131
|
return false;
|
|
132
132
|
}
|
|
@@ -152,9 +152,21 @@ const standardOptions = (ssgOptions, entrypoints) => {
|
|
|
152
152
|
for (const entrypoint of entrypoints) {
|
|
153
153
|
const {
|
|
154
154
|
entryName
|
|
155
|
-
} = entrypoint; //
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
} = entrypoint; // TODO: may be async function
|
|
156
|
+
|
|
157
|
+
if (Array.isArray(server === null || server === void 0 ? void 0 : server.baseUrl)) {
|
|
158
|
+
for (const url of server.baseUrl) {
|
|
159
|
+
const matchUrl = entryName === 'main' ? url : `${url}/${entryName}`;
|
|
160
|
+
const route = routes.find(route => route.urlPath === matchUrl);
|
|
161
|
+
intermediateOptions[route === null || route === void 0 ? void 0 : route.urlPath] = ssgOptions(entryName, {
|
|
162
|
+
baseUrl: url
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
intermediateOptions[entryName] = ssgOptions(entryName, {
|
|
167
|
+
baseUrl: server === null || server === void 0 ? void 0 : server.baseUrl
|
|
168
|
+
});
|
|
169
|
+
}
|
|
158
170
|
}
|
|
159
171
|
|
|
160
172
|
return intermediateOptions;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ServerRoute as ModernRoute } from '@modern-js/types';
|
|
2
|
+
import { ServerConfig } from '@modern-js/core';
|
|
2
3
|
import { SsgRoute, SSGConfig, EntryPoint, SSGMultiEntryOptions } from '../types';
|
|
3
4
|
export declare function formatOutput(filename: string): string;
|
|
4
5
|
export declare function formatPath(str: string): string;
|
|
@@ -8,7 +9,7 @@ export declare function getOutput(route: SsgRoute, base: string, agreed?: boolea
|
|
|
8
9
|
export declare const readJSONSpec: (dir: string) => ModernRoute[];
|
|
9
10
|
export declare const writeJSONSpec: (dir: string, routes: ModernRoute[]) => void;
|
|
10
11
|
export declare const replaceWithAlias: (base: string, filePath: string, alias: string) => string;
|
|
11
|
-
export declare const standardOptions: (ssgOptions: SSGConfig, entrypoints: EntryPoint[]) => false | SSGMultiEntryOptions;
|
|
12
|
+
export declare const standardOptions: (ssgOptions: SSGConfig, entrypoints: EntryPoint[], routes: ModernRoute[], server: ServerConfig) => false | SSGMultiEntryOptions;
|
|
12
13
|
export declare const openRouteSSR: (routes: ModernRoute[], entries?: string[]) => {
|
|
13
14
|
isSSR: boolean;
|
|
14
15
|
bundle: string;
|
|
@@ -18,4 +19,5 @@ export declare const openRouteSSR: (routes: ModernRoute[], entries?: string[]) =
|
|
|
18
19
|
isSPA?: boolean | undefined;
|
|
19
20
|
isApi?: boolean | undefined;
|
|
20
21
|
enableModernMode?: boolean | undefined;
|
|
22
|
+
responseHeaders?: Record<string, unknown> | undefined;
|
|
21
23
|
}[];
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.16.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -55,24 +55,22 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@babel/runtime": "^7.18.0",
|
|
58
|
-
"@modern-js/utils": "
|
|
58
|
+
"@modern-js/utils": "1.16.0",
|
|
59
59
|
"node-mocks-http": "^1.10.1",
|
|
60
60
|
"normalize-path": "^3.0.0",
|
|
61
61
|
"portfinder": "^1.0.28",
|
|
62
62
|
"react-router-dom": "^5.2.1"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@modern-js/types": "1.
|
|
66
|
-
"@modern-js/prod-server": "1.
|
|
65
|
+
"@modern-js/types": "1.16.0",
|
|
66
|
+
"@modern-js/prod-server": "1.16.0",
|
|
67
67
|
"@types/jest": "^27",
|
|
68
68
|
"@types/node": "^14",
|
|
69
|
-
"@types/react": "^17",
|
|
70
|
-
"@types/react-dom": "^17",
|
|
71
69
|
"@types/react-router": "^5.1.16",
|
|
72
70
|
"@types/react-router-dom": "^5.1.8",
|
|
73
|
-
"@modern-js/core": "1.
|
|
74
|
-
"@scripts/build": "
|
|
75
|
-
"@scripts/jest-config": "
|
|
71
|
+
"@modern-js/core": "1.16.0",
|
|
72
|
+
"@scripts/build": "1.15.0",
|
|
73
|
+
"@scripts/jest-config": "1.15.0",
|
|
76
74
|
"react": "^17",
|
|
77
75
|
"typescript": "^4",
|
|
78
76
|
"jest": "^27"
|