vite-react-ssg 0.7.0-beta.1 → 0.7.0-beta.2
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/LICENSE +21 -21
- package/README.md +555 -555
- package/bin/vite-react-ssg.js +3 -3
- package/dist/chunks/jsdomGlobal.cjs +80 -80
- package/dist/chunks/jsdomGlobal.mjs +80 -80
- package/dist/node.cjs +18 -1
- package/dist/node.mjs +19 -2
- package/package.json +1 -1
package/bin/vite-react-ssg.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict'
|
|
3
|
-
import('../dist/node/cli.mjs')
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict'
|
|
3
|
+
import('../dist/node/cli.mjs')
|
|
@@ -6,86 +6,86 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
6
6
|
|
|
7
7
|
const JSDOM__default = /*#__PURE__*/_interopDefaultCompat(JSDOM);
|
|
8
8
|
|
|
9
|
-
/*
|
|
10
|
-
MIT License
|
|
11
|
-
|
|
12
|
-
Copyright for portions of global-jsdom are held by Rico Sta. Cruz, 2016 as part of
|
|
13
|
-
jsdom-global. All other copyright for global-jsdom are held by jonathan schatz, 2017.
|
|
14
|
-
|
|
15
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
-
in the Software without restriction, including without limitation the rights
|
|
18
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
-
furnished to do so, subject to the following conditions:
|
|
21
|
-
|
|
22
|
-
The above copyright notice and this permission notice shall be included in all
|
|
23
|
-
copies or substantial portions of the Software.
|
|
24
|
-
|
|
25
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
-
SOFTWARE.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const defaultHtml = '<!doctype html><html><head><meta charset="utf-8"></head><body></body></html>';
|
|
36
|
-
|
|
37
|
-
// define this here so that we only ever dynamically populate KEYS once.
|
|
38
|
-
|
|
39
|
-
const KEYS = [];
|
|
40
|
-
|
|
41
|
-
function jsdomGlobal(html = defaultHtml, options = {}) {
|
|
42
|
-
// Idempotency
|
|
43
|
-
if (global.navigator
|
|
44
|
-
&& global.navigator.userAgent
|
|
45
|
-
&& global.navigator.userAgent.includes('Node.js')
|
|
46
|
-
&& global.document
|
|
47
|
-
&& typeof global.document.destroy === 'function') {
|
|
48
|
-
return global.document.destroy
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// set a default url if we don't get one - otherwise things explode when we copy localstorage keys
|
|
52
|
-
if (!('url' in options))
|
|
53
|
-
Object.assign(options, { url: 'http://localhost:3000' });
|
|
54
|
-
|
|
55
|
-
// enable pretendToBeVisual by default since react needs
|
|
56
|
-
// window.requestAnimationFrame, see https://github.com/jsdom/jsdom#pretending-to-be-a-visual-browser
|
|
57
|
-
if (!('pretendToBeVisual' in options))
|
|
58
|
-
Object.assign(options, { pretendToBeVisual: true });
|
|
59
|
-
|
|
60
|
-
const jsdom = new JSDOM__default.JSDOM(html, options);
|
|
61
|
-
const { window } = jsdom;
|
|
62
|
-
const { document } = window;
|
|
63
|
-
|
|
64
|
-
// generate our list of keys by enumerating document.window - this list may vary
|
|
65
|
-
// based on the jsdom version. filter out internal methods as well as anything
|
|
66
|
-
// that node already defines
|
|
67
|
-
|
|
68
|
-
if (KEYS.length === 0) {
|
|
69
|
-
KEYS.push(...Object.getOwnPropertyNames(window).filter(k => !k.startsWith('_')).filter(k => !(k in global)));
|
|
70
|
-
// going to add our jsdom instance, see below
|
|
71
|
-
KEYS.push('$jsdom');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
KEYS.forEach(key => global[key] = window[key]);
|
|
75
|
-
|
|
76
|
-
// setup document / window / window.console
|
|
77
|
-
global.document = document;
|
|
78
|
-
global.window = window;
|
|
79
|
-
window.console = global.console;
|
|
80
|
-
|
|
81
|
-
// add access to our jsdom instance
|
|
82
|
-
global.$jsdom = jsdom;
|
|
83
|
-
|
|
84
|
-
const cleanup = () => KEYS.forEach(key => delete global[key]);
|
|
85
|
-
|
|
86
|
-
document.destroy = cleanup;
|
|
87
|
-
|
|
88
|
-
return cleanup
|
|
9
|
+
/*
|
|
10
|
+
MIT License
|
|
11
|
+
|
|
12
|
+
Copyright for portions of global-jsdom are held by Rico Sta. Cruz, 2016 as part of
|
|
13
|
+
jsdom-global. All other copyright for global-jsdom are held by jonathan schatz, 2017.
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const defaultHtml = '<!doctype html><html><head><meta charset="utf-8"></head><body></body></html>';
|
|
36
|
+
|
|
37
|
+
// define this here so that we only ever dynamically populate KEYS once.
|
|
38
|
+
|
|
39
|
+
const KEYS = [];
|
|
40
|
+
|
|
41
|
+
function jsdomGlobal(html = defaultHtml, options = {}) {
|
|
42
|
+
// Idempotency
|
|
43
|
+
if (global.navigator
|
|
44
|
+
&& global.navigator.userAgent
|
|
45
|
+
&& global.navigator.userAgent.includes('Node.js')
|
|
46
|
+
&& global.document
|
|
47
|
+
&& typeof global.document.destroy === 'function') {
|
|
48
|
+
return global.document.destroy
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// set a default url if we don't get one - otherwise things explode when we copy localstorage keys
|
|
52
|
+
if (!('url' in options))
|
|
53
|
+
Object.assign(options, { url: 'http://localhost:3000' });
|
|
54
|
+
|
|
55
|
+
// enable pretendToBeVisual by default since react needs
|
|
56
|
+
// window.requestAnimationFrame, see https://github.com/jsdom/jsdom#pretending-to-be-a-visual-browser
|
|
57
|
+
if (!('pretendToBeVisual' in options))
|
|
58
|
+
Object.assign(options, { pretendToBeVisual: true });
|
|
59
|
+
|
|
60
|
+
const jsdom = new JSDOM__default.JSDOM(html, options);
|
|
61
|
+
const { window } = jsdom;
|
|
62
|
+
const { document } = window;
|
|
63
|
+
|
|
64
|
+
// generate our list of keys by enumerating document.window - this list may vary
|
|
65
|
+
// based on the jsdom version. filter out internal methods as well as anything
|
|
66
|
+
// that node already defines
|
|
67
|
+
|
|
68
|
+
if (KEYS.length === 0) {
|
|
69
|
+
KEYS.push(...Object.getOwnPropertyNames(window).filter(k => !k.startsWith('_')).filter(k => !(k in global)));
|
|
70
|
+
// going to add our jsdom instance, see below
|
|
71
|
+
KEYS.push('$jsdom');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
KEYS.forEach(key => global[key] = window[key]);
|
|
75
|
+
|
|
76
|
+
// setup document / window / window.console
|
|
77
|
+
global.document = document;
|
|
78
|
+
global.window = window;
|
|
79
|
+
window.console = global.console;
|
|
80
|
+
|
|
81
|
+
// add access to our jsdom instance
|
|
82
|
+
global.$jsdom = jsdom;
|
|
83
|
+
|
|
84
|
+
const cleanup = () => KEYS.forEach(key => delete global[key]);
|
|
85
|
+
|
|
86
|
+
document.destroy = cleanup;
|
|
87
|
+
|
|
88
|
+
return cleanup
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
exports.jsdomGlobal = jsdomGlobal;
|
|
@@ -1,85 +1,85 @@
|
|
|
1
1
|
import JSDOM from 'jsdom';
|
|
2
2
|
|
|
3
|
-
/*
|
|
4
|
-
MIT License
|
|
5
|
-
|
|
6
|
-
Copyright for portions of global-jsdom are held by Rico Sta. Cruz, 2016 as part of
|
|
7
|
-
jsdom-global. All other copyright for global-jsdom are held by jonathan schatz, 2017.
|
|
8
|
-
|
|
9
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
-
in the Software without restriction, including without limitation the rights
|
|
12
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
-
furnished to do so, subject to the following conditions:
|
|
15
|
-
|
|
16
|
-
The above copyright notice and this permission notice shall be included in all
|
|
17
|
-
copies or substantial portions of the Software.
|
|
18
|
-
|
|
19
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
-
SOFTWARE.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const defaultHtml = '<!doctype html><html><head><meta charset="utf-8"></head><body></body></html>';
|
|
30
|
-
|
|
31
|
-
// define this here so that we only ever dynamically populate KEYS once.
|
|
32
|
-
|
|
33
|
-
const KEYS = [];
|
|
34
|
-
|
|
35
|
-
function jsdomGlobal(html = defaultHtml, options = {}) {
|
|
36
|
-
// Idempotency
|
|
37
|
-
if (global.navigator
|
|
38
|
-
&& global.navigator.userAgent
|
|
39
|
-
&& global.navigator.userAgent.includes('Node.js')
|
|
40
|
-
&& global.document
|
|
41
|
-
&& typeof global.document.destroy === 'function') {
|
|
42
|
-
return global.document.destroy
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// set a default url if we don't get one - otherwise things explode when we copy localstorage keys
|
|
46
|
-
if (!('url' in options))
|
|
47
|
-
Object.assign(options, { url: 'http://localhost:3000' });
|
|
48
|
-
|
|
49
|
-
// enable pretendToBeVisual by default since react needs
|
|
50
|
-
// window.requestAnimationFrame, see https://github.com/jsdom/jsdom#pretending-to-be-a-visual-browser
|
|
51
|
-
if (!('pretendToBeVisual' in options))
|
|
52
|
-
Object.assign(options, { pretendToBeVisual: true });
|
|
53
|
-
|
|
54
|
-
const jsdom = new JSDOM.JSDOM(html, options);
|
|
55
|
-
const { window } = jsdom;
|
|
56
|
-
const { document } = window;
|
|
57
|
-
|
|
58
|
-
// generate our list of keys by enumerating document.window - this list may vary
|
|
59
|
-
// based on the jsdom version. filter out internal methods as well as anything
|
|
60
|
-
// that node already defines
|
|
61
|
-
|
|
62
|
-
if (KEYS.length === 0) {
|
|
63
|
-
KEYS.push(...Object.getOwnPropertyNames(window).filter(k => !k.startsWith('_')).filter(k => !(k in global)));
|
|
64
|
-
// going to add our jsdom instance, see below
|
|
65
|
-
KEYS.push('$jsdom');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
KEYS.forEach(key => global[key] = window[key]);
|
|
69
|
-
|
|
70
|
-
// setup document / window / window.console
|
|
71
|
-
global.document = document;
|
|
72
|
-
global.window = window;
|
|
73
|
-
window.console = global.console;
|
|
74
|
-
|
|
75
|
-
// add access to our jsdom instance
|
|
76
|
-
global.$jsdom = jsdom;
|
|
77
|
-
|
|
78
|
-
const cleanup = () => KEYS.forEach(key => delete global[key]);
|
|
79
|
-
|
|
80
|
-
document.destroy = cleanup;
|
|
81
|
-
|
|
82
|
-
return cleanup
|
|
3
|
+
/*
|
|
4
|
+
MIT License
|
|
5
|
+
|
|
6
|
+
Copyright for portions of global-jsdom are held by Rico Sta. Cruz, 2016 as part of
|
|
7
|
+
jsdom-global. All other copyright for global-jsdom are held by jonathan schatz, 2017.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const defaultHtml = '<!doctype html><html><head><meta charset="utf-8"></head><body></body></html>';
|
|
30
|
+
|
|
31
|
+
// define this here so that we only ever dynamically populate KEYS once.
|
|
32
|
+
|
|
33
|
+
const KEYS = [];
|
|
34
|
+
|
|
35
|
+
function jsdomGlobal(html = defaultHtml, options = {}) {
|
|
36
|
+
// Idempotency
|
|
37
|
+
if (global.navigator
|
|
38
|
+
&& global.navigator.userAgent
|
|
39
|
+
&& global.navigator.userAgent.includes('Node.js')
|
|
40
|
+
&& global.document
|
|
41
|
+
&& typeof global.document.destroy === 'function') {
|
|
42
|
+
return global.document.destroy
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// set a default url if we don't get one - otherwise things explode when we copy localstorage keys
|
|
46
|
+
if (!('url' in options))
|
|
47
|
+
Object.assign(options, { url: 'http://localhost:3000' });
|
|
48
|
+
|
|
49
|
+
// enable pretendToBeVisual by default since react needs
|
|
50
|
+
// window.requestAnimationFrame, see https://github.com/jsdom/jsdom#pretending-to-be-a-visual-browser
|
|
51
|
+
if (!('pretendToBeVisual' in options))
|
|
52
|
+
Object.assign(options, { pretendToBeVisual: true });
|
|
53
|
+
|
|
54
|
+
const jsdom = new JSDOM.JSDOM(html, options);
|
|
55
|
+
const { window } = jsdom;
|
|
56
|
+
const { document } = window;
|
|
57
|
+
|
|
58
|
+
// generate our list of keys by enumerating document.window - this list may vary
|
|
59
|
+
// based on the jsdom version. filter out internal methods as well as anything
|
|
60
|
+
// that node already defines
|
|
61
|
+
|
|
62
|
+
if (KEYS.length === 0) {
|
|
63
|
+
KEYS.push(...Object.getOwnPropertyNames(window).filter(k => !k.startsWith('_')).filter(k => !(k in global)));
|
|
64
|
+
// going to add our jsdom instance, see below
|
|
65
|
+
KEYS.push('$jsdom');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
KEYS.forEach(key => global[key] = window[key]);
|
|
69
|
+
|
|
70
|
+
// setup document / window / window.console
|
|
71
|
+
global.document = document;
|
|
72
|
+
global.window = window;
|
|
73
|
+
window.console = global.console;
|
|
74
|
+
|
|
75
|
+
// add access to our jsdom instance
|
|
76
|
+
global.$jsdom = jsdom;
|
|
77
|
+
|
|
78
|
+
const cleanup = () => KEYS.forEach(key => delete global[key]);
|
|
79
|
+
|
|
80
|
+
document.destroy = cleanup;
|
|
81
|
+
|
|
82
|
+
return cleanup
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
export { jsdomGlobal };
|
package/dist/node.cjs
CHANGED
|
@@ -888,6 +888,10 @@ async function routesToPaths(routes) {
|
|
|
888
888
|
}
|
|
889
889
|
if (route.index)
|
|
890
890
|
addEntry(prefix, route.entry);
|
|
891
|
+
if (route.index && !path) {
|
|
892
|
+
addEntry("/", route.entry);
|
|
893
|
+
paths.add("/");
|
|
894
|
+
}
|
|
891
895
|
if (Array.isArray(route.children))
|
|
892
896
|
await getPaths(route.children, path);
|
|
893
897
|
}
|
|
@@ -1178,6 +1182,13 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1178
1182
|
} = Object.assign({}, config.ssgOptions || {}, ssgOptions);
|
|
1179
1183
|
if (fs__default.existsSync(ssgOut))
|
|
1180
1184
|
await fs__default.remove(ssgOut);
|
|
1185
|
+
const clientLogger = vite.createLogger();
|
|
1186
|
+
const loggerWarn = clientLogger.warn;
|
|
1187
|
+
clientLogger.warn = (msg, options) => {
|
|
1188
|
+
if (msg.includes("vite:resolve") && msg.includes("externalized for browser compatibility"))
|
|
1189
|
+
return;
|
|
1190
|
+
loggerWarn(msg, options);
|
|
1191
|
+
};
|
|
1181
1192
|
buildLog("Build for client...");
|
|
1182
1193
|
await vite.build(vite.mergeConfig(viteConfig, {
|
|
1183
1194
|
build: {
|
|
@@ -1195,6 +1206,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1195
1206
|
}
|
|
1196
1207
|
}
|
|
1197
1208
|
},
|
|
1209
|
+
customLogger: clientLogger,
|
|
1198
1210
|
mode: config.mode,
|
|
1199
1211
|
ssr: { noExternal: ["vite-react-ssg"] }
|
|
1200
1212
|
}));
|
|
@@ -1295,7 +1307,12 @@ ${err.stack}`);
|
|
|
1295
1307
|
});
|
|
1296
1308
|
}
|
|
1297
1309
|
await queue.start().onIdle();
|
|
1298
|
-
|
|
1310
|
+
buildLog("Generating static loader data manifest...");
|
|
1311
|
+
const staticLoaderDataManifestString = JSON.stringify(staticLoaderDataManifest, null, 0);
|
|
1312
|
+
await fs__default.writeFile(node_path.join(out, `static-loader-data-manifest-${hash}.json`), staticLoaderDataManifestString);
|
|
1313
|
+
config.logger.info(
|
|
1314
|
+
`${kolorist.dim(`${outDir}/`)}${kolorist.cyan(`static-loader-data-manifest-${hash}.json`.padEnd(15, " "))} ${kolorist.dim(getSize(staticLoaderDataManifestString))}`
|
|
1315
|
+
);
|
|
1299
1316
|
await fs__default.remove(node_path.join(root, ".vite-react-ssg-temp"));
|
|
1300
1317
|
const pwaPlugin = config.plugins.find((i) => i.name === "vite-plugin-pwa")?.api;
|
|
1301
1318
|
if (pwaPlugin && !pwaPlugin.disabled && pwaPlugin.generateSW) {
|
package/dist/node.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { join, isAbsolute, parse, dirname } from 'node:path';
|
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import { gray, yellow, blue, dim, cyan, red, green, reset, bold, bgLightCyan } from 'kolorist';
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
|
-
import { resolveConfig, build as build$1, mergeConfig, version as version$1, send, createServer } from 'vite';
|
|
5
|
+
import { resolveConfig, createLogger, build as build$1, mergeConfig, version as version$1, send, createServer } from 'vite';
|
|
6
6
|
import { JSDOM } from 'jsdom';
|
|
7
7
|
import { s as serializeState } from './shared/vite-react-ssg.579feabb.mjs';
|
|
8
8
|
import { a as withTrailingSlash, r as removeLeadingSlash, c as convertRoutesToDataRoutes, j as joinUrlSegments } from './shared/vite-react-ssg.054e813a.mjs';
|
|
@@ -881,6 +881,10 @@ async function routesToPaths(routes) {
|
|
|
881
881
|
}
|
|
882
882
|
if (route.index)
|
|
883
883
|
addEntry(prefix, route.entry);
|
|
884
|
+
if (route.index && !path) {
|
|
885
|
+
addEntry("/", route.entry);
|
|
886
|
+
paths.add("/");
|
|
887
|
+
}
|
|
884
888
|
if (Array.isArray(route.children))
|
|
885
889
|
await getPaths(route.children, path);
|
|
886
890
|
}
|
|
@@ -1171,6 +1175,13 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1171
1175
|
} = Object.assign({}, config.ssgOptions || {}, ssgOptions);
|
|
1172
1176
|
if (fs.existsSync(ssgOut))
|
|
1173
1177
|
await fs.remove(ssgOut);
|
|
1178
|
+
const clientLogger = createLogger();
|
|
1179
|
+
const loggerWarn = clientLogger.warn;
|
|
1180
|
+
clientLogger.warn = (msg, options) => {
|
|
1181
|
+
if (msg.includes("vite:resolve") && msg.includes("externalized for browser compatibility"))
|
|
1182
|
+
return;
|
|
1183
|
+
loggerWarn(msg, options);
|
|
1184
|
+
};
|
|
1174
1185
|
buildLog("Build for client...");
|
|
1175
1186
|
await build$1(mergeConfig(viteConfig, {
|
|
1176
1187
|
build: {
|
|
@@ -1188,6 +1199,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1188
1199
|
}
|
|
1189
1200
|
}
|
|
1190
1201
|
},
|
|
1202
|
+
customLogger: clientLogger,
|
|
1191
1203
|
mode: config.mode,
|
|
1192
1204
|
ssr: { noExternal: ["vite-react-ssg"] }
|
|
1193
1205
|
}));
|
|
@@ -1288,7 +1300,12 @@ ${err.stack}`);
|
|
|
1288
1300
|
});
|
|
1289
1301
|
}
|
|
1290
1302
|
await queue.start().onIdle();
|
|
1291
|
-
|
|
1303
|
+
buildLog("Generating static loader data manifest...");
|
|
1304
|
+
const staticLoaderDataManifestString = JSON.stringify(staticLoaderDataManifest, null, 0);
|
|
1305
|
+
await fs.writeFile(join(out, `static-loader-data-manifest-${hash}.json`), staticLoaderDataManifestString);
|
|
1306
|
+
config.logger.info(
|
|
1307
|
+
`${dim(`${outDir}/`)}${cyan(`static-loader-data-manifest-${hash}.json`.padEnd(15, " "))} ${dim(getSize(staticLoaderDataManifestString))}`
|
|
1308
|
+
);
|
|
1292
1309
|
await fs.remove(join(root, ".vite-react-ssg-temp"));
|
|
1293
1310
|
const pwaPlugin = config.plugins.find((i) => i.name === "vite-plugin-pwa")?.api;
|
|
1294
1311
|
if (pwaPlugin && !pwaPlugin.disabled && pwaPlugin.generateSW) {
|