@modern-js/plugin-ssg 1.2.10 → 1.2.13
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 +26 -0
- package/dist/js/modern/index.js +2 -2
- package/dist/js/modern/libs/util.js +4 -4
- package/dist/js/modern/server/index.js +2 -1
- package/dist/js/node/index.js +2 -2
- package/dist/js/node/libs/util.js +4 -4
- package/dist/js/node/server/index.js +2 -1
- package/dist/types/libs/util.d.ts +1 -1
- package/package.json +31 -8
- package/.eslintrc.js +0 -6
- package/jest.config.js +0 -7
- package/modern.config.js +0 -2
- package/tsconfig.json +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @modern-js/plugin-ssg
|
|
2
2
|
|
|
3
|
+
## 1.2.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6c8ab42dd: optimize whether to do SSR bundle
|
|
8
|
+
|
|
9
|
+
## 1.2.12
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- d32f35134: chore: add modern/jest/eslint/ts config files to .npmignore
|
|
14
|
+
- Updated dependencies [d32f35134]
|
|
15
|
+
- Updated dependencies [6ae4a34ae]
|
|
16
|
+
- Updated dependencies [b80229c79]
|
|
17
|
+
- Updated dependencies [948cc4436]
|
|
18
|
+
- @modern-js/utils@1.7.3
|
|
19
|
+
|
|
20
|
+
## 1.2.11
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- 69a728375: fix: remove exports.jsnext:source after publish
|
|
25
|
+
- Updated dependencies [cd7346b0d]
|
|
26
|
+
- Updated dependencies [69a728375]
|
|
27
|
+
- @modern-js/utils@1.7.2
|
|
28
|
+
|
|
3
29
|
## 1.2.10
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/js/modern/index.js
CHANGED
|
@@ -106,11 +106,11 @@ export default (() => ({
|
|
|
106
106
|
} else {
|
|
107
107
|
// Unless entryOptions is set to false
|
|
108
108
|
// the default behavior is to add all file-based routes
|
|
109
|
-
if (entryOptions
|
|
109
|
+
if (!entryOptions) {
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
if (
|
|
113
|
+
if (entryOptions === true) {
|
|
114
114
|
entryOptions = {
|
|
115
115
|
preventDefault: [],
|
|
116
116
|
routes: [],
|
|
@@ -41,7 +41,7 @@ export function getUrlPrefix(route, baseUrl) {
|
|
|
41
41
|
const filters = baseUrl.filter(url => route.urlPath.includes(url));
|
|
42
42
|
|
|
43
43
|
if (filters.length > 1) {
|
|
44
|
-
const matched = filters.sort((a, b) => a.length - b.length)[0]; // this should never
|
|
44
|
+
const matched = filters.sort((a, b) => a.length - b.length)[0]; // this should never happened
|
|
45
45
|
|
|
46
46
|
if (!matched) {
|
|
47
47
|
throw new Error('');
|
|
@@ -58,7 +58,7 @@ export function getUrlPrefix(route, baseUrl) {
|
|
|
58
58
|
const prefix = `${base}/${entryName}`;
|
|
59
59
|
return prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;
|
|
60
60
|
} // if no output, return default path for aggred-route(relative),
|
|
61
|
-
// or
|
|
61
|
+
// or throw error for control-route
|
|
62
62
|
|
|
63
63
|
export function getOutput(route, base, agreed) {
|
|
64
64
|
const {
|
|
@@ -131,7 +131,7 @@ export const standardOptions = (ssgOptions, entrypoints) => {
|
|
|
131
131
|
|
|
132
132
|
return false;
|
|
133
133
|
};
|
|
134
|
-
export const openRouteSSR = routes => routes.map(ssgRoute => _objectSpread(_objectSpread({}, ssgRoute), {}, {
|
|
135
|
-
isSSR:
|
|
134
|
+
export const openRouteSSR = (routes, entries = []) => routes.map(ssgRoute => _objectSpread(_objectSpread({}, ssgRoute), {}, {
|
|
135
|
+
isSSR: entries.includes(ssgRoute.entryName),
|
|
136
136
|
bundle: `${SERVER_BUNDLE_DIRECTORY}/${ssgRoute.entryName}.js`
|
|
137
137
|
}));
|
|
@@ -6,7 +6,8 @@ import { CLOSE_SIGN } from "./consts";
|
|
|
6
6
|
export const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) => new Promise((resolve, reject) => {
|
|
7
7
|
// this side of the shallow copy of a route for subsequent render processing, to prevent the modification of the current field
|
|
8
8
|
// manually enable the server-side rendering configuration for all routes that require SSG
|
|
9
|
-
const
|
|
9
|
+
const entries = ssgRoutes.map(route => route.entryName);
|
|
10
|
+
const backup = openRouteSSR(pageRoutes, entries);
|
|
10
11
|
const total = backup.concat(apiRoutes);
|
|
11
12
|
const cp = childProcess.fork(path.join(__dirname, 'process'), {
|
|
12
13
|
cwd: appDirectory,
|
package/dist/js/node/index.js
CHANGED
|
@@ -124,11 +124,11 @@ var _default = () => ({
|
|
|
124
124
|
} else {
|
|
125
125
|
// Unless entryOptions is set to false
|
|
126
126
|
// the default behavior is to add all file-based routes
|
|
127
|
-
if (entryOptions
|
|
127
|
+
if (!entryOptions) {
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
if (
|
|
131
|
+
if (entryOptions === true) {
|
|
132
132
|
entryOptions = {
|
|
133
133
|
preventDefault: [],
|
|
134
134
|
routes: [],
|
|
@@ -60,7 +60,7 @@ function getUrlPrefix(route, baseUrl) {
|
|
|
60
60
|
const filters = baseUrl.filter(url => route.urlPath.includes(url));
|
|
61
61
|
|
|
62
62
|
if (filters.length > 1) {
|
|
63
|
-
const matched = filters.sort((a, b) => a.length - b.length)[0]; // this should never
|
|
63
|
+
const matched = filters.sort((a, b) => a.length - b.length)[0]; // this should never happened
|
|
64
64
|
|
|
65
65
|
if (!matched) {
|
|
66
66
|
throw new Error('');
|
|
@@ -77,7 +77,7 @@ function getUrlPrefix(route, baseUrl) {
|
|
|
77
77
|
const prefix = `${base}/${entryName}`;
|
|
78
78
|
return prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;
|
|
79
79
|
} // if no output, return default path for aggred-route(relative),
|
|
80
|
-
// or
|
|
80
|
+
// or throw error for control-route
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
function getOutput(route, base, agreed) {
|
|
@@ -165,8 +165,8 @@ const standardOptions = (ssgOptions, entrypoints) => {
|
|
|
165
165
|
|
|
166
166
|
exports.standardOptions = standardOptions;
|
|
167
167
|
|
|
168
|
-
const openRouteSSR = routes => routes.map(ssgRoute => _objectSpread(_objectSpread({}, ssgRoute), {}, {
|
|
169
|
-
isSSR:
|
|
168
|
+
const openRouteSSR = (routes, entries = []) => routes.map(ssgRoute => _objectSpread(_objectSpread({}, ssgRoute), {}, {
|
|
169
|
+
isSSR: entries.includes(ssgRoute.entryName),
|
|
170
170
|
bundle: `${_utils.SERVER_BUNDLE_DIRECTORY}/${ssgRoute.entryName}.js`
|
|
171
171
|
}));
|
|
172
172
|
|
|
@@ -20,7 +20,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
20
|
const createServer = (api, ssgRoutes, pageRoutes, apiRoutes, options, appDirectory) => new Promise((resolve, reject) => {
|
|
21
21
|
// this side of the shallow copy of a route for subsequent render processing, to prevent the modification of the current field
|
|
22
22
|
// manually enable the server-side rendering configuration for all routes that require SSG
|
|
23
|
-
const
|
|
23
|
+
const entries = ssgRoutes.map(route => route.entryName);
|
|
24
|
+
const backup = (0, _util.openRouteSSR)(pageRoutes, entries);
|
|
24
25
|
const total = backup.concat(apiRoutes);
|
|
25
26
|
|
|
26
27
|
const cp = _child_process.default.fork(_path.default.join(__dirname, 'process'), {
|
|
@@ -9,7 +9,7 @@ export declare const readJSONSpec: (dir: string) => ModernRoute[];
|
|
|
9
9
|
export declare const writeJSONSpec: (dir: string, routes: ModernRoute[]) => void;
|
|
10
10
|
export declare const replaceWithAlias: (base: string, filePath: string, alias: string) => string;
|
|
11
11
|
export declare const standardOptions: (ssgOptions: SSGConfig, entrypoints: EntryPoint[]) => false | SSGMultiEntryOptions;
|
|
12
|
-
export declare const openRouteSSR: (routes: ModernRoute[]) => {
|
|
12
|
+
export declare const openRouteSSR: (routes: ModernRoute[], entries?: string[]) => {
|
|
13
13
|
isSSR: boolean;
|
|
14
14
|
bundle: string;
|
|
15
15
|
entryName?: string | undefined;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.2.
|
|
14
|
+
"version": "1.2.13",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -55,23 +55,23 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@babel/runtime": "^7",
|
|
58
|
-
"@modern-js/utils": "^1.6
|
|
58
|
+
"@modern-js/utils": "^1.7.6",
|
|
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.5.
|
|
66
|
-
"@modern-js/prod-server": "1.1.
|
|
67
|
-
"@types/jest": "^
|
|
65
|
+
"@modern-js/types": "1.5.4",
|
|
66
|
+
"@modern-js/prod-server": "1.1.7",
|
|
67
|
+
"@types/jest": "^27",
|
|
68
68
|
"@types/node": "^14",
|
|
69
69
|
"@types/react": "^17",
|
|
70
70
|
"@types/react-dom": "^17",
|
|
71
71
|
"@types/react-router": "^5.1.16",
|
|
72
72
|
"@types/react-router-dom": "^5.1.8",
|
|
73
73
|
"typescript": "^4",
|
|
74
|
-
"@modern-js/core": "1.
|
|
74
|
+
"@modern-js/core": "1.11.1",
|
|
75
75
|
"@scripts/build": "0.0.0",
|
|
76
76
|
"jest": "^27",
|
|
77
77
|
"@scripts/jest-config": "0.0.0"
|
|
@@ -86,11 +86,34 @@
|
|
|
86
86
|
"registry": "https://registry.npmjs.org/",
|
|
87
87
|
"access": "public"
|
|
88
88
|
},
|
|
89
|
+
"wireit": {
|
|
90
|
+
"build": {
|
|
91
|
+
"command": "modern build",
|
|
92
|
+
"files": [
|
|
93
|
+
"src/**/*",
|
|
94
|
+
"tsconfig.json",
|
|
95
|
+
"package.json"
|
|
96
|
+
],
|
|
97
|
+
"output": [
|
|
98
|
+
"dist/**/*"
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
"test": {
|
|
102
|
+
"command": "jest --passWithNoTests",
|
|
103
|
+
"files": [
|
|
104
|
+
"src/**/*",
|
|
105
|
+
"tsconfig.json",
|
|
106
|
+
"package.json",
|
|
107
|
+
"tests/**/*"
|
|
108
|
+
],
|
|
109
|
+
"output": []
|
|
110
|
+
}
|
|
111
|
+
},
|
|
89
112
|
"scripts": {
|
|
90
113
|
"new": "modern new",
|
|
91
|
-
"build": "
|
|
114
|
+
"build": "wireit",
|
|
92
115
|
"dev": "modern build --watch",
|
|
93
|
-
"test": "
|
|
116
|
+
"test": "wireit"
|
|
94
117
|
},
|
|
95
118
|
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
|
96
119
|
}
|
package/.eslintrc.js
DELETED
package/jest.config.js
DELETED
package/modern.config.js
DELETED