vite-react-ssg 0.7.2 → 0.8.0-beta.1
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/README.md +10 -4
- package/dist/chunks/jsdomGlobal.cjs +10 -65
- package/dist/chunks/jsdomGlobal.mjs +10 -65
- package/dist/client/single-page.cjs +8 -6
- package/dist/client/single-page.d.cts +3 -4
- package/dist/client/single-page.d.mts +3 -4
- package/dist/client/single-page.d.ts +3 -4
- package/dist/client/single-page.mjs +9 -7
- package/dist/index.cjs +19 -12
- package/dist/index.d.cts +3 -4
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.mjs +17 -10
- package/dist/node/cli.cjs +9 -8
- package/dist/node/cli.mjs +7 -6
- package/dist/node.cjs +22 -1722
- package/dist/node.d.cts +1 -2
- package/dist/node.d.mts +1 -2
- package/dist/node.d.ts +1 -2
- package/dist/node.mjs +17 -1716
- package/dist/shared/vite-react-ssg.4y2OEiyV.mjs +31 -0
- package/dist/shared/{vite-react-ssg.a292c181.mjs → vite-react-ssg.B6SGTWpD.mjs} +5 -4
- package/dist/shared/{vite-react-ssg.c1d49976.cjs → vite-react-ssg.BuZVBVT6.cjs} +5 -8
- package/dist/shared/{vite-react-ssg.054e813a.mjs → vite-react-ssg.C0y5wbxl.mjs} +1 -30
- package/dist/shared/{vite-react-ssg.0408f7e1.cjs → vite-react-ssg.C2GpVZF1.cjs} +0 -34
- package/dist/shared/vite-react-ssg.CFQGqC60.cjs +36 -0
- package/dist/shared/vite-react-ssg.CZ2uxKni.mjs +1029 -0
- package/dist/shared/vite-react-ssg.CjIppNIS.mjs +30 -0
- package/dist/shared/vite-react-ssg.D0EGioth.cjs +35 -0
- package/dist/shared/{vite-react-ssg.4d155759.d.ts → vite-react-ssg.Txy2EJkI.d.cts} +26 -7
- package/dist/shared/{vite-react-ssg.4d155759.d.cts → vite-react-ssg.Txy2EJkI.d.mts} +26 -7
- package/dist/shared/{vite-react-ssg.4d155759.d.mts → vite-react-ssg.Txy2EJkI.d.ts} +26 -7
- package/dist/shared/vite-react-ssg.sc14Rk9F.cjs +1038 -0
- package/dist/tanstack.cjs +150 -0
- package/dist/tanstack.d.cts +29 -0
- package/dist/tanstack.d.mts +29 -0
- package/dist/tanstack.d.ts +29 -0
- package/dist/tanstack.mjs +143 -0
- package/package.json +33 -22
- /package/dist/shared/{vite-react-ssg.579feabb.mjs → vite-react-ssg.C6pK7rvr.mjs} +0 -0
- /package/dist/shared/{vite-react-ssg.bee8a5a9.cjs → vite-react-ssg.CjsEygxB.cjs} +0 -0
- /package/dist/shared/{vite-react-ssg.faf3855a.d.cts → vite-react-ssg.Cm9gBlfg.d.cts} +0 -0
- /package/dist/shared/{vite-react-ssg.faf3855a.d.mts → vite-react-ssg.Cm9gBlfg.d.mts} +0 -0
- /package/dist/shared/{vite-react-ssg.faf3855a.d.ts → vite-react-ssg.Cm9gBlfg.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -146,7 +146,7 @@ This function is only valid for dynamic route.
|
|
|
146
146
|
```tsx
|
|
147
147
|
const route = {
|
|
148
148
|
path: 'nest/:b',
|
|
149
|
-
|
|
149
|
+
lazy: () => import('./pages/nest/[b]'),
|
|
150
150
|
entry: 'src/pages/nest/[b].tsx',
|
|
151
151
|
// To determine which paths will be pre-rendered
|
|
152
152
|
getStaticPaths: () => ['nest/b1', 'nest/b2'],
|
|
@@ -187,6 +187,12 @@ const routes = [
|
|
|
187
187
|
]
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
+
**Note that** during the build process, `vite-react-ssg` will [automatically detect](https://github.com/Daydreamer-riri/vite-react-ssg/blob/main/src/node/assets.ts#L5) the files directly dynamically imported in the function you pass to the `lazy` field. This helps `vite-react-ssg` to get the route's style files or other static resources during the build, preventing [flash of unstyled content](https://en.wikipedia.org/wiki/Flash_of_unstyled_content).
|
|
191
|
+
|
|
192
|
+
If you still encounter FOUC (flash of unstyled content), please open an issue.
|
|
193
|
+
|
|
194
|
+
If your component isn't loading, make sure you have wrapped it or its parent in `Suspense` tags as described in the [React documentation](https://react.dev/reference/react/lazy#usage).
|
|
195
|
+
|
|
190
196
|
See [example](./examples/lazy-pages/src/App.tsx).
|
|
191
197
|
|
|
192
198
|
## Data fetch
|
|
@@ -459,9 +465,9 @@ interface ViteReactSSGOptions {
|
|
|
459
465
|
*
|
|
460
466
|
* @default 'none'
|
|
461
467
|
*/
|
|
462
|
-
formatting?: '
|
|
468
|
+
formatting?: 'prettify' | 'none'
|
|
463
469
|
/**
|
|
464
|
-
* Vite
|
|
470
|
+
* Vite environment mode.
|
|
465
471
|
*/
|
|
466
472
|
mode?: string
|
|
467
473
|
/**
|
|
@@ -475,7 +481,7 @@ interface ViteReactSSGOptions {
|
|
|
475
481
|
dirStyle?: 'flat' | 'nested'
|
|
476
482
|
/**
|
|
477
483
|
* Generate for all routes, including dynamic routes.
|
|
478
|
-
* If enabled, you will need to
|
|
484
|
+
* If enabled, you will need to configure your serve
|
|
479
485
|
* manually to handle dynamic routes properly.
|
|
480
486
|
*
|
|
481
487
|
* @default false
|
|
@@ -6,86 +6,31 @@ 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
9
|
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
10
|
const KEYS = [];
|
|
40
|
-
|
|
41
11
|
function jsdomGlobal(html = defaultHtml, options = {}) {
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
12
|
+
if (global.navigator && global.navigator.userAgent && global.navigator.userAgent.includes("Node.js") && global.document && typeof global.document.destroy === "function") {
|
|
13
|
+
return global.document.destroy;
|
|
49
14
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (!(
|
|
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))
|
|
15
|
+
if (!("url" in options))
|
|
16
|
+
Object.assign(options, { url: "http://localhost:3000" });
|
|
17
|
+
if (!("pretendToBeVisual" in options))
|
|
58
18
|
Object.assign(options, { pretendToBeVisual: true });
|
|
59
|
-
|
|
60
19
|
const jsdom = new JSDOM__default.JSDOM(html, options);
|
|
61
20
|
const { window } = jsdom;
|
|
62
21
|
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
22
|
if (KEYS.length === 0) {
|
|
69
|
-
KEYS.push(...Object.getOwnPropertyNames(window).filter(k => !k.startsWith(
|
|
70
|
-
|
|
71
|
-
KEYS.push('$jsdom');
|
|
23
|
+
KEYS.push(...Object.getOwnPropertyNames(window).filter((k) => !k.startsWith("_")).filter((k) => !(k in global)));
|
|
24
|
+
KEYS.push("$jsdom");
|
|
72
25
|
}
|
|
73
|
-
|
|
74
|
-
KEYS.forEach(key => global[key] = window[key]);
|
|
75
|
-
|
|
76
|
-
// setup document / window / window.console
|
|
26
|
+
KEYS.forEach((key) => global[key] = window[key]);
|
|
77
27
|
global.document = document;
|
|
78
28
|
global.window = window;
|
|
79
29
|
window.console = global.console;
|
|
80
|
-
|
|
81
|
-
// add access to our jsdom instance
|
|
82
30
|
global.$jsdom = jsdom;
|
|
83
|
-
|
|
84
|
-
const cleanup = () => KEYS.forEach(key => delete global[key]);
|
|
85
|
-
|
|
31
|
+
const cleanup = () => KEYS.forEach((key) => delete global[key]);
|
|
86
32
|
document.destroy = cleanup;
|
|
87
|
-
|
|
88
|
-
return cleanup
|
|
33
|
+
return cleanup;
|
|
89
34
|
}
|
|
90
35
|
|
|
91
36
|
exports.jsdomGlobal = jsdomGlobal;
|
|
@@ -1,85 +1,30 @@
|
|
|
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
3
|
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
4
|
const KEYS = [];
|
|
34
|
-
|
|
35
5
|
function jsdomGlobal(html = defaultHtml, options = {}) {
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
6
|
+
if (global.navigator && global.navigator.userAgent && global.navigator.userAgent.includes("Node.js") && global.document && typeof global.document.destroy === "function") {
|
|
7
|
+
return global.document.destroy;
|
|
43
8
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (!(
|
|
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))
|
|
9
|
+
if (!("url" in options))
|
|
10
|
+
Object.assign(options, { url: "http://localhost:3000" });
|
|
11
|
+
if (!("pretendToBeVisual" in options))
|
|
52
12
|
Object.assign(options, { pretendToBeVisual: true });
|
|
53
|
-
|
|
54
13
|
const jsdom = new JSDOM.JSDOM(html, options);
|
|
55
14
|
const { window } = jsdom;
|
|
56
15
|
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
16
|
if (KEYS.length === 0) {
|
|
63
|
-
KEYS.push(...Object.getOwnPropertyNames(window).filter(k => !k.startsWith(
|
|
64
|
-
|
|
65
|
-
KEYS.push('$jsdom');
|
|
17
|
+
KEYS.push(...Object.getOwnPropertyNames(window).filter((k) => !k.startsWith("_")).filter((k) => !(k in global)));
|
|
18
|
+
KEYS.push("$jsdom");
|
|
66
19
|
}
|
|
67
|
-
|
|
68
|
-
KEYS.forEach(key => global[key] = window[key]);
|
|
69
|
-
|
|
70
|
-
// setup document / window / window.console
|
|
20
|
+
KEYS.forEach((key) => global[key] = window[key]);
|
|
71
21
|
global.document = document;
|
|
72
22
|
global.window = window;
|
|
73
23
|
window.console = global.console;
|
|
74
|
-
|
|
75
|
-
// add access to our jsdom instance
|
|
76
24
|
global.$jsdom = jsdom;
|
|
77
|
-
|
|
78
|
-
const cleanup = () => KEYS.forEach(key => delete global[key]);
|
|
79
|
-
|
|
25
|
+
const cleanup = () => KEYS.forEach((key) => delete global[key]);
|
|
80
26
|
document.destroy = cleanup;
|
|
81
|
-
|
|
82
|
-
return cleanup
|
|
27
|
+
return cleanup;
|
|
83
28
|
}
|
|
84
29
|
|
|
85
30
|
export { jsdomGlobal };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
3
4
|
const client = require('react-dom/client');
|
|
4
5
|
const reactHelmetAsync = require('react-helmet-async');
|
|
5
6
|
const React = require('react');
|
|
6
|
-
const ClientOnly = require('../shared/vite-react-ssg.
|
|
7
|
-
const state = require('../shared/vite-react-ssg.
|
|
7
|
+
const ClientOnly = require('../shared/vite-react-ssg.BuZVBVT6.cjs');
|
|
8
|
+
const state = require('../shared/vite-react-ssg.CjsEygxB.cjs');
|
|
8
9
|
|
|
9
10
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
10
11
|
|
|
@@ -17,7 +18,7 @@ function ViteReactSSG(App, fn, options = {}) {
|
|
|
17
18
|
ssrWhenDev,
|
|
18
19
|
getStyleCollector = null
|
|
19
20
|
} = options;
|
|
20
|
-
if (
|
|
21
|
+
if (undefined.DEV && ssrWhenDev !== void 0)
|
|
21
22
|
console.warn("[vite-react-ssg] `ssrWhenDev` option is no longer needed. If you want to use csr, just replace `vite-react-ssg dev` with `vite`.");
|
|
22
23
|
const isClient = typeof window !== "undefined";
|
|
23
24
|
async function createRoot(client = false, routePath) {
|
|
@@ -38,7 +39,8 @@ function ViteReactSSG(App, fn, options = {}) {
|
|
|
38
39
|
routes: void 0,
|
|
39
40
|
routerOptions: void 0,
|
|
40
41
|
base: "/",
|
|
41
|
-
app: App
|
|
42
|
+
app: App,
|
|
43
|
+
routerType: "single-page"
|
|
42
44
|
};
|
|
43
45
|
if (client) {
|
|
44
46
|
await ClientOnly.documentReady();
|
|
@@ -60,9 +62,9 @@ function ViteReactSSG(App, fn, options = {}) {
|
|
|
60
62
|
return;
|
|
61
63
|
}
|
|
62
64
|
await createRoot(true);
|
|
63
|
-
const app = /* @__PURE__ */
|
|
65
|
+
const app = /* @__PURE__ */ jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: App });
|
|
64
66
|
const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
|
|
65
|
-
if (!isSSR &&
|
|
67
|
+
if (!isSSR && undefined.DEV) {
|
|
66
68
|
const root = client.createRoot(container);
|
|
67
69
|
React__default.startTransition(() => {
|
|
68
70
|
root.render(app);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.
|
|
3
|
-
export { I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterOptions, S as StyleCollector, b as ViteReactSSGOptions } from '../shared/vite-react-ssg.
|
|
4
|
-
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.
|
|
5
|
-
import 'critters';
|
|
2
|
+
import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.Txy2EJkI.cjs';
|
|
3
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterOptions, S as StyleCollector, b as ViteReactSSGOptions } from '../shared/vite-react-ssg.Txy2EJkI.cjs';
|
|
4
|
+
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.Cm9gBlfg.cjs';
|
|
6
5
|
import 'react-router-dom';
|
|
7
6
|
import 'react-helmet-async';
|
|
8
7
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.
|
|
3
|
-
export { I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterOptions, S as StyleCollector, b as ViteReactSSGOptions } from '../shared/vite-react-ssg.
|
|
4
|
-
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.
|
|
5
|
-
import 'critters';
|
|
2
|
+
import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.Txy2EJkI.mjs';
|
|
3
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterOptions, S as StyleCollector, b as ViteReactSSGOptions } from '../shared/vite-react-ssg.Txy2EJkI.mjs';
|
|
4
|
+
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.Cm9gBlfg.mjs';
|
|
6
5
|
import 'react-router-dom';
|
|
7
6
|
import 'react-helmet-async';
|
|
8
7
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.
|
|
3
|
-
export { I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterOptions, S as StyleCollector, b as ViteReactSSGOptions } from '../shared/vite-react-ssg.
|
|
4
|
-
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.
|
|
5
|
-
import 'critters';
|
|
2
|
+
import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.Txy2EJkI.js';
|
|
3
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterOptions, S as StyleCollector, b as ViteReactSSGOptions } from '../shared/vite-react-ssg.Txy2EJkI.js';
|
|
4
|
+
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.Cm9gBlfg.js';
|
|
6
5
|
import 'react-router-dom';
|
|
7
6
|
import 'react-helmet-async';
|
|
8
7
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
1
2
|
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
2
3
|
import { HelmetProvider } from 'react-helmet-async';
|
|
3
4
|
import React from 'react';
|
|
4
|
-
import { d as documentReady } from '../shared/vite-react-ssg.
|
|
5
|
-
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.
|
|
6
|
-
import { d as deserializeState } from '../shared/vite-react-ssg.
|
|
5
|
+
import { d as documentReady } from '../shared/vite-react-ssg.B6SGTWpD.mjs';
|
|
6
|
+
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.B6SGTWpD.mjs';
|
|
7
|
+
import { d as deserializeState } from '../shared/vite-react-ssg.C6pK7rvr.mjs';
|
|
7
8
|
|
|
8
9
|
function ViteReactSSG(App, fn, options = {}) {
|
|
9
10
|
const {
|
|
@@ -12,7 +13,7 @@ function ViteReactSSG(App, fn, options = {}) {
|
|
|
12
13
|
ssrWhenDev,
|
|
13
14
|
getStyleCollector = null
|
|
14
15
|
} = options;
|
|
15
|
-
if (
|
|
16
|
+
if (import.meta.env.DEV && ssrWhenDev !== void 0)
|
|
16
17
|
console.warn("[vite-react-ssg] `ssrWhenDev` option is no longer needed. If you want to use csr, just replace `vite-react-ssg dev` with `vite`.");
|
|
17
18
|
const isClient = typeof window !== "undefined";
|
|
18
19
|
async function createRoot$1(client = false, routePath) {
|
|
@@ -33,7 +34,8 @@ function ViteReactSSG(App, fn, options = {}) {
|
|
|
33
34
|
routes: void 0,
|
|
34
35
|
routerOptions: void 0,
|
|
35
36
|
base: "/",
|
|
36
|
-
app: App
|
|
37
|
+
app: App,
|
|
38
|
+
routerType: "single-page"
|
|
37
39
|
};
|
|
38
40
|
if (client) {
|
|
39
41
|
await documentReady();
|
|
@@ -55,9 +57,9 @@ function ViteReactSSG(App, fn, options = {}) {
|
|
|
55
57
|
return;
|
|
56
58
|
}
|
|
57
59
|
await createRoot$1(true);
|
|
58
|
-
const app = /* @__PURE__ */
|
|
60
|
+
const app = /* @__PURE__ */ jsx(HelmetProvider, { children: App });
|
|
59
61
|
const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
|
|
60
|
-
if (!isSSR &&
|
|
62
|
+
if (!isSSR && import.meta.env.DEV) {
|
|
61
63
|
const root = createRoot(container);
|
|
62
64
|
React.startTransition(() => {
|
|
63
65
|
root.render(app);
|
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
3
4
|
const React = require('react');
|
|
4
5
|
const client = require('react-dom/client');
|
|
5
6
|
const reactHelmetAsync = require('react-helmet-async');
|
|
6
7
|
const reactRouterDom = require('react-router-dom');
|
|
7
|
-
const ClientOnly = require('./shared/vite-react-ssg.
|
|
8
|
-
const state = require('./shared/vite-react-ssg.
|
|
9
|
-
const
|
|
8
|
+
const ClientOnly = require('./shared/vite-react-ssg.BuZVBVT6.cjs');
|
|
9
|
+
const state = require('./shared/vite-react-ssg.CjsEygxB.cjs');
|
|
10
|
+
const path = require('./shared/vite-react-ssg.CFQGqC60.cjs');
|
|
11
|
+
const remixRouter = require('./shared/vite-react-ssg.C2GpVZF1.cjs');
|
|
10
12
|
|
|
11
13
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
12
14
|
|
|
@@ -40,7 +42,7 @@ const Link = React.forwardRef((props, ref) => {
|
|
|
40
42
|
event.defaultPrevented = true;
|
|
41
43
|
event.preventDefault();
|
|
42
44
|
}
|
|
43
|
-
return /* @__PURE__ */
|
|
45
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Link, { ...props, ref, onClick: handleClick });
|
|
44
46
|
});
|
|
45
47
|
Link.displayName = "Link";
|
|
46
48
|
const NavLink = React.forwardRef((props, ref) => {
|
|
@@ -71,7 +73,7 @@ const NavLink = React.forwardRef((props, ref) => {
|
|
|
71
73
|
event.defaultPrevented = true;
|
|
72
74
|
event.preventDefault();
|
|
73
75
|
}
|
|
74
|
-
return /* @__PURE__ */
|
|
76
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.NavLink, { ...props, ref, onClick: handleClick });
|
|
75
77
|
});
|
|
76
78
|
NavLink.displayName = "NavLink";
|
|
77
79
|
|
|
@@ -82,7 +84,7 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
82
84
|
ssrWhenDev,
|
|
83
85
|
getStyleCollector = null
|
|
84
86
|
} = options;
|
|
85
|
-
if (
|
|
87
|
+
if (undefined.DEV && ssrWhenDev !== void 0)
|
|
86
88
|
console.warn("[vite-react-ssg] `ssrWhenDev` option is no longer needed. If you want to use csr, just replace `vite-react-ssg dev` with `vite`.");
|
|
87
89
|
const isClient = typeof window !== "undefined";
|
|
88
90
|
const BASE_URL = routerOptions.basename ?? "/";
|
|
@@ -105,7 +107,8 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
105
107
|
transformState,
|
|
106
108
|
routePath,
|
|
107
109
|
base: BASE_URL,
|
|
108
|
-
getStyleCollector
|
|
110
|
+
getStyleCollector,
|
|
111
|
+
routerType: "remix"
|
|
109
112
|
};
|
|
110
113
|
if (client) {
|
|
111
114
|
await ClientOnly.documentReady();
|
|
@@ -138,9 +141,9 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
138
141
|
);
|
|
139
142
|
}
|
|
140
143
|
const { router } = await createRoot(true);
|
|
141
|
-
const app = /* @__PURE__ */
|
|
144
|
+
const app = /* @__PURE__ */ jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.RouterProvider, { router }) });
|
|
142
145
|
const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
|
|
143
|
-
if (!isSSR &&
|
|
146
|
+
if (!isSSR && undefined.DEV) {
|
|
144
147
|
const root = client.createRoot(container);
|
|
145
148
|
React__default.startTransition(() => {
|
|
146
149
|
root.render(app);
|
|
@@ -154,6 +157,10 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
154
157
|
}
|
|
155
158
|
return createRoot;
|
|
156
159
|
function transformStaticLoaderRoute(route) {
|
|
160
|
+
const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
|
|
161
|
+
if (!isSSR) {
|
|
162
|
+
return route;
|
|
163
|
+
}
|
|
157
164
|
const loader = async ({ request }) => {
|
|
158
165
|
if (undefined.DEV) {
|
|
159
166
|
const routeId = encodeURIComponent(route.id);
|
|
@@ -165,14 +172,14 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
165
172
|
if (window.__VITE_REACT_SSG_STATIC_LOADER_DATA__) {
|
|
166
173
|
staticLoadData = window.__VITE_REACT_SSG_STATIC_LOADER_DATA__;
|
|
167
174
|
} else {
|
|
168
|
-
const manifestUrl =
|
|
169
|
-
staticLoadData = await (await fetch(
|
|
175
|
+
const manifestUrl = path.joinUrlSegments(BASE_URL, `static-loader-data-manifest-${window.__VITE_REACT_SSG_HASH__}.json`);
|
|
176
|
+
staticLoadData = await (await fetch(path.withLeadingSlash(manifestUrl))).json();
|
|
170
177
|
window.__VITE_REACT_SSG_STATIC_LOADER_DATA__ = staticLoadData;
|
|
171
178
|
}
|
|
172
179
|
const { url } = request;
|
|
173
180
|
let { pathname } = new URL(url);
|
|
174
181
|
if (BASE_URL !== "/") {
|
|
175
|
-
pathname =
|
|
182
|
+
pathname = path.stripBase(pathname, BASE_URL);
|
|
176
183
|
}
|
|
177
184
|
const routeData = staticLoadData?.[pathname]?.[route.id];
|
|
178
185
|
return routeData ?? null;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { c as RouterOptions, V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.
|
|
2
|
-
export { I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.
|
|
3
|
-
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.
|
|
1
|
+
import { c as RouterOptions, V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.Txy2EJkI.cjs';
|
|
2
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.Txy2EJkI.cjs';
|
|
3
|
+
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.Cm9gBlfg.cjs';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { LinkProps, NavLinkProps } from 'react-router-dom';
|
|
6
|
-
import 'critters';
|
|
7
6
|
import 'react-helmet-async';
|
|
8
7
|
|
|
9
8
|
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { c as RouterOptions, V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.
|
|
2
|
-
export { I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.
|
|
3
|
-
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.
|
|
1
|
+
import { c as RouterOptions, V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.Txy2EJkI.mjs';
|
|
2
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.Txy2EJkI.mjs';
|
|
3
|
+
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.Cm9gBlfg.mjs';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { LinkProps, NavLinkProps } from 'react-router-dom';
|
|
6
|
-
import 'critters';
|
|
7
6
|
import 'react-helmet-async';
|
|
8
7
|
|
|
9
8
|
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { c as RouterOptions, V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.
|
|
2
|
-
export { I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.
|
|
3
|
-
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.
|
|
1
|
+
import { c as RouterOptions, V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.Txy2EJkI.js';
|
|
2
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.Txy2EJkI.js';
|
|
3
|
+
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.Cm9gBlfg.js';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { LinkProps, NavLinkProps } from 'react-router-dom';
|
|
6
|
-
import 'critters';
|
|
7
6
|
import 'react-helmet-async';
|
|
8
7
|
|
|
9
8
|
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
1
2
|
import React, { forwardRef } from 'react';
|
|
2
3
|
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
3
4
|
import { HelmetProvider } from 'react-helmet-async';
|
|
4
5
|
import { useLinkClickHandler, Link as Link$1, NavLink as NavLink$1, matchRoutes, createBrowserRouter, RouterProvider } from 'react-router-dom';
|
|
5
|
-
import { d as documentReady } from './shared/vite-react-ssg.
|
|
6
|
-
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.
|
|
7
|
-
import { d as deserializeState } from './shared/vite-react-ssg.
|
|
8
|
-
import {
|
|
6
|
+
import { d as documentReady } from './shared/vite-react-ssg.B6SGTWpD.mjs';
|
|
7
|
+
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.B6SGTWpD.mjs';
|
|
8
|
+
import { d as deserializeState } from './shared/vite-react-ssg.C6pK7rvr.mjs';
|
|
9
|
+
import { j as joinUrlSegments, w as withLeadingSlash, s as stripBase } from './shared/vite-react-ssg.CjIppNIS.mjs';
|
|
10
|
+
import { c as convertRoutesToDataRoutes } from './shared/vite-react-ssg.C0y5wbxl.mjs';
|
|
9
11
|
|
|
10
12
|
const Link = forwardRef((props, ref) => {
|
|
11
13
|
const {
|
|
@@ -35,7 +37,7 @@ const Link = forwardRef((props, ref) => {
|
|
|
35
37
|
event.defaultPrevented = true;
|
|
36
38
|
event.preventDefault();
|
|
37
39
|
}
|
|
38
|
-
return /* @__PURE__ */
|
|
40
|
+
return /* @__PURE__ */ jsx(Link$1, { ...props, ref, onClick: handleClick });
|
|
39
41
|
});
|
|
40
42
|
Link.displayName = "Link";
|
|
41
43
|
const NavLink = forwardRef((props, ref) => {
|
|
@@ -66,7 +68,7 @@ const NavLink = forwardRef((props, ref) => {
|
|
|
66
68
|
event.defaultPrevented = true;
|
|
67
69
|
event.preventDefault();
|
|
68
70
|
}
|
|
69
|
-
return /* @__PURE__ */
|
|
71
|
+
return /* @__PURE__ */ jsx(NavLink$1, { ...props, ref, onClick: handleClick });
|
|
70
72
|
});
|
|
71
73
|
NavLink.displayName = "NavLink";
|
|
72
74
|
|
|
@@ -77,7 +79,7 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
77
79
|
ssrWhenDev,
|
|
78
80
|
getStyleCollector = null
|
|
79
81
|
} = options;
|
|
80
|
-
if (
|
|
82
|
+
if (import.meta.env.DEV && ssrWhenDev !== void 0)
|
|
81
83
|
console.warn("[vite-react-ssg] `ssrWhenDev` option is no longer needed. If you want to use csr, just replace `vite-react-ssg dev` with `vite`.");
|
|
82
84
|
const isClient = typeof window !== "undefined";
|
|
83
85
|
const BASE_URL = routerOptions.basename ?? "/";
|
|
@@ -100,7 +102,8 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
100
102
|
transformState,
|
|
101
103
|
routePath,
|
|
102
104
|
base: BASE_URL,
|
|
103
|
-
getStyleCollector
|
|
105
|
+
getStyleCollector,
|
|
106
|
+
routerType: "remix"
|
|
104
107
|
};
|
|
105
108
|
if (client) {
|
|
106
109
|
await documentReady();
|
|
@@ -133,9 +136,9 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
133
136
|
);
|
|
134
137
|
}
|
|
135
138
|
const { router } = await createRoot$1(true);
|
|
136
|
-
const app = /* @__PURE__ */
|
|
139
|
+
const app = /* @__PURE__ */ jsx(HelmetProvider, { children: /* @__PURE__ */ jsx(RouterProvider, { router }) });
|
|
137
140
|
const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
|
|
138
|
-
if (!isSSR &&
|
|
141
|
+
if (!isSSR && import.meta.env.DEV) {
|
|
139
142
|
const root = createRoot(container);
|
|
140
143
|
React.startTransition(() => {
|
|
141
144
|
root.render(app);
|
|
@@ -149,6 +152,10 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
149
152
|
}
|
|
150
153
|
return createRoot$1;
|
|
151
154
|
function transformStaticLoaderRoute(route) {
|
|
155
|
+
const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
|
|
156
|
+
if (!isSSR) {
|
|
157
|
+
return route;
|
|
158
|
+
}
|
|
152
159
|
const loader = async ({ request }) => {
|
|
153
160
|
if (import.meta.env.DEV) {
|
|
154
161
|
const routeId = encodeURIComponent(route.id);
|
package/dist/node/cli.cjs
CHANGED
|
@@ -3,22 +3,23 @@
|
|
|
3
3
|
const kolorist = require('kolorist');
|
|
4
4
|
const yargs = require('yargs');
|
|
5
5
|
const helpers = require('yargs/helpers');
|
|
6
|
-
const
|
|
6
|
+
const dev = require('../shared/vite-react-ssg.sc14Rk9F.cjs');
|
|
7
7
|
const webFetch = require('@remix-run/web-fetch');
|
|
8
8
|
require('node:path');
|
|
9
9
|
require('node:module');
|
|
10
|
+
require('p-queue');
|
|
10
11
|
require('fs-extra');
|
|
11
12
|
require('vite');
|
|
12
13
|
require('jsdom');
|
|
13
|
-
require('../shared/vite-react-ssg.
|
|
14
|
-
require('../shared/vite-react-ssg.
|
|
15
|
-
require('
|
|
16
|
-
require('react');
|
|
14
|
+
require('../shared/vite-react-ssg.CjsEygxB.cjs');
|
|
15
|
+
require('../shared/vite-react-ssg.CFQGqC60.cjs');
|
|
16
|
+
require('react/jsx-runtime');
|
|
17
17
|
require('react-helmet-async');
|
|
18
18
|
require('node:stream');
|
|
19
19
|
require('react-dom/server');
|
|
20
|
-
require('react-router-dom');
|
|
21
20
|
require('node:events');
|
|
21
|
+
require('../shared/vite-react-ssg.C2GpVZF1.cjs');
|
|
22
|
+
require('../shared/vite-react-ssg.D0EGioth.cjs');
|
|
22
23
|
|
|
23
24
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
24
25
|
|
|
@@ -53,7 +54,7 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("vite-react-ssg").usage
|
|
|
53
54
|
}),
|
|
54
55
|
async (args) => {
|
|
55
56
|
const { config: configFile = void 0, ...ssgOptions } = args;
|
|
56
|
-
await
|
|
57
|
+
await dev.build(ssgOptions, { configFile });
|
|
57
58
|
}
|
|
58
59
|
).command(
|
|
59
60
|
"dev",
|
|
@@ -78,7 +79,7 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("vite-react-ssg").usage
|
|
|
78
79
|
}),
|
|
79
80
|
async (args) => {
|
|
80
81
|
const { config: configFile = void 0, host, ...ssgOptions } = args;
|
|
81
|
-
await
|
|
82
|
+
await dev.dev(ssgOptions, { configFile, server: { host } });
|
|
82
83
|
}
|
|
83
84
|
).fail((msg, err, yargs2) => {
|
|
84
85
|
console.error(`
|