@rangojs/router 0.0.0-experimental.124 → 0.0.0-experimental.126
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 +6 -4
- package/dist/bin/rango.js +3 -4
- package/dist/vite/index.js +315 -68
- package/package.json +19 -18
- package/skills/breadcrumbs/SKILL.md +60 -0
- package/skills/hooks/SKILL.md +2 -2
- package/skills/route/SKILL.md +6 -0
- package/skills/server-actions/SKILL.md +25 -1
- package/skills/testing/SKILL.md +17 -17
- package/skills/testing/cache-prerender.md +29 -3
- package/skills/testing/flight.md +13 -10
- package/skills/testing/render-handler.md +3 -0
- package/skills/testing/server-tree.md +1 -1
- package/skills/testing/setup.md +1 -1
- package/src/__internal.ts +0 -65
- package/src/browser/action-coordinator.ts +1 -1
- package/src/browser/action-fence.ts +10 -0
- package/src/browser/event-controller.ts +1 -83
- package/src/browser/navigation-store-handle.ts +3 -4
- package/src/browser/navigation-store.ts +0 -39
- package/src/browser/navigation-transaction.ts +0 -32
- package/src/browser/partial-update.ts +23 -84
- package/src/browser/prefetch/cache.ts +6 -45
- package/src/browser/prefetch/queue.ts +6 -3
- package/src/browser/rango-state.ts +2 -23
- package/src/browser/react/Link.tsx +0 -2
- package/src/browser/react/NavigationProvider.tsx +2 -1
- package/src/browser/react/ScrollRestoration.tsx +10 -6
- package/src/browser/react/filter-segment-order.ts +0 -2
- package/src/browser/react/index.ts +0 -45
- package/src/browser/react/location-state-shared.ts +0 -13
- package/src/browser/react/location-state.ts +0 -1
- package/src/browser/react/use-action.ts +6 -15
- package/src/browser/react/use-handle.ts +0 -5
- package/src/browser/react/use-link-status.ts +0 -4
- package/src/browser/react/use-navigation.ts +0 -3
- package/src/browser/react/use-params.ts +0 -2
- package/src/browser/react/use-router.ts +2 -1
- package/src/browser/react/use-search-params.ts +0 -5
- package/src/browser/react/use-segments.ts +0 -13
- package/src/browser/rsc-router.tsx +10 -3
- package/src/browser/server-action-bridge.ts +51 -3
- package/src/browser/types.ts +23 -5
- package/src/browser/validate-redirect-origin.ts +43 -16
- package/src/build/index.ts +8 -9
- package/src/build/route-trie.ts +46 -11
- package/src/build/route-types/param-extraction.ts +6 -3
- package/src/build/route-types/router-processing.ts +0 -8
- package/src/cache/cache-policy.ts +0 -54
- package/src/cache/cache-runtime.ts +48 -24
- package/src/cache/cache-scope.ts +0 -27
- package/src/cache/cache-tag.ts +0 -37
- package/src/cache/cf/cf-cache-store.ts +72 -45
- package/src/cache/cf/index.ts +0 -24
- package/src/cache/document-cache.ts +10 -36
- package/src/cache/handle-snapshot.ts +0 -40
- package/src/cache/index.ts +0 -27
- package/src/cache/memory-segment-store.ts +0 -52
- package/src/cache/profile-registry.ts +6 -30
- package/src/cache/read-through-swr.ts +41 -11
- package/src/cache/segment-codec.ts +0 -16
- package/src/cache/types.ts +0 -98
- package/src/client.rsc.tsx +4 -22
- package/src/client.tsx +19 -32
- package/src/context-var.ts +12 -0
- package/src/defer.ts +196 -0
- package/src/deps/ssr.ts +0 -1
- package/src/handle.ts +2 -12
- package/src/handles/MetaTags.tsx +0 -14
- package/src/handles/breadcrumbs.ts +16 -5
- package/src/handles/meta.ts +0 -39
- package/src/host/cookie-handler.ts +0 -36
- package/src/host/errors.ts +0 -24
- package/src/host/index.ts +6 -0
- package/src/host/pattern-matcher.ts +7 -50
- package/src/host/router.ts +1 -65
- package/src/host/testing.ts +0 -16
- package/src/host/types.ts +6 -2
- package/src/href-client.ts +0 -4
- package/src/index.rsc.ts +27 -2
- package/src/index.ts +7 -0
- package/src/internal-debug.ts +2 -4
- package/src/loader.rsc.ts +4 -15
- package/src/loader.ts +3 -9
- package/src/network-error-thrower.tsx +1 -6
- package/src/outlet-provider.tsx +1 -5
- package/src/prerender/param-hash.ts +10 -11
- package/src/prerender/store.ts +23 -30
- package/src/prerender.ts +34 -0
- package/src/redirect-origin.ts +100 -0
- package/src/root-error-boundary.tsx +1 -19
- package/src/route-content-wrapper.tsx +1 -44
- package/src/route-definition/dsl-helpers.ts +7 -19
- package/src/route-definition/helpers-types.ts +3 -3
- package/src/route-definition/redirect.ts +43 -9
- package/src/route-definition/resolve-handler-use.ts +6 -0
- package/src/route-map-builder.ts +0 -16
- package/src/router/content-negotiation.ts +0 -13
- package/src/router/error-handling.ts +12 -16
- package/src/router/find-match.ts +4 -31
- package/src/router/intercept-resolution.ts +10 -1
- package/src/router/lazy-includes.ts +1 -57
- package/src/router/loader-resolution.ts +25 -23
- package/src/router/logging.ts +0 -6
- package/src/router/manifest.ts +1 -25
- package/src/router/match-api.ts +0 -20
- package/src/router/match-context.ts +0 -22
- package/src/router/match-handlers.ts +0 -43
- package/src/router/match-middleware/background-revalidation.ts +0 -7
- package/src/router/match-middleware/cache-lookup.ts +96 -179
- package/src/router/match-middleware/cache-store.ts +0 -31
- package/src/router/match-middleware/intercept-resolution.ts +0 -22
- package/src/router/match-middleware/segment-resolution.ts +0 -22
- package/src/router/match-pipelines.ts +1 -42
- package/src/router/match-result.ts +1 -52
- package/src/router/metrics.ts +0 -34
- package/src/router/middleware-types.ts +0 -116
- package/src/router/middleware.ts +77 -60
- package/src/router/navigation-snapshot.ts +0 -51
- package/src/router/params-util.ts +23 -0
- package/src/router/pattern-matching.ts +5 -56
- package/src/router/prerender-match.ts +56 -51
- package/src/router/request-classification.ts +1 -38
- package/src/router/revalidation.ts +14 -62
- package/src/router/route-snapshot.ts +0 -1
- package/src/router/router-context.ts +0 -27
- package/src/router/router-interfaces.ts +10 -0
- package/src/router/segment-resolution/fresh.ts +25 -57
- package/src/router/segment-resolution/helpers.ts +34 -0
- package/src/router/segment-resolution/loader-cache.ts +35 -23
- package/src/router/segment-resolution/revalidation.ts +188 -283
- package/src/router/segment-resolution/streamed-handler-telemetry.ts +52 -0
- package/src/router/segment-resolution.ts +4 -1
- package/src/router/segment-wrappers.ts +0 -3
- package/src/router/telemetry-otel.ts +0 -20
- package/src/router/telemetry.ts +0 -22
- package/src/router/timeout.ts +0 -20
- package/src/router/trie-matching.ts +66 -45
- package/src/router/types.ts +1 -63
- package/src/router/url-params.ts +0 -5
- package/src/router.ts +8 -11
- package/src/rsc/handler-context.ts +1 -0
- package/src/rsc/handler.ts +20 -4
- package/src/rsc/helpers.ts +71 -3
- package/src/rsc/json-route-result.ts +38 -0
- package/src/rsc/origin-guard.ts +9 -15
- package/src/rsc/progressive-enhancement.ts +10 -1
- package/src/rsc/redirect-guard.ts +99 -0
- package/src/rsc/response-route-handler.ts +23 -18
- package/src/rsc/rsc-rendering.ts +2 -7
- package/src/rsc/runtime-warnings.ts +14 -0
- package/src/rsc/server-action.ts +34 -29
- package/src/rsc/types.ts +6 -3
- package/src/search-params.ts +0 -16
- package/src/segment-loader-promise.ts +14 -2
- package/src/segment-system.tsx +79 -88
- package/src/server/handle-store.ts +7 -24
- package/src/server/loader-registry.ts +5 -24
- package/src/server/request-context.ts +29 -92
- package/src/ssr/index.tsx +14 -14
- package/src/static-handler.ts +2 -27
- package/src/testing/cache-status.ts +44 -48
- package/src/testing/collect-handle.ts +1 -24
- package/src/testing/dispatch.ts +43 -6
- package/src/testing/e2e/index.ts +1 -22
- package/src/testing/e2e/matchers.ts +0 -16
- package/src/testing/flight-matchers.ts +0 -13
- package/src/testing/flight-normalize.ts +3 -30
- package/src/testing/flight.ts +46 -48
- package/src/testing/generated-routes.ts +1 -41
- package/src/testing/index.ts +1 -21
- package/src/testing/internal/context.ts +3 -45
- package/src/testing/internal/seed-vars.ts +0 -26
- package/src/testing/render-handler.ts +31 -61
- package/src/testing/render-route.tsx +75 -103
- package/src/testing/run-loader.ts +0 -96
- package/src/testing/run-middleware.ts +0 -26
- package/src/theme/ThemeProvider.tsx +0 -52
- package/src/theme/ThemeScript.tsx +0 -6
- package/src/theme/constants.ts +0 -12
- package/src/theme/index.ts +0 -7
- package/src/theme/theme-context.ts +1 -5
- package/src/theme/theme-script.ts +0 -14
- package/src/theme/use-theme.ts +0 -3
- package/src/types/boundaries.ts +0 -35
- package/src/types/error-types.ts +25 -89
- package/src/types/global-namespace.ts +4 -14
- package/src/types/handler-context.ts +28 -9
- package/src/types/index.ts +0 -10
- package/src/types/request-scope.ts +0 -19
- package/src/types/route-config.ts +6 -50
- package/src/types/route-entry.ts +0 -6
- package/src/types/segments.ts +0 -13
- package/src/urls/include-helper.ts +0 -4
- package/src/urls/index.ts +0 -6
- package/src/urls/path-helper-types.ts +2 -2
- package/src/urls/path-helper.ts +0 -54
- package/src/urls/urls-function.ts +0 -13
- package/src/use-loader.tsx +0 -186
- package/src/vite/discovery/bundle-postprocess.ts +2 -1
- package/src/vite/discovery/discover-routers.ts +28 -18
- package/src/vite/discovery/prerender-collection.ts +2 -4
- package/src/vite/discovery/state.ts +5 -0
- package/src/vite/discovery/virtual-module-codegen.ts +1 -11
- package/src/vite/plugin-types.ts +35 -9
- package/src/vite/plugins/cjs-to-esm.ts +0 -11
- package/src/vite/plugins/client-ref-dedup.ts +0 -11
- package/src/vite/plugins/client-ref-hashing.ts +0 -10
- package/src/vite/plugins/cloudflare-protocol-stub.ts +0 -20
- package/src/vite/plugins/expose-action-id.ts +2 -73
- package/src/vite/plugins/expose-id-utils.ts +0 -55
- package/src/vite/plugins/expose-ids/export-analysis.ts +0 -38
- package/src/vite/plugins/expose-ids/handler-transform.ts +0 -15
- package/src/vite/plugins/expose-ids/loader-transform.ts +0 -15
- package/src/vite/plugins/expose-ids/router-transform.ts +0 -13
- package/src/vite/plugins/expose-internal-ids.ts +10 -0
- package/src/vite/plugins/performance-tracks.ts +0 -3
- package/src/vite/plugins/refresh-cmd.ts +1 -1
- package/src/vite/plugins/use-cache-transform.ts +21 -46
- package/src/vite/plugins/version-injector.ts +0 -20
- package/src/vite/plugins/version-plugin.ts +1 -49
- package/src/vite/plugins/virtual-entries.ts +0 -15
- package/src/vite/rango.ts +2 -108
- package/src/vite/router-discovery.ts +9 -1
- package/src/vite/utils/ast-handler-extract.ts +0 -16
- package/src/vite/utils/bundle-analysis.ts +6 -13
- package/src/vite/utils/client-chunks.ts +0 -6
- package/src/vite/utils/forward-user-plugins.ts +0 -22
- package/src/vite/utils/manifest-utils.ts +0 -4
- package/src/vite/utils/package-resolution.ts +1 -73
- package/src/vite/utils/prerender-utils.ts +0 -35
- package/src/vite/utils/shared-utils.ts +3 -35
- package/src/browser/shallow.ts +0 -40
- package/src/handles/index.ts +0 -7
- package/src/router/middleware-cookies.ts +0 -55
package/dist/vite/index.js
CHANGED
|
@@ -431,7 +431,6 @@ function exposeActionId() {
|
|
|
431
431
|
counterTransform?.record(id, performance.now() - start);
|
|
432
432
|
}
|
|
433
433
|
},
|
|
434
|
-
// Build mode: renderChunk runs after all transforms and bundling complete
|
|
435
434
|
renderChunk(code, chunk) {
|
|
436
435
|
const start = counterRender ? performance.now() : 0;
|
|
437
436
|
try {
|
|
@@ -1345,6 +1344,7 @@ ${lazyImports.join(",\n")}
|
|
|
1345
1344
|
// --------------- Loader pre-scan (build mode) ---------------
|
|
1346
1345
|
async buildStart() {
|
|
1347
1346
|
if (!isBuild) return;
|
|
1347
|
+
if (this.environment && this.environment.name !== "rsc") return;
|
|
1348
1348
|
const fs2 = await import("node:fs/promises");
|
|
1349
1349
|
const SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage"]);
|
|
1350
1350
|
async function scanDir(dir) {
|
|
@@ -1841,7 +1841,7 @@ function useCacheTransform() {
|
|
|
1841
1841
|
};
|
|
1842
1842
|
}
|
|
1843
1843
|
function transformFileLevelUseCache(code, ast, filePath, sourceId, isBuild, isLayoutOrTemplate, transformWrapExport) {
|
|
1844
|
-
const
|
|
1844
|
+
const unconfirmedExports = [];
|
|
1845
1845
|
const { exportNames, output } = transformWrapExport(code, ast, {
|
|
1846
1846
|
runtime: (value, name) => {
|
|
1847
1847
|
const funcId = isBuild ? hashId(filePath, name) : `${filePath}#${name}`;
|
|
@@ -1850,16 +1850,17 @@ function transformFileLevelUseCache(code, ast, filePath, sourceId, isBuild, isLa
|
|
|
1850
1850
|
rejectNonAsyncFunction: false,
|
|
1851
1851
|
filter: (name, meta) => {
|
|
1852
1852
|
if (name === "default" && isLayoutOrTemplate) return false;
|
|
1853
|
-
if (meta.isFunction
|
|
1854
|
-
|
|
1853
|
+
if (meta.isFunction !== true) {
|
|
1854
|
+
unconfirmedExports.push(name);
|
|
1855
1855
|
return false;
|
|
1856
1856
|
}
|
|
1857
1857
|
return true;
|
|
1858
1858
|
}
|
|
1859
1859
|
});
|
|
1860
|
-
if (
|
|
1860
|
+
if (unconfirmedExports.length > 0) {
|
|
1861
|
+
const plural = unconfirmedExports.length > 1;
|
|
1861
1862
|
throw new Error(
|
|
1862
|
-
`[rango:use-cache] File-level "use cache" in ${sourceId}
|
|
1863
|
+
`[rango:use-cache] File-level "use cache" in ${sourceId} only wraps exports that are statically-confirmed functions. ${plural ? "These exports are" : "This export is"} not: ${unconfirmedExports.map((n) => `"${n}"`).join(", ")}. Declare them directly (export async function foo() {} or export const foo = async () => {}). A factory or otherwise statically-indeterminate initializer (export const foo = makeCached(fn)) is rejected even if it returns a function at runtime -- rewrite it as a direct async function, or move non-function exports to a separate module.`
|
|
1863
1864
|
);
|
|
1864
1865
|
}
|
|
1865
1866
|
if (exportNames.length === 0) {
|
|
@@ -1997,7 +1998,6 @@ function clientRefDedup() {
|
|
|
1997
1998
|
if (this.environment?.name !== "client") return;
|
|
1998
1999
|
if (!importer?.includes(CLIENT_IN_SERVER_PROXY_PREFIX)) return;
|
|
1999
2000
|
if (!source.includes("/node_modules/")) return;
|
|
2000
|
-
if (!importer) return;
|
|
2001
2001
|
const packageName = extractPackageName(source);
|
|
2002
2002
|
if (!packageName) return;
|
|
2003
2003
|
if (clientExclude.includes(packageName)) return;
|
|
@@ -2130,7 +2130,7 @@ import { resolve } from "node:path";
|
|
|
2130
2130
|
// package.json
|
|
2131
2131
|
var package_default = {
|
|
2132
2132
|
name: "@rangojs/router",
|
|
2133
|
-
version: "0.0.0-experimental.
|
|
2133
|
+
version: "0.0.0-experimental.126",
|
|
2134
2134
|
description: "Django-inspired RSC router with composable URL patterns",
|
|
2135
2135
|
keywords: [
|
|
2136
2136
|
"react",
|
|
@@ -2422,10 +2422,10 @@ function extractParamsFromPattern(pattern) {
|
|
|
2422
2422
|
function formatRouteEntry(key, pattern, _params, search) {
|
|
2423
2423
|
const hasSearch = search && Object.keys(search).length > 0;
|
|
2424
2424
|
if (!hasSearch) {
|
|
2425
|
-
return ` ${key}:
|
|
2425
|
+
return ` ${key}: ${JSON.stringify(pattern)},`;
|
|
2426
2426
|
}
|
|
2427
|
-
const searchBody = Object.entries(search).map(([k, v]) => `${k}:
|
|
2428
|
-
return ` ${key}: { path:
|
|
2427
|
+
const searchBody = Object.entries(search).map(([k, v]) => `${k}: ${JSON.stringify(v)}`).join(", ");
|
|
2428
|
+
return ` ${key}: { path: ${JSON.stringify(pattern)}, search: { ${searchBody} } },`;
|
|
2429
2429
|
}
|
|
2430
2430
|
|
|
2431
2431
|
// src/build/route-types/ast-route-extraction.ts
|
|
@@ -2541,7 +2541,31 @@ declare global {
|
|
|
2541
2541
|
}
|
|
2542
2542
|
|
|
2543
2543
|
// src/build/route-types/scan-filter.ts
|
|
2544
|
+
import { join, relative } from "node:path";
|
|
2544
2545
|
import picomatch from "picomatch";
|
|
2546
|
+
var DEFAULT_EXCLUDE_PATTERNS = [
|
|
2547
|
+
"**/__tests__/**",
|
|
2548
|
+
"**/__mocks__/**",
|
|
2549
|
+
"**/dist/**",
|
|
2550
|
+
"**/coverage/**",
|
|
2551
|
+
"**/*.test.{ts,tsx,js,jsx}",
|
|
2552
|
+
"**/*.spec.{ts,tsx,js,jsx}"
|
|
2553
|
+
];
|
|
2554
|
+
function createScanFilter(root, opts) {
|
|
2555
|
+
const { include, exclude } = opts;
|
|
2556
|
+
const hasInclude = include && include.length > 0;
|
|
2557
|
+
const hasCustomExclude = exclude !== void 0;
|
|
2558
|
+
if (!hasInclude && !hasCustomExclude) return void 0;
|
|
2559
|
+
const effectiveExclude = exclude ?? DEFAULT_EXCLUDE_PATTERNS;
|
|
2560
|
+
const includeMatcher = hasInclude ? picomatch(include) : null;
|
|
2561
|
+
const excludeMatcher = effectiveExclude.length > 0 ? picomatch(effectiveExclude) : null;
|
|
2562
|
+
return (absolutePath) => {
|
|
2563
|
+
const rel = relative(root, absolutePath);
|
|
2564
|
+
if (excludeMatcher && excludeMatcher(rel)) return false;
|
|
2565
|
+
if (includeMatcher) return includeMatcher(rel);
|
|
2566
|
+
return true;
|
|
2567
|
+
};
|
|
2568
|
+
}
|
|
2545
2569
|
|
|
2546
2570
|
// src/build/route-types/per-module-writer.ts
|
|
2547
2571
|
import ts4 from "typescript";
|
|
@@ -2810,7 +2834,7 @@ import {
|
|
|
2810
2834
|
readdirSync
|
|
2811
2835
|
} from "node:fs";
|
|
2812
2836
|
import {
|
|
2813
|
-
join,
|
|
2837
|
+
join as join2,
|
|
2814
2838
|
dirname as dirname2,
|
|
2815
2839
|
resolve as resolve3,
|
|
2816
2840
|
sep,
|
|
@@ -2846,7 +2870,7 @@ function findRouterFilesRecursive(dir, filter, results) {
|
|
|
2846
2870
|
const childDirs = [];
|
|
2847
2871
|
const routerFilesInDir = [];
|
|
2848
2872
|
for (const entry of entries) {
|
|
2849
|
-
const fullPath =
|
|
2873
|
+
const fullPath = join2(dir, entry.name);
|
|
2850
2874
|
if (entry.isDirectory()) {
|
|
2851
2875
|
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === "coverage" || entry.name === "__tests__" || entry.name === "__mocks__" || entry.name.startsWith("."))
|
|
2852
2876
|
continue;
|
|
@@ -3006,7 +3030,7 @@ function applyBasenameToRoutes(result, basename2) {
|
|
|
3006
3030
|
}
|
|
3007
3031
|
function genFileTsPath(sourceFile) {
|
|
3008
3032
|
const base = pathBasename(sourceFile).replace(/\.(tsx?|jsx?)$/, "");
|
|
3009
|
-
return
|
|
3033
|
+
return join2(dirname2(sourceFile), `${base}.named-routes.gen.ts`);
|
|
3010
3034
|
}
|
|
3011
3035
|
function resolveSearchSchemas(publicRouteNames, runtimeSchemas, sourceFile) {
|
|
3012
3036
|
if (runtimeSchemas && Object.keys(runtimeSchemas).length > 0) {
|
|
@@ -3072,7 +3096,7 @@ function findRouterFiles(root, filter) {
|
|
|
3072
3096
|
}
|
|
3073
3097
|
function writeCombinedRouteTypes(root, knownRouterFiles, opts) {
|
|
3074
3098
|
try {
|
|
3075
|
-
const oldCombinedPath =
|
|
3099
|
+
const oldCombinedPath = join2(root, "src", "named-routes.gen.ts");
|
|
3076
3100
|
if (existsSync3(oldCombinedPath)) {
|
|
3077
3101
|
unlinkSync(oldCombinedPath);
|
|
3078
3102
|
console.log(
|
|
@@ -3282,7 +3306,6 @@ function createVersionPlugin() {
|
|
|
3282
3306
|
}
|
|
3283
3307
|
return null;
|
|
3284
3308
|
},
|
|
3285
|
-
// Track RSC module changes and update version
|
|
3286
3309
|
async hotUpdate(ctx) {
|
|
3287
3310
|
if (!isDev) return;
|
|
3288
3311
|
const isRscModule = this.environment?.name === "rsc";
|
|
@@ -3359,9 +3382,6 @@ function performanceTracksOptimizeDepsPlugin() {
|
|
|
3359
3382
|
const RSDW_CLIENT_RE = /react-server-dom-webpack-client\.browser\.(development|production)\.js$/;
|
|
3360
3383
|
return {
|
|
3361
3384
|
name: "@rangojs/router:performance-tracks-optimize-deps",
|
|
3362
|
-
// Vite 8 optimizes deps with Rolldown (Rollup-style plugin pipeline), so the
|
|
3363
|
-
// pre-bundled RSDW client is patched via load() rather than esbuild's onLoad.
|
|
3364
|
-
// Returning code overrides Rolldown's default filesystem read for the module.
|
|
3365
3385
|
async load(id) {
|
|
3366
3386
|
const cleanId = id.split("?")[0] ?? id;
|
|
3367
3387
|
if (!RSDW_CLIENT_RE.test(cleanId)) return null;
|
|
@@ -3504,7 +3524,7 @@ function getManualChunks(id) {
|
|
|
3504
3524
|
}
|
|
3505
3525
|
|
|
3506
3526
|
// src/vite/plugins/client-ref-hashing.ts
|
|
3507
|
-
import { relative } from "node:path";
|
|
3527
|
+
import { relative as relative2 } from "node:path";
|
|
3508
3528
|
import { createHash as createHash2 } from "node:crypto";
|
|
3509
3529
|
var debug7 = createRangoDebugger(NS.transform);
|
|
3510
3530
|
var CLIENT_PKG_PROXY_PREFIX = "/@id/__x00__virtual:vite-rsc/client-package-proxy/";
|
|
@@ -3521,10 +3541,10 @@ function computeProductionHash(projectRoot, refKey) {
|
|
|
3521
3541
|
const absPath = decodeURIComponent(
|
|
3522
3542
|
refKey.slice(CLIENT_IN_SERVER_PKG_PROXY_PREFIX.length)
|
|
3523
3543
|
);
|
|
3524
|
-
toHash =
|
|
3544
|
+
toHash = relative2(projectRoot, absPath).replaceAll("\\", "/");
|
|
3525
3545
|
} else if (refKey.startsWith(FS_PREFIX)) {
|
|
3526
3546
|
const absPath = refKey.slice(FS_PREFIX.length - 1);
|
|
3527
|
-
toHash =
|
|
3547
|
+
toHash = relative2(projectRoot, absPath).replaceAll("\\", "/");
|
|
3528
3548
|
} else if (refKey.startsWith("/")) {
|
|
3529
3549
|
toHash = refKey.slice(1);
|
|
3530
3550
|
} else {
|
|
@@ -3551,7 +3571,6 @@ function hashClientRefs(projectRoot) {
|
|
|
3551
3571
|
const counter = createCounter(debug7, "hash-client-refs");
|
|
3552
3572
|
return {
|
|
3553
3573
|
name: "@rangojs/router:hash-client-refs",
|
|
3554
|
-
// Run after the RSC plugin's transform (default enforce is normal)
|
|
3555
3574
|
enforce: "post",
|
|
3556
3575
|
applyToEnvironment(env) {
|
|
3557
3576
|
return env.name === "rsc";
|
|
@@ -4060,6 +4079,49 @@ function checkSelfGenWrite(state, filePath, consume) {
|
|
|
4060
4079
|
}
|
|
4061
4080
|
}
|
|
4062
4081
|
|
|
4082
|
+
// src/router/logging.ts
|
|
4083
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4084
|
+
|
|
4085
|
+
// src/internal-debug.ts
|
|
4086
|
+
var INTERNAL_RANGO_DEBUG = typeof __RANGO_DEBUG__ !== "undefined" ? __RANGO_DEBUG__ : typeof process !== "undefined" && Boolean(process.env?.INTERNAL_RANGO_DEBUG);
|
|
4087
|
+
|
|
4088
|
+
// src/router/logging.ts
|
|
4089
|
+
var routerLogContext = new AsyncLocalStorage();
|
|
4090
|
+
|
|
4091
|
+
// src/router/pattern-matching.ts
|
|
4092
|
+
function parsePattern(pattern) {
|
|
4093
|
+
const segments = [];
|
|
4094
|
+
const segmentRegex = /\/(:([a-zA-Z_][a-zA-Z0-9_]*)(\(([^)]+)\))?(\?)?([^/]*)|(\*)|([^/]+))/g;
|
|
4095
|
+
let match;
|
|
4096
|
+
while ((match = segmentRegex.exec(pattern)) !== null) {
|
|
4097
|
+
const [
|
|
4098
|
+
,
|
|
4099
|
+
,
|
|
4100
|
+
paramName,
|
|
4101
|
+
,
|
|
4102
|
+
constraint,
|
|
4103
|
+
optional,
|
|
4104
|
+
suffix,
|
|
4105
|
+
wildcard,
|
|
4106
|
+
staticText
|
|
4107
|
+
] = match;
|
|
4108
|
+
if (wildcard) {
|
|
4109
|
+
segments.push({ type: "wildcard", value: "*", optional: false });
|
|
4110
|
+
} else if (paramName) {
|
|
4111
|
+
segments.push({
|
|
4112
|
+
type: "param",
|
|
4113
|
+
value: paramName,
|
|
4114
|
+
optional: optional === "?",
|
|
4115
|
+
constraint: constraint ? constraint.split("|") : void 0,
|
|
4116
|
+
suffix: suffix || void 0
|
|
4117
|
+
});
|
|
4118
|
+
} else if (staticText) {
|
|
4119
|
+
segments.push({ type: "static", value: staticText, optional: false });
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
4122
|
+
return segments;
|
|
4123
|
+
}
|
|
4124
|
+
|
|
4063
4125
|
// src/build/prefix-tree-utils.ts
|
|
4064
4126
|
function flattenLeafEntries(prefixTree, routeManifest, result) {
|
|
4065
4127
|
function visit(node, ancestorStaticPrefixes) {
|
|
@@ -4102,6 +4164,216 @@ function buildRouteToStaticPrefix(prefixTree, result) {
|
|
|
4102
4164
|
}
|
|
4103
4165
|
}
|
|
4104
4166
|
|
|
4167
|
+
// src/build/route-trie.ts
|
|
4168
|
+
function buildRouteTrie(routeManifest, routeAncestry, routeToStaticPrefix, routeTrailingSlash, prerenderRouteNames, passthroughRouteNames, responseTypeRoutes) {
|
|
4169
|
+
const root = {};
|
|
4170
|
+
for (const [routeName, pattern] of Object.entries(routeManifest)) {
|
|
4171
|
+
const ancestry = routeAncestry[routeName] || [];
|
|
4172
|
+
const staticPrefix = routeToStaticPrefix[routeName] || "";
|
|
4173
|
+
const trailingSlash = routeTrailingSlash?.[routeName];
|
|
4174
|
+
const responseType = responseTypeRoutes?.[routeName];
|
|
4175
|
+
const hasTrailingSlash = pattern.length > 1 && pattern.endsWith("/");
|
|
4176
|
+
const normalizedPattern = hasTrailingSlash ? pattern.slice(0, -1) : pattern;
|
|
4177
|
+
const segments = parsePattern(normalizedPattern);
|
|
4178
|
+
insertRoute(root, segments, 0, {
|
|
4179
|
+
n: routeName,
|
|
4180
|
+
sp: staticPrefix,
|
|
4181
|
+
a: ancestry,
|
|
4182
|
+
...trailingSlash ? { ts: trailingSlash } : {},
|
|
4183
|
+
...prerenderRouteNames?.has(routeName) ? { pr: true } : {},
|
|
4184
|
+
...passthroughRouteNames?.has(routeName) ? { pt: true } : {},
|
|
4185
|
+
...responseType ? { rt: responseType } : {}
|
|
4186
|
+
});
|
|
4187
|
+
}
|
|
4188
|
+
sortSuffixParams(root);
|
|
4189
|
+
return root;
|
|
4190
|
+
}
|
|
4191
|
+
function sortSuffixParams(node) {
|
|
4192
|
+
if (node.xp) {
|
|
4193
|
+
const sorted = {};
|
|
4194
|
+
for (const suffix of Object.keys(node.xp).sort(
|
|
4195
|
+
(a, b) => b.length - a.length
|
|
4196
|
+
)) {
|
|
4197
|
+
sorted[suffix] = node.xp[suffix];
|
|
4198
|
+
}
|
|
4199
|
+
node.xp = sorted;
|
|
4200
|
+
}
|
|
4201
|
+
if (node.s) {
|
|
4202
|
+
for (const child of Object.values(node.s)) {
|
|
4203
|
+
sortSuffixParams(child);
|
|
4204
|
+
}
|
|
4205
|
+
}
|
|
4206
|
+
if (node.p) {
|
|
4207
|
+
sortSuffixParams(node.p.c);
|
|
4208
|
+
}
|
|
4209
|
+
if (node.xp) {
|
|
4210
|
+
for (const child of Object.values(node.xp)) {
|
|
4211
|
+
sortSuffixParams(child.c);
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
}
|
|
4215
|
+
function buildPerRouterTrie(manifest) {
|
|
4216
|
+
const ancestry = manifest._routeAncestry;
|
|
4217
|
+
if (!ancestry || Object.keys(ancestry).length === 0) {
|
|
4218
|
+
return null;
|
|
4219
|
+
}
|
|
4220
|
+
const routeToStaticPrefix = {};
|
|
4221
|
+
for (const name of Object.keys(manifest.routeManifest)) {
|
|
4222
|
+
routeToStaticPrefix[name] = "";
|
|
4223
|
+
}
|
|
4224
|
+
if (manifest.prefixTree) {
|
|
4225
|
+
buildRouteToStaticPrefix(manifest.prefixTree, routeToStaticPrefix);
|
|
4226
|
+
}
|
|
4227
|
+
return buildRouteTrie(
|
|
4228
|
+
manifest.routeManifest,
|
|
4229
|
+
ancestry,
|
|
4230
|
+
routeToStaticPrefix,
|
|
4231
|
+
manifest.routeTrailingSlash,
|
|
4232
|
+
manifest.prerenderRoutes ? new Set(manifest.prerenderRoutes) : void 0,
|
|
4233
|
+
manifest.passthroughRoutes ? new Set(manifest.passthroughRoutes) : void 0,
|
|
4234
|
+
manifest.responseTypeRoutes
|
|
4235
|
+
);
|
|
4236
|
+
}
|
|
4237
|
+
function insertRoute(node, segments, index, leaf) {
|
|
4238
|
+
const constraints = {};
|
|
4239
|
+
for (const seg of segments) {
|
|
4240
|
+
if (seg.type === "param") {
|
|
4241
|
+
if (seg.constraint) {
|
|
4242
|
+
constraints[seg.value] = seg.constraint;
|
|
4243
|
+
}
|
|
4244
|
+
}
|
|
4245
|
+
}
|
|
4246
|
+
const leafBase = {
|
|
4247
|
+
...leaf,
|
|
4248
|
+
...Object.keys(constraints).length > 0 ? { cv: constraints } : {}
|
|
4249
|
+
};
|
|
4250
|
+
insertSegments(node, segments, index, leafBase, []);
|
|
4251
|
+
}
|
|
4252
|
+
function mergeLeaves(existing, leaf) {
|
|
4253
|
+
if (!existing) return leaf;
|
|
4254
|
+
if (existing.rt && leaf.rt) {
|
|
4255
|
+
const merged = leaf;
|
|
4256
|
+
merged.nv = existing.nv || [];
|
|
4257
|
+
merged.nv.push({ routeKey: existing.n, responseType: existing.rt });
|
|
4258
|
+
return merged;
|
|
4259
|
+
}
|
|
4260
|
+
if (leaf.rt && !existing.rt) {
|
|
4261
|
+
if (!existing.nv) {
|
|
4262
|
+
existing.nv = [];
|
|
4263
|
+
existing.rf = true;
|
|
4264
|
+
}
|
|
4265
|
+
existing.nv.push({ routeKey: leaf.n, responseType: leaf.rt });
|
|
4266
|
+
return existing;
|
|
4267
|
+
}
|
|
4268
|
+
if (!leaf.rt && existing.rt) {
|
|
4269
|
+
if (!leaf.nv) leaf.nv = [];
|
|
4270
|
+
if (existing.nv) leaf.nv.push(...existing.nv);
|
|
4271
|
+
leaf.nv.push({ routeKey: existing.n, responseType: existing.rt });
|
|
4272
|
+
return leaf;
|
|
4273
|
+
}
|
|
4274
|
+
return leaf;
|
|
4275
|
+
}
|
|
4276
|
+
function mergeLeaf(node, leaf) {
|
|
4277
|
+
node.r = mergeLeaves(node.r, leaf);
|
|
4278
|
+
}
|
|
4279
|
+
function buildLeaf(leafBase, paramNames) {
|
|
4280
|
+
return paramNames.length > 0 ? { ...leafBase, pa: [...paramNames] } : { ...leafBase };
|
|
4281
|
+
}
|
|
4282
|
+
function insertSegments(node, segments, index, leafBase, paramNames) {
|
|
4283
|
+
if (index >= segments.length) {
|
|
4284
|
+
mergeLeaf(node, buildLeaf(leafBase, paramNames));
|
|
4285
|
+
return;
|
|
4286
|
+
}
|
|
4287
|
+
const segment = segments[index];
|
|
4288
|
+
if (segment.type === "static") {
|
|
4289
|
+
if (!node.s) node.s = {};
|
|
4290
|
+
if (!node.s[segment.value]) node.s[segment.value] = {};
|
|
4291
|
+
insertSegments(
|
|
4292
|
+
node.s[segment.value],
|
|
4293
|
+
segments,
|
|
4294
|
+
index + 1,
|
|
4295
|
+
leafBase,
|
|
4296
|
+
paramNames
|
|
4297
|
+
);
|
|
4298
|
+
} else if (segment.type === "param") {
|
|
4299
|
+
if (segment.optional) {
|
|
4300
|
+
insertSegments(node, segments, index + 1, leafBase, paramNames);
|
|
4301
|
+
}
|
|
4302
|
+
if (segment.suffix) {
|
|
4303
|
+
if (!node.xp) node.xp = {};
|
|
4304
|
+
if (!node.xp[segment.suffix]) {
|
|
4305
|
+
node.xp[segment.suffix] = { n: segment.value, c: {} };
|
|
4306
|
+
}
|
|
4307
|
+
insertSegments(node.xp[segment.suffix].c, segments, index + 1, leafBase, [
|
|
4308
|
+
...paramNames,
|
|
4309
|
+
segment.value
|
|
4310
|
+
]);
|
|
4311
|
+
} else {
|
|
4312
|
+
if (!node.p) {
|
|
4313
|
+
node.p = { n: segment.value, c: {} };
|
|
4314
|
+
}
|
|
4315
|
+
insertSegments(node.p.c, segments, index + 1, leafBase, [
|
|
4316
|
+
...paramNames,
|
|
4317
|
+
segment.value
|
|
4318
|
+
]);
|
|
4319
|
+
}
|
|
4320
|
+
} else if (segment.type === "wildcard") {
|
|
4321
|
+
const wildLeaf = {
|
|
4322
|
+
...buildLeaf(leafBase, paramNames),
|
|
4323
|
+
pn: "*"
|
|
4324
|
+
};
|
|
4325
|
+
const existing = node.w ? { ...node.w } : void 0;
|
|
4326
|
+
const merged = mergeLeaves(existing, wildLeaf);
|
|
4327
|
+
node.w = merged;
|
|
4328
|
+
}
|
|
4329
|
+
}
|
|
4330
|
+
|
|
4331
|
+
// src/build/collect-fallback-refs.ts
|
|
4332
|
+
var CLIENT_REF = /* @__PURE__ */ Symbol.for("react.client.reference");
|
|
4333
|
+
var MAX_DEPTH = 40;
|
|
4334
|
+
var SYNTHETIC_PROPS = {
|
|
4335
|
+
error: new Error("rango: build-time fallback-chunk discovery"),
|
|
4336
|
+
reset: () => {
|
|
4337
|
+
},
|
|
4338
|
+
pathname: "/",
|
|
4339
|
+
info: { componentStack: "" }
|
|
4340
|
+
};
|
|
4341
|
+
function isReactNodeLike(v) {
|
|
4342
|
+
return Array.isArray(v) || typeof v === "object" && v !== null && "$$typeof" in v;
|
|
4343
|
+
}
|
|
4344
|
+
function walkElementTree(node, report, depth) {
|
|
4345
|
+
if (node == null || depth > MAX_DEPTH) return;
|
|
4346
|
+
if (Array.isArray(node)) {
|
|
4347
|
+
for (const child of node) walkElementTree(child, report, depth + 1);
|
|
4348
|
+
return;
|
|
4349
|
+
}
|
|
4350
|
+
if (typeof node !== "object") return;
|
|
4351
|
+
const el = node;
|
|
4352
|
+
const type = el.type;
|
|
4353
|
+
if (type?.$$typeof === CLIENT_REF && typeof type.$$id === "string") {
|
|
4354
|
+
report(type.$$id.split("#")[0]);
|
|
4355
|
+
}
|
|
4356
|
+
const props = el.props;
|
|
4357
|
+
if (props && typeof props === "object") {
|
|
4358
|
+
walkElementTree(props.children, report, depth + 1);
|
|
4359
|
+
for (const key in props) {
|
|
4360
|
+
if (key === "children") continue;
|
|
4361
|
+
const value = props[key];
|
|
4362
|
+
if (isReactNodeLike(value)) walkElementTree(value, report, depth + 1);
|
|
4363
|
+
}
|
|
4364
|
+
}
|
|
4365
|
+
}
|
|
4366
|
+
function collectFallbackClientRefs(boundary, report) {
|
|
4367
|
+
try {
|
|
4368
|
+
let node = boundary;
|
|
4369
|
+
if (typeof node === "function") {
|
|
4370
|
+
node = node(SYNTHETIC_PROPS);
|
|
4371
|
+
}
|
|
4372
|
+
walkElementTree(node, report, 0);
|
|
4373
|
+
} catch {
|
|
4374
|
+
}
|
|
4375
|
+
}
|
|
4376
|
+
|
|
4105
4377
|
// src/vite/utils/manifest-utils.ts
|
|
4106
4378
|
function jsonParseExpression(value) {
|
|
4107
4379
|
const json = JSON.stringify(value);
|
|
@@ -4110,6 +4382,9 @@ function jsonParseExpression(value) {
|
|
|
4110
4382
|
}
|
|
4111
4383
|
|
|
4112
4384
|
// src/context-var.ts
|
|
4385
|
+
function hasContextVars(variables) {
|
|
4386
|
+
return Object.keys(variables).length > 0 || Object.getOwnPropertySymbols(variables).length > 0;
|
|
4387
|
+
}
|
|
4113
4388
|
var NON_CACHEABLE_KEYS = /* @__PURE__ */ Symbol.for(
|
|
4114
4389
|
"rango:non-cacheable-keys"
|
|
4115
4390
|
);
|
|
@@ -4362,7 +4637,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
|
|
|
4362
4637
|
(performance.now() - getParamsStart).toFixed(1)
|
|
4363
4638
|
);
|
|
4364
4639
|
const concurrency = def.options?.concurrency ?? 1;
|
|
4365
|
-
const hasBuildVars =
|
|
4640
|
+
const hasBuildVars = hasContextVars(buildVars);
|
|
4366
4641
|
for (const params of paramsList) {
|
|
4367
4642
|
let url = substituteRouteParams(
|
|
4368
4643
|
pattern,
|
|
@@ -4804,8 +5079,8 @@ async function discoverRouters(state, rscEnv) {
|
|
|
4804
5079
|
computeProductionHash(state.projectRoot, refKey)
|
|
4805
5080
|
) : void 0;
|
|
4806
5081
|
const collectFromBoundaryNode = (node) => {
|
|
4807
|
-
if (collectClientFallbackRef
|
|
4808
|
-
|
|
5082
|
+
if (collectClientFallbackRef) {
|
|
5083
|
+
collectFallbackClientRefs(node, collectClientFallbackRef);
|
|
4809
5084
|
}
|
|
4810
5085
|
};
|
|
4811
5086
|
const manifestGenStart = debug10 ? performance.now() : 0;
|
|
@@ -4864,18 +5139,14 @@ async function discoverRouters(state, rscEnv) {
|
|
|
4864
5139
|
if (manifest.routeTrailingSlash) {
|
|
4865
5140
|
Object.assign(mergedRouteTrailingSlash, manifest.routeTrailingSlash);
|
|
4866
5141
|
}
|
|
4867
|
-
flattenLeafEntries(
|
|
4868
|
-
manifest.prefixTree,
|
|
4869
|
-
manifest.routeManifest,
|
|
4870
|
-
newMergedPrecomputedEntries
|
|
4871
|
-
);
|
|
4872
|
-
newPerRouterManifestDataMap.set(id, manifest.routeManifest);
|
|
4873
5142
|
const routerPrecomputed = [];
|
|
4874
5143
|
flattenLeafEntries(
|
|
4875
5144
|
manifest.prefixTree,
|
|
4876
5145
|
manifest.routeManifest,
|
|
4877
5146
|
routerPrecomputed
|
|
4878
5147
|
);
|
|
5148
|
+
newMergedPrecomputedEntries.push(...routerPrecomputed);
|
|
5149
|
+
newPerRouterManifestDataMap.set(id, manifest.routeManifest);
|
|
4879
5150
|
newPerRouterPrecomputedMap.set(id, routerPrecomputed);
|
|
4880
5151
|
console.log(
|
|
4881
5152
|
`[rango] Router "${id}" -> ${routeCount} routes (${staticRoutes} static, ${dynamicRoutes} dynamic)`
|
|
@@ -4899,8 +5170,7 @@ async function discoverRouters(state, rscEnv) {
|
|
|
4899
5170
|
let newMergedRouteTrie = null;
|
|
4900
5171
|
const trieStart = debug10 ? performance.now() : 0;
|
|
4901
5172
|
if (Object.keys(newMergedRouteManifest).length > 0) {
|
|
4902
|
-
|
|
4903
|
-
if (buildRouteTrie && mergedRouteAncestry) {
|
|
5173
|
+
if (mergedRouteAncestry) {
|
|
4904
5174
|
const routeToStaticPrefix = {};
|
|
4905
5175
|
for (const { manifest } of allManifests) {
|
|
4906
5176
|
for (const name of Object.keys(manifest.routeManifest)) {
|
|
@@ -4937,9 +5207,8 @@ async function discoverRouters(state, rscEnv) {
|
|
|
4937
5207
|
passthroughRouteNames,
|
|
4938
5208
|
mergedResponseTypeRoutes
|
|
4939
5209
|
);
|
|
4940
|
-
const buildPerRouterTrie = buildMod.buildPerRouterTrie;
|
|
4941
5210
|
for (const { id, manifest } of allManifests) {
|
|
4942
|
-
const perRouterTrie = buildPerRouterTrie
|
|
5211
|
+
const perRouterTrie = buildPerRouterTrie(manifest);
|
|
4943
5212
|
if (perRouterTrie) {
|
|
4944
5213
|
newPerRouterTrieMap.set(id, perRouterTrie);
|
|
4945
5214
|
}
|
|
@@ -4963,7 +5232,7 @@ async function discoverRouters(state, rscEnv) {
|
|
|
4963
5232
|
}
|
|
4964
5233
|
|
|
4965
5234
|
// src/vite/discovery/route-types-writer.ts
|
|
4966
|
-
import { dirname as dirname3, join as
|
|
5235
|
+
import { dirname as dirname3, join as join3, resolve as resolve6 } from "node:path";
|
|
4967
5236
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, existsSync as existsSync5, unlinkSync as unlinkSync2 } from "node:fs";
|
|
4968
5237
|
function filterUserNamedRoutes(manifest) {
|
|
4969
5238
|
const filtered = {};
|
|
@@ -4995,7 +5264,7 @@ function writeRouteTypesFiles(state) {
|
|
|
4995
5264
|
const entryDir = dirname3(
|
|
4996
5265
|
resolve6(state.projectRoot, state.resolvedEntryPath)
|
|
4997
5266
|
);
|
|
4998
|
-
const oldCombinedPath =
|
|
5267
|
+
const oldCombinedPath = join3(entryDir, "named-routes.gen.ts");
|
|
4999
5268
|
if (existsSync5(oldCombinedPath)) {
|
|
5000
5269
|
unlinkSync2(oldCombinedPath);
|
|
5001
5270
|
console.log(
|
|
@@ -5077,7 +5346,7 @@ function supplementGenFilesWithRuntimeRoutes(state) {
|
|
|
5077
5346
|
}
|
|
5078
5347
|
|
|
5079
5348
|
// src/vite/discovery/virtual-module-codegen.ts
|
|
5080
|
-
import { dirname as dirname4, basename, join as
|
|
5349
|
+
import { dirname as dirname4, basename, join as join4 } from "node:path";
|
|
5081
5350
|
function generateRoutesManifestModule(state) {
|
|
5082
5351
|
const hasManifest = state.mergedRouteManifest && Object.keys(state.mergedRouteManifest).length > 0;
|
|
5083
5352
|
if (hasManifest) {
|
|
@@ -5092,7 +5361,7 @@ function generateRoutesManifestModule(state) {
|
|
|
5092
5361
|
/\.(tsx?|jsx?)$/,
|
|
5093
5362
|
""
|
|
5094
5363
|
);
|
|
5095
|
-
const genPath =
|
|
5364
|
+
const genPath = join4(
|
|
5096
5365
|
routerDir,
|
|
5097
5366
|
`${routerBasename}.named-routes.gen.js`
|
|
5098
5367
|
).replaceAll("\\", "/");
|
|
@@ -5177,7 +5446,7 @@ function generatePerRouterModule(state, routerId) {
|
|
|
5177
5446
|
/\.(tsx?|jsx?)$/,
|
|
5178
5447
|
""
|
|
5179
5448
|
);
|
|
5180
|
-
const genPath =
|
|
5449
|
+
const genPath = join4(
|
|
5181
5450
|
routerDir,
|
|
5182
5451
|
`${routerBasename}.named-routes.gen.js`
|
|
5183
5452
|
).replaceAll("\\", "/");
|
|
@@ -5200,7 +5469,7 @@ function generatePerRouterModule(state, routerId) {
|
|
|
5200
5469
|
`export const precomputedEntries = ${jsonParseExpression(entries)};`
|
|
5201
5470
|
);
|
|
5202
5471
|
}
|
|
5203
|
-
return lines.join("\n") || "
|
|
5472
|
+
return lines.join("\n") || "";
|
|
5204
5473
|
}
|
|
5205
5474
|
|
|
5206
5475
|
// src/vite/discovery/bundle-postprocess.ts
|
|
@@ -5271,7 +5540,7 @@ function postprocessBundle(state) {
|
|
|
5271
5540
|
manifestMap[key] = `./assets/${assetFileName}`;
|
|
5272
5541
|
}
|
|
5273
5542
|
const manifestCode = [
|
|
5274
|
-
`const m
|
|
5543
|
+
`const m=${jsonParseExpression(manifestMap)};`,
|
|
5275
5544
|
`export function loadPrerenderAsset(s){return import(s)}`,
|
|
5276
5545
|
`export default m;`,
|
|
5277
5546
|
""
|
|
@@ -5599,6 +5868,7 @@ function createRouterDiscoveryPlugin(entryPath, opts) {
|
|
|
5599
5868
|
},
|
|
5600
5869
|
configResolved(config) {
|
|
5601
5870
|
s.projectRoot = config.root;
|
|
5871
|
+
s.scanFilter = opts?.discovery ? createScanFilter(s.projectRoot, opts.discovery) : void 0;
|
|
5602
5872
|
s.isBuildMode = config.command === "build";
|
|
5603
5873
|
viteCommand = config.command;
|
|
5604
5874
|
viteMode = config.mode;
|
|
@@ -6535,8 +6805,6 @@ async function rango(options) {
|
|
|
6535
6805
|
enforce: "pre",
|
|
6536
6806
|
config() {
|
|
6537
6807
|
return {
|
|
6538
|
-
// Exclude rsc-router modules from optimization to prevent module duplication
|
|
6539
|
-
// This ensures the same Context instance is used by both browser entry and RSC proxy modules
|
|
6540
6808
|
optimizeDeps: {
|
|
6541
6809
|
exclude: excludeDeps,
|
|
6542
6810
|
rolldownOptions: sharedRolldownOptions
|
|
@@ -6559,21 +6827,12 @@ async function rango(options) {
|
|
|
6559
6827
|
client: {
|
|
6560
6828
|
build: {
|
|
6561
6829
|
rollupOptions: {
|
|
6562
|
-
// FILE_NAME_CONFLICT (and any other client-build warning) is
|
|
6563
|
-
// emitted by the CLIENT environment build, which consults THIS
|
|
6564
|
-
// env's onwarn -- Vite 8's environment builds do NOT propagate
|
|
6565
|
-
// the top-level build.rollupOptions.onwarn into the client env.
|
|
6566
|
-
// Wire it here so the suppression runs where the conflicts
|
|
6567
|
-
// originate (the top-level handler is invoked 0x for these; the
|
|
6568
|
-
// client-env handler is invoked for all of them).
|
|
6569
6830
|
onwarn,
|
|
6570
6831
|
output: {
|
|
6571
6832
|
manualChunks: getManualChunks
|
|
6572
6833
|
}
|
|
6573
6834
|
}
|
|
6574
6835
|
},
|
|
6575
|
-
// Pre-bundle rsc-html-stream to prevent discovery during first request
|
|
6576
|
-
// Exclude rsc-router modules to ensure same Context instance
|
|
6577
6836
|
optimizeDeps: {
|
|
6578
6837
|
include: [nested("rsc-html-stream/client")],
|
|
6579
6838
|
exclude: excludeDeps,
|
|
@@ -6581,12 +6840,9 @@ async function rango(options) {
|
|
|
6581
6840
|
}
|
|
6582
6841
|
},
|
|
6583
6842
|
ssr: {
|
|
6584
|
-
// Build SSR inside RSC directory so wrangler can deploy self-contained dist/rsc
|
|
6585
6843
|
build: {
|
|
6586
6844
|
outDir: "./dist/rsc/ssr"
|
|
6587
6845
|
},
|
|
6588
|
-
// Pre-bundle SSR entry and React for proper module linking with childEnvironments
|
|
6589
|
-
// All deps must be listed to avoid late discovery triggering ERR_OUTDATED_OPTIMIZED_DEP
|
|
6590
6846
|
optimizeDeps: {
|
|
6591
6847
|
entries: [finalEntries.ssr],
|
|
6592
6848
|
include: [
|
|
@@ -6606,10 +6862,7 @@ async function rango(options) {
|
|
|
6606
6862
|
}
|
|
6607
6863
|
},
|
|
6608
6864
|
rsc: {
|
|
6609
|
-
// RSC environment needs exclude list and esbuild options
|
|
6610
|
-
// Exclude rsc-router modules to prevent createContext in RSC environment
|
|
6611
6865
|
optimizeDeps: {
|
|
6612
|
-
// Pre-bundle all RSC deps to prevent late discovery triggering ERR_OUTDATED_OPTIMIZED_DEP
|
|
6613
6866
|
include: [
|
|
6614
6867
|
"react",
|
|
6615
6868
|
"react/jsx-runtime",
|
|
@@ -6695,13 +6948,6 @@ ${list}`);
|
|
|
6695
6948
|
client: {
|
|
6696
6949
|
build: {
|
|
6697
6950
|
rollupOptions: {
|
|
6698
|
-
// FILE_NAME_CONFLICT (and any other client-build warning) is
|
|
6699
|
-
// emitted by the CLIENT environment build, which consults THIS
|
|
6700
|
-
// env's onwarn -- Vite 8's environment builds do NOT propagate
|
|
6701
|
-
// the top-level build.rollupOptions.onwarn into the client env.
|
|
6702
|
-
// Wire it here so the suppression runs where the conflicts
|
|
6703
|
-
// originate (the top-level handler is invoked 0x for these; the
|
|
6704
|
-
// client-env handler is invoked for all of them).
|
|
6705
6951
|
onwarn,
|
|
6706
6952
|
output: {
|
|
6707
6953
|
manualChunks: getManualChunks
|
|
@@ -6817,6 +7063,7 @@ ${list}`);
|
|
|
6817
7063
|
enableBuildPrerender: prerenderEnabled,
|
|
6818
7064
|
buildEnv: options?.buildEnv,
|
|
6819
7065
|
preset,
|
|
7066
|
+
discovery: options?.discovery,
|
|
6820
7067
|
clientChunkCtx
|
|
6821
7068
|
})
|
|
6822
7069
|
);
|
|
@@ -6832,7 +7079,7 @@ ${list}`);
|
|
|
6832
7079
|
// src/vite/plugins/refresh-cmd.ts
|
|
6833
7080
|
function poke() {
|
|
6834
7081
|
return {
|
|
6835
|
-
name: "
|
|
7082
|
+
name: "@rangojs/router:poke",
|
|
6836
7083
|
apply: "serve",
|
|
6837
7084
|
configureServer(server) {
|
|
6838
7085
|
const stdin = process.stdin;
|