vite-react-ssg 0.8.4 → 0.8.5

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.
Files changed (43) hide show
  1. package/README.md +10 -8
  2. package/dist/client/single-page.d.mts +4 -4
  3. package/dist/client/single-page.d.ts +4 -4
  4. package/dist/client/single-page.mjs +7 -6
  5. package/dist/index.d.mts +5 -4
  6. package/dist/index.d.ts +5 -4
  7. package/dist/index.mjs +10 -8
  8. package/dist/node/cli.mjs +9 -9
  9. package/dist/node.d.mts +2 -2
  10. package/dist/node.d.ts +2 -2
  11. package/dist/node.mjs +7 -7
  12. package/dist/shared/{vite-react-ssg.Cm9gBlfg.d.ts → vite-react-ssg.-NlgsPvg.d.mts} +8 -8
  13. package/dist/shared/{vite-react-ssg.Cm9gBlfg.d.mts → vite-react-ssg.-NlgsPvg.d.ts} +8 -8
  14. package/dist/shared/{vite-react-ssg.C0y5wbxl.mjs → vite-react-ssg.C_MPXL9p.mjs} +1 -1
  15. package/dist/shared/{vite-react-ssg.Di0pROyF.d.cts → vite-react-ssg.D2OE2Bw1.d.mts} +6 -1
  16. package/dist/shared/{vite-react-ssg.Di0pROyF.d.mts → vite-react-ssg.D2OE2Bw1.d.ts} +6 -1
  17. package/dist/shared/{vite-react-ssg.CfJcpdWF.mjs → vite-react-ssg.Dx4ca9OM.mjs} +18 -4
  18. package/dist/shared/{vite-react-ssg.CKcl-j8g.mjs → vite-react-ssg.EDckwhJo.mjs} +222 -218
  19. package/dist/tanstack.d.mts +5 -4
  20. package/dist/tanstack.d.ts +5 -4
  21. package/dist/tanstack.mjs +9 -7
  22. package/package.json +32 -33
  23. package/dist/chunks/jsdomGlobal.cjs +0 -36
  24. package/dist/client/single-page.cjs +0 -75
  25. package/dist/client/single-page.d.cts +0 -11
  26. package/dist/index.cjs +0 -196
  27. package/dist/index.d.cts +0 -26
  28. package/dist/node/cli.cjs +0 -89
  29. package/dist/node/cli.d.cts +0 -2
  30. package/dist/node.cjs +0 -24
  31. package/dist/node.d.cts +0 -11
  32. package/dist/shared/vite-react-ssg.B4jDfvXh.cjs +0 -106
  33. package/dist/shared/vite-react-ssg.C2GpVZF1.cjs +0 -38
  34. package/dist/shared/vite-react-ssg.CFQGqC60.cjs +0 -36
  35. package/dist/shared/vite-react-ssg.CjsEygxB.cjs +0 -37
  36. package/dist/shared/vite-react-ssg.Cm9gBlfg.d.cts +0 -15
  37. package/dist/shared/vite-react-ssg.DWHmkjdM.cjs +0 -35
  38. package/dist/shared/vite-react-ssg.Di0pROyF.d.ts +0 -214
  39. package/dist/shared/vite-react-ssg.Dus0yLsZ.cjs +0 -1082
  40. package/dist/style-collectors/styled-components.cjs +0 -20
  41. package/dist/style-collectors/styled-components.d.cts +0 -9
  42. package/dist/tanstack.cjs +0 -144
  43. package/dist/tanstack.d.cts +0 -30
