vite-react-ssg 0.3.2 → 0.3.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.
- package/dist/index.d.ts +2 -2
- package/dist/node/cli.cjs +1 -1
- package/dist/node/cli.mjs +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.mjs +1 -1
- package/dist/shared/{vite-react-ssg.9cf631b2.cjs → vite-react-ssg.69de2462.cjs} +10 -10
- package/dist/shared/{vite-react-ssg.f12aa7be.mjs → vite-react-ssg.f8eacfb1.mjs} +8 -8
- package/dist/{types-c03d6a58.d.ts → types-3aee4b6b.d.ts} +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RouterOptions, V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from './types-
|
|
2
|
-
export { I as IndexRouteRecord, N as NonIndexRouteRecord, c as RouteRecord, S as StyleCollector, b as ViteReactSSGOptions } from './types-
|
|
1
|
+
import { R as RouterOptions, V as ViteReactSSGContext, a as ViteReactSSGClientOptions } from './types-3aee4b6b.js';
|
|
2
|
+
export { I as IndexRouteRecord, N as NonIndexRouteRecord, c as RouteRecord, S as StyleCollector, b as ViteReactSSGOptions } from './types-3aee4b6b.js';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
4
|
import { HelmetProps } from 'react-helmet-async';
|
|
5
5
|
import { LinkProps, NavLinkProps } from 'react-router-dom';
|
package/dist/node/cli.cjs
CHANGED
|
@@ -4,7 +4,7 @@ const kolorist = require('kolorist');
|
|
|
4
4
|
const yargs = require('yargs');
|
|
5
5
|
const helpers = require('yargs/helpers');
|
|
6
6
|
const webFetch = require('@remix-run/web-fetch');
|
|
7
|
-
const dev = require('../shared/vite-react-ssg.
|
|
7
|
+
const dev = require('../shared/vite-react-ssg.69de2462.cjs');
|
|
8
8
|
require('node:path');
|
|
9
9
|
require('node:module');
|
|
10
10
|
require('fs-extra');
|
package/dist/node/cli.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { gray, bold, red, reset, underline } from 'kolorist';
|
|
|
2
2
|
import yargs from 'yargs';
|
|
3
3
|
import { hideBin } from 'yargs/helpers';
|
|
4
4
|
import { Request, Response, fetch as fetch$1, Headers, FormData } from '@remix-run/web-fetch';
|
|
5
|
-
import { b as build, d as dev } from '../shared/vite-react-ssg.
|
|
5
|
+
import { b as build, d as dev } from '../shared/vite-react-ssg.f8eacfb1.mjs';
|
|
6
6
|
import 'node:path';
|
|
7
7
|
import 'node:module';
|
|
8
8
|
import 'fs-extra';
|
package/dist/node.cjs
CHANGED
package/dist/node.d.ts
CHANGED
package/dist/node.mjs
CHANGED
|
@@ -867,7 +867,7 @@ ${kolorist.gray("[vite-react-ssg]")} ${kolorist.yellow(text)}${count ? kolorist.
|
|
|
867
867
|
function getSize(str) {
|
|
868
868
|
return `${(str.length / 1024).toFixed(2)} KiB`;
|
|
869
869
|
}
|
|
870
|
-
function routesToPaths(routes) {
|
|
870
|
+
async function routesToPaths(routes) {
|
|
871
871
|
const pathToEntry = {};
|
|
872
872
|
function addEntry(path, entry) {
|
|
873
873
|
if (!entry)
|
|
@@ -883,17 +883,17 @@ function routesToPaths(routes) {
|
|
|
883
883
|
return { paths: ["/"], pathToEntry };
|
|
884
884
|
const paths = /* @__PURE__ */ new Set();
|
|
885
885
|
const lazyPaths = /* @__PURE__ */ new Set();
|
|
886
|
-
const getPaths = (routes2, prefix = "") => {
|
|
886
|
+
const getPaths = async (routes2, prefix = "") => {
|
|
887
887
|
prefix = prefix.replace(/\/$/g, "");
|
|
888
888
|
for (const route of routes2) {
|
|
889
889
|
let path = route.path;
|
|
890
890
|
path = handlePath(path, prefix, route.entry);
|
|
891
891
|
if (route.getStaticPaths && path?.includes(":")) {
|
|
892
|
-
const staticPaths = route.getStaticPaths();
|
|
892
|
+
const staticPaths = await route.getStaticPaths();
|
|
893
893
|
for (let staticPath of staticPaths) {
|
|
894
894
|
staticPath = handlePath(staticPath, prefix, route.entry);
|
|
895
895
|
if (Array.isArray(route.children))
|
|
896
|
-
getPaths(route.children, staticPath);
|
|
896
|
+
await getPaths(route.children, staticPath);
|
|
897
897
|
}
|
|
898
898
|
}
|
|
899
899
|
if (route.lazy)
|
|
@@ -901,10 +901,10 @@ function routesToPaths(routes) {
|
|
|
901
901
|
if (route.index)
|
|
902
902
|
addEntry(prefix, route.entry);
|
|
903
903
|
if (Array.isArray(route.children))
|
|
904
|
-
getPaths(route.children, path);
|
|
904
|
+
await getPaths(route.children, path);
|
|
905
905
|
}
|
|
906
906
|
};
|
|
907
|
-
getPaths(routes);
|
|
907
|
+
await getPaths(routes);
|
|
908
908
|
return { paths: Array.from(paths), pathToEntry, lazyPaths: Array.from(lazyPaths) };
|
|
909
909
|
function handlePath(path, prefix, entry) {
|
|
910
910
|
if (path != null) {
|
|
@@ -950,7 +950,7 @@ async function resolveAlias(config, entry) {
|
|
|
950
950
|
return result || node_path.join(config.root, entry);
|
|
951
951
|
}
|
|
952
952
|
const { version } = JSON.parse(
|
|
953
|
-
node_fs.readFileSync(new URL("../../package.json", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/vite-react-ssg.
|
|
953
|
+
node_fs.readFileSync(new URL("../../package.json", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/vite-react-ssg.69de2462.cjs', document.baseURI).href)))).toString()
|
|
954
954
|
);
|
|
955
955
|
function createRequest(path) {
|
|
956
956
|
const url = new URL(path, "http://vite-react-ssg.com");
|
|
@@ -1233,13 +1233,13 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1233
1233
|
const prefix = format === "esm" && process.platform === "win32" ? "file://" : "";
|
|
1234
1234
|
const ext = format === "esm" ? ".mjs" : ".cjs";
|
|
1235
1235
|
const serverEntry = node_path.join(prefix, ssgOut, node_path.parse(ssrEntry).name + ext);
|
|
1236
|
-
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/vite-react-ssg.
|
|
1236
|
+
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('shared/vite-react-ssg.69de2462.cjs', document.baseURI).href)));
|
|
1237
1237
|
const { createRoot, includedRoutes: serverEntryIncludedRoutes } = format === "esm" ? await import(serverEntry) : _require(serverEntry);
|
|
1238
1238
|
const includedRoutes = serverEntryIncludedRoutes || configIncludedRoutes;
|
|
1239
1239
|
const { routes } = await createRoot(false);
|
|
1240
|
-
const { lazyPaths } = routesToPaths(routes);
|
|
1240
|
+
const { lazyPaths } = await routesToPaths(routes);
|
|
1241
1241
|
const dataRoutes = await preLoad([...routes], lazyPaths);
|
|
1242
|
-
const { paths, pathToEntry } = routesToPaths(dataRoutes);
|
|
1242
|
+
const { paths, pathToEntry } = await routesToPaths(dataRoutes);
|
|
1243
1243
|
let routesPaths = includeAllRoutes ? paths : await includedRoutes(paths, routes || []);
|
|
1244
1244
|
routesPaths = DefaultIncludedRoutes(routesPaths);
|
|
1245
1245
|
routesPaths = Array.from(new Set(routesPaths));
|
|
@@ -859,7 +859,7 @@ ${gray("[vite-react-ssg]")} ${yellow(text)}${count ? blue(` (${count})`) : ""}`)
|
|
|
859
859
|
function getSize(str) {
|
|
860
860
|
return `${(str.length / 1024).toFixed(2)} KiB`;
|
|
861
861
|
}
|
|
862
|
-
function routesToPaths(routes) {
|
|
862
|
+
async function routesToPaths(routes) {
|
|
863
863
|
const pathToEntry = {};
|
|
864
864
|
function addEntry(path, entry) {
|
|
865
865
|
if (!entry)
|
|
@@ -875,17 +875,17 @@ function routesToPaths(routes) {
|
|
|
875
875
|
return { paths: ["/"], pathToEntry };
|
|
876
876
|
const paths = /* @__PURE__ */ new Set();
|
|
877
877
|
const lazyPaths = /* @__PURE__ */ new Set();
|
|
878
|
-
const getPaths = (routes2, prefix = "") => {
|
|
878
|
+
const getPaths = async (routes2, prefix = "") => {
|
|
879
879
|
prefix = prefix.replace(/\/$/g, "");
|
|
880
880
|
for (const route of routes2) {
|
|
881
881
|
let path = route.path;
|
|
882
882
|
path = handlePath(path, prefix, route.entry);
|
|
883
883
|
if (route.getStaticPaths && path?.includes(":")) {
|
|
884
|
-
const staticPaths = route.getStaticPaths();
|
|
884
|
+
const staticPaths = await route.getStaticPaths();
|
|
885
885
|
for (let staticPath of staticPaths) {
|
|
886
886
|
staticPath = handlePath(staticPath, prefix, route.entry);
|
|
887
887
|
if (Array.isArray(route.children))
|
|
888
|
-
getPaths(route.children, staticPath);
|
|
888
|
+
await getPaths(route.children, staticPath);
|
|
889
889
|
}
|
|
890
890
|
}
|
|
891
891
|
if (route.lazy)
|
|
@@ -893,10 +893,10 @@ function routesToPaths(routes) {
|
|
|
893
893
|
if (route.index)
|
|
894
894
|
addEntry(prefix, route.entry);
|
|
895
895
|
if (Array.isArray(route.children))
|
|
896
|
-
getPaths(route.children, path);
|
|
896
|
+
await getPaths(route.children, path);
|
|
897
897
|
}
|
|
898
898
|
};
|
|
899
|
-
getPaths(routes);
|
|
899
|
+
await getPaths(routes);
|
|
900
900
|
return { paths: Array.from(paths), pathToEntry, lazyPaths: Array.from(lazyPaths) };
|
|
901
901
|
function handlePath(path, prefix, entry) {
|
|
902
902
|
if (path != null) {
|
|
@@ -1229,9 +1229,9 @@ async function build(ssgOptions = {}, viteConfig = {}) {
|
|
|
1229
1229
|
const { createRoot, includedRoutes: serverEntryIncludedRoutes } = format === "esm" ? await import(serverEntry) : _require(serverEntry);
|
|
1230
1230
|
const includedRoutes = serverEntryIncludedRoutes || configIncludedRoutes;
|
|
1231
1231
|
const { routes } = await createRoot(false);
|
|
1232
|
-
const { lazyPaths } = routesToPaths(routes);
|
|
1232
|
+
const { lazyPaths } = await routesToPaths(routes);
|
|
1233
1233
|
const dataRoutes = await preLoad([...routes], lazyPaths);
|
|
1234
|
-
const { paths, pathToEntry } = routesToPaths(dataRoutes);
|
|
1234
|
+
const { paths, pathToEntry } = await routesToPaths(dataRoutes);
|
|
1235
1235
|
let routesPaths = includeAllRoutes ? paths : await includedRoutes(paths, routes || []);
|
|
1236
1236
|
routesPaths = DefaultIncludedRoutes(routesPaths);
|
|
1237
1237
|
routesPaths = Array.from(new Set(routesPaths));
|
|
@@ -153,7 +153,7 @@ interface CommonRouteOptions {
|
|
|
153
153
|
*
|
|
154
154
|
* @example () => ['path1', 'path2']
|
|
155
155
|
*/
|
|
156
|
-
getStaticPaths?: () => string[]
|
|
156
|
+
getStaticPaths?: () => string[] | Promise<string[]>;
|
|
157
157
|
}
|
|
158
158
|
type NonIndexRouteRecord = Omit<NonIndexRouteObject, 'children'> & {
|
|
159
159
|
children?: RouteRecord[];
|