vite-react-ssg 0.8.5 → 0.8.7
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 +1 -0
- package/dist/client/single-page.d.mts +2 -2
- package/dist/client/single-page.d.ts +2 -2
- package/dist/client/single-page.mjs +5 -5
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +6 -6
- package/dist/node/cli.mjs +4 -4
- package/dist/node.d.mts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.mjs +2 -2
- package/dist/shared/{vite-react-ssg.D2OE2Bw1.d.mts → vite-react-ssg.B2xAADcy.d.mts} +2 -2
- package/dist/shared/{vite-react-ssg.D2OE2Bw1.d.ts → vite-react-ssg.B2xAADcy.d.ts} +2 -2
- package/dist/shared/{vite-react-ssg.Dx4ca9OM.mjs → vite-react-ssg.BxjO14Et.mjs} +2 -2
- package/dist/shared/{vite-react-ssg.C_MPXL9p.mjs → vite-react-ssg.C0y5wbxl.mjs} +1 -1
- package/dist/shared/{vite-react-ssg.EDckwhJo.mjs → vite-react-ssg.DJ8C7Edx.mjs} +17 -16
- package/dist/tanstack.d.mts +2 -2
- package/dist/tanstack.d.ts +2 -2
- package/dist/tanstack.mjs +4 -4
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ and [`wouter`](https://github.com/molefrog/wouter) is in progress!**
|
|
|
10
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
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
12
|
|
|
13
|
+
[](https://github.com/vitejs/awesome-vite)
|
|
13
14
|
[](https://www.npmjs.com/package/vite-react-ssg)
|
|
14
15
|
|
|
15
16
|
## Table of contents
|
|
@@ -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 RouterFutureConfig, d 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.B2xAADcy.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.B2xAADcy.mjs';
|
|
4
4
|
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.-NlgsPvg.mjs';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'react-router-dom';
|
|
@@ -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 RouterFutureConfig, d 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.B2xAADcy.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.B2xAADcy.js';
|
|
4
4
|
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.-NlgsPvg.js';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'react-router-dom';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { HelmetProvider } from 'react-helmet-async';
|
|
3
|
-
import { r as render, h as hydrate, d as documentReady } from '../shared/vite-react-ssg.
|
|
4
|
-
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.
|
|
3
|
+
import { r as render, h as hydrate, d as documentReady } from '../shared/vite-react-ssg.BxjO14Et.mjs';
|
|
4
|
+
export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.BxjO14Et.mjs';
|
|
5
5
|
import { d as deserializeState } from '../shared/vite-react-ssg.C6pK7rvr.mjs';
|
|
6
6
|
import 'react';
|
|
7
7
|
import 'react-dom';
|
|
@@ -13,7 +13,7 @@ function ViteReactSSG(App, fn, options = {}) {
|
|
|
13
13
|
ssrWhenDev,
|
|
14
14
|
getStyleCollector = null
|
|
15
15
|
} = options;
|
|
16
|
-
if (process.env.NODE_ENV === "development" && ssrWhenDev !==
|
|
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(client = false, routePath) {
|
|
@@ -31,8 +31,8 @@ function ViteReactSSG(App, fn, options = {}) {
|
|
|
31
31
|
transformState,
|
|
32
32
|
routePath,
|
|
33
33
|
getStyleCollector,
|
|
34
|
-
routes:
|
|
35
|
-
routerOptions:
|
|
34
|
+
routes: void 0,
|
|
35
|
+
routerOptions: void 0,
|
|
36
36
|
base: "/",
|
|
37
37
|
app: App,
|
|
38
38
|
routerType: "single-page"
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as ViteReactSSGContext, d as RouterOptions, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.
|
|
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.
|
|
1
|
+
import { V as ViteReactSSGContext, d as RouterOptions, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.B2xAADcy.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.B2xAADcy.mjs';
|
|
3
3
|
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.-NlgsPvg.mjs';
|
|
4
4
|
import { LinkProps, NavLinkProps } from 'react-router-dom';
|
|
5
5
|
import React from 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as ViteReactSSGContext, d as RouterOptions, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.
|
|
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.
|
|
1
|
+
import { V as ViteReactSSGContext, d as RouterOptions, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.B2xAADcy.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.B2xAADcy.js';
|
|
3
3
|
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.-NlgsPvg.js';
|
|
4
4
|
import { LinkProps, NavLinkProps } from 'react-router-dom';
|
|
5
5
|
import React from 'react';
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { HelmetProvider } from 'react-helmet-async';
|
|
3
3
|
import { useLinkClickHandler, Link as Link$1, NavLink as NavLink$1, matchRoutes, createBrowserRouter, RouterProvider } from 'react-router-dom';
|
|
4
|
-
import { r as render, h as hydrate, d as documentReady } from './shared/vite-react-ssg.
|
|
5
|
-
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.
|
|
4
|
+
import { r as render, h as hydrate, d as documentReady } from './shared/vite-react-ssg.BxjO14Et.mjs';
|
|
5
|
+
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.BxjO14Et.mjs';
|
|
6
6
|
import { j as joinUrlSegments, w as withLeadingSlash, s as stripBase } from './shared/vite-react-ssg.CjIppNIS.mjs';
|
|
7
|
-
import { c as convertRoutesToDataRoutes } from './shared/vite-react-ssg.
|
|
7
|
+
import { c as convertRoutesToDataRoutes } from './shared/vite-react-ssg.C0y5wbxl.mjs';
|
|
8
8
|
import { d as deserializeState } from './shared/vite-react-ssg.C6pK7rvr.mjs';
|
|
9
9
|
import React, { forwardRef } from 'react';
|
|
10
10
|
import 'react-dom';
|
|
@@ -79,7 +79,7 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
79
79
|
ssrWhenDev,
|
|
80
80
|
getStyleCollector = null
|
|
81
81
|
} = options;
|
|
82
|
-
if (process.env.NODE_ENV === "development" && ssrWhenDev !==
|
|
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 ?? "/";
|
|
@@ -88,7 +88,7 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
88
88
|
const browserRouter = client ? createBrowserRouter(
|
|
89
89
|
convertRoutesToDataRoutes(routerOptions.routes, transformStaticLoaderRoute),
|
|
90
90
|
{ basename: BASE_URL, future: routerFeature }
|
|
91
|
-
) :
|
|
91
|
+
) : void 0;
|
|
92
92
|
const appRenderCallbacks = [];
|
|
93
93
|
const onSSRAppRendered = client ? () => {
|
|
94
94
|
} : (cb) => appRenderCallbacks.push(cb);
|
|
@@ -135,7 +135,7 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
135
135
|
await Promise.all(
|
|
136
136
|
lazeMatches.map(async (m) => {
|
|
137
137
|
const routeModule = await m.route.lazy();
|
|
138
|
-
Object.assign(m.route, { ...routeModule, lazy:
|
|
138
|
+
Object.assign(m.route, { ...routeModule, lazy: void 0 });
|
|
139
139
|
})
|
|
140
140
|
);
|
|
141
141
|
}
|
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.DJ8C7Edx.mjs';
|
|
5
5
|
import { Headers, Request, Response, fetch, FormData } from '@remix-run/web-fetch';
|
|
6
6
|
import 'node:module';
|
|
7
7
|
import 'node:path';
|
|
@@ -15,7 +15,7 @@ import 'react/jsx-runtime';
|
|
|
15
15
|
import 'react-helmet-async';
|
|
16
16
|
import 'node:events';
|
|
17
17
|
import 'node:stream';
|
|
18
|
-
import '../shared/vite-react-ssg.
|
|
18
|
+
import '../shared/vite-react-ssg.C0y5wbxl.mjs';
|
|
19
19
|
import 'react-dom/server';
|
|
20
20
|
import '../shared/vite-react-ssg.B-j07kW6.mjs';
|
|
21
21
|
|
|
@@ -47,7 +47,7 @@ yargs(hideBin(process.argv)).scriptName("vite-react-ssg").usage("$0 [args]").com
|
|
|
47
47
|
describe: "The base path to render"
|
|
48
48
|
}),
|
|
49
49
|
async (args) => {
|
|
50
|
-
const { config: configFile =
|
|
50
|
+
const { config: configFile = void 0, ...ssgOptions } = args;
|
|
51
51
|
await build(ssgOptions, { configFile });
|
|
52
52
|
}
|
|
53
53
|
).command(
|
|
@@ -72,7 +72,7 @@ yargs(hideBin(process.argv)).scriptName("vite-react-ssg").usage("$0 [args]").com
|
|
|
72
72
|
describe: "The host to expose"
|
|
73
73
|
}),
|
|
74
74
|
async (args) => {
|
|
75
|
-
const { config: configFile =
|
|
75
|
+
const { config: configFile = void 0, host, ...ssgOptions } = args;
|
|
76
76
|
await dev(ssgOptions, { configFile, server: { host } });
|
|
77
77
|
}
|
|
78
78
|
).fail((msg, err, yargs2) => {
|
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.B2xAADcy.mjs';
|
|
3
3
|
import 'beasties';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'react-router-dom';
|
package/dist/node.d.ts
CHANGED
package/dist/node.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { b as build, d as dev } from './shared/vite-react-ssg.
|
|
1
|
+
export { b as build, d as dev } from './shared/vite-react-ssg.DJ8C7Edx.mjs';
|
|
2
2
|
import 'node:module';
|
|
3
3
|
import 'node:path';
|
|
4
4
|
import 'fs-extra';
|
|
@@ -12,6 +12,6 @@ import 'react/jsx-runtime';
|
|
|
12
12
|
import 'react-helmet-async';
|
|
13
13
|
import 'node:events';
|
|
14
14
|
import 'node:stream';
|
|
15
|
-
import './shared/vite-react-ssg.
|
|
15
|
+
import './shared/vite-react-ssg.C0y5wbxl.mjs';
|
|
16
16
|
import 'react-dom/server';
|
|
17
17
|
import './shared/vite-react-ssg.B-j07kW6.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Options } from 'beasties';
|
|
2
|
-
import {
|
|
3
|
-
import { NonIndexRouteObject, IndexRouteObject, FutureConfig
|
|
2
|
+
import { ReactElement, ReactNode } from 'react';
|
|
3
|
+
import { createBrowserRouter, NonIndexRouteObject, IndexRouteObject, FutureConfig } from 'react-router-dom';
|
|
4
4
|
|
|
5
5
|
type Router = ReturnType<typeof createBrowserRouter>;
|
|
6
6
|
interface CrittersOptions {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Options } from 'beasties';
|
|
2
|
-
import {
|
|
3
|
-
import { NonIndexRouteObject, IndexRouteObject, FutureConfig
|
|
2
|
+
import { ReactElement, ReactNode } from 'react';
|
|
3
|
+
import { createBrowserRouter, NonIndexRouteObject, IndexRouteObject, FutureConfig } from 'react-router-dom';
|
|
4
4
|
|
|
5
5
|
type Router = ReturnType<typeof createBrowserRouter>;
|
|
6
6
|
interface CrittersOptions {
|
|
@@ -14,7 +14,7 @@ function render(app, container, renderOptions = {}) {
|
|
|
14
14
|
if (useLegacyRender || !isReact18) {
|
|
15
15
|
reactRender(app, container);
|
|
16
16
|
} else if (isReact19) {
|
|
17
|
-
import('react-dom/client').then(({ createRoot }) => {
|
|
17
|
+
import('react-dom/client').then(({ default: { createRoot } }) => {
|
|
18
18
|
const root = createRoot(container);
|
|
19
19
|
React.startTransition(() => {
|
|
20
20
|
root.render(app);
|
|
@@ -38,7 +38,7 @@ function hydrate(app, container, renderOptions = {}) {
|
|
|
38
38
|
if (useLegacyRender || !isReact18) {
|
|
39
39
|
reactHydrate(app, container);
|
|
40
40
|
} else if (isReact19) {
|
|
41
|
-
import('react-dom/client').then(({ hydrateRoot }) => {
|
|
41
|
+
import('react-dom/client').then(({ default: { hydrateRoot } }) => {
|
|
42
42
|
React.startTransition(() => {
|
|
43
43
|
hydrateRoot(container, app);
|
|
44
44
|
});
|
|
@@ -15,7 +15,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath = [])
|
|
|
15
15
|
...route,
|
|
16
16
|
...mapRouteProperties(route),
|
|
17
17
|
id,
|
|
18
|
-
children:
|
|
18
|
+
children: void 0
|
|
19
19
|
};
|
|
20
20
|
if (route.children) {
|
|
21
21
|
pathOrLayoutRoute.children = convertRoutesToDataRoutes(
|
|
@@ -11,7 +11,7 @@ import { jsx, Fragment } from 'react/jsx-runtime';
|
|
|
11
11
|
import { HelmetProvider } from 'react-helmet-async';
|
|
12
12
|
import { once } from 'node:events';
|
|
13
13
|
import { Readable, Writable } from 'node:stream';
|
|
14
|
-
import { c as convertRoutesToDataRoutes } from './vite-react-ssg.
|
|
14
|
+
import { c as convertRoutesToDataRoutes } from './vite-react-ssg.C0y5wbxl.mjs';
|
|
15
15
|
import * as ReactDomServer from 'react-dom/server';
|
|
16
16
|
import { M as META_CONTAINER_ID } from './vite-react-ssg.B-j07kW6.mjs';
|
|
17
17
|
|
|
@@ -103,7 +103,7 @@ async function getBeastiesOrCritters(outDir, options = {}) {
|
|
|
103
103
|
...options
|
|
104
104
|
});
|
|
105
105
|
} catch (e) {
|
|
106
|
-
return
|
|
106
|
+
return void 0;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -117,8 +117,7 @@ async function renderHTML({
|
|
|
117
117
|
htmlAttributes,
|
|
118
118
|
initialState
|
|
119
119
|
}) {
|
|
120
|
-
const stateScript =
|
|
121
|
-
<script>window.__INITIAL_STATE__=${initialState}<\/script>` : "";
|
|
120
|
+
const stateScript = "";
|
|
122
121
|
const scriptPlaceHolder = `
|
|
123
122
|
<script>${SCRIPT_COMMENT_PLACEHOLDER}<\/script>`;
|
|
124
123
|
const headStartTag = "<head>";
|
|
@@ -277,7 +276,7 @@ async function toNodeRequest(res, nodeRes) {
|
|
|
277
276
|
}
|
|
278
277
|
}
|
|
279
278
|
function json(data, init) {
|
|
280
|
-
if (init ===
|
|
279
|
+
if (init === void 0) {
|
|
281
280
|
init = {};
|
|
282
281
|
}
|
|
283
282
|
const responseInit = typeof init === "number" ? {
|
|
@@ -357,7 +356,7 @@ class WritableAsPromise extends Writable {
|
|
|
357
356
|
}
|
|
358
357
|
}
|
|
359
358
|
|
|
360
|
-
const version = "0.8.
|
|
359
|
+
const version = "0.8.7";
|
|
361
360
|
|
|
362
361
|
function buildLog(text, count) {
|
|
363
362
|
console.log(`
|
|
@@ -428,7 +427,7 @@ function isDynamicSegmentsRoute(route) {
|
|
|
428
427
|
return dynamicRE.test(route);
|
|
429
428
|
}
|
|
430
429
|
|
|
431
|
-
function extractHelmet(context, styleCollector) {
|
|
430
|
+
function extractHelmet(html, context, styleCollector) {
|
|
432
431
|
const { helmet } = context;
|
|
433
432
|
const htmlAttributes = helmet.htmlAttributes.toString();
|
|
434
433
|
const bodyAttributes = helmet.bodyAttributes.toString();
|
|
@@ -442,7 +441,7 @@ function extractHelmet(context, styleCollector) {
|
|
|
442
441
|
helmet.link.toString(),
|
|
443
442
|
helmet.script.toString()
|
|
444
443
|
];
|
|
445
|
-
const styleTag = styleCollector?.toString?.(
|
|
444
|
+
const styleTag = styleCollector?.toString?.(html) ?? "";
|
|
446
445
|
const metaAttributes = metaStrings.filter(Boolean);
|
|
447
446
|
return { htmlAttributes, bodyAttributes, metaAttributes, styleTag };
|
|
448
447
|
}
|
|
@@ -470,7 +469,7 @@ class RemixAdapter {
|
|
|
470
469
|
if (styleCollector)
|
|
471
470
|
app = styleCollector.collect(app);
|
|
472
471
|
const appHTML = await renderStaticApp(app);
|
|
473
|
-
const { htmlAttributes, bodyAttributes, metaAttributes, styleTag } = extractHelmet(helmetContext, styleCollector);
|
|
472
|
+
const { htmlAttributes, bodyAttributes, metaAttributes, styleTag } = extractHelmet(appHTML, helmetContext, styleCollector);
|
|
474
473
|
return { appHTML, htmlAttributes, bodyAttributes, metaAttributes, styleTag, routerContext };
|
|
475
474
|
}
|
|
476
475
|
handleLoader = async (req, res) => {
|
|
@@ -528,7 +527,7 @@ async function callRouteLoader({
|
|
|
528
527
|
request: stripDataParam(stripIndexParam(request)),
|
|
529
528
|
params
|
|
530
529
|
});
|
|
531
|
-
if (result ===
|
|
530
|
+
if (result === void 0) {
|
|
532
531
|
throw new Error(
|
|
533
532
|
`You defined a loader for route "${routeId}" but didn't return anything from your \`loader\` function. Please return a value or \`null\`.`
|
|
534
533
|
);
|
|
@@ -576,7 +575,7 @@ class SinglePageAdapter {
|
|
|
576
575
|
if (styleCollector)
|
|
577
576
|
app = styleCollector.collect(app);
|
|
578
577
|
const appHTML = await renderStaticApp(app);
|
|
579
|
-
const { htmlAttributes, bodyAttributes, metaAttributes, styleTag } = extractHelmet(helmetContext, styleCollector);
|
|
578
|
+
const { htmlAttributes, bodyAttributes, metaAttributes, styleTag } = extractHelmet(appHTML, helmetContext, styleCollector);
|
|
580
579
|
return { appHTML, htmlAttributes, bodyAttributes, metaAttributes, styleTag, routerContext: { loaderData: {} } };
|
|
581
580
|
};
|
|
582
581
|
handleLoader = () => {
|
|
@@ -613,7 +612,7 @@ class TanstackAdapter {
|
|
|
613
612
|
const appHTML = await renderStaticApp(app);
|
|
614
613
|
const jsdom = new JSDOM(appHTML);
|
|
615
614
|
const headElements = jsdom.window.document.querySelector(`#${META_CONTAINER_ID}`);
|
|
616
|
-
const { htmlAttributes, bodyAttributes, metaAttributes, styleTag } = extractHelmet(helmetContext, styleCollector);
|
|
615
|
+
const { htmlAttributes, bodyAttributes, metaAttributes, styleTag } = extractHelmet(appHTML, helmetContext, styleCollector);
|
|
617
616
|
if (headElements?.innerHTML) {
|
|
618
617
|
metaAttributes.unshift(headElements.innerHTML);
|
|
619
618
|
headElements.innerHTML = "";
|
|
@@ -649,7 +648,8 @@ class TanstackAdapter {
|
|
|
649
648
|
loaderDeps,
|
|
650
649
|
abortController,
|
|
651
650
|
context,
|
|
652
|
-
cause
|
|
651
|
+
cause,
|
|
652
|
+
index
|
|
653
653
|
} = _match;
|
|
654
654
|
const search = router.options.parseSearch(url.search);
|
|
655
655
|
const searchStr = router.options.stringifySearch(search);
|
|
@@ -665,10 +665,11 @@ class TanstackAdapter {
|
|
|
665
665
|
...url,
|
|
666
666
|
search,
|
|
667
667
|
searchStr,
|
|
668
|
-
state: {}
|
|
668
|
+
state: { __TSR_index: index }
|
|
669
669
|
},
|
|
670
670
|
cause,
|
|
671
|
-
route: matchRoute
|
|
671
|
+
route: matchRoute,
|
|
672
|
+
parentMatchPromise: null
|
|
672
673
|
};
|
|
673
674
|
};
|
|
674
675
|
const loaderData = await matchRoute.options.loader?.(getLoaderContext());
|
|
@@ -800,7 +801,7 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
800
801
|
routesPaths = DefaultIncludedRoutes(routesPaths);
|
|
801
802
|
routesPaths = Array.from(new Set(routesPaths));
|
|
802
803
|
buildLog("Rendering Pages...", routesPaths.length);
|
|
803
|
-
const beasties = beastiesOptions !== false ? await getBeastiesOrCritters(outDir, { publicPath: configBase, ...beastiesOptions }) :
|
|
804
|
+
const beasties = beastiesOptions !== false ? await getBeastiesOrCritters(outDir, { publicPath: configBase, ...beastiesOptions }) : void 0;
|
|
804
805
|
if (beasties)
|
|
805
806
|
console.log(`${gray("[vite-react-ssg]")} ${blue("Critical CSS generation enabled via `beasties`")}`);
|
|
806
807
|
const ssrManifest = JSON.parse(await fs.readFile(join(out, ...dotVitedir, "ssr-manifest.json"), "utf-8"));
|
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, c as RouterFutureConfig, 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.B2xAADcy.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.B2xAADcy.mjs';
|
|
4
4
|
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.-NlgsPvg.mjs';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'react';
|
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, c as RouterFutureConfig, 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.B2xAADcy.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.B2xAADcy.js';
|
|
4
4
|
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.-NlgsPvg.js';
|
|
5
5
|
import 'beasties';
|
|
6
6
|
import 'react';
|
package/dist/tanstack.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { RouterProvider } from '@tanstack/react-router';
|
|
3
3
|
import { Meta, StartClient } from '@tanstack/start';
|
|
4
4
|
import { HelmetProvider } from 'react-helmet-async';
|
|
5
|
-
import { r as render, h as hydrate, d as documentReady } from './shared/vite-react-ssg.
|
|
6
|
-
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.
|
|
5
|
+
import { r as render, h as hydrate, d as documentReady } from './shared/vite-react-ssg.BxjO14Et.mjs';
|
|
6
|
+
export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.BxjO14Et.mjs';
|
|
7
7
|
import { j as joinUrlSegments, w as withLeadingSlash, s as stripBase } from './shared/vite-react-ssg.CjIppNIS.mjs';
|
|
8
8
|
import { d as deserializeState } from './shared/vite-react-ssg.C6pK7rvr.mjs';
|
|
9
9
|
import { M as META_CONTAINER_ID, c as convertRouteTreeToRouteOption } 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 (process.env.NODE_ENV === "development" && ssrWhenDev !==
|
|
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 ?? "/";
|
|
@@ -71,7 +71,7 @@ function Experimental_ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
71
71
|
const routeData = staticLoadData?.[pathname]?.find((item) => item.id === node.id);
|
|
72
72
|
return routeData?.loaderData ?? null;
|
|
73
73
|
};
|
|
74
|
-
} :
|
|
74
|
+
} : void 0
|
|
75
75
|
);
|
|
76
76
|
const router = routerOptions.router;
|
|
77
77
|
router.options.isServer = !client;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-react-ssg",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.8.
|
|
5
|
-
"packageManager": "pnpm@10.
|
|
4
|
+
"version": "0.8.7",
|
|
5
|
+
"packageManager": "pnpm@10.12.1",
|
|
6
6
|
"description": "Static-site generation for React on Vite.",
|
|
7
7
|
"author": "Riri <Daydreamerriri@outlook.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"react-dom": "^17.0.2 || ^18.0.0 || ^19.0.0",
|
|
84
84
|
"react-router-dom": "^6.14.1",
|
|
85
85
|
"styled-components": "^6.0.0",
|
|
86
|
-
"vite": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
|
|
86
|
+
"vite": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@tanstack/react-router": {
|
|
@@ -120,35 +120,35 @@
|
|
|
120
120
|
},
|
|
121
121
|
"devDependencies": {
|
|
122
122
|
"@ririd/eslint-config": "^1.4.0",
|
|
123
|
-
"@tanstack/react-router": "^1.
|
|
124
|
-
"@tanstack/start": "^1.
|
|
123
|
+
"@tanstack/react-router": "^1.121.24",
|
|
124
|
+
"@tanstack/start": "^1.120.20",
|
|
125
125
|
"@types/fs-extra": "^11.0.4",
|
|
126
126
|
"@types/jsdom": "^21.1.7",
|
|
127
|
-
"@types/node": "^18.19.
|
|
127
|
+
"@types/node": "^18.19.112",
|
|
128
128
|
"@types/react": "catalog:",
|
|
129
129
|
"@types/react-dom": "catalog:",
|
|
130
130
|
"@types/yargs": "^17.0.33",
|
|
131
|
-
"@vitejs/plugin-react-swc": "^3.
|
|
132
|
-
"beasties": "^0.
|
|
133
|
-
"bumpp": "^
|
|
131
|
+
"@vitejs/plugin-react-swc": "^3.10.2",
|
|
132
|
+
"beasties": "^0.3.4",
|
|
133
|
+
"bumpp": "^10.2.0",
|
|
134
134
|
"critters": "^0.0.25",
|
|
135
|
-
"eslint": "^9.
|
|
135
|
+
"eslint": "^9.29.0",
|
|
136
136
|
"esno": "^4.8.0",
|
|
137
137
|
"fast-glob": "3.3.2",
|
|
138
|
-
"prettier": "^3.5.
|
|
138
|
+
"prettier": "^3.5.3",
|
|
139
139
|
"react": "catalog:",
|
|
140
140
|
"react-dom": "catalog:",
|
|
141
|
-
"react-router-dom": "^6.
|
|
141
|
+
"react-router-dom": "^6.30.1",
|
|
142
142
|
"rimraf": "5.0.1",
|
|
143
143
|
"styled-components": "6.0.5",
|
|
144
|
-
"typescript": "^5.
|
|
145
|
-
"unbuild": "^3.
|
|
144
|
+
"typescript": "^5.8.3",
|
|
145
|
+
"unbuild": "^3.5.0",
|
|
146
146
|
"vite": "catalog:",
|
|
147
147
|
"vitest": "1.6.1"
|
|
148
148
|
},
|
|
149
149
|
"pnpm": {
|
|
150
150
|
"overrides": {
|
|
151
|
-
"@babel/traverse": "^7.
|
|
151
|
+
"@babel/traverse": "^7.27.4"
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}
|