package/README.md CHANGED
@@ -73,10 +73,10 @@ export const createRoot = ViteReactSSG(
73
73
 
74
74
  ```tsx
75
75
  // src/App.tsx
76
- import React from 'react'
77
76
  import type { RouteRecord } from 'vite-react-ssg'
78
- import './App.css'
77
+ import React from 'react'
79
78
  import Layout from './Layout'
79
+ import './App.css'
80
80
 
81
81
  export const routes: RouteRecord[] = [
82
82
  {
@@ -374,9 +374,9 @@ export const routes: RouteRecord[] = [
374
374
  Just set `base` in vite.config.ts like:
375
375
 
376
376
  ```ts
377
+ import react from '@vitejs/plugin-react-swc'
377
378
  // vite.config.ts
378
379
  import { defineConfig } from 'vite'
379
- import react from '@vitejs/plugin-react-swc'
380
380
 
381
381
  // https://vitejs.dev/config/
382
382
  export default defineConfig({
@@ -510,6 +510,11 @@ interface ViteReactSSGOptions {
510
510
  * @default 'src/main.ts'
511
511
  */
512
512
  entry?: string
513
+ /**
514
+ * The path of the index.html file (relative to the project root).
515
+ * @default 'index.html'
516
+ */
517
+ htmlEntry?: string
513
518
  /**
514
519
  * Mock browser global variables (window, document, etc...) from SSG.
515
520
  *
@@ -648,11 +653,8 @@ export default defineConfig({
648
653
 
649
654
  ## Roadmap
650
655
 
651
- - [x] Preload assets
652
- - [x] Document head
653
- - [x] SSR in dev environment
654
- - [x] More Client components, such as `<ClientOnly />`
655
- - [x] `getStaticPaths` for dynamic routes
656
+ - [ ] Support `react19`
657
+ - [ ] no index.html mode
656
658
 
657
659
  ## Credits
658
660
 
@@ -1,9 +1,9 @@
1
1
  import { ReactNode } from 'react';
2
- import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.Di0pROyF.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.Di0pROyF.mjs';
4
- export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.Cm9gBlfg.mjs';
5
- import 'react-router-dom';
2
+ import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.D2OE2Bw1.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.D2OE2Bw1.mjs';
4
+ export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.-NlgsPvg.mjs';
6
5
  import 'beasties';
6
+ import 'react-router-dom';
7
7
  import 'react-helmet-async';
8
8
 
9
9
  declare function ViteReactSSG(App: ReactNode, fn?: (context: ViteReactSSGContext<false>) => Promise<void> | void, options?: ViteReactSSGClientOptions): (client?: boolean, routePath?: string) => Promise<ViteReactSSGContext<false>>;
@@ -1,9 +1,9 @@
1
1
  import { ReactNode } from 'react';
2
- import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.Di0pROyF.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.Di0pROyF.js';
4
- export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.Cm9gBlfg.js';
5
- import 'react-router-dom';
2
+ import { V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from '../shared/vite-react-ssg.D2OE2Bw1.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.D2OE2Bw1.js';
4
+ export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.-NlgsPvg.js';
6
5
  import 'beasties';
6
+ import 'react-router-dom';
7
7
  import 'react-helmet-async';
8
8
 
9
9
  declare function ViteReactSSG(App: ReactNode, fn?: (context: ViteReactSSGContext<false>) => Promise<void> | void, options?: ViteReactSSGClientOptions): (client?: boolean, routePath?: string) => Promise<ViteReactSSGContext<false>>;
@@ -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.CfJcpdWF.mjs';
4
- export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.CfJcpdWF.mjs';
3
+ import { r as render, h as hydrate, d as documentReady } from '../shared/vite-react-ssg.Dx4ca9OM.mjs';
4
+ export { C as ClientOnly, H as Head } from '../shared/vite-react-ssg.Dx4ca9OM.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 !== void 0)
16
+ if (process.env.NODE_ENV === "development" && ssrWhenDev !== undefined)
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: void 0,
35
- routerOptions: void 0,
34
+ routes: undefined,
35
+ routerOptions: undefined,
36
36
  base: "/",
37
37
  app: App,
38
38
  routerType: "single-page"
@@ -56,7 +56,8 @@ function ViteReactSSG(App, fn, options = {}) {
56
56
  console.warn("[vite-react-ssg] Root container not found.");
57
57
  return;
58
58
  }
59
- await createRoot(true);
59
+ const context = await createRoot(true);
60
+ window.__VITE_REACT_SSG_CONTEXT__ = context;
60
61
  const app = /* @__PURE__ */ jsx(HelmetProvider, { children: App });
61
62
  const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
62
63
  if (!isSSR && process.env.NODE_ENV === "development") {
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { d as RouterOptions, V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.Di0pROyF.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.Di0pROyF.mjs';
3
- export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.Cm9gBlfg.mjs';
4
- import React from 'react';
1
+ import { V as ViteReactSSGContext, d as RouterOptions, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.D2OE2Bw1.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.D2OE2Bw1.mjs';
3
+ export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.-NlgsPvg.mjs';
5
4
  import { LinkProps, NavLinkProps } from 'react-router-dom';
5
+ import React from 'react';
6
6
  import 'beasties';
7
7
  import 'react-helmet-async';
8
8
 
@@ -20,6 +20,7 @@ declare global {
20
20
  interface Window {
21
21
  __VITE_REACT_SSG_STATIC_LOADER_DATA__: any;
22
22
  __VITE_REACT_SSG_HASH__: string;
23
+ __VITE_REACT_SSG_CONTEXT__: ViteReactSSGContext<true>;
23
24
  }
24
25
  }
25
26
 
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { d as RouterOptions, V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.Di0pROyF.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.Di0pROyF.js';
3
- export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.Cm9gBlfg.js';
4
- import React from 'react';
1
+ import { V as ViteReactSSGContext, d as RouterOptions, a as ViteReactSSGClientOptions } from './shared/vite-react-ssg.D2OE2Bw1.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.D2OE2Bw1.js';
3
+ export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.-NlgsPvg.js';
5
4
  import { LinkProps, NavLinkProps } from 'react-router-dom';
5
+ import React from 'react';
6
6
  import 'beasties';
7
7
  import 'react-helmet-async';
8
8
 
@@ -20,6 +20,7 @@ declare global {
20
20
  interface Window {
21
21
  __VITE_REACT_SSG_STATIC_LOADER_DATA__: any;
22
22
  __VITE_REACT_SSG_HASH__: string;
23
+ __VITE_REACT_SSG_CONTEXT__: ViteReactSSGContext<true>;
23
24
  }
24
25
  }
25
26
 
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
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.CfJcpdWF.mjs';
5
- export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.CfJcpdWF.mjs';
6
- import { d as deserializeState } from './shared/vite-react-ssg.C6pK7rvr.mjs';
4
+ import { r as render, h as hydrate, d as documentReady } from './shared/vite-react-ssg.Dx4ca9OM.mjs';
5
+ export { C as ClientOnly, H as Head } from './shared/vite-react-ssg.Dx4ca9OM.mjs';
7
6
  import { j as joinUrlSegments, w as withLeadingSlash, s as stripBase } from './shared/vite-react-ssg.CjIppNIS.mjs';
8
- import { c as convertRoutesToDataRoutes } from './shared/vite-react-ssg.C0y5wbxl.mjs';
7
+ import { c as convertRoutesToDataRoutes } from './shared/vite-react-ssg.C_MPXL9p.mjs';
8
+ import { d as deserializeState } from './shared/vite-react-ssg.C6pK7rvr.mjs';
9
9
  import React, { forwardRef } from 'react';
10
10
  import 'react-dom';
11
11
 
@@ -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 !== void 0)
82
+ if (process.env.NODE_ENV === "development" && ssrWhenDev !== undefined)
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
- ) : void 0;
91
+ ) : undefined;
92
92
  const appRenderCallbacks = [];
93
93
  const onSSRAppRendered = client ? () => {
94
94
  } : (cb) => appRenderCallbacks.push(cb);
@@ -135,11 +135,13 @@ 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: void 0 });
138
+ Object.assign(m.route, { ...routeModule, lazy: undefined });
139
139
  })
140
140
  );
