vite-react-ssg 0.8.0 → 0.8.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/README.md +26 -0
- package/bin/vite-react-ssg.js +0 -0
- package/dist/client/single-page.cjs +3 -3
- package/dist/client/single-page.d.cts +2 -2
- package/dist/client/single-page.d.mts +2 -2
- package/dist/client/single-page.d.ts +2 -2
- package/dist/client/single-page.mjs +4 -4
- package/dist/index.cjs +10 -6
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +11 -7
- package/dist/node/cli.cjs +1 -1
- package/dist/node/cli.mjs +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.mts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.mjs +1 -1
- package/dist/shared/{vite-react-ssg.D5dVt1Iv.cjs → vite-react-ssg.BEenhaUp.cjs} +10 -12
- package/dist/shared/{vite-react-ssg.DObRRhiz.mjs → vite-react-ssg.CCvTYWeJ.mjs} +9 -11
- package/dist/shared/{vite-react-ssg.B6SGTWpD.mjs → vite-react-ssg.DdDMKzrS.mjs} +1 -1
- package/dist/shared/{vite-react-ssg.MPbH7GTN.d.cts → vite-react-ssg.WtHsP9dD.d.cts} +10 -3
- package/dist/shared/{vite-react-ssg.MPbH7GTN.d.mts → vite-react-ssg.WtHsP9dD.d.mts} +10 -3
- package/dist/shared/{vite-react-ssg.MPbH7GTN.d.ts → vite-react-ssg.WtHsP9dD.d.ts} +10 -3
- package/dist/shared/{vite-react-ssg.BuZVBVT6.cjs → vite-react-ssg.yL7u7OP5.cjs} +1 -1
- package/dist/tanstack.cjs +4 -4
- package/dist/tanstack.d.cts +2 -2
- package/dist/tanstack.d.mts +2 -2
- package/dist/tanstack.d.ts +2 -2
- package/dist/tanstack.mjs +5 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,6 +7,9 @@ See demo(also document): [docs](https://vite-react-ssg.netlify.app/)
|
|
|
7
7
|
**🎈 Support for [`@tanstack/router`](https://tanstack.com/router/latest/docs/framework/react/overview)
|
|
8
8
|
and [`wouter`](https://github.com/molefrog/wouter) is in progress!**
|
|
9
9
|
|
|
10
|
+
Support for the [`@tanstack/router`](https://tanstack.com/router/latest/docs/framework/react/overview) router is still experimental, and `pathname.lazy.tsx routes` are not yet supported.
|
|
11
|
+
For usage examples, see: [`main`/examples/tanstack/src/main.tsx](https://github.com/Daydreamer-riri/vite-react-ssg/blob/main/examples/tanstack/src/main.tsx)
|
|
12
|
+
|
|
10
13
|
[](https://www.npmjs.com/package/vite-react-ssg)
|
|
11
14
|
|
|
12
15
|
## Table of contents
|
|
@@ -371,6 +374,29 @@ See: [react-router's create-browser-router](https://reactrouter.com/en/main/rout
|
|
|
371
374
|
|
|
372
375
|
[Example](./examples/lazy-pages/vite.config.ts)
|
|
373
376
|
|
|
377
|
+
## Future config
|
|
378
|
+
|
|
379
|
+
```tsx
|
|
380
|
+
export const createRoot = ViteReactSSG(
|
|
381
|
+
{
|
|
382
|
+
routes,
|
|
383
|
+
basename: import.meta.env.BASE_URL,
|
|
384
|
+
future: {
|
|
385
|
+
v7_normalizeFormMethod: true,
|
|
386
|
+
v7_startTransition: true,
|
|
387
|
+
v7_fetcherPersist: true,
|
|
388
|
+
v7_relativeSplatPath: true,
|
|
389
|
+
v7_skipActionErrorRevalidation: true,
|
|
390
|
+
v7_partialHydration: true,
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
)
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
See: [react-router's optsfuture](https://reactrouter.com/6.28.0/routers/create-browser-router#optsfuture)
|
|
397
|
+
|
|
398
|
+
[Example](./examples/lazy-pages/src/main.tsx)
|
|
399
|
+
|
|
374
400
|
## CSS in JS
|
|
375
401
|
|
|
376
402
|
Use the `getStyleCollector` option to specify an SSR/SSG style collector. Currently only supports `styled-components`.
|
package/bin/vite-react-ssg.js
CHANGED
|
File without changes
|
|
@@ -4,7 +4,7 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
const client = require('react-dom/client');
|
|
5
5
|
const reactHelmetAsync = require('react-helmet-async');
|
|
6
6
|
const React = require('react');
|
|
7
|
-
const ClientOnly = require('../shared/vite-react-ssg.
|
|
7
|
+
const ClientOnly = require('../shared/vite-react-ssg.yL7u7OP5.cjs');
|
|
8
8
|
const state = require('../shared/vite-react-ssg.CjsEygxB.cjs');
|
|
9
9
|
|
|
10
10
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
@@ -18,7 +18,7 @@ function ViteReactSSG(App, fn, options = {}) {
|
|
|
18
18
|
ssrWhenDev,
|
|
19
19
|
getStyleCollector = null
|
|
20
20
|
} = options;
|
|
21
|
-
if (
|
|
21
|
+
if (process.env.NODE_ENV === "development" && ssrWhenDev !== void 0)
|
|
22
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`.");
|
|
23
23
|
const isClient = typeof window !== "undefined";
|
|
24
24
|
async function createRoot(client = false, routePath) {
|
|
@@ -64,7 +64,7 @@ function ViteReactSSG(App, fn, options = {}) {
|
|
|
64
64
|
await createRoot(true);
|
|
65
65
|
const app = /* @__PURE__ */ jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: App });
|
|
66
66
|
const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
|
|
67
|
-
if (!isSSR &&
|
|
67
|
+
if (!isSSR && process.env.NODE_ENV === "development") {
|
|
68
68
|
const root = client.createRoot(container);
|
|
69
69
|
React__default.startTransition(() => {
|
|
70
70
|
root.render(app);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.
|
|
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.
|
|
2
|
+
import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.WtHsP9dD.cjs';
|
|
3
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, d as RouterOptions, S as StyleCollector, b as ViteReactSSGOptions } from '../shared/vite-react-ssg.WtHsP9dD.cjs';
|
|
4
4
|
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.Cm9gBlfg.cjs';
|
|
5
5
|
import 'react-router-dom';
|
|
6
6
|
import 'beasties';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.
|
|
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.
|
|
2
|
+
import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.WtHsP9dD.mjs';
|
|
3
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, d as RouterOptions, S as StyleCollector, b as ViteReactSSGOptions } from '../shared/vite-react-ssg.WtHsP9dD.mjs';
|
|
4
4
|
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.Cm9gBlfg.mjs';
|
|
5
5
|
import 'react-router-dom';
|
|
6
6
|
import 'beasties';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.
|
|
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.
|
|
2
|
+
import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.WtHsP9dD.js';
|
|
3
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, d as RouterOptions, S as StyleCollector, b as ViteReactSSGOptions } from '../shared/vite-react-ssg.WtHsP9dD.js';
|
|
4
4
|
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.Cm9gBlfg.js';
|
|
5
5
|
import 'react-router-dom';
|
|
6
6
|
import 'beasties';
|
|
@@ -2,8 +2,8 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
3
3
|
import { HelmetProvider } from 'react-helmet-async';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import { d as documentReady } from '../shared/vite-react-ssg.
|
|
6
|
-
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.
|
|
5
|
+
import { d as documentReady } from '../shared/vite-react-ssg.DdDMKzrS.mjs';
|
|
6
|
+
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.DdDMKzrS.mjs';
|
|
7
7
|
import { d as deserializeState } from '../shared/vite-react-ssg.C6pK7rvr.mjs';
|
|
8
8
|
|
|
9
9
|
function ViteReactSSG(App, fn, options = {}) {
|
|
@@ -13,7 +13,7 @@ function ViteReactSSG(App, fn, options = {}) {
|
|
|
13
13
|
ssrWhenDev,
|
|
14
14
|
getStyleCollector = null
|
|
15
15
|
} = options;
|
|
16
|
-
if (
|
|
16
|
+
if (process.env.NODE_ENV === "development" && ssrWhenDev !== void 0)
|
|
17
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`.");
|
|
18
18
|
const isClient = typeof window !== "undefined";
|
|
19
19
|
async function createRoot$1(client = false, routePath) {
|
|
@@ -59,7 +59,7 @@ function ViteReactSSG(App, fn, options = {}) {
|
|
|
59
59
|
await createRoot$1(true);
|
|
60
60
|
const app = /* @__PURE__ */ jsx(HelmetProvider, { children: App });
|
|
61
61
|
const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
|
|
62
|
-
if (!isSSR &&
|
|
62
|
+
if (!isSSR && process.env.NODE_ENV === "development") {
|
|
63
63
|
const root = createRoot(container);
|
|
64
64
|
React.startTransition(() => {
|
|
65
65
|
root.render(app);
|
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ const React = require('react');
|
|
|
5
5
|
const client = require('react-dom/client');
|
|
6
6
|
const reactHelmetAsync = require('react-helmet-async');
|
|
7
7
|
const reactRouterDom = require('react-router-dom');
|
|
8
|
-
const ClientOnly = require('./shared/vite-react-ssg.
|
|
8
|
+
const ClientOnly = require('./shared/vite-react-ssg.yL7u7OP5.cjs');
|
|
9
9
|
const state = require('./shared/vite-react-ssg.CjsEygxB.cjs');
|
|
10
10
|
const path = require('./shared/vite-react-ssg.CFQGqC60.cjs');
|
|
11
11
|
const remixRouter = require('./shared/vite-react-ssg.C2GpVZF1.cjs');
|
|
@@ -84,12 +84,16 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
84
84
|
ssrWhenDev,
|
|
85
85
|
getStyleCollector = null
|
|
86
86
|
} = options;
|
|
87
|
-
if (
|
|
87
|
+
if (process.env.NODE_ENV === "development" && ssrWhenDev !== void 0)
|
|
88
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`.");
|
|
89
89
|
const isClient = typeof window !== "undefined";
|
|
90
90
|
const BASE_URL = routerOptions.basename ?? "/";
|
|
91
|
+
const { v7_startTransition, ...routerFeature } = routerOptions.future ?? {};
|
|
91
92
|
async function createRoot(client = false, routePath) {
|
|
92
|
-
const browserRouter = client ? reactRouterDom.createBrowserRouter(
|
|
93
|
+
const browserRouter = client ? reactRouterDom.createBrowserRouter(
|
|
94
|
+
remixRouter.convertRoutesToDataRoutes(routerOptions.routes, transformStaticLoaderRoute),
|
|
95
|
+
{ basename: BASE_URL, future: routerFeature }
|
|
96
|
+
) : void 0;
|
|
93
97
|
const appRenderCallbacks = [];
|
|
94
98
|
const onSSRAppRendered = client ? () => {
|
|
95
99
|
} : (cb) => appRenderCallbacks.push(cb);
|
|
@@ -141,9 +145,9 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
141
145
|
);
|
|
142
146
|
}
|
|
143
147
|
const { router } = await createRoot(true);
|
|
144
|
-
const app = /* @__PURE__ */ jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.RouterProvider, { router }) });
|
|
148
|
+
const app = /* @__PURE__ */ jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.RouterProvider, { router, future: { v7_startTransition } }) });
|
|
145
149
|
const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
|
|
146
|
-
if (!isSSR &&
|
|
150
|
+
if (!isSSR && process.env.NODE_ENV === "development") {
|
|
147
151
|
const root = client.createRoot(container);
|
|
148
152
|
React__default.startTransition(() => {
|
|
149
153
|
root.render(app);
|
|
@@ -162,7 +166,7 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
162
166
|
return route;
|
|
163
167
|
}
|
|
164
168
|
const loader = async ({ request }) => {
|
|
165
|
-
if (
|
|
169
|
+
if (process.env.NODE_ENV === "development") {
|
|
166
170
|
const routeId = encodeURIComponent(route.id);
|
|
167
171
|
const dataQuery = `_data=${routeId}`;
|
|
168
172
|
const url = request.url.includes("?") ? `${request.url}&${dataQuery}` : `${request.url}?${dataQuery}`;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
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.
|
|
1
|
+
import { d as RouterOptions, V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.WtHsP9dD.cjs';
|
|
2
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.WtHsP9dD.cjs';
|
|
3
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';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
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.
|
|
1
|
+
import { d as RouterOptions, V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.WtHsP9dD.mjs';
|
|
2
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.WtHsP9dD.mjs';
|
|
3
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';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
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.
|
|
1
|
+
import { d as RouterOptions, V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.WtHsP9dD.js';
|
|
2
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.WtHsP9dD.js';
|
|
3
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';
|
package/dist/index.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import React, { forwardRef } from 'react';
|
|
|
3
3
|
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
4
4
|
import { HelmetProvider } from 'react-helmet-async';
|
|
5
5
|
import { useLinkClickHandler, Link as Link$1, NavLink as NavLink$1, matchRoutes, createBrowserRouter, RouterProvider } from 'react-router-dom';
|
|
6
|
-
import { d as documentReady } from './shared/vite-react-ssg.
|
|
7
|
-
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.
|
|
6
|
+
import { d as documentReady } from './shared/vite-react-ssg.DdDMKzrS.mjs';
|
|
7
|
+
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.DdDMKzrS.mjs';
|
|
8
8
|
import { d as deserializeState } from './shared/vite-react-ssg.C6pK7rvr.mjs';
|
|
9
9
|
import { j as joinUrlSegments, w as withLeadingSlash, s as stripBase } from './shared/vite-react-ssg.CjIppNIS.mjs';
|
|
10
10
|
import { c as convertRoutesToDataRoutes } from './shared/vite-react-ssg.C0y5wbxl.mjs';
|
|
@@ -79,12 +79,16 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
79
79
|
ssrWhenDev,
|
|
80
80
|
getStyleCollector = null
|
|
81
81
|
} = options;
|
|
82
|
-
if (
|
|
82
|
+
if (process.env.NODE_ENV === "development" && ssrWhenDev !== void 0)
|
|
83
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`.");
|
|
84
84
|
const isClient = typeof window !== "undefined";
|
|
85
85
|
const BASE_URL = routerOptions.basename ?? "/";
|
|
86
|
+
const { v7_startTransition, ...routerFeature } = routerOptions.future ?? {};
|
|
86
87
|
async function createRoot$1(client = false, routePath) {
|
|
87
|
-
const browserRouter = client ? createBrowserRouter(
|
|
88
|
+
const browserRouter = client ? createBrowserRouter(
|
|
89
|
+
convertRoutesToDataRoutes(routerOptions.routes, transformStaticLoaderRoute),
|
|
90
|
+
{ basename: BASE_URL, future: routerFeature }
|
|
91
|
+
) : void 0;
|
|
88
92
|
const appRenderCallbacks = [];
|
|
89
93
|
const onSSRAppRendered = client ? () => {
|
|
90
94
|
} : (cb) => appRenderCallbacks.push(cb);
|
|
@@ -136,9 +140,9 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
136
140
|
);
|
|
137
141
|
}
|
|
138
142
|
const { router } = await createRoot$1(true);
|
|
139
|
-
const app = /* @__PURE__ */ jsx(HelmetProvider, { children: /* @__PURE__ */ jsx(RouterProvider, { router }) });
|
|
143
|
+
const app = /* @__PURE__ */ jsx(HelmetProvider, { children: /* @__PURE__ */ jsx(RouterProvider, { router, future: { v7_startTransition } }) });
|
|
140
144
|
const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
|
|
141
|
-
if (!isSSR &&
|
|
145
|
+
if (!isSSR && process.env.NODE_ENV === "development") {
|
|
142
146
|
const root = createRoot(container);
|
|
143
147
|
React.startTransition(() => {
|
|
144
148
|
root.render(app);
|
|
@@ -157,7 +161,7 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
157
161
|
return route;
|
|
158
162
|
}
|
|
159
163
|
const loader = async ({ request }) => {
|
|
160
|
-
if (
|
|
164
|
+
if (process.env.NODE_ENV === "development") {
|
|
161
165
|
const routeId = encodeURIComponent(route.id);
|
|
162
166
|
const dataQuery = `_data=${routeId}`;
|
|
163
167
|
const url = request.url.includes("?") ? `${request.url}&${dataQuery}` : `${request.url}?${dataQuery}`;
|
package/dist/node/cli.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const kolorist = require('kolorist');
|
|
4
4
|
const yargs = require('yargs');
|
|
5
5
|
const helpers = require('yargs/helpers');
|
|
6
|
-
const dev = require('../shared/vite-react-ssg.
|
|
6
|
+
const dev = require('../shared/vite-react-ssg.BEenhaUp.cjs');
|
|
7
7
|
const webFetch = require('@remix-run/web-fetch');
|
|
8
8
|
require('node:path');
|
|
9
9
|
require('node:module');
|
package/dist/node/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { gray, bold, red, reset, underline } from 'kolorist';
|
|
2
2
|
import yargs from 'yargs';
|
|
3
3
|
import { hideBin } from 'yargs/helpers';
|
|
4
|
-
import { b as build, d as dev } from '../shared/vite-react-ssg.
|
|
4
|
+
import { b as build, d as dev } from '../shared/vite-react-ssg.CCvTYWeJ.mjs';
|
|
5
5
|
import { Headers, Request, Response, fetch, FormData } from '@remix-run/web-fetch';
|
|
6
6
|
import 'node:path';
|
|
7
7
|
import 'node:module';
|
package/dist/node.cjs
CHANGED
package/dist/node.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InlineConfig } from 'vite';
|
|
2
|
-
import { b as ViteReactSSGOptions } from './shared/vite-react-ssg.
|
|
2
|
+
import { b as ViteReactSSGOptions } from './shared/vite-react-ssg.WtHsP9dD.cjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'react-router-dom';
|
|
5
5
|
import 'beasties';
|
package/dist/node.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InlineConfig } from 'vite';
|
|
2
|
-
import { b as ViteReactSSGOptions } from './shared/vite-react-ssg.
|
|
2
|
+
import { b as ViteReactSSGOptions } from './shared/vite-react-ssg.WtHsP9dD.mjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'react-router-dom';
|
|
5
5
|
import 'beasties';
|
package/dist/node.d.ts
CHANGED
package/dist/node.mjs
CHANGED
|
@@ -23,7 +23,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
23
23
|
const PQueue__default = /*#__PURE__*/_interopDefaultCompat(PQueue);
|
|
24
24
|
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
25
25
|
|
|
26
|
-
const version = "0.8.
|
|
26
|
+
const version = "0.8.2";
|
|
27
27
|
|
|
28
28
|
function buildLog(text, count) {
|
|
29
29
|
console.log(`
|
|
@@ -458,7 +458,7 @@ class RemixAdapter {
|
|
|
458
458
|
this.context = context;
|
|
459
459
|
}
|
|
460
460
|
async render(path$1) {
|
|
461
|
-
const { base, routes, getStyleCollector } = this.context;
|
|
461
|
+
const { base, routes, getStyleCollector, routerOptions } = this.context;
|
|
462
462
|
const fetchUrl = `${path.withTrailingSlash(base)}${path.removeLeadingSlash(path$1)}`;
|
|
463
463
|
const request = createRequest(fetchUrl);
|
|
464
464
|
const styleCollector = getStyleCollector ? await getStyleCollector() : null;
|
|
@@ -470,7 +470,7 @@ class RemixAdapter {
|
|
|
470
470
|
if (_context instanceof Response)
|
|
471
471
|
throw _context;
|
|
472
472
|
routerContext = _context;
|
|
473
|
-
const router = createStaticRouter(dataRoutes, routerContext);
|
|
473
|
+
const router = createStaticRouter(dataRoutes, routerContext, { future: routerOptions.future });
|
|
474
474
|
let app = /* @__PURE__ */ jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { context: helmetContext, children: /* @__PURE__ */ jsxRuntime.jsx(StaticRouterProvider, { router, context: routerContext }) });
|
|
475
475
|
if (styleCollector)
|
|
476
476
|
app = styleCollector.collect(app);
|
|
@@ -755,8 +755,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
755
755
|
}
|
|
756
756
|
},
|
|
757
757
|
customLogger: clientLogger,
|
|
758
|
-
mode: config.mode
|
|
759
|
-
ssr: { noExternal: ["vite-react-ssg"] }
|
|
758
|
+
mode: config.mode
|
|
760
759
|
}));
|
|
761
760
|
if (mock) {
|
|
762
761
|
const { jsdomGlobal } = await import('../chunks/jsdomGlobal.cjs');
|
|
@@ -788,14 +787,13 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
788
787
|
}
|
|
789
788
|
}
|
|
790
789
|
},
|
|
791
|
-
mode: config.mode
|
|
792
|
-
ssr: { noExternal: ["vite-react-ssg", "vite-react-ssg/tanstack"] }
|
|
790
|
+
mode: config.mode
|
|
793
791
|
}));
|
|
794
792
|
const prefix = format === "esm" && process.platform === "win32" ? "file://" : "";
|
|
795
793
|
const ext = format === "esm" ? ".mjs" : ".cjs";
|
|
796
794
|
const serverEntry = node_path.join(prefix, ssgOut, node_path.parse(ssrEntry).name + ext);
|
|
797
795
|
const serverManifest = JSON.parse(await fs__default.readFile(node_path.join(ssgOut, ...dotVitedir, "manifest.json"), "utf-8"));
|
|
798
|
-
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/vite-react-ssg.
|
|
796
|
+
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/vite-react-ssg.BEenhaUp.cjs', document.baseURI).href)));
|
|
799
797
|
const { createRoot, includedRoutes: serverEntryIncludedRoutes } = format === "esm" ? await import(serverEntry) : _require(serverEntry);
|
|
800
798
|
const includedRoutes = serverEntryIncludedRoutes || configIncludedRoutes;
|
|
801
799
|
const { routes } = await createRoot(false);
|
|
@@ -932,9 +930,11 @@ function ssrServerPlugin({
|
|
|
932
930
|
[ssrEntry, entry].map(async (entry2) => await server.moduleGraph.getModuleByUrl(entry2))
|
|
933
931
|
);
|
|
934
932
|
const assetsUrls = /* @__PURE__ */ new Set();
|
|
933
|
+
const collectedMods = /* @__PURE__ */ new Set();
|
|
935
934
|
const collectAssets = async (mod) => {
|
|
936
|
-
if (!mod || !mod?.ssrTransformResult)
|
|
935
|
+
if (!mod || !mod?.ssrTransformResult || collectedMods.has(mod))
|
|
937
936
|
return;
|
|
937
|
+
collectedMods.add(mod);
|
|
938
938
|
const { deps = [], dynamicDeps = [] } = mod?.ssrTransformResult;
|
|
939
939
|
const allDeps = [...deps, ...dynamicDeps];
|
|
940
940
|
for (const dep of allDeps) {
|
|
@@ -1023,9 +1023,7 @@ ${err.stack}`
|
|
|
1023
1023
|
})
|
|
1024
1024
|
]
|
|
1025
1025
|
},
|
|
1026
|
-
{
|
|
1027
|
-
ssr: { noExternal: ["vite-react-ssg"] }
|
|
1028
|
-
}
|
|
1026
|
+
{}
|
|
1029
1027
|
)
|
|
1030
1028
|
);
|
|
1031
1029
|
await viteServer.listen();
|
|
@@ -15,7 +15,7 @@ import { once } from 'node:events';
|
|
|
15
15
|
import { c as convertRoutesToDataRoutes } from './vite-react-ssg.C0y5wbxl.mjs';
|
|
16
16
|
import { M as META_CONTAINER_ID } from './vite-react-ssg.B-j07kW6.mjs';
|
|
17
17
|
|
|
18
|
-
const version = "0.8.
|
|
18
|
+
const version = "0.8.2";
|
|
19
19
|
|
|
20
20
|
function buildLog(text, count) {
|
|
21
21
|
console.log(`
|
|
@@ -450,7 +450,7 @@ class RemixAdapter {
|
|
|
450
450
|
this.context = context;
|
|
451
451
|
}
|
|
452
452
|
async render(path) {
|
|
453
|
-
const { base, routes, getStyleCollector } = this.context;
|
|
453
|
+
const { base, routes, getStyleCollector, routerOptions } = this.context;
|
|
454
454
|
const fetchUrl = `${withTrailingSlash(base)}${removeLeadingSlash(path)}`;
|
|
455
455
|
const request = createRequest(fetchUrl);
|
|
456
456
|
const styleCollector = getStyleCollector ? await getStyleCollector() : null;
|
|
@@ -462,7 +462,7 @@ class RemixAdapter {
|
|
|
462
462
|
if (_context instanceof Response)
|
|
463
463
|
throw _context;
|
|
464
464
|
routerContext = _context;
|
|
465
|
-
const router = createStaticRouter(dataRoutes, routerContext);
|
|
465
|
+
const router = createStaticRouter(dataRoutes, routerContext, { future: routerOptions.future });
|
|
466
466
|
let app = /* @__PURE__ */ jsx(HelmetProvider, { context: helmetContext, children: /* @__PURE__ */ jsx(StaticRouterProvider, { router, context: routerContext }) });
|
|
467
467
|
if (styleCollector)
|
|
468
468
|
app = styleCollector.collect(app);
|
|
@@ -747,8 +747,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
747
747
|
}
|
|
748
748
|
},
|
|
749
749
|
customLogger: clientLogger,
|
|
750
|
-
mode: config.mode
|
|
751
|
-
ssr: { noExternal: ["vite-react-ssg"] }
|
|
750
|
+
mode: config.mode
|
|
752
751
|
}));
|
|
753
752
|
if (mock) {
|
|
754
753
|
const { jsdomGlobal } = await import('../chunks/jsdomGlobal.mjs');
|
|
@@ -780,8 +779,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
780
779
|
}
|
|
781
780
|
}
|
|
782
781
|
},
|
|
783
|
-
mode: config.mode
|
|
784
|
-
ssr: { noExternal: ["vite-react-ssg", "vite-react-ssg/tanstack"] }
|
|
782
|
+
mode: config.mode
|
|
785
783
|
}));
|
|
786
784
|
const prefix = format === "esm" && process.platform === "win32" ? "file://" : "";
|
|
787
785
|
const ext = format === "esm" ? ".mjs" : ".cjs";
|
|
@@ -924,9 +922,11 @@ function ssrServerPlugin({
|
|
|
924
922
|
[ssrEntry, entry].map(async (entry2) => await server.moduleGraph.getModuleByUrl(entry2))
|
|
925
923
|
);
|
|
926
924
|
const assetsUrls = /* @__PURE__ */ new Set();
|
|
925
|
+
const collectedMods = /* @__PURE__ */ new Set();
|
|
927
926
|
const collectAssets = async (mod) => {
|
|
928
|
-
if (!mod || !mod?.ssrTransformResult)
|
|
927
|
+
if (!mod || !mod?.ssrTransformResult || collectedMods.has(mod))
|
|
929
928
|
return;
|
|
929
|
+
collectedMods.add(mod);
|
|
930
930
|
const { deps = [], dynamicDeps = [] } = mod?.ssrTransformResult;
|
|
931
931
|
const allDeps = [...deps, ...dynamicDeps];
|
|
932
932
|
for (const dep of allDeps) {
|
|
@@ -1015,9 +1015,7 @@ ${err.stack}`
|
|
|
1015
1015
|
})
|
|
1016
1016
|
]
|
|
1017
1017
|
},
|
|
1018
|
-
{
|
|
1019
|
-
ssr: { noExternal: ["vite-react-ssg"] }
|
|
1020
|
-
}
|
|
1018
|
+
{}
|
|
1021
1019
|
)
|
|
1022
1020
|
);
|
|
1023
1021
|
await viteServer.listen();
|
|
@@ -29,7 +29,7 @@ function ClientOnly({
|
|
|
29
29
|
}) {
|
|
30
30
|
const isBrowser = useIsClient();
|
|
31
31
|
if (isBrowser) {
|
|
32
|
-
if (typeof children !== "function" &&
|
|
32
|
+
if (typeof children !== "function" && process.env.NODE_ENV === "development") {
|
|
33
33
|
throw new Error(
|
|
34
34
|
`vite-react-ssg error: The children of <ClientOnly> must be a "render function", e.g. <ClientOnly>{() => <span>{window.location.href}</span>}</ClientOnly>.
|
|
35
35
|
Current type: ${isValidElement(children) ? "React element" : typeof children}`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { NonIndexRouteObject, IndexRouteObject, createBrowserRouter } from 'react-router-dom';
|
|
2
|
+
import { NonIndexRouteObject, IndexRouteObject, FutureConfig, createBrowserRouter } from 'react-router-dom';
|
|
3
3
|
import { Options } from 'beasties';
|
|
4
4
|
|
|
5
5
|
type Router = ReturnType<typeof createBrowserRouter>;
|
|
@@ -187,10 +187,17 @@ type NonIndexRouteRecord = Omit<NonIndexRouteObject, 'children'> & {
|
|
|
187
187
|
} & CommonRouteOptions;
|
|
188
188
|
type IndexRouteRecord = IndexRouteObject & CommonRouteOptions;
|
|
189
189
|
type RouteRecord = NonIndexRouteRecord | IndexRouteRecord;
|
|
190
|
+
interface RouterFutureConfig {
|
|
191
|
+
v7_fetcherPersist?: boolean;
|
|
192
|
+
v7_normalizeFormMethod?: boolean;
|
|
193
|
+
v7_partialHydration?: boolean;
|
|
194
|
+
v7_relativeSplatPath?: boolean;
|
|
195
|
+
v7_skipActionErrorRevalidation?: boolean;
|
|
196
|
+
}
|
|
190
197
|
interface RouterOptions {
|
|
191
198
|
routes: RouteRecord[];
|
|
192
|
-
createFetchRequest?: <T>(req: T) => Request;
|
|
193
199
|
basename?: string;
|
|
200
|
+
future?: Partial<RouterFutureConfig & FutureConfig>;
|
|
194
201
|
}
|
|
195
202
|
interface StyleCollector {
|
|
196
203
|
collect: (app: ReactElement) => ReactElement;
|
|
@@ -203,4 +210,4 @@ declare module 'vite' {
|
|
|
203
210
|
}
|
|
204
211
|
}
|
|
205
212
|
|
|
206
|
-
export type { CrittersOptions as C, IndexRouteRecord as I, NonIndexRouteRecord as N, RouteRecord as R, StyleCollector as S, ViteReactSSGContext as V, ViteReactSSGClientOptions as a, ViteReactSSGOptions as b,
|
|
213
|
+
export type { CrittersOptions as C, IndexRouteRecord as I, NonIndexRouteRecord as N, RouteRecord as R, StyleCollector as S, ViteReactSSGContext as V, ViteReactSSGClientOptions as a, ViteReactSSGOptions as b, RouterFutureConfig as c, RouterOptions as d };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { NonIndexRouteObject, IndexRouteObject, createBrowserRouter } from 'react-router-dom';
|
|
2
|
+
import { NonIndexRouteObject, IndexRouteObject, FutureConfig, createBrowserRouter } from 'react-router-dom';
|
|
3
3
|
import { Options } from 'beasties';
|
|
4
4
|
|
|
5
5
|
type Router = ReturnType<typeof createBrowserRouter>;
|
|
@@ -187,10 +187,17 @@ type NonIndexRouteRecord = Omit<NonIndexRouteObject, 'children'> & {
|
|
|
187
187
|
} & CommonRouteOptions;
|
|
188
188
|
type IndexRouteRecord = IndexRouteObject & CommonRouteOptions;
|
|
189
189
|
type RouteRecord = NonIndexRouteRecord | IndexRouteRecord;
|
|
190
|
+
interface RouterFutureConfig {
|
|
191
|
+
v7_fetcherPersist?: boolean;
|
|
192
|
+
v7_normalizeFormMethod?: boolean;
|
|
193
|
+
v7_partialHydration?: boolean;
|
|
194
|
+
v7_relativeSplatPath?: boolean;
|
|
195
|
+
v7_skipActionErrorRevalidation?: boolean;
|
|
196
|
+
}
|
|
190
197
|
interface RouterOptions {
|
|
191
198
|
routes: RouteRecord[];
|
|
192
|
-
createFetchRequest?: <T>(req: T) => Request;
|
|
193
199
|
basename?: string;
|
|
200
|
+
future?: Partial<RouterFutureConfig & FutureConfig>;
|
|
194
201
|
}
|
|
195
202
|
interface StyleCollector {
|
|
196
203
|
collect: (app: ReactElement) => ReactElement;
|
|
@@ -203,4 +210,4 @@ declare module 'vite' {
|
|
|
203
210
|
}
|
|
204
211
|
}
|
|
205
212
|
|
|
206
|
-
export type { CrittersOptions as C, IndexRouteRecord as I, NonIndexRouteRecord as N, RouteRecord as R, StyleCollector as S, ViteReactSSGContext as V, ViteReactSSGClientOptions as a, ViteReactSSGOptions as b,
|
|
213
|
+
export type { CrittersOptions as C, IndexRouteRecord as I, NonIndexRouteRecord as N, RouteRecord as R, StyleCollector as S, ViteReactSSGContext as V, ViteReactSSGClientOptions as a, ViteReactSSGOptions as b, RouterFutureConfig as c, RouterOptions as d };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { NonIndexRouteObject, IndexRouteObject, createBrowserRouter } from 'react-router-dom';
|
|
2
|
+
import { NonIndexRouteObject, IndexRouteObject, FutureConfig, createBrowserRouter } from 'react-router-dom';
|
|
3
3
|
import { Options } from 'beasties';
|
|
4
4
|
|
|
5
5
|
type Router = ReturnType<typeof createBrowserRouter>;
|
|
@@ -187,10 +187,17 @@ type NonIndexRouteRecord = Omit<NonIndexRouteObject, 'children'> & {
|
|
|
187
187
|
} & CommonRouteOptions;
|
|
188
188
|
type IndexRouteRecord = IndexRouteObject & CommonRouteOptions;
|
|
189
189
|
type RouteRecord = NonIndexRouteRecord | IndexRouteRecord;
|
|
190
|
+
interface RouterFutureConfig {
|
|
191
|
+
v7_fetcherPersist?: boolean;
|
|
192
|
+
v7_normalizeFormMethod?: boolean;
|
|
193
|
+
v7_partialHydration?: boolean;
|
|
194
|
+
v7_relativeSplatPath?: boolean;
|
|
195
|
+
v7_skipActionErrorRevalidation?: boolean;
|
|
196
|
+
}
|
|
190
197
|
interface RouterOptions {
|
|
191
198
|
routes: RouteRecord[];
|
|
192
|
-
createFetchRequest?: <T>(req: T) => Request;
|
|
193
199
|
basename?: string;
|
|
200
|
+
future?: Partial<RouterFutureConfig & FutureConfig>;
|
|
194
201
|
}
|
|
195
202
|
interface StyleCollector {
|
|
196
203
|
collect: (app: ReactElement) => ReactElement;
|
|
@@ -203,4 +210,4 @@ declare module 'vite' {
|
|
|
203
210
|
}
|
|
204
211
|
}
|
|
205
212
|
|
|
206
|
-
export type { CrittersOptions as C, IndexRouteRecord as I, NonIndexRouteRecord as N, RouteRecord as R, StyleCollector as S, ViteReactSSGContext as V, ViteReactSSGClientOptions as a, ViteReactSSGOptions as b,
|
|
213
|
+
export type { CrittersOptions as C, IndexRouteRecord as I, NonIndexRouteRecord as N, RouteRecord as R, StyleCollector as S, ViteReactSSGContext as V, ViteReactSSGClientOptions as a, ViteReactSSGOptions as b, RouterFutureConfig as c, RouterOptions as d };
|
|
@@ -31,7 +31,7 @@ function ClientOnly({
|
|
|
31
31
|
}) {
|
|
32
32
|
const isBrowser = useIsClient();
|
|
33
33
|
if (isBrowser) {
|
|
34
|
-
if (typeof children !== "function" &&
|
|
34
|
+
if (typeof children !== "function" && process.env.NODE_ENV === "development") {
|
|
35
35
|
throw new Error(
|
|
36
36
|
`vite-react-ssg error: The children of <ClientOnly> must be a "render function", e.g. <ClientOnly>{() => <span>{window.location.href}</span>}</ClientOnly>.
|
|
37
37
|
Current type: ${React.isValidElement(children) ? "React element" : typeof children}`
|
package/dist/tanstack.cjs
CHANGED
|
@@ -6,7 +6,7 @@ const client = require('react-dom/client');
|
|
|
6
6
|
const reactHelmetAsync = require('react-helmet-async');
|
|
7
7
|
const reactRouter = require('@tanstack/react-router');
|
|
8
8
|
const start = require('@tanstack/start');
|
|
9
|
-
const ClientOnly = require('./shared/vite-react-ssg.
|
|
9
|
+
const ClientOnly = require('./shared/vite-react-ssg.yL7u7OP5.cjs');
|
|
10
10
|
const state = require('./shared/vite-react-ssg.CjsEygxB.cjs');
|
|
11
11
|
const tanstackRouter = require('./shared/vite-react-ssg.DWHmkjdM.cjs');
|
|
12
12
|
const path = require('./shared/vite-react-ssg.CFQGqC60.cjs');
|
|
@@ -23,7 +23,7 @@ function Experimental_ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
23
23
|
ssrWhenDev,
|
|
24
24
|
getStyleCollector = null
|
|
25
25
|
} = options;
|
|
26
|
-
if (
|
|
26
|
+
if (process.env.NODE_ENV === "development" && ssrWhenDev !== void 0)
|
|
27
27
|
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`.");
|
|
28
28
|
const isClient = typeof window !== "undefined";
|
|
29
29
|
const BASE_URL = routerOptions.basename ?? "/";
|
|
@@ -49,7 +49,7 @@ function Experimental_ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
49
49
|
return;
|
|
50
50
|
node.options.loader = async (ctx) => {
|
|
51
51
|
let pathname = ctx.location.pathname;
|
|
52
|
-
if (
|
|
52
|
+
if (process.env.NODE_ENV === "development") {
|
|
53
53
|
const routeId = encodeURIComponent(node.id);
|
|
54
54
|
const dataQuery = `_data=${routeId}`;
|
|
55
55
|
const href = ctx.location.href;
|
|
@@ -124,7 +124,7 @@ function Experimental_ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
124
124
|
}
|
|
125
125
|
const { router } = await createRoot(true);
|
|
126
126
|
const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
|
|
127
|
-
if (!isSSR &&
|
|
127
|
+
if (!isSSR && process.env.NODE_ENV === "development") {
|
|
128
128
|
const root = client.createRoot(container);
|
|
129
129
|
React__default.startTransition(() => {
|
|
130
130
|
root.render(
|
package/dist/tanstack.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyRouter } from '@tanstack/react-router';
|
|
2
|
-
import { V as ViteReactSSGContext$1, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.
|
|
3
|
-
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.
|
|
2
|
+
import { V as ViteReactSSGContext$1, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.WtHsP9dD.cjs';
|
|
3
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.WtHsP9dD.cjs';
|
|
4
4
|
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.Cm9gBlfg.cjs';
|
|
5
5
|
import 'react';
|
|
6
6
|
import 'react-router-dom';
|
package/dist/tanstack.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyRouter } from '@tanstack/react-router';
|
|
2
|
-
import { V as ViteReactSSGContext$1, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.
|
|
3
|
-
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.
|
|
2
|
+
import { V as ViteReactSSGContext$1, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.WtHsP9dD.mjs';
|
|
3
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.WtHsP9dD.mjs';
|
|
4
4
|
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.Cm9gBlfg.mjs';
|
|
5
5
|
import 'react';
|
|
6
6
|
import 'react-router-dom';
|
package/dist/tanstack.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyRouter } from '@tanstack/react-router';
|
|
2
|
-
import { V as ViteReactSSGContext$1, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.
|
|
3
|
-
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.
|
|
2
|
+
import { V as ViteReactSSGContext$1, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.WtHsP9dD.js';
|
|
3
|
+
export { C as CrittersOptions, I as IndexRouteRecord, N as NonIndexRouteRecord, R as RouteRecord, c as RouterFutureConfig, S as StyleCollector, b as ViteReactSSGOptions } from './shared/vite-react-ssg.WtHsP9dD.js';
|
|
4
4
|
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.Cm9gBlfg.js';
|
|
5
5
|
import 'react';
|
|
6
6
|
import 'react-router-dom';
|
package/dist/tanstack.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
|
4
4
|
import { HelmetProvider } from 'react-helmet-async';
|
|
5
5
|
import { RouterProvider } from '@tanstack/react-router';
|
|
6
6
|
import { StartClient, Meta } from '@tanstack/start';
|
|
7
|
-
import { d as documentReady } from './shared/vite-react-ssg.
|
|
8
|
-
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.
|
|
7
|
+
import { d as documentReady } from './shared/vite-react-ssg.DdDMKzrS.mjs';
|
|
8
|
+
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.DdDMKzrS.mjs';
|
|
9
9
|
import { d as deserializeState } from './shared/vite-react-ssg.C6pK7rvr.mjs';
|
|
10
10
|
import { M as META_CONTAINER_ID, c as convertRouteTreeToRouteOption } from './shared/vite-react-ssg.B-j07kW6.mjs';
|
|
11
11
|
export { r as registerPaths } from './shared/vite-react-ssg.B-j07kW6.mjs';
|
|
@@ -19,7 +19,7 @@ function Experimental_ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
19
19
|
ssrWhenDev,
|
|
20
20
|
getStyleCollector = null
|
|
21
21
|
} = options;
|
|
22
|
-
if (
|
|
22
|
+
if (process.env.NODE_ENV === "development" && ssrWhenDev !== void 0)
|
|
23
23
|
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`.");
|
|
24
24
|
const isClient = typeof window !== "undefined";
|
|
25
25
|
const BASE_URL = routerOptions.basename ?? "/";
|
|
@@ -45,7 +45,7 @@ function Experimental_ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
45
45
|
return;
|
|
46
46
|
node.options.loader = async (ctx) => {
|
|
47
47
|
let pathname = ctx.location.pathname;
|
|
48
|
-
if (
|
|
48
|
+
if (process.env.NODE_ENV === "development") {
|
|
49
49
|
const routeId = encodeURIComponent(node.id);
|
|
50
50
|
const dataQuery = `_data=${routeId}`;
|
|
51
51
|
const href = ctx.location.href;
|
|
@@ -120,7 +120,7 @@ function Experimental_ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
120
120
|
}
|
|
121
121
|
const { router } = await createRoot$1(true);
|
|
122
122
|
const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
|
|
123
|
-
if (!isSSR &&
|
|
123
|
+
if (!isSSR && process.env.NODE_ENV === "development") {
|
|
124
124
|
const root = createRoot(container);
|
|
125
125
|
React.startTransition(() => {
|
|
126
126
|
root.render(
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-react-ssg",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.2",
|
|
5
5
|
"packageManager": "pnpm@9.12.3",
|
|
6
6
|
"description": "Static-site generation for React on Vite.",
|
|
7
7
|
"author": "Riri <Daydreamerriri@outlook.com>",
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
"prettier": "^3.3.3",
|
|
145
145
|
"react": "^18.2.0",
|
|
146
146
|
"react-dom": "^18.2.0",
|
|
147
|
-
"react-router-dom": "^6.
|
|
147
|
+
"react-router-dom": "^6.28.0",
|
|
148
148
|
"rimraf": "5.0.1",
|
|
149
149
|
"styled-components": "6.0.5",
|
|
150
150
|
"typescript": "^5.6.2",
|