@react-router/dev 0.0.0-experimental-f1dd850aa → 0.0.0-experimental-e87ed2fd4
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/cli/index.js +33 -13
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +1 -1
- package/dist/vite.js +51 -76
- package/package.json +6 -6
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @react-router/dev v0.0.0-experimental-
|
|
3
|
+
* @react-router/dev v0.0.0-experimental-e87ed2fd4
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -915,7 +915,7 @@ function generateServerBuild(ctx) {
|
|
|
915
915
|
function generateRoutes(ctx) {
|
|
916
916
|
const fileToRoutes = /* @__PURE__ */ new Map();
|
|
917
917
|
const lineages = /* @__PURE__ */ new Map();
|
|
918
|
-
const
|
|
918
|
+
const allPages = /* @__PURE__ */ new Set();
|
|
919
919
|
const routeToPages = /* @__PURE__ */ new Map();
|
|
920
920
|
for (const route of Object.values(ctx.config.routes)) {
|
|
921
921
|
let routeIds = fileToRoutes.get(route.file);
|
|
@@ -926,16 +926,17 @@ function generateRoutes(ctx) {
|
|
|
926
926
|
routeIds.add(route.id);
|
|
927
927
|
const lineage2 = lineage(ctx.config.routes, route);
|
|
928
928
|
lineages.set(route.id, lineage2);
|
|
929
|
-
const
|
|
930
|
-
if (!
|
|
931
|
-
pages
|
|
929
|
+
const fullpath2 = fullpath(lineage2);
|
|
930
|
+
if (!fullpath2) continue;
|
|
931
|
+
const pages = explodeOptionalSegments(fullpath2);
|
|
932
|
+
pages.forEach((page) => allPages.add(page));
|
|
932
933
|
lineage2.forEach(({ id }) => {
|
|
933
934
|
let routePages = routeToPages.get(id);
|
|
934
935
|
if (!routePages) {
|
|
935
936
|
routePages = /* @__PURE__ */ new Set();
|
|
936
937
|
routeToPages.set(id, routePages);
|
|
937
938
|
}
|
|
938
|
-
routePages.add(page);
|
|
939
|
+
pages.forEach((page) => routePages.add(page));
|
|
939
940
|
});
|
|
940
941
|
}
|
|
941
942
|
const routesTs = {
|
|
@@ -951,7 +952,7 @@ function generateRoutes(ctx) {
|
|
|
951
952
|
routeFiles: RouteFiles
|
|
952
953
|
}
|
|
953
954
|
}
|
|
954
|
-
` + "\n\n" + generate(pagesType(
|
|
955
|
+
` + "\n\n" + generate(pagesType(allPages)).code + "\n\n" + generate(routeFilesType({ fileToRoutes, routeToPages })).code
|
|
955
956
|
};
|
|
956
957
|
const allAnnotations = Array.from(fileToRoutes.entries()).filter(([file]) => isInAppDirectory(ctx, file)).map(
|
|
957
958
|
([file, routeIds]) => getRouteAnnotations({ ctx, file, routeIds, lineages })
|
|
@@ -1156,6 +1157,29 @@ function paramsType(path8) {
|
|
|
1156
1157
|
})
|
|
1157
1158
|
);
|
|
1158
1159
|
}
|
|
1160
|
+
function explodeOptionalSegments(path8) {
|
|
1161
|
+
let segments = path8.split("/");
|
|
1162
|
+
if (segments.length === 0) return [];
|
|
1163
|
+
let [first, ...rest] = segments;
|
|
1164
|
+
let isOptional = first.endsWith("?");
|
|
1165
|
+
let required = first.replace(/\?$/, "");
|
|
1166
|
+
if (rest.length === 0) {
|
|
1167
|
+
return isOptional ? [required, ""] : [required];
|
|
1168
|
+
}
|
|
1169
|
+
let restExploded = explodeOptionalSegments(rest.join("/"));
|
|
1170
|
+
let result = [];
|
|
1171
|
+
result.push(
|
|
1172
|
+
...restExploded.map(
|
|
1173
|
+
(subpath) => subpath === "" ? required : [required, subpath].join("/")
|
|
1174
|
+
)
|
|
1175
|
+
);
|
|
1176
|
+
if (isOptional) {
|
|
1177
|
+
result.push(...restExploded);
|
|
1178
|
+
}
|
|
1179
|
+
return result.map(
|
|
1180
|
+
(exploded) => path8.startsWith("/") && exploded === "" ? "/" : exploded
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1159
1183
|
var import_dedent, Path3, Pathe, t2;
|
|
1160
1184
|
var init_generate = __esm({
|
|
1161
1185
|
"typegen/generate.ts"() {
|
|
@@ -1368,14 +1392,10 @@ var init_route_chunks = __esm({
|
|
|
1368
1392
|
});
|
|
1369
1393
|
|
|
1370
1394
|
// vite/with-props.ts
|
|
1371
|
-
var import_dedent2, vmod;
|
|
1372
1395
|
var init_with_props = __esm({
|
|
1373
1396
|
"vite/with-props.ts"() {
|
|
1374
1397
|
"use strict";
|
|
1375
|
-
import_dedent2 = __toESM(require("dedent"));
|
|
1376
1398
|
init_babel();
|
|
1377
|
-
init_virtual_module();
|
|
1378
|
-
vmod = create("with-props");
|
|
1379
1399
|
}
|
|
1380
1400
|
});
|
|
1381
1401
|
|
|
@@ -1778,7 +1798,7 @@ async function viteAppBuild(root, {
|
|
|
1778
1798
|
},
|
|
1779
1799
|
configResolved(config) {
|
|
1780
1800
|
let hasReactRouterPlugin = config.plugins.find(
|
|
1781
|
-
(
|
|
1801
|
+
(plugin) => plugin.name === "react-router"
|
|
1782
1802
|
);
|
|
1783
1803
|
if (!hasReactRouterPlugin) {
|
|
1784
1804
|
throw new Error(
|
|
@@ -1917,7 +1937,7 @@ async function dev(root, {
|
|
|
1917
1937
|
clearScreen,
|
|
1918
1938
|
logLevel
|
|
1919
1939
|
});
|
|
1920
|
-
if (!server.config.plugins.find((
|
|
1940
|
+
if (!server.config.plugins.find((plugin) => plugin.name === "react-router")) {
|
|
1921
1941
|
console.error(
|
|
1922
1942
|
import_picocolors6.default.red("React Router Vite plugin not found in Vite config")
|
|
1923
1943
|
);
|
package/dist/config.js
CHANGED
package/dist/routes.js
CHANGED
package/dist/vite/cloudflare.js
CHANGED
package/dist/vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-e87ed2fd4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -902,7 +902,7 @@ var { t: t2 } = babel_exports;
|
|
|
902
902
|
function generateRoutes(ctx) {
|
|
903
903
|
const fileToRoutes = /* @__PURE__ */ new Map();
|
|
904
904
|
const lineages = /* @__PURE__ */ new Map();
|
|
905
|
-
const
|
|
905
|
+
const allPages = /* @__PURE__ */ new Set();
|
|
906
906
|
const routeToPages = /* @__PURE__ */ new Map();
|
|
907
907
|
for (const route of Object.values(ctx.config.routes)) {
|
|
908
908
|
let routeIds = fileToRoutes.get(route.file);
|
|
@@ -913,16 +913,17 @@ function generateRoutes(ctx) {
|
|
|
913
913
|
routeIds.add(route.id);
|
|
914
914
|
const lineage2 = lineage(ctx.config.routes, route);
|
|
915
915
|
lineages.set(route.id, lineage2);
|
|
916
|
-
const
|
|
917
|
-
if (!
|
|
918
|
-
pages
|
|
916
|
+
const fullpath2 = fullpath(lineage2);
|
|
917
|
+
if (!fullpath2) continue;
|
|
918
|
+
const pages = explodeOptionalSegments(fullpath2);
|
|
919
|
+
pages.forEach((page) => allPages.add(page));
|
|
919
920
|
lineage2.forEach(({ id }) => {
|
|
920
921
|
let routePages = routeToPages.get(id);
|
|
921
922
|
if (!routePages) {
|
|
922
923
|
routePages = /* @__PURE__ */ new Set();
|
|
923
924
|
routeToPages.set(id, routePages);
|
|
924
925
|
}
|
|
925
|
-
routePages.add(page);
|
|
926
|
+
pages.forEach((page) => routePages.add(page));
|
|
926
927
|
});
|
|
927
928
|
}
|
|
928
929
|
const routesTs = {
|
|
@@ -938,7 +939,7 @@ function generateRoutes(ctx) {
|
|
|
938
939
|
routeFiles: RouteFiles
|
|
939
940
|
}
|
|
940
941
|
}
|
|
941
|
-
` + "\n\n" + generate(pagesType(
|
|
942
|
+
` + "\n\n" + generate(pagesType(allPages)).code + "\n\n" + generate(routeFilesType({ fileToRoutes, routeToPages })).code
|
|
942
943
|
};
|
|
943
944
|
const allAnnotations = Array.from(fileToRoutes.entries()).filter(([file]) => isInAppDirectory(ctx, file)).map(
|
|
944
945
|
([file, routeIds]) => getRouteAnnotations({ ctx, file, routeIds, lineages })
|
|
@@ -1143,6 +1144,29 @@ function paramsType(path6) {
|
|
|
1143
1144
|
})
|
|
1144
1145
|
);
|
|
1145
1146
|
}
|
|
1147
|
+
function explodeOptionalSegments(path6) {
|
|
1148
|
+
let segments = path6.split("/");
|
|
1149
|
+
if (segments.length === 0) return [];
|
|
1150
|
+
let [first, ...rest] = segments;
|
|
1151
|
+
let isOptional = first.endsWith("?");
|
|
1152
|
+
let required = first.replace(/\?$/, "");
|
|
1153
|
+
if (rest.length === 0) {
|
|
1154
|
+
return isOptional ? [required, ""] : [required];
|
|
1155
|
+
}
|
|
1156
|
+
let restExploded = explodeOptionalSegments(rest.join("/"));
|
|
1157
|
+
let result = [];
|
|
1158
|
+
result.push(
|
|
1159
|
+
...restExploded.map(
|
|
1160
|
+
(subpath) => subpath === "" ? required : [required, subpath].join("/")
|
|
1161
|
+
)
|
|
1162
|
+
);
|
|
1163
|
+
if (isOptional) {
|
|
1164
|
+
result.push(...restExploded);
|
|
1165
|
+
}
|
|
1166
|
+
return result.map(
|
|
1167
|
+
(exploded) => path6.startsWith("/") && exploded === "" ? "/" : exploded
|
|
1168
|
+
);
|
|
1169
|
+
}
|
|
1146
1170
|
|
|
1147
1171
|
// typegen/index.ts
|
|
1148
1172
|
async function clearRouteModuleAnnotations(ctx) {
|
|
@@ -2183,59 +2207,11 @@ function getRouteChunkNameFromModuleId(id) {
|
|
|
2183
2207
|
}
|
|
2184
2208
|
|
|
2185
2209
|
// vite/with-props.ts
|
|
2186
|
-
var
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
enforce: "pre",
|
|
2192
|
-
resolveId(id) {
|
|
2193
|
-
if (id === vmod.id) return vmod.resolvedId;
|
|
2194
|
-
},
|
|
2195
|
-
async load(id) {
|
|
2196
|
-
if (id !== vmod.resolvedId) return;
|
|
2197
|
-
return import_dedent2.default`
|
|
2198
|
-
import { createElement as h } from "react";
|
|
2199
|
-
import { useActionData, useLoaderData, useMatches, useParams, useRouteError } from "react-router";
|
|
2200
|
-
|
|
2201
|
-
export function withComponentProps(Component) {
|
|
2202
|
-
return function Wrapped() {
|
|
2203
|
-
const props = {
|
|
2204
|
-
params: useParams(),
|
|
2205
|
-
loaderData: useLoaderData(),
|
|
2206
|
-
actionData: useActionData(),
|
|
2207
|
-
matches: useMatches(),
|
|
2208
|
-
};
|
|
2209
|
-
return h(Component, props);
|
|
2210
|
-
};
|
|
2211
|
-
}
|
|
2212
|
-
|
|
2213
|
-
export function withHydrateFallbackProps(HydrateFallback) {
|
|
2214
|
-
return function Wrapped() {
|
|
2215
|
-
const props = {
|
|
2216
|
-
params: useParams(),
|
|
2217
|
-
loaderData: useLoaderData(),
|
|
2218
|
-
actionData: useActionData(),
|
|
2219
|
-
};
|
|
2220
|
-
return h(HydrateFallback, props);
|
|
2221
|
-
};
|
|
2222
|
-
}
|
|
2223
|
-
|
|
2224
|
-
export function withErrorBoundaryProps(ErrorBoundary) {
|
|
2225
|
-
return function Wrapped() {
|
|
2226
|
-
const props = {
|
|
2227
|
-
params: useParams(),
|
|
2228
|
-
loaderData: useLoaderData(),
|
|
2229
|
-
actionData: useActionData(),
|
|
2230
|
-
error: useRouteError(),
|
|
2231
|
-
};
|
|
2232
|
-
return h(ErrorBoundary, props);
|
|
2233
|
-
};
|
|
2234
|
-
}
|
|
2235
|
-
`;
|
|
2236
|
-
}
|
|
2237
|
-
};
|
|
2238
|
-
var transform = (ast) => {
|
|
2210
|
+
var namedComponentExports = ["HydrateFallback", "ErrorBoundary"];
|
|
2211
|
+
function isNamedComponentExport(name) {
|
|
2212
|
+
return namedComponentExports.includes(name);
|
|
2213
|
+
}
|
|
2214
|
+
var decorateComponentExportsWithProps = (ast) => {
|
|
2239
2215
|
const hocs = [];
|
|
2240
2216
|
function getHocUid(path6, hocName) {
|
|
2241
2217
|
const uid = path6.scope.generateUidIdentifier(hocName);
|
|
@@ -2248,7 +2224,7 @@ var transform = (ast) => {
|
|
|
2248
2224
|
const declaration = path6.get("declaration");
|
|
2249
2225
|
const expr = declaration.isExpression() ? declaration.node : declaration.isFunctionDeclaration() ? toFunctionExpression(declaration.node) : void 0;
|
|
2250
2226
|
if (expr) {
|
|
2251
|
-
const uid = getHocUid(path6, "
|
|
2227
|
+
const uid = getHocUid(path6, "UNSAFE_withComponentProps");
|
|
2252
2228
|
declaration.replaceWith(t.callExpression(uid, [expr]));
|
|
2253
2229
|
}
|
|
2254
2230
|
return;
|
|
@@ -2263,8 +2239,8 @@ var transform = (ast) => {
|
|
|
2263
2239
|
if (!expr) return;
|
|
2264
2240
|
if (!id.isIdentifier()) return;
|
|
2265
2241
|
const { name } = id.node;
|
|
2266
|
-
if (!
|
|
2267
|
-
const uid = getHocUid(path6, `
|
|
2242
|
+
if (!isNamedComponentExport(name)) return;
|
|
2243
|
+
const uid = getHocUid(path6, `UNSAFE_with${name}Props`);
|
|
2268
2244
|
init.replaceWith(t.callExpression(uid, [expr]));
|
|
2269
2245
|
});
|
|
2270
2246
|
return;
|
|
@@ -2273,8 +2249,8 @@ var transform = (ast) => {
|
|
|
2273
2249
|
const { id } = decl.node;
|
|
2274
2250
|
if (!id) return;
|
|
2275
2251
|
const { name } = id;
|
|
2276
|
-
if (!
|
|
2277
|
-
const uid = getHocUid(path6, `
|
|
2252
|
+
if (!isNamedComponentExport(name)) return;
|
|
2253
|
+
const uid = getHocUid(path6, `UNSAFE_with${name}Props`);
|
|
2278
2254
|
decl.replaceWith(
|
|
2279
2255
|
t.variableDeclaration("const", [
|
|
2280
2256
|
t.variableDeclarator(
|
|
@@ -2293,7 +2269,7 @@ var transform = (ast) => {
|
|
|
2293
2269
|
hocs.map(
|
|
2294
2270
|
([name, identifier]) => t.importSpecifier(identifier, t.identifier(name))
|
|
2295
2271
|
),
|
|
2296
|
-
t.stringLiteral(
|
|
2272
|
+
t.stringLiteral("react-router")
|
|
2297
2273
|
)
|
|
2298
2274
|
);
|
|
2299
2275
|
}
|
|
@@ -2390,8 +2366,8 @@ var virtual = {
|
|
|
2390
2366
|
browserManifest: create("browser-manifest")
|
|
2391
2367
|
};
|
|
2392
2368
|
var invalidateVirtualModules = (viteDevServer) => {
|
|
2393
|
-
Object.values(virtual).forEach((
|
|
2394
|
-
let mod = viteDevServer.moduleGraph.getModuleById(
|
|
2369
|
+
Object.values(virtual).forEach((vmod) => {
|
|
2370
|
+
let mod = viteDevServer.moduleGraph.getModuleById(vmod.resolvedId);
|
|
2395
2371
|
if (mod) {
|
|
2396
2372
|
viteDevServer.moduleGraph.invalidateModule(mod);
|
|
2397
2373
|
}
|
|
@@ -2625,7 +2601,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2625
2601
|
};
|
|
2626
2602
|
let pluginIndex = (pluginName) => {
|
|
2627
2603
|
invariant(viteConfig);
|
|
2628
|
-
return viteConfig.plugins.findIndex((
|
|
2604
|
+
return viteConfig.plugins.findIndex((plugin) => plugin.name === pluginName);
|
|
2629
2605
|
};
|
|
2630
2606
|
let getServerEntry = async ({ routeIds }) => {
|
|
2631
2607
|
invariant(viteConfig, "viteconfig required to generate the server entry");
|
|
@@ -3211,9 +3187,9 @@ var reactRouterVitePlugin = () => {
|
|
|
3211
3187
|
envFile: false,
|
|
3212
3188
|
plugins: [
|
|
3213
3189
|
childCompilerPlugins.filter(
|
|
3214
|
-
(
|
|
3215
|
-
).map((
|
|
3216
|
-
...
|
|
3190
|
+
(plugin) => typeof plugin === "object" && plugin !== null && "name" in plugin && plugin.name !== "react-router" && plugin.name !== "react-router:route-exports" && plugin.name !== "react-router:hmr-updates"
|
|
3191
|
+
).map((plugin) => ({
|
|
3192
|
+
...plugin,
|
|
3217
3193
|
configureServer: void 0,
|
|
3218
3194
|
configurePreviewServer: void 0
|
|
3219
3195
|
}))
|
|
@@ -3603,8 +3579,8 @@ var reactRouterVitePlugin = () => {
|
|
|
3603
3579
|
name: "react-router:virtual-modules",
|
|
3604
3580
|
enforce: "pre",
|
|
3605
3581
|
resolveId(id) {
|
|
3606
|
-
const
|
|
3607
|
-
if (
|
|
3582
|
+
const vmod = Object.values(virtual).find((vmod2) => vmod2.id === id);
|
|
3583
|
+
if (vmod) return vmod.resolvedId;
|
|
3608
3584
|
},
|
|
3609
3585
|
async load(id) {
|
|
3610
3586
|
switch (id) {
|
|
@@ -3715,7 +3691,6 @@ var reactRouterVitePlugin = () => {
|
|
|
3715
3691
|
}
|
|
3716
3692
|
}
|
|
3717
3693
|
},
|
|
3718
|
-
plugin,
|
|
3719
3694
|
{
|
|
3720
3695
|
name: "react-router:route-exports",
|
|
3721
3696
|
async transform(code, id, options) {
|
|
@@ -3752,7 +3727,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3752
3727
|
if (!options?.ssr) {
|
|
3753
3728
|
removeExports(ast, SERVER_ONLY_ROUTE_EXPORTS);
|
|
3754
3729
|
}
|
|
3755
|
-
|
|
3730
|
+
decorateComponentExportsWithProps(ast);
|
|
3756
3731
|
return generate(ast, {
|
|
3757
3732
|
sourceMaps: true,
|
|
3758
3733
|
filename: id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-router/dev",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-e87ed2fd4",
|
|
4
4
|
"description": "Dev tools and CLI for React Router",
|
|
5
5
|
"homepage": "https://reactrouter.com",
|
|
6
6
|
"bugs": {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"set-cookie-parser": "^2.6.0",
|
|
87
87
|
"valibot": "^0.41.0",
|
|
88
88
|
"vite-node": "3.0.0-beta.2",
|
|
89
|
-
"@react-router/node": "0.0.0-experimental-
|
|
89
|
+
"@react-router/node": "0.0.0-experimental-e87ed2fd4"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@types/babel__core": "^7.20.5",
|
|
@@ -110,15 +110,15 @@
|
|
|
110
110
|
"vite": "^6.1.0",
|
|
111
111
|
"wireit": "0.14.9",
|
|
112
112
|
"wrangler": "^4.2.0",
|
|
113
|
-
"@react-router/serve": "0.0.0-experimental-
|
|
114
|
-
"react-router": "^0.0.0-experimental-
|
|
113
|
+
"@react-router/serve": "0.0.0-experimental-e87ed2fd4",
|
|
114
|
+
"react-router": "^0.0.0-experimental-e87ed2fd4"
|
|
115
115
|
},
|
|
116
116
|
"peerDependencies": {
|
|
117
117
|
"typescript": "^5.1.0",
|
|
118
118
|
"vite": "^5.1.0 || ^6.0.0",
|
|
119
119
|
"wrangler": "^3.28.2 || ^4.0.0",
|
|
120
|
-
"@react-router/serve": "^0.0.0-experimental-
|
|
121
|
-
"react-router": "^0.0.0-experimental-
|
|
120
|
+
"@react-router/serve": "^0.0.0-experimental-e87ed2fd4",
|
|
121
|
+
"react-router": "^0.0.0-experimental-e87ed2fd4"
|
|
122
122
|
},
|
|
123
123
|
"peerDependenciesMeta": {
|
|
124
124
|
"@react-router/serve": {
|