141
141
  }
142
- const { router } = await createRoot(true);
142
+ const context = await createRoot(true);
143
+ window.__VITE_REACT_SSG_CONTEXT__ = context;
144
+ const { router } = context;
143
145
  const app = /* @__PURE__ */ jsx(HelmetProvider, { children: /* @__PURE__ */ jsx(RouterProvider, { router, future: { v7_startTransition } }) });
144
146
  const isSSR = document.querySelector("[data-server-rendered=true]") !== null;
145
147
  if (!isSSR && process.env.NODE_ENV === "development") {
package/dist/node/cli.mjs CHANGED
@@ -1,22 +1,22 @@
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.CKcl-j8g.mjs';
4
+ import { b as build, d as dev } from '../shared/vite-react-ssg.EDckwhJo.mjs';
5
5
  import { Headers, Request, Response, fetch, FormData } from '@remix-run/web-fetch';
6
- import 'node:path';
7
6
  import 'node:module';
8
- import 'p-queue';
7
+ import 'node:path';
9
8
  import 'fs-extra';
10
- import 'vite';
11
9
  import 'jsdom';
12
- import '../shared/vite-react-ssg.C6pK7rvr.mjs';
10
+ import 'p-queue';
11
+ import 'vite';
13
12
  import '../shared/vite-react-ssg.CjIppNIS.mjs';
13
+ import '../shared/vite-react-ssg.C6pK7rvr.mjs';
14
14
  import 'react/jsx-runtime';
15
15
  import 'react-helmet-async';
16
+ import 'node:events';
16
17
  import 'node:stream';
18
+ import '../shared/vite-react-ssg.C_MPXL9p.mjs';
17
19
  import 'react-dom/server';
18
- import 'node:events';
19
- import '../shared/vite-react-ssg.C0y5wbxl.mjs';
20
20
  import '../shared/vite-react-ssg.B-j07kW6.mjs';
21
21
 
22
22
  function installGlobals() {
@@ -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 = void 0, ...ssgOptions } = args;
50
+ const { config: configFile = undefined, ...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 = void 0, host, ...ssgOptions } = args;
75
+ const { config: configFile = undefined, 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,8 +1,8 @@
1
1
  import { InlineConfig } from 'vite';
2
- import { b as ViteReactSSGOptions } from './shared/vite-react-ssg.Di0pROyF.mjs';
2
+ import { b as ViteReactSSGOptions } from './shared/vite-react-ssg.D2OE2Bw1.mjs';
3
+ import 'beasties';
3
4
  import 'react';
4
5
  import 'react-router-dom';
5
- import 'beasties';
6
6
 
7
7
  declare function build(ssgOptions?: Partial<ViteReactSSGOptions>, viteConfig?: InlineConfig): Promise<void>;
8
8
 
package/dist/node.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { InlineConfig } from 'vite';
2
- import { b as ViteReactSSGOptions } from './shared/vite-react-ssg.Di0pROyF.js';
2
+ import { b as ViteReactSSGOptions } from './shared/vite-react-ssg.D2OE2Bw1.js';
3
+ import 'beasties';
3
4
  import 'react';
4
5
  import 'react-router-dom';
5
- import 'beasties';
6
6
 
7
7
  declare function build(ssgOptions?: Partial<ViteReactSSGOptions>, viteConfig?: InlineConfig): Promise<void>;
8
8
 
package/dist/node.mjs CHANGED
@@ -1,17 +1,17 @@
1
- export { b as build, d as dev } from './shared/vite-react-ssg.CKcl-j8g.mjs';
2
- import 'node:path';
1
+ export { b as build, d as dev } from './shared/vite-react-ssg.EDckwhJo.mjs';
3
2
  import 'node:module';
3
+ import 'node:path';
4
+ import 'fs-extra';
5
+ import 'jsdom';
4
6
  import 'kolorist';
5
7
  import 'p-queue';
6
- import 'fs-extra';
7
8
  import 'vite';
8
- import 'jsdom';
9
- import './shared/vite-react-ssg.C6pK7rvr.mjs';
10
9
  import './shared/vite-react-ssg.CjIppNIS.mjs';
10
+ import './shared/vite-react-ssg.C6pK7rvr.mjs';
11
11
  import 'react/jsx-runtime';
12
12
  import 'react-helmet-async';
13
+ import 'node:events';
13
14
  import 'node:stream';
15
+ import './shared/vite-react-ssg.C_MPXL9p.mjs';
14
16
  import 'react-dom/server';
15
- import 'node:events';
16
- import './shared/vite-react-ssg.C0y5wbxl.mjs';
17
17
  import './shared/vite-react-ssg.B-j07kW6.mjs';
@@ -1,15 +1,15 @@
1
- import { ReactNode } from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
  import { HelmetProps } from 'react-helmet-async';
3
3
 
4
+ interface ClientOnlyProps {
5
+ children?: () => React.ReactNode;
6
+ fallback?: React.ReactNode;
7
+ }
8
+ declare function ClientOnly({ children, fallback, }: ClientOnlyProps): React.ReactNode | null;
9
+
4
10
  type Props = HelmetProps & {
5
11
  children: ReactNode;
6
12
  };
7
- declare function Head(props: Props): JSX.Element;
8
-
9
- interface ClientOnlyProps {
10
- children?: () => JSX.Element;
11
- fallback?: JSX.Element;
12
- }
13
- declare function ClientOnly({ children, fallback, }: ClientOnlyProps): JSX.Element | null;
13
+ declare function Head(props: Props): React.ReactNode;
14
14
 
15
15
  export { ClientOnly as C, Head as H };
@@ -1,15 +1,15 @@
1
- import { ReactNode } from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
  import { HelmetProps } from 'react-helmet-async';
3
3
 
4
+ interface ClientOnlyProps {
5
+ children?: () => React.ReactNode;
6
+ fallback?: React.ReactNode;
7
+ }
8
+ declare function ClientOnly({ children, fallback, }: ClientOnlyProps): React.ReactNode | null;
9
+
4
10
  type Props = HelmetProps & {
5
11
  children: ReactNode;
6
12
  };
7
- declare function Head(props: Props): JSX.Element;
8
-
9
- interface ClientOnlyProps {
10
- children?: () => JSX.Element;
11
- fallback?: JSX.Element;
12
- }
13
- declare function ClientOnly({ children, fallback, }: ClientOnlyProps): JSX.Element | null;
13
+ declare function Head(props: Props): React.ReactNode;
14
14
 
15
15
  export { ClientOnly as C, Head as H };
@@ -15,7 +15,7 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath = [])
15
15
  ...route,
16
16
  ...mapRouteProperties(route),
17
17
  id,
18
- children: void 0
18
+ children: undefined
19
19
  };
