vite-react-ssg 0.0.1 → 0.0.3

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.
@@ -1,6 +1,5 @@
1
1
  import { Options } from 'critters';
2
- import { ReactNode } from 'react';
3
- import { RouteObject, createBrowserRouter } from 'react-router-dom';
2
+ import { NonIndexRouteObject, IndexRouteObject, createBrowserRouter } from 'react-router-dom';
4
3
 
5
4
  type Router = ReturnType<typeof createBrowserRouter>;
6
5
  interface ViteReactSSGOptions {
@@ -31,6 +30,8 @@ interface ViteReactSSGOptions {
31
30
  /**
32
31
  * Apply formatter to the generated index file.
33
32
  *
33
+ * **It will cause Hydration Failed.**
34
+ *
34
35
  * @default 'none'
35
36
  */
36
37
  formatting?: 'minify' | 'prettify' | 'none';
@@ -103,7 +104,6 @@ interface ViteReactSSGOptions {
103
104
  concurrency?: number;
104
105
  }
105
106
  interface ViteReactSSGContext<HasRouter extends boolean = true> {
106
- app?: ReactNode;
107
107
  router?: HasRouter extends true ? Router : undefined;
108
108
  routes: HasRouter extends true ? Readonly<RouteRecord[]> : undefined;
109
109
  routerOptions: RouterOptions;
@@ -127,7 +127,19 @@ interface ViteReactSSGClientOptions {
127
127
  */
128
128
  rootContainer?: string | Element;
129
129
  }
130
- type RouteRecord = RouteObject & {};
130
+ interface CommonRouteOptions {
131
+ /**
132
+ * Used to obtain static resources through manifest
133
+ *
134
+ * @example `src/pages/home.tsx
135
+ */
136
+ entry?: string;
137
+ }
138
+ type NonIndexRouteRecord = Omit<NonIndexRouteObject, 'children'> & {
139
+ children?: RouteRecord[];
140
+ } & CommonRouteOptions;
141
+ type IndexRouteRecord = IndexRouteObject & CommonRouteOptions;
142
+ type RouteRecord = NonIndexRouteRecord | IndexRouteRecord;
131
143
  interface RouterOptions {
132
144
  routes: RouteRecord[];
133
145
  createFetchRequest?: <T>(req: T) => Request;
@@ -138,4 +150,4 @@ declare module 'vite' {
138
150
  }
139
151
  }
140
152
 
141
- export { RouterOptions as R, ViteReactSSGContext as V, ViteReactSSGClientOptions as a, ViteReactSSGOptions as b };
153
+ export { IndexRouteRecord as I, NonIndexRouteRecord as N, RouterOptions as R, ViteReactSSGContext as V, ViteReactSSGClientOptions as a, ViteReactSSGOptions as b, RouteRecord as c };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-react-ssg",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.3",
5
5
  "packageManager": "pnpm@8.6.6",
6
6
  "description": "",
7
7
  "author": "Riri <Daydreamerriri@outlook.com>",
@@ -80,23 +80,24 @@
80
80
  "html5parser": "^2.0.2",
81
81
  "jsdom": "^22.1.0",
82
82
  "kolorist": "^1.8.0",
83
+ "prettier": "^3.0.0",
83
84
  "react-helmet-async": "^1.3.0",
84
85
  "yargs": "^17.7.2"
85
86
  },
86
87
  "devDependencies": {
87
- "@ririd/eslint-config": "0.5.1",
88
+ "@ririd/eslint-config": "0.6.0",
88
89
  "@types/fs-extra": "^11.0.1",
89
90
  "@types/html-minifier": "^4.0.2",
90
91
  "@types/jsdom": "^21.1.1",
91
92
  "@types/node": "^18.15.11",
93
+ "@types/prettier": "^2.7.3",
92
94
  "@types/react": "^18.2.14",
93
95
  "@types/react-dom": "^18.2.6",
94
- "@types/react-helmet-async": "^1.0.3",
95
96
  "@types/yargs": "^17.0.24",
96
97
  "bumpp": "^9.1.0",
97
98
  "critters": "^0.0.19",
98
- "eslint": "^8.40.0",
99
- "esno": "^0.16.3",
99
+ "eslint": "^8.45.0",
100
+ "esno": "^0.17.0",
100
101
  "p-queue": "^7.3.4",
101
102
  "react": "^18.2.0",
102
103
  "react-dom": "^18.2.0",
@@ -105,8 +106,8 @@
105
106
  "simple-git-hooks": "^2.8.1",
106
107
  "typescript": "5.1.6",
107
108
  "unbuild": "^1.2.1",
108
- "vite": "^4.3.9",
109
+ "vite": "^4.4.0",
109
110
  "vite-plugin-pwa": "^0.16.4",
110
111
  "vitest": "0.33.0"
111
112
  }
112
- }
113
+ }