vite-react-ssg 0.3.1 → 0.3.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 +2 -0
- package/dist/index.cjs +11 -11
- package/dist/index.mjs +11 -11
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Static-site generation for React on Vite.
|
|
4
4
|
|
|
5
|
+
See demo(also document): [docs](https://vite-react-ssg.netlify.app/)
|
|
6
|
+
|
|
5
7
|
[](https://www.npmjs.com/package/vite-react-ssg)
|
|
6
8
|
|
|
7
9
|
# Table of contents
|
package/dist/index.cjs
CHANGED
|
@@ -149,6 +149,17 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
149
149
|
if (isClient) {
|
|
150
150
|
(async () => {
|
|
151
151
|
const container = typeof rootContainer === "string" ? document.querySelector(rootContainer) : rootContainer;
|
|
152
|
+
const lazeMatches = reactRouterDom.matchRoutes(routerOptions.routes, window.location)?.filter(
|
|
153
|
+
(m) => m.route.lazy
|
|
154
|
+
);
|
|
155
|
+
if (lazeMatches && lazeMatches?.length > 0) {
|
|
156
|
+
await Promise.all(
|
|
157
|
+
lazeMatches.map(async (m) => {
|
|
158
|
+
const routeModule = await m.route.lazy();
|
|
159
|
+
Object.assign(m.route, { ...routeModule, lazy: void 0 });
|
|
160
|
+
})
|
|
161
|
+
);
|
|
162
|
+
}
|
|
152
163
|
const { router } = await createRoot(true);
|
|
153
164
|
const app = /* @__PURE__ */ React__default.createElement(reactHelmetAsync.HelmetProvider, null, /* @__PURE__ */ React__default.createElement(SiteMetadataDefaults.SiteMetadataDefaults, null), /* @__PURE__ */ React__default.createElement(reactRouterDom.RouterProvider, { router }));
|
|
154
165
|
if (!ssrWhenDev && undefined.DEV) {
|
|
@@ -157,17 +168,6 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
157
168
|
root.render(app);
|
|
158
169
|
});
|
|
159
170
|
} else {
|
|
160
|
-
const lazeMatches = reactRouterDom.matchRoutes(routerOptions.routes, window.location)?.filter(
|
|
161
|
-
(m) => m.route.lazy
|
|
162
|
-
);
|
|
163
|
-
if (lazeMatches && lazeMatches?.length > 0) {
|
|
164
|
-
await Promise.all(
|
|
165
|
-
lazeMatches.map(async (m) => {
|
|
166
|
-
const routeModule = await m.route.lazy();
|
|
167
|
-
Object.assign(m.route, { ...routeModule, lazy: void 0 });
|
|
168
|
-
})
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
171
|
React__default.startTransition(() => {
|
|
172
172
|
client.hydrateRoot(container, app);
|
|
173
173
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -144,6 +144,17 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
144
144
|
if (isClient) {
|
|
145
145
|
(async () => {
|
|
146
146
|
const container = typeof rootContainer === "string" ? document.querySelector(rootContainer) : rootContainer;
|
|
147
|
+
const lazeMatches = matchRoutes(routerOptions.routes, window.location)?.filter(
|
|
148
|
+
(m) => m.route.lazy
|
|
149
|
+
);
|
|
150
|
+
if (lazeMatches && lazeMatches?.length > 0) {
|
|
151
|
+
await Promise.all(
|
|
152
|
+
lazeMatches.map(async (m) => {
|
|
153
|
+
const routeModule = await m.route.lazy();
|
|
154
|
+
Object.assign(m.route, { ...routeModule, lazy: void 0 });
|
|
155
|
+
})
|
|
156
|
+
);
|
|
157
|
+
}
|
|
147
158
|
const { router } = await createRoot$1(true);
|
|
148
159
|
const app = /* @__PURE__ */ React.createElement(HelmetProvider, null, /* @__PURE__ */ React.createElement(SiteMetadataDefaults, null), /* @__PURE__ */ React.createElement(RouterProvider, { router }));
|
|
149
160
|
if (!ssrWhenDev && import.meta.env.DEV) {
|
|
@@ -152,17 +163,6 @@ function ViteReactSSG(routerOptions, fn, options = {}) {
|
|
|
152
163
|
root.render(app);
|
|
153
164
|
});
|
|
154
165
|
} else {
|
|
155
|
-
const lazeMatches = matchRoutes(routerOptions.routes, window.location)?.filter(
|
|
156
|
-
(m) => m.route.lazy
|
|
157
|
-
);
|
|
158
|
-
if (lazeMatches && lazeMatches?.length > 0) {
|
|
159
|
-
await Promise.all(
|
|
160
|
-
lazeMatches.map(async (m) => {
|
|
161
|
-
const routeModule = await m.route.lazy();
|
|
162
|
-
Object.assign(m.route, { ...routeModule, lazy: void 0 });
|
|
163
|
-
})
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
166
|
React.startTransition(() => {
|
|
167
167
|
hydrateRoot(container, app);
|
|
168
168
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-react-ssg",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"packageManager": "pnpm@8.6.6",
|
|
6
6
|
"description": "",
|
|
7
7
|
"author": "Riri <Daydreamerriri@outlook.com>",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"build": "unbuild",
|
|
63
63
|
"dev": "unbuild --stub",
|
|
64
64
|
"lint": "eslint .",
|
|
65
|
+
"test": "pnpm -r --filter=./examples/* build && vitest run",
|
|
65
66
|
"prepublishOnly": "nr build",
|
|
66
67
|
"release": "bumpp && npm publish",
|
|
67
68
|
"start": "esno src/index.ts",
|
|
@@ -110,9 +111,10 @@
|
|
|
110
111
|
"@types/react-dom": "^18.2.6",
|
|
111
112
|
"@types/yargs": "^17.0.24",
|
|
112
113
|
"bumpp": "^9.1.0",
|
|
113
|
-
"critters": "^0.0.
|
|
114
|
+
"critters": "^0.0.20",
|
|
114
115
|
"eslint": "^8.45.0",
|
|
115
116
|
"esno": "^0.17.0",
|
|
117
|
+
"fast-glob": "3.3.1",
|
|
116
118
|
"p-queue": "^7.3.4",
|
|
117
119
|
"react": "^18.2.0",
|
|
118
120
|
"react-dom": "^18.2.0",
|
|
@@ -121,8 +123,8 @@
|
|
|
121
123
|
"styled-components": "6.0.5",
|
|
122
124
|
"typescript": "5.1.6",
|
|
123
125
|
"unbuild": "^1.2.1",
|
|
124
|
-
"vite": "^4.4.
|
|
126
|
+
"vite": "^4.4.9",
|
|
125
127
|
"vite-plugin-pwa": "^0.16.4",
|
|
126
|
-
"vitest": "0.
|
|
128
|
+
"vitest": "0.34.1"
|
|
127
129
|
}
|
|
128
130
|
}
|