20
20
  if (route.children) {
21
21
  pathOrLayoutRoute.children = convertRoutesToDataRoutes(
@@ -1,6 +1,6 @@
1
+ import { Options } from 'beasties';
1
2
  import { ReactNode, ReactElement } from 'react';
2
3
  import { NonIndexRouteObject, IndexRouteObject, FutureConfig, createBrowserRouter } from 'react-router-dom';
3
- import { Options } from 'beasties';
4
4
 
5
5
  type Router = ReturnType<typeof createBrowserRouter>;
6
6
  interface CrittersOptions {
@@ -41,6 +41,11 @@ interface ViteReactSSGOptions<Context = ViteReactSSGContext> {
41
41
  * @default 'src/main.ts'
42
42
  */
43
43
  entry?: string;
44
+ /**
45
+ * The path of the index.html file (relative to the project root).
46
+ * @default 'index.html'
47
+ */
48
+ htmlEntry?: string;
44
49
  /**
45
50
  * Mock browser global variables (window, document, etc...) from SSG.
46
51
  *
@@ -1,6 +1,6 @@
1
+ import { Options } from 'beasties';
1
2
  import { ReactNode, ReactElement } from 'react';
2
3
  import { NonIndexRouteObject, IndexRouteObject, FutureConfig, createBrowserRouter } from 'react-router-dom';
3
- import { Options } from 'beasties';
4
4
 
5
5
  type Router = ReturnType<typeof createBrowserRouter>;
6
6
  interface CrittersOptions {
@@ -41,6 +41,11 @@ interface ViteReactSSGOptions<Context = ViteReactSSGContext> {
41
41
  * @default 'src/main.ts'
42
42
  */
43
43
  entry?: string;
44
+ /**
45
+ * The path of the index.html file (relative to the project root).
46
+ * @default 'index.html'
47
+ */
48
+ htmlEntry?: string;
44
49
  /**
45
50
  * Mock browser global variables (window, document, etc...) from SSG.
46
51
  *
@@ -8,10 +8,18 @@ const CopyReactDOM = {
8
8
  };
9
9
  const { version, render: reactRender, hydrate: reactHydrate } = CopyReactDOM;
10
10
  const isReact18 = Number((version || "").split(".")[0]) > 17;
11
+ const isReact19 = Number((version || "").split(".")[0]) > 18;
11
12
  function render(app, container, renderOptions = {}) {
12
13
  const { useLegacyRender } = renderOptions;
13
14
  if (useLegacyRender || !isReact18) {
14
15
  reactRender(app, container);
16
+ } else if (isReact19) {
17
+ import('react-dom/client').then(({ createRoot }) => {
18
+ const root = createRoot(container);
19
+ React.startTransition(() => {
20
+ root.render(app);
21
+ });
22
+ });
15
23
  } else {
16
24
  CopyReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = true;
17
25
  const { createRoot } = CopyReactDOM;
@@ -29,6 +37,12 @@ function hydrate(app, container, renderOptions = {}) {
29
37
  const { useLegacyRender } = renderOptions;
30
38
  if (useLegacyRender || !isReact18) {
31
39
  reactHydrate(app, container);
40
+ } else if (isReact19) {
41
+ import('react-dom/client').then(({ hydrateRoot }) => {
42
+ React.startTransition(() => {
43
+ hydrateRoot(container, app);
44
+ });
45
+ });
32
46
  } else {
33
47
  CopyReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = true;
34
48
  const { hydrateRoot } = CopyReactDOM;
@@ -51,10 +65,6 @@ function documentReady(_passThrough) {
51
65
  return Promise.resolve(_passThrough);
52
66
  }
53
67
 
54
- function Head(props) {
55
- return /* @__PURE__ */ jsx(Helmet, { ...props });
56
- }
57
-
58
68
  function useIsClient() {
59
69
  const [isBrowser, setIsBrowser] = useState(false);
60
70
  useEffect(() => {
@@ -80,4 +90,8 @@ Current type: ${isValidElement(children) ? "React element" : typeof children}`
80
90
  return fallback ?? null;
81
91
  }
82
92
 
93
+ function Head(props) {
94
+ return /* @__PURE__ */ jsx(Helmet, { ...props });
95
+ }
96
+
83
97
  export { ClientOnly as C, Head as H, documentReady as d, hydrate as h, render as r };