@rangojs/router 0.0.0-experimental.107 → 0.0.0-experimental.109
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 +4 -4
- package/dist/bin/rango.js +16 -16
- package/dist/vite/index.js +146 -150
- package/package.json +6 -6
- package/skills/hooks/SKILL.md +2 -0
- package/skills/links/SKILL.md +13 -1
- package/skills/loader/SKILL.md +1 -1
- package/skills/middleware/SKILL.md +3 -3
- package/skills/mime-routes/SKILL.md +27 -0
- package/skills/prerender/SKILL.md +13 -13
- package/skills/rango/SKILL.md +9 -0
- package/skills/response-routes/SKILL.md +58 -9
- package/skills/router-setup/SKILL.md +3 -3
- package/skills/typesafety/SKILL.md +273 -31
- package/src/__augment-tests__/augment.ts +81 -0
- package/src/__augment-tests__/augmented.check.ts +117 -0
- package/src/browser/index.ts +3 -3
- package/src/browser/react/location-state-shared.ts +3 -3
- package/src/browser/react/use-handle.ts +17 -9
- package/src/browser/rsc-router.tsx +14 -14
- package/src/browser/segment-structure-assert.ts +2 -2
- package/src/build/generate-manifest.ts +3 -3
- package/src/build/route-types/codegen.ts +4 -4
- package/src/build/route-types/include-resolution.ts +1 -1
- package/src/build/route-types/per-module-writer.ts +3 -3
- package/src/build/route-types/router-processing.ts +4 -4
- package/src/build/route-types/scan-filter.ts +1 -1
- package/src/client.tsx +4 -7
- package/src/errors.ts +1 -1
- package/src/handle.ts +2 -2
- package/src/href-client.ts +136 -19
- package/src/index.rsc.ts +4 -4
- package/src/index.ts +2 -2
- package/src/loader.rsc.ts +1 -1
- package/src/loader.ts +1 -1
- package/src/prerender.ts +4 -4
- package/src/route-definition/dsl-helpers.ts +2 -2
- package/src/route-definition/helpers-types.ts +2 -2
- package/src/router/error-handling.ts +1 -1
- package/src/router/lazy-includes.ts +2 -2
- package/src/router/metrics.ts +1 -1
- package/src/router/middleware-types.ts +1 -1
- package/src/router/prerender-match.ts +1 -1
- package/src/router/router-interfaces.ts +34 -28
- package/src/router/router-options.ts +1 -1
- package/src/router/router-registry.ts +2 -5
- package/src/router/segment-resolution/fresh.ts +2 -2
- package/src/router/segment-resolution/revalidation.ts +2 -2
- package/src/router.ts +13 -16
- package/src/rsc/handler-context.ts +2 -2
- package/src/rsc/index.ts +1 -1
- package/src/rsc/types.ts +2 -2
- package/src/search-params.ts +4 -4
- package/src/serialize.ts +243 -0
- package/src/server/context.ts +16 -16
- package/src/static-handler.ts +1 -1
- package/src/types/global-namespace.ts +39 -26
- package/src/types/handler-context.ts +3 -3
- package/src/urls/path-helper-types.ts +2 -2
- package/src/urls/pattern-types.ts +34 -0
- package/src/urls/type-extraction.ts +6 -1
- package/src/use-loader.tsx +6 -4
- package/src/vite/discovery/bundle-postprocess.ts +6 -6
- package/src/vite/discovery/discover-routers.ts +3 -3
- package/src/vite/discovery/discovery-errors.ts +1 -1
- package/src/vite/discovery/prerender-collection.ts +19 -25
- package/src/vite/discovery/route-types-writer.ts +3 -3
- package/src/vite/discovery/state.ts +4 -4
- package/src/vite/plugins/cloudflare-protocol-stub.ts +1 -1
- package/src/vite/plugins/expose-action-id.ts +2 -2
- package/src/vite/plugins/expose-id-utils.ts +12 -8
- package/src/vite/plugins/expose-ids/export-analysis.ts +33 -9
- package/src/vite/plugins/expose-internal-ids.ts +1 -1
- package/src/vite/plugins/performance-tracks.ts +12 -16
- package/src/vite/plugins/use-cache-transform.ts +1 -1
- package/src/vite/plugins/version-plugin.ts +2 -2
- package/src/vite/plugins/virtual-entries.ts +2 -2
- package/src/vite/rango.ts +11 -11
- package/src/vite/router-discovery.ts +26 -29
- package/src/vite/utils/ast-handler-extract.ts +15 -15
- package/src/vite/utils/bundle-analysis.ts +4 -2
- package/src/vite/utils/forward-user-plugins.ts +46 -17
- package/src/vite/utils/shared-utils.ts +26 -22
package/dist/vite/index.js
CHANGED
|
@@ -21,8 +21,8 @@ function hashId(filePath, exportName) {
|
|
|
21
21
|
function makeStubId(filePath, exportName, isBuild) {
|
|
22
22
|
return isBuild ? hashId(filePath, exportName) : `${filePath}#${exportName}`;
|
|
23
23
|
}
|
|
24
|
-
function hashInlineId(filePath,
|
|
25
|
-
const input =
|
|
24
|
+
function hashInlineId(filePath, fnName, index) {
|
|
25
|
+
const input = `${filePath}:${fnName}:${index}`;
|
|
26
26
|
return crypto.createHash("sha256").update(input).digest("hex").slice(0, 8);
|
|
27
27
|
}
|
|
28
28
|
function buildExportMap(program) {
|
|
@@ -292,7 +292,7 @@ function getRscPluginApi(config) {
|
|
|
292
292
|
);
|
|
293
293
|
if (plugin) {
|
|
294
294
|
console.warn(
|
|
295
|
-
`[
|
|
295
|
+
`[rango:expose-action-id] RSC plugin found by API structure (name: "${plugin.name}"). Consider updating the name lookup if the plugin was renamed.`
|
|
296
296
|
);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
@@ -393,7 +393,7 @@ function exposeActionId() {
|
|
|
393
393
|
}
|
|
394
394
|
if (!rscPluginApi) {
|
|
395
395
|
throw new Error(
|
|
396
|
-
"[
|
|
396
|
+
"[rango] Could not find @vitejs/plugin-rsc. @rangojs/router requires the Vite RSC plugin, which is included automatically by rango()."
|
|
397
397
|
);
|
|
398
398
|
}
|
|
399
399
|
if (!isBuild) return;
|
|
@@ -475,7 +475,7 @@ function isDirectivePrologueStatement(node) {
|
|
|
475
475
|
function findImportInsertionPos(code, parseAst4) {
|
|
476
476
|
let program;
|
|
477
477
|
try {
|
|
478
|
-
program = parseAst4(code, {
|
|
478
|
+
program = parseAst4(code, { lang: "tsx" });
|
|
479
479
|
} catch {
|
|
480
480
|
return 0;
|
|
481
481
|
}
|
|
@@ -515,7 +515,7 @@ function walkNode(node, parent, ancestors, enter) {
|
|
|
515
515
|
function findHandlerCalls(code, fnName, parseAst4) {
|
|
516
516
|
let program;
|
|
517
517
|
try {
|
|
518
|
-
program = parseAst4(code, {
|
|
518
|
+
program = parseAst4(code, { lang: "tsx" });
|
|
519
519
|
} catch {
|
|
520
520
|
return [];
|
|
521
521
|
}
|
|
@@ -589,7 +589,7 @@ function getImportedLocalNamesFromProgram(program, importedName) {
|
|
|
589
589
|
}
|
|
590
590
|
function getImportedLocalNames(code, importedName, parseAst4) {
|
|
591
591
|
try {
|
|
592
|
-
const program = parseAst4(code, {
|
|
592
|
+
const program = parseAst4(code, { lang: "tsx" });
|
|
593
593
|
return getImportedLocalNamesFromProgram(program, importedName);
|
|
594
594
|
} catch {
|
|
595
595
|
return /* @__PURE__ */ new Set();
|
|
@@ -598,7 +598,7 @@ function getImportedLocalNames(code, importedName, parseAst4) {
|
|
|
598
598
|
function extractImportDeclarations(code, parseAst4) {
|
|
599
599
|
let program;
|
|
600
600
|
try {
|
|
601
|
-
program = parseAst4(code, {
|
|
601
|
+
program = parseAst4(code, { lang: "tsx" });
|
|
602
602
|
} catch {
|
|
603
603
|
return [];
|
|
604
604
|
}
|
|
@@ -653,7 +653,7 @@ function isSafeVariableDeclaration(node, handlerNames) {
|
|
|
653
653
|
function extractModuleLevelDeclarations(code, parseAst4, handlerNames) {
|
|
654
654
|
let program;
|
|
655
655
|
try {
|
|
656
|
-
program = parseAst4(code, {
|
|
656
|
+
program = parseAst4(code, { lang: "tsx" });
|
|
657
657
|
} catch {
|
|
658
658
|
return [];
|
|
659
659
|
}
|
|
@@ -697,14 +697,12 @@ function transformInlineHandlers(fnName, virtualPrefix, s, code, filePath, virtu
|
|
|
697
697
|
parseAst4,
|
|
698
698
|
handlerNames
|
|
699
699
|
);
|
|
700
|
-
const lineCounts = /* @__PURE__ */ new Map();
|
|
701
700
|
const importStatements = [];
|
|
702
|
-
for (const site of inlineSites) {
|
|
703
|
-
const
|
|
704
|
-
lineCounts.set(site.lineNumber, lineCount + 1);
|
|
705
|
-
const hash = hashInlineId(filePath, site.lineNumber, lineCount);
|
|
701
|
+
for (const [siteIndex, site] of inlineSites.entries()) {
|
|
702
|
+
const hash = hashInlineId(filePath, fnName, siteIndex);
|
|
706
703
|
const exportName = `__sh_${hash}`;
|
|
707
|
-
const
|
|
704
|
+
const idSuffix = `${filePath}:${fnName}:${siteIndex}`;
|
|
705
|
+
const virtualId = `\0${virtualPrefix}${idSuffix}`;
|
|
708
706
|
const handlerCode = code.slice(site.callStart, site.callEnd);
|
|
709
707
|
virtualRegistry.set(virtualId, {
|
|
710
708
|
originalModuleId: moduleId,
|
|
@@ -714,7 +712,7 @@ function transformInlineHandlers(fnName, virtualPrefix, s, code, filePath, virtu
|
|
|
714
712
|
exportName
|
|
715
713
|
});
|
|
716
714
|
s.overwrite(site.callStart, site.callEnd, exportName);
|
|
717
|
-
const importId = `${virtualPrefix}${
|
|
715
|
+
const importId = `${virtualPrefix}${idSuffix}`;
|
|
718
716
|
importStatements.push(`import { ${exportName} } from "${importId}";`);
|
|
719
717
|
}
|
|
720
718
|
if (importStatements.length > 0) {
|
|
@@ -810,6 +808,17 @@ function getCalledIdentifierFromCall(callExpr) {
|
|
|
810
808
|
}
|
|
811
809
|
return null;
|
|
812
810
|
}
|
|
811
|
+
function unwrapSignatureWrappedCall(init, fnNameSet) {
|
|
812
|
+
if (init?.type !== "CallExpression") return init;
|
|
813
|
+
const directId = getCalledIdentifierFromCall(init);
|
|
814
|
+
if (directId && fnNameSet.has(directId)) return init;
|
|
815
|
+
const firstArg = init.arguments?.[0];
|
|
816
|
+
if (firstArg?.type === "CallExpression") {
|
|
817
|
+
const innerId = getCalledIdentifierFromCall(firstArg);
|
|
818
|
+
if (innerId && fnNameSet.has(innerId)) return firstArg;
|
|
819
|
+
}
|
|
820
|
+
return init;
|
|
821
|
+
}
|
|
813
822
|
function collectCreateExportBindingsFallback(code, fnNames) {
|
|
814
823
|
const alternation = fnNames.map(escapeRegExp).join("|");
|
|
815
824
|
const exportConstPattern = new RegExp(
|
|
@@ -869,7 +878,7 @@ function collectCreateExportBindingsFallback(code, fnNames) {
|
|
|
869
878
|
function collectCreateExportBindings(code, fnNames, program) {
|
|
870
879
|
if (!program) {
|
|
871
880
|
try {
|
|
872
|
-
program = parseAst(code, {
|
|
881
|
+
program = parseAst(code, { lang: "tsx" });
|
|
873
882
|
} catch {
|
|
874
883
|
return collectCreateExportBindingsFallback(code, fnNames);
|
|
875
884
|
}
|
|
@@ -882,16 +891,16 @@ function collectCreateExportBindings(code, fnNames, program) {
|
|
|
882
891
|
return;
|
|
883
892
|
}
|
|
884
893
|
for (const decl of varDecl.declarations ?? []) {
|
|
885
|
-
const
|
|
886
|
-
|
|
894
|
+
const callExpr = unwrapSignatureWrappedCall(decl?.init, fnNameSet);
|
|
895
|
+
const calledIdentifier = getCalledIdentifierFromCall(callExpr);
|
|
896
|
+
if (decl?.id?.type !== "Identifier" || callExpr?.type !== "CallExpression" || !calledIdentifier || !fnNameSet.has(calledIdentifier)) {
|
|
887
897
|
continue;
|
|
888
898
|
}
|
|
889
899
|
const localName = decl.id.name;
|
|
890
900
|
const exportNames = exportMap.get(localName) ?? [];
|
|
891
901
|
if (exportNames.length === 0) continue;
|
|
892
|
-
const
|
|
893
|
-
const
|
|
894
|
-
const calleeEnd = decl.init.callee.end;
|
|
902
|
+
const callEnd = callExpr.end;
|
|
903
|
+
const calleeEnd = callExpr.callee.end;
|
|
895
904
|
let openParenPos = -1;
|
|
896
905
|
for (let i = calleeEnd; i < callEnd; i++) {
|
|
897
906
|
if (code[i] === "(") {
|
|
@@ -905,10 +914,10 @@ function collectCreateExportBindings(code, fnNames, program) {
|
|
|
905
914
|
bindings.push({
|
|
906
915
|
localName,
|
|
907
916
|
exportNames,
|
|
908
|
-
callExprStart:
|
|
917
|
+
callExprStart: callExpr.start,
|
|
909
918
|
callOpenParenPos: openParenPos,
|
|
910
919
|
callCloseParenPos: closeParenPos,
|
|
911
|
-
argCount:
|
|
920
|
+
argCount: callExpr.arguments?.length ?? 0,
|
|
912
921
|
statementEnd
|
|
913
922
|
});
|
|
914
923
|
}
|
|
@@ -929,7 +938,7 @@ function collectCreateExportBindings(code, fnNames, program) {
|
|
|
929
938
|
}
|
|
930
939
|
function buildUnsupportedShapeWarning(filePath, fnName) {
|
|
931
940
|
return [
|
|
932
|
-
`[
|
|
941
|
+
`[rango] Unsupported ${fnName} shape in "${filePath}".`,
|
|
933
942
|
`Supported shapes are:`,
|
|
934
943
|
` - export const X = ${fnName}(...)`,
|
|
935
944
|
` - const X = ${fnName}(...); export { X }`,
|
|
@@ -1335,7 +1344,7 @@ ${lazyImports.join(",\n")}
|
|
|
1335
1344
|
}
|
|
1336
1345
|
if (_cachedAst !== void 0 || _astParseFailed) return _cachedAst;
|
|
1337
1346
|
try {
|
|
1338
|
-
_cachedAst = parseAst2(code, {
|
|
1347
|
+
_cachedAst = parseAst2(code, { lang: "tsx" });
|
|
1339
1348
|
} catch {
|
|
1340
1349
|
_astParseFailed = true;
|
|
1341
1350
|
}
|
|
@@ -1716,7 +1725,7 @@ function useCacheTransform() {
|
|
|
1716
1725
|
let ast;
|
|
1717
1726
|
try {
|
|
1718
1727
|
const { parseAst: parseAst4 } = await import("vite");
|
|
1719
|
-
ast = parseAst4(code);
|
|
1728
|
+
ast = parseAst4(code, { lang: "tsx" });
|
|
1720
1729
|
} catch {
|
|
1721
1730
|
return;
|
|
1722
1731
|
}
|
|
@@ -1938,7 +1947,7 @@ import {
|
|
|
1938
1947
|
import { createElement, StrictMode } from "react";
|
|
1939
1948
|
import { hydrateRoot } from "react-dom/client";
|
|
1940
1949
|
import { rscStream } from "@rangojs/router/internal/deps/html-stream-client";
|
|
1941
|
-
import { initBrowserApp,
|
|
1950
|
+
import { initBrowserApp, Rango } from "@rangojs/router/browser";
|
|
1942
1951
|
|
|
1943
1952
|
async function initializeApp() {
|
|
1944
1953
|
const deps = {
|
|
@@ -1953,7 +1962,7 @@ async function initializeApp() {
|
|
|
1953
1962
|
|
|
1954
1963
|
hydrateRoot(
|
|
1955
1964
|
document,
|
|
1956
|
-
createElement(StrictMode, null, createElement(
|
|
1965
|
+
createElement(StrictMode, null, createElement(Rango))
|
|
1957
1966
|
);
|
|
1958
1967
|
}
|
|
1959
1968
|
|
|
@@ -2040,7 +2049,7 @@ import { resolve } from "node:path";
|
|
|
2040
2049
|
// package.json
|
|
2041
2050
|
var package_default = {
|
|
2042
2051
|
name: "@rangojs/router",
|
|
2043
|
-
version: "0.0.0-experimental.
|
|
2052
|
+
version: "0.0.0-experimental.109",
|
|
2044
2053
|
description: "Django-inspired RSC router with composable URL patterns",
|
|
2045
2054
|
keywords: [
|
|
2046
2055
|
"react",
|
|
@@ -2175,7 +2184,7 @@ var package_default = {
|
|
|
2175
2184
|
scripts: {
|
|
2176
2185
|
build: "pnpm dlx esbuild src/vite/index.ts --bundle --format=esm --outfile=dist/vite/index.js --platform=node --packages=external && mkdir -p dist/vite/plugins && cp src/vite/plugins/cloudflare-protocol-loader-hook.mjs dist/vite/plugins/cloudflare-protocol-loader-hook.mjs && pnpm dlx esbuild src/bin/rango.ts --bundle --format=esm --outfile=dist/bin/rango.js --platform=node --packages=external --banner:js='#!/usr/bin/env node' && chmod +x dist/bin/rango.js",
|
|
2177
2186
|
prepublishOnly: "pnpm build",
|
|
2178
|
-
typecheck: "tsc --noEmit && tsc -p tsconfig.strict-check.json --noEmit",
|
|
2187
|
+
typecheck: "tsc --noEmit && tsc -p tsconfig.strict-check.json --noEmit && tsc -p tsconfig.augment-check.json --noEmit",
|
|
2179
2188
|
test: "playwright test",
|
|
2180
2189
|
"test:ui": "playwright test --ui",
|
|
2181
2190
|
"test:unit": "vitest run",
|
|
@@ -2183,7 +2192,7 @@ var package_default = {
|
|
|
2183
2192
|
},
|
|
2184
2193
|
dependencies: {
|
|
2185
2194
|
"@types/debug": "^4.1.12",
|
|
2186
|
-
"@vitejs/plugin-rsc": "^0.5.
|
|
2195
|
+
"@vitejs/plugin-rsc": "^0.5.26",
|
|
2187
2196
|
debug: "^4.4.1",
|
|
2188
2197
|
"magic-string": "^0.30.17",
|
|
2189
2198
|
picomatch: "^4.0.3",
|
|
@@ -2203,11 +2212,11 @@ var package_default = {
|
|
|
2203
2212
|
vitest: "^4.0.0"
|
|
2204
2213
|
},
|
|
2205
2214
|
peerDependencies: {
|
|
2206
|
-
"@cloudflare/vite-plugin": "^1.
|
|
2207
|
-
"@vitejs/plugin-rsc": "^0.5.
|
|
2215
|
+
"@cloudflare/vite-plugin": "^1.38.0",
|
|
2216
|
+
"@vitejs/plugin-rsc": "^0.5.26",
|
|
2208
2217
|
react: ">=19.2.6 <20",
|
|
2209
2218
|
"react-dom": ">=19.2.6 <20",
|
|
2210
|
-
vite: "^
|
|
2219
|
+
vite: "^8.0.0"
|
|
2211
2220
|
},
|
|
2212
2221
|
peerDependenciesMeta: {
|
|
2213
2222
|
"@cloudflare/vite-plugin": {
|
|
@@ -2400,7 +2409,7 @@ ${objectBody}
|
|
|
2400
2409
|
} as const;
|
|
2401
2410
|
|
|
2402
2411
|
declare global {
|
|
2403
|
-
namespace
|
|
2412
|
+
namespace Rango {
|
|
2404
2413
|
interface GeneratedRouteMap extends Readonly<typeof NamedRoutes> {}
|
|
2405
2414
|
}
|
|
2406
2415
|
}
|
|
@@ -2635,7 +2644,7 @@ function buildCombinedRouteMapWithSearch(filePath, variableName, visited, diagno
|
|
|
2635
2644
|
const realPath = resolve2(filePath);
|
|
2636
2645
|
const key = variableName ? `${realPath}:${variableName}` : realPath;
|
|
2637
2646
|
if (visited.has(key)) {
|
|
2638
|
-
console.warn(`[
|
|
2647
|
+
console.warn(`[rango] Circular include detected, skipping: ${key}`);
|
|
2639
2648
|
return { routes: {}, searchSchemas: {} };
|
|
2640
2649
|
}
|
|
2641
2650
|
visited.add(key);
|
|
@@ -2705,7 +2714,7 @@ function findRouterFilesRecursive(dir, filter, results) {
|
|
|
2705
2714
|
entries = readdirSync(dir, { withFileTypes: true });
|
|
2706
2715
|
} catch (err) {
|
|
2707
2716
|
console.warn(
|
|
2708
|
-
`[
|
|
2717
|
+
`[rango] Failed to scan directory ${dir}: ${err.message}`
|
|
2709
2718
|
);
|
|
2710
2719
|
return;
|
|
2711
2720
|
}
|
|
@@ -2761,7 +2770,7 @@ function findNestedRouterConflict(routerFiles) {
|
|
|
2761
2770
|
}
|
|
2762
2771
|
return null;
|
|
2763
2772
|
}
|
|
2764
|
-
function formatNestedRouterConflictError(conflict, prefix = "[
|
|
2773
|
+
function formatNestedRouterConflictError(conflict, prefix = "[rango]") {
|
|
2765
2774
|
return `${prefix} Nested router roots are not supported.
|
|
2766
2775
|
Router root: ${conflict.ancestor}
|
|
2767
2776
|
Nested router: ${conflict.nested}
|
|
@@ -2923,7 +2932,7 @@ function writeCombinedRouteTypes(root, knownRouterFiles, opts) {
|
|
|
2923
2932
|
if (existsSync3(oldCombinedPath)) {
|
|
2924
2933
|
unlinkSync(oldCombinedPath);
|
|
2925
2934
|
console.log(
|
|
2926
|
-
`[
|
|
2935
|
+
`[rango] Removed stale combined route types: ${oldCombinedPath}`
|
|
2927
2936
|
);
|
|
2928
2937
|
}
|
|
2929
2938
|
} catch {
|
|
@@ -2978,7 +2987,7 @@ function writeCombinedRouteTypes(root, knownRouterFiles, opts) {
|
|
|
2978
2987
|
}
|
|
2979
2988
|
writeFileSync(outPath, source);
|
|
2980
2989
|
console.log(
|
|
2981
|
-
`[
|
|
2990
|
+
`[rango] Generated route types (${Object.keys(result.routes).length} routes) -> ${outPath}`
|
|
2982
2991
|
);
|
|
2983
2992
|
}
|
|
2984
2993
|
}
|
|
@@ -2995,7 +3004,7 @@ function normalizeModuleId(id) {
|
|
|
2995
3004
|
function getClientModuleSignature(source) {
|
|
2996
3005
|
let program;
|
|
2997
3006
|
try {
|
|
2998
|
-
program = parseAst3(source, {
|
|
3007
|
+
program = parseAst3(source, { lang: "tsx" });
|
|
2999
3008
|
} catch {
|
|
3000
3009
|
return void 0;
|
|
3001
3010
|
}
|
|
@@ -3083,7 +3092,7 @@ function createVersionPlugin() {
|
|
|
3083
3092
|
let versionCounter = 0;
|
|
3084
3093
|
const bumpVersion = (reason) => {
|
|
3085
3094
|
currentVersion = Date.now().toString(16) + String(++versionCounter);
|
|
3086
|
-
console.log(`[
|
|
3095
|
+
console.log(`[rango] ${reason}, version updated: ${currentVersion}`);
|
|
3087
3096
|
const rscEnv = server?.environments?.rsc;
|
|
3088
3097
|
const versionMod = rscEnv?.moduleGraph?.getModuleById(
|
|
3089
3098
|
"\0" + VIRTUAL_IDS.version
|
|
@@ -3208,22 +3217,18 @@ function patchRsdwClientDebugInfoRecovery(code) {
|
|
|
3208
3217
|
};
|
|
3209
3218
|
}
|
|
3210
3219
|
function performanceTracksOptimizeDepsPlugin() {
|
|
3220
|
+
const RSDW_CLIENT_RE = /react-server-dom-webpack-client\.browser\.(development|production)\.js$/;
|
|
3211
3221
|
return {
|
|
3212
3222
|
name: "@rangojs/router:performance-tracks-optimize-deps",
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
contents: patched.code,
|
|
3223
|
-
loader: "js"
|
|
3224
|
-
};
|
|
3225
|
-
}
|
|
3226
|
-
);
|
|
3223
|
+
// Vite 8 optimizes deps with Rolldown (Rollup-style plugin pipeline), so the
|
|
3224
|
+
// pre-bundled RSDW client is patched via load() rather than esbuild's onLoad.
|
|
3225
|
+
// Returning code overrides Rolldown's default filesystem read for the module.
|
|
3226
|
+
async load(id) {
|
|
3227
|
+
const cleanId = id.split("?")[0] ?? id;
|
|
3228
|
+
if (!RSDW_CLIENT_RE.test(cleanId)) return null;
|
|
3229
|
+
const code = await readFile(cleanId, "utf8");
|
|
3230
|
+
const patched = patchRsdwClientDebugInfoRecovery(code);
|
|
3231
|
+
return { code: patched.code };
|
|
3227
3232
|
}
|
|
3228
3233
|
};
|
|
3229
3234
|
}
|
|
@@ -3250,24 +3255,21 @@ function performanceTracksPlugin() {
|
|
|
3250
3255
|
}
|
|
3251
3256
|
|
|
3252
3257
|
// src/vite/utils/shared-utils.ts
|
|
3253
|
-
var
|
|
3258
|
+
var versionRolldownPlugin = {
|
|
3254
3259
|
name: "@rangojs/router-version",
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
loader: "js"
|
|
3265
|
-
})
|
|
3266
|
-
);
|
|
3260
|
+
resolveId(id) {
|
|
3261
|
+
if (id === VIRTUAL_IDS.version) return "\0" + VIRTUAL_IDS.version;
|
|
3262
|
+
return void 0;
|
|
3263
|
+
},
|
|
3264
|
+
load(id) {
|
|
3265
|
+
if (id === "\0" + VIRTUAL_IDS.version) {
|
|
3266
|
+
return getVirtualVersionContent("dev");
|
|
3267
|
+
}
|
|
3268
|
+
return void 0;
|
|
3267
3269
|
}
|
|
3268
3270
|
};
|
|
3269
|
-
var
|
|
3270
|
-
plugins: [
|
|
3271
|
+
var sharedRolldownOptions = {
|
|
3272
|
+
plugins: [versionRolldownPlugin, performanceTracksOptimizeDepsPlugin()]
|
|
3271
3273
|
};
|
|
3272
3274
|
function createVirtualEntriesPlugin(entries, routerPathRef) {
|
|
3273
3275
|
const virtualModules = {};
|
|
@@ -3310,7 +3312,7 @@ function createVirtualEntriesPlugin(entries, routerPathRef) {
|
|
|
3310
3312
|
};
|
|
3311
3313
|
}
|
|
3312
3314
|
function onwarn(warning, defaultHandler) {
|
|
3313
|
-
if (warning.code === "MODULE_LEVEL_DIRECTIVE" || warning.code === "SOURCEMAP_ERROR" || warning.code === "EMPTY_BUNDLE") {
|
|
3315
|
+
if (warning.code === "MODULE_LEVEL_DIRECTIVE" || warning.code === "SOURCEMAP_ERROR" || warning.code === "EMPTY_BUNDLE" || warning.code === "INEFFECTIVE_DYNAMIC_IMPORT") {
|
|
3314
3316
|
return;
|
|
3315
3317
|
}
|
|
3316
3318
|
if (warning.message?.includes("Sourcemap is likely to be incorrect")) {
|
|
@@ -3562,7 +3564,7 @@ function createCloudflareProtocolStubPlugin() {
|
|
|
3562
3564
|
if (!code.includes(CF_PREFIX)) return null;
|
|
3563
3565
|
let ast;
|
|
3564
3566
|
try {
|
|
3565
|
-
ast = this.parse(code);
|
|
3567
|
+
ast = this.parse(code, { lang: "tsx" });
|
|
3566
3568
|
} catch {
|
|
3567
3569
|
return null;
|
|
3568
3570
|
}
|
|
@@ -3718,7 +3720,7 @@ function extractHandlerExportsFromChunk(chunkCode, handlerModules, fnName, detec
|
|
|
3718
3720
|
if (detectPassthrough) {
|
|
3719
3721
|
const eFnName = escapeRegExp(fnName);
|
|
3720
3722
|
const callStartRe = new RegExp(
|
|
3721
|
-
`const\\s+${eName}\\s*=\\s*${eFnName}\\s*(?:<[^>]*>)?\\s*\\(`
|
|
3723
|
+
`(?:const|let|var)\\s+${eName}\\s*=\\s*${eFnName}\\s*(?:<[^>]*>)?\\s*\\(`
|
|
3722
3724
|
);
|
|
3723
3725
|
const callStart = callStartRe.exec(chunkCode);
|
|
3724
3726
|
if (callStart) {
|
|
@@ -3743,7 +3745,7 @@ function evictHandlerCode(code, exports, fnName, brand) {
|
|
|
3743
3745
|
if (passthrough) continue;
|
|
3744
3746
|
const eName = escapeRegExp(name);
|
|
3745
3747
|
const callStartRe = new RegExp(
|
|
3746
|
-
`const\\s+${eName}\\s*=\\s*${eFnName}\\s*(?:<[^>]*>)?\\s*\\(`
|
|
3748
|
+
`(?:const|let|var)\\s+${eName}\\s*=\\s*${eFnName}\\s*(?:<[^>]*>)?\\s*\\(`
|
|
3747
3749
|
);
|
|
3748
3750
|
const startMatch = callStartRe.exec(modified);
|
|
3749
3751
|
if (!startMatch) continue;
|
|
@@ -4091,7 +4093,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
|
|
|
4091
4093
|
const progressInterval = totalDynamic > 0 ? setInterval(() => {
|
|
4092
4094
|
const elapsed = ((performance.now() - paramsStart) / 1e3).toFixed(1);
|
|
4093
4095
|
console.log(
|
|
4094
|
-
`[
|
|
4096
|
+
`[rango] Resolving prerender params... ${resolvedRoutes}/${totalDynamic} routes (${elapsed}s)`
|
|
4095
4097
|
);
|
|
4096
4098
|
}, 5e3) : void 0;
|
|
4097
4099
|
try {
|
|
@@ -4128,7 +4130,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
|
|
|
4128
4130
|
get env() {
|
|
4129
4131
|
if (buildEnv !== void 0) return buildEnv;
|
|
4130
4132
|
throw new Error(
|
|
4131
|
-
"[
|
|
4133
|
+
"[rango] ctx.env is not available during build-time getParams(). Configure buildEnv in your rango() plugin options to enable build-time env access."
|
|
4132
4134
|
);
|
|
4133
4135
|
}
|
|
4134
4136
|
};
|
|
@@ -4169,7 +4171,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
|
|
|
4169
4171
|
resolvedRoutes++;
|
|
4170
4172
|
if (err.name === "Skip") {
|
|
4171
4173
|
console.log(
|
|
4172
|
-
`[
|
|
4174
|
+
`[rango] SKIP route "${routeName}" - ${err.message}`
|
|
4173
4175
|
);
|
|
4174
4176
|
notifyOnError(
|
|
4175
4177
|
registry,
|
|
@@ -4182,14 +4184,14 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
|
|
|
4182
4184
|
continue;
|
|
4183
4185
|
}
|
|
4184
4186
|
console.error(
|
|
4185
|
-
`[
|
|
4187
|
+
`[rango] Failed to get params for prerender route "${routeName}": ${err.message}`
|
|
4186
4188
|
);
|
|
4187
4189
|
notifyOnError(registry, err, "prerender", routeName);
|
|
4188
4190
|
throw err;
|
|
4189
4191
|
}
|
|
4190
4192
|
} else {
|
|
4191
4193
|
console.warn(
|
|
4192
|
-
`[
|
|
4194
|
+
`[rango] Dynamic prerender route "${routeName}" has no getParams(), skipping`
|
|
4193
4195
|
);
|
|
4194
4196
|
}
|
|
4195
4197
|
}
|
|
@@ -4200,7 +4202,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
|
|
|
4200
4202
|
clearInterval(progressInterval);
|
|
4201
4203
|
const elapsed = ((performance.now() - paramsStart) / 1e3).toFixed(1);
|
|
4202
4204
|
console.log(
|
|
4203
|
-
`[
|
|
4205
|
+
`[rango] Resolved prerender params: ${resolvedRoutes}/${totalDynamic} routes (${elapsed}s)`
|
|
4204
4206
|
);
|
|
4205
4207
|
}
|
|
4206
4208
|
}
|
|
@@ -4214,7 +4216,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
|
|
|
4214
4216
|
const maxConcurrency = Math.max(...entries.map((e) => e.concurrency));
|
|
4215
4217
|
const concurrencyNote = maxConcurrency > 1 ? ` (concurrency: ${maxConcurrency})` : "";
|
|
4216
4218
|
console.log(
|
|
4217
|
-
`[
|
|
4219
|
+
`[rango] Pre-rendering ${entries.length} URL(s)${concurrencyNote}...`
|
|
4218
4220
|
);
|
|
4219
4221
|
debug9?.(
|
|
4220
4222
|
"prerender loop: %d entries, max concurrency %d",
|
|
@@ -4247,7 +4249,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
|
|
|
4247
4249
|
if (result.passthrough) {
|
|
4248
4250
|
const elapsed2 = (performance.now() - startUrl).toFixed(0);
|
|
4249
4251
|
console.log(
|
|
4250
|
-
`[
|
|
4252
|
+
`[rango] PASS ${entry.urlPath.padEnd(40)} (${elapsed2}ms) - live fallback`
|
|
4251
4253
|
);
|
|
4252
4254
|
doneCount++;
|
|
4253
4255
|
break;
|
|
@@ -4280,7 +4282,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
|
|
|
4280
4282
|
}
|
|
4281
4283
|
const elapsed = (performance.now() - startUrl).toFixed(0);
|
|
4282
4284
|
console.log(
|
|
4283
|
-
`[
|
|
4285
|
+
`[rango] OK ${entry.urlPath.padEnd(40)} (${elapsed}ms)`
|
|
4284
4286
|
);
|
|
4285
4287
|
doneCount++;
|
|
4286
4288
|
break;
|
|
@@ -4288,7 +4290,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
|
|
|
4288
4290
|
if (err.name === "Skip") {
|
|
4289
4291
|
const elapsed2 = (performance.now() - startUrl).toFixed(0);
|
|
4290
4292
|
console.log(
|
|
4291
|
-
`[
|
|
4293
|
+
`[rango] SKIP ${entry.urlPath.padEnd(40)} (${elapsed2}ms) - ${err.message}`
|
|
4292
4294
|
);
|
|
4293
4295
|
skipCount++;
|
|
4294
4296
|
notifyOnError(
|
|
@@ -4303,7 +4305,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
|
|
|
4303
4305
|
}
|
|
4304
4306
|
const elapsed = (performance.now() - startUrl).toFixed(0);
|
|
4305
4307
|
console.error(
|
|
4306
|
-
`[
|
|
4308
|
+
`[rango] FAIL ${entry.urlPath.padEnd(40)} (${elapsed}ms) - ${err.message}`
|
|
4307
4309
|
);
|
|
4308
4310
|
notifyOnError(
|
|
4309
4311
|
registry,
|
|
@@ -4325,7 +4327,7 @@ async function expandPrerenderRoutes(state, rscEnv, registry, allManifests) {
|
|
|
4325
4327
|
const parts = [`${doneCount} done`];
|
|
4326
4328
|
if (skipCount > 0) parts.push(`${skipCount} skipped`);
|
|
4327
4329
|
console.log(
|
|
4328
|
-
`[
|
|
4330
|
+
`[rango] Pre-render complete: ${parts.join(", ")} (${totalElapsed}ms total)`
|
|
4329
4331
|
);
|
|
4330
4332
|
debug9?.(
|
|
4331
4333
|
"expandPrerenderRoutes done: %d done, %d skipped, %sms (overall %sms)",
|
|
@@ -4351,16 +4353,14 @@ async function renderStaticHandlers(state, rscEnv, registry) {
|
|
|
4351
4353
|
totalStaticCount += exportNames.length;
|
|
4352
4354
|
}
|
|
4353
4355
|
const startStatic = performance.now();
|
|
4354
|
-
console.log(
|
|
4355
|
-
`[rsc-router] Rendering ${totalStaticCount} static handler(s)...`
|
|
4356
|
-
);
|
|
4356
|
+
console.log(`[rango] Rendering ${totalStaticCount} static handler(s)...`);
|
|
4357
4357
|
for (const [moduleId, exportNames] of state.resolvedStaticModules) {
|
|
4358
4358
|
let mod;
|
|
4359
4359
|
try {
|
|
4360
4360
|
mod = await rscEnv.runner.import(moduleId);
|
|
4361
4361
|
} catch (err) {
|
|
4362
4362
|
console.error(
|
|
4363
|
-
`[
|
|
4363
|
+
`[rango] Failed to import static module ${moduleId}: ${err.message}`
|
|
4364
4364
|
);
|
|
4365
4365
|
notifyOnError(registry, err, "static");
|
|
4366
4366
|
throw err;
|
|
@@ -4390,9 +4390,7 @@ async function renderStaticHandlers(state, rscEnv, registry) {
|
|
|
4390
4390
|
exportValue
|
|
4391
4391
|
);
|
|
4392
4392
|
const elapsed = (performance.now() - startHandler).toFixed(0);
|
|
4393
|
-
console.log(
|
|
4394
|
-
`[rsc-router] OK ${name.padEnd(40)} (${elapsed}ms)`
|
|
4395
|
-
);
|
|
4393
|
+
console.log(`[rango] OK ${name.padEnd(40)} (${elapsed}ms)`);
|
|
4396
4394
|
staticDone++;
|
|
4397
4395
|
handled = true;
|
|
4398
4396
|
break;
|
|
@@ -4401,7 +4399,7 @@ async function renderStaticHandlers(state, rscEnv, registry) {
|
|
|
4401
4399
|
if (err.name === "Skip") {
|
|
4402
4400
|
const elapsed2 = (performance.now() - startHandler).toFixed(0);
|
|
4403
4401
|
console.log(
|
|
4404
|
-
`[
|
|
4402
|
+
`[rango] SKIP ${name.padEnd(40)} (${elapsed2}ms) - ${err.message}`
|
|
4405
4403
|
);
|
|
4406
4404
|
staticSkip++;
|
|
4407
4405
|
notifyOnError(registry, err, "static", void 0, void 0, true);
|
|
@@ -4410,16 +4408,14 @@ async function renderStaticHandlers(state, rscEnv, registry) {
|
|
|
4410
4408
|
}
|
|
4411
4409
|
const elapsed = (performance.now() - startHandler).toFixed(0);
|
|
4412
4410
|
console.error(
|
|
4413
|
-
`[
|
|
4411
|
+
`[rango] FAIL ${name.padEnd(40)} (${elapsed}ms) - ${err.message}`
|
|
4414
4412
|
);
|
|
4415
4413
|
notifyOnError(registry, err, "static");
|
|
4416
4414
|
throw err;
|
|
4417
4415
|
}
|
|
4418
4416
|
}
|
|
4419
4417
|
if (!handled) {
|
|
4420
|
-
console.warn(
|
|
4421
|
-
`[rsc-router] No router could render static handler "${name}"`
|
|
4422
|
-
);
|
|
4418
|
+
console.warn(`[rango] No router could render static handler "${name}"`);
|
|
4423
4419
|
}
|
|
4424
4420
|
}
|
|
4425
4421
|
}
|
|
@@ -4430,7 +4426,7 @@ async function renderStaticHandlers(state, rscEnv, registry) {
|
|
|
4430
4426
|
const staticParts = [`${staticDone} done`];
|
|
4431
4427
|
if (staticSkip > 0) staticParts.push(`${staticSkip} skipped`);
|
|
4432
4428
|
console.log(
|
|
4433
|
-
`[
|
|
4429
|
+
`[rango] Static render complete: ${staticParts.join(", ")} (${totalStaticElapsed}ms total)`
|
|
4434
4430
|
);
|
|
4435
4431
|
debug9?.(
|
|
4436
4432
|
"renderStaticHandlers done: %d done, %d skipped, %sms (overall %sms)",
|
|
@@ -4478,7 +4474,7 @@ async function resolveHostRouterHandlers(hostRegistry) {
|
|
|
4478
4474
|
return errors;
|
|
4479
4475
|
}
|
|
4480
4476
|
function formatNoRoutersError(entryPath, errors) {
|
|
4481
|
-
const base = `[
|
|
4477
|
+
const base = `[rango] No routers found in registry after importing ${entryPath}`;
|
|
4482
4478
|
if (errors.length === 0) {
|
|
4483
4479
|
return base;
|
|
4484
4480
|
}
|
|
@@ -4536,7 +4532,7 @@ async function discoverRouters(state, rscEnv) {
|
|
|
4536
4532
|
const hostRegistry = serverMod.HostRouterRegistry;
|
|
4537
4533
|
if (hostRegistry && hostRegistry.size > 0) {
|
|
4538
4534
|
console.log(
|
|
4539
|
-
`[
|
|
4535
|
+
`[rango] Found ${hostRegistry.size} host router(s), resolving lazy handlers...`
|
|
4540
4536
|
);
|
|
4541
4537
|
const handlerErrors = await resolveHostRouterHandlers(hostRegistry);
|
|
4542
4538
|
discoveryErrors.push(...handlerErrors);
|
|
@@ -4646,7 +4642,7 @@ async function discoverRouters(state, rscEnv) {
|
|
|
4646
4642
|
);
|
|
4647
4643
|
newPerRouterPrecomputedMap.set(id, routerPrecomputed);
|
|
4648
4644
|
console.log(
|
|
4649
|
-
`[
|
|
4645
|
+
`[rango] Router "${id}" -> ${routeCount} routes (${staticRoutes} static, ${dynamicRoutes} dynamic)`
|
|
4650
4646
|
);
|
|
4651
4647
|
}
|
|
4652
4648
|
if (registry.size > 1) {
|
|
@@ -4655,7 +4651,7 @@ async function discoverRouters(state, rscEnv) {
|
|
|
4655
4651
|
);
|
|
4656
4652
|
if (autoIds.length > 1) {
|
|
4657
4653
|
console.warn(
|
|
4658
|
-
`[
|
|
4654
|
+
`[rango] WARNING: ${autoIds.length} routers use auto-generated IDs (${autoIds.join(", ")}). In multi-router setups, each createRouter() must have an explicit \`id\` option to ensure per-router manifest data is matched correctly at runtime. Example: createRouter({ id: "site", ... })`
|
|
4659
4655
|
);
|
|
4660
4656
|
}
|
|
4661
4657
|
}
|
|
@@ -4800,7 +4796,7 @@ function writeRouteTypesFiles(state) {
|
|
|
4800
4796
|
if (existsSync5(oldCombinedPath)) {
|
|
4801
4797
|
unlinkSync2(oldCombinedPath);
|
|
4802
4798
|
console.log(
|
|
4803
|
-
`[
|
|
4799
|
+
`[rango] Removed stale combined route types: ${oldCombinedPath}`
|
|
4804
4800
|
);
|
|
4805
4801
|
}
|
|
4806
4802
|
} catch {
|
|
@@ -4814,7 +4810,7 @@ function writeRouteTypesFiles(state) {
|
|
|
4814
4810
|
if (!sourceFile) continue;
|
|
4815
4811
|
if (sourceFile.includes("node_modules")) {
|
|
4816
4812
|
throw new Error(
|
|
4817
|
-
`[
|
|
4813
|
+
`[rango] Router "${id}" has sourceFile inside node_modules: ${sourceFile}
|
|
4818
4814
|
This means createRouter() stack trace parsing matched a Vite internal frame.
|
|
4819
4815
|
Set an explicit \`id\` on createRouter() or check the call site.`
|
|
4820
4816
|
);
|
|
@@ -4845,7 +4841,7 @@ Set an explicit \`id\` on createRouter() or check the call site.`
|
|
|
4845
4841
|
if (existing !== source) {
|
|
4846
4842
|
markSelfGenWrite(state, outPath, source);
|
|
4847
4843
|
writeFileSync3(outPath, source);
|
|
4848
|
-
console.log(`[
|
|
4844
|
+
console.log(`[rango] Generated route types -> ${outPath}`);
|
|
4849
4845
|
}
|
|
4850
4846
|
}
|
|
4851
4847
|
}
|
|
@@ -5067,12 +5063,12 @@ function postprocessBundle(state) {
|
|
|
5067
5063
|
writeFileSync4(chunkPath, result.code);
|
|
5068
5064
|
const savedKB = (result.savedBytes / 1024).toFixed(1);
|
|
5069
5065
|
console.log(
|
|
5070
|
-
`[
|
|
5066
|
+
`[rango] Evicted ${target.label} (${savedKB} KB saved): ${info.fileName}`
|
|
5071
5067
|
);
|
|
5072
5068
|
}
|
|
5073
5069
|
} catch (replaceErr) {
|
|
5074
5070
|
console.warn(
|
|
5075
|
-
`[
|
|
5071
|
+
`[rango] Failed to evict ${target.label}: ${replaceErr.message}`
|
|
5076
5072
|
);
|
|
5077
5073
|
}
|
|
5078
5074
|
}
|
|
@@ -5110,11 +5106,11 @@ function postprocessBundle(state) {
|
|
|
5110
5106
|
writeFileSync4(rscEntryPath, injection + rscCode);
|
|
5111
5107
|
const totalKB = (totalBytes / 1024).toFixed(1);
|
|
5112
5108
|
console.log(
|
|
5113
|
-
`[
|
|
5109
|
+
`[rango] Wrote prerender assets (${totalKB} KB total, ${Object.keys(state.prerenderManifestEntries).length} entries)`
|
|
5114
5110
|
);
|
|
5115
5111
|
} catch (err) {
|
|
5116
5112
|
throw new Error(
|
|
5117
|
-
`[
|
|
5113
|
+
`[rango] Failed to write prerender assets: ${err.message}`
|
|
5118
5114
|
);
|
|
5119
5115
|
}
|
|
5120
5116
|
}
|
|
@@ -5148,11 +5144,11 @@ function postprocessBundle(state) {
|
|
|
5148
5144
|
writeFileSync4(rscEntryPath, injection + rscCode);
|
|
5149
5145
|
const totalKB = (totalBytes / 1024).toFixed(1);
|
|
5150
5146
|
console.log(
|
|
5151
|
-
`[
|
|
5147
|
+
`[rango] Wrote static assets (${totalKB} KB total, ${Object.keys(state.staticManifestEntries).length} entries)`
|
|
5152
5148
|
);
|
|
5153
5149
|
} catch (err) {
|
|
5154
5150
|
throw new Error(
|
|
5155
|
-
`[
|
|
5151
|
+
`[rango] Failed to write static assets: ${err.message}`
|
|
5156
5152
|
);
|
|
5157
5153
|
}
|
|
5158
5154
|
}
|
|
@@ -5270,12 +5266,17 @@ function pickForwardedRunnerConfig(config) {
|
|
|
5270
5266
|
if (r.extensions !== void 0) resolve10.extensions = r.extensions;
|
|
5271
5267
|
if (r.preserveSymlinks !== void 0)
|
|
5272
5268
|
resolve10.preserveSymlinks = r.preserveSymlinks;
|
|
5273
|
-
|
|
5274
|
-
const
|
|
5269
|
+
if (r.tsconfigPaths !== void 0) resolve10.tsconfigPaths = r.tsconfigPaths;
|
|
5270
|
+
const userOxc = config.oxc;
|
|
5271
|
+
const userJsx = userOxc && typeof userOxc === "object" && typeof userOxc.jsx === "object" && userOxc.jsx !== null ? userOxc.jsx : {};
|
|
5272
|
+
const oxc = userOxc && typeof userOxc === "object" ? {
|
|
5273
|
+
...userOxc,
|
|
5274
|
+
jsx: { ...userJsx, runtime: "automatic", importSource: "react" }
|
|
5275
|
+
} : { jsx: { runtime: "automatic", importSource: "react" } };
|
|
5275
5276
|
return {
|
|
5276
5277
|
resolve: resolve10,
|
|
5277
5278
|
define: config.define,
|
|
5278
|
-
|
|
5279
|
+
oxc
|
|
5279
5280
|
};
|
|
5280
5281
|
}
|
|
5281
5282
|
|
|
@@ -5294,7 +5295,7 @@ function ensureCloudflareProtocolLoaderRegistered() {
|
|
|
5294
5295
|
);
|
|
5295
5296
|
} catch (err) {
|
|
5296
5297
|
console.warn(
|
|
5297
|
-
`[
|
|
5298
|
+
`[rango] Could not register Node ESM loader hook for cloudflare:* imports (${err?.message ?? err}). Falling back to Vite transform only.`
|
|
5298
5299
|
);
|
|
5299
5300
|
}
|
|
5300
5301
|
}
|
|
@@ -5305,9 +5306,8 @@ async function createTempRscServer(state, options = {}) {
|
|
|
5305
5306
|
const resolveConfig = runnerConfig?.resolve ?? {
|
|
5306
5307
|
alias: state.userResolveAlias
|
|
5307
5308
|
};
|
|
5308
|
-
const
|
|
5309
|
-
jsx: "automatic",
|
|
5310
|
-
jsxImportSource: "react"
|
|
5309
|
+
const oxcConfig = runnerConfig?.oxc ?? {
|
|
5310
|
+
jsx: { runtime: "automatic", importSource: "react" }
|
|
5311
5311
|
};
|
|
5312
5312
|
return createViteServer({
|
|
5313
5313
|
root: state.projectRoot,
|
|
@@ -5317,7 +5317,7 @@ async function createTempRscServer(state, options = {}) {
|
|
|
5317
5317
|
logLevel: "silent",
|
|
5318
5318
|
resolve: resolveConfig,
|
|
5319
5319
|
...runnerConfig?.define ? { define: runnerConfig.define } : {},
|
|
5320
|
-
|
|
5320
|
+
oxc: oxcConfig,
|
|
5321
5321
|
...options.cacheDir && { cacheDir: options.cacheDir },
|
|
5322
5322
|
plugins: [
|
|
5323
5323
|
rsc({
|
|
@@ -5348,7 +5348,7 @@ async function resolveBuildEnv(option, factoryCtx) {
|
|
|
5348
5348
|
if (option === "auto") {
|
|
5349
5349
|
if (factoryCtx.preset !== "cloudflare") {
|
|
5350
5350
|
throw new Error(
|
|
5351
|
-
'[
|
|
5351
|
+
'[rango] buildEnv: "auto" is only supported with preset: "cloudflare". Use a factory function or plain object for other presets.'
|
|
5352
5352
|
);
|
|
5353
5353
|
}
|
|
5354
5354
|
try {
|
|
@@ -5364,7 +5364,7 @@ async function resolveBuildEnv(option, factoryCtx) {
|
|
|
5364
5364
|
};
|
|
5365
5365
|
} catch (err) {
|
|
5366
5366
|
throw new Error(
|
|
5367
|
-
`[
|
|
5367
|
+
`[rango] buildEnv: "auto" requires wrangler to be installed.
|
|
5368
5368
|
Install it with: pnpm add -D wrangler
|
|
5369
5369
|
${err.message}`
|
|
5370
5370
|
);
|
|
@@ -5395,7 +5395,7 @@ async function releaseBuildEnv(s) {
|
|
|
5395
5395
|
try {
|
|
5396
5396
|
await s.buildEnvDispose();
|
|
5397
5397
|
} catch (err) {
|
|
5398
|
-
console.warn(`[
|
|
5398
|
+
console.warn(`[rango] buildEnv dispose failed: ${err.message}`);
|
|
5399
5399
|
}
|
|
5400
5400
|
s.buildEnvDispose = null;
|
|
5401
5401
|
}
|
|
@@ -5563,9 +5563,7 @@ function createRouterDiscoveryPlugin(entryPath, opts) {
|
|
|
5563
5563
|
"getOrCreateTempServer: FAILED message=%s",
|
|
5564
5564
|
err.message
|
|
5565
5565
|
);
|
|
5566
|
-
console.warn(
|
|
5567
|
-
`[rsc-router] Failed to create temp runner: ${err.message}`
|
|
5568
|
-
);
|
|
5566
|
+
console.warn(`[rango] Failed to create temp runner: ${err.message}`);
|
|
5569
5567
|
}
|
|
5570
5568
|
return null;
|
|
5571
5569
|
}
|
|
@@ -5652,7 +5650,7 @@ function createRouterDiscoveryPlugin(entryPath, opts) {
|
|
|
5652
5650
|
}
|
|
5653
5651
|
} catch (err) {
|
|
5654
5652
|
console.warn(
|
|
5655
|
-
`[
|
|
5653
|
+
`[rango] Cloudflare dev discovery failed: ${err.message}
|
|
5656
5654
|
${err.stack}`
|
|
5657
5655
|
);
|
|
5658
5656
|
}
|
|
@@ -5696,7 +5694,7 @@ ${err.stack}`
|
|
|
5696
5694
|
);
|
|
5697
5695
|
} catch (err) {
|
|
5698
5696
|
console.warn(
|
|
5699
|
-
`[
|
|
5697
|
+
`[rango] Router discovery failed: ${err.message}
|
|
5700
5698
|
${err.stack}`
|
|
5701
5699
|
);
|
|
5702
5700
|
} finally {
|
|
@@ -5776,7 +5774,7 @@ ${err.stack}`
|
|
|
5776
5774
|
registry = serverMod.RouterRegistry ?? null;
|
|
5777
5775
|
} catch (err) {
|
|
5778
5776
|
console.warn(
|
|
5779
|
-
`[
|
|
5777
|
+
`[rango] Dev prerender module refresh failed: ${err.message}`
|
|
5780
5778
|
);
|
|
5781
5779
|
res.statusCode = 500;
|
|
5782
5780
|
res.end(`Prerender handler error: ${err.message}`);
|
|
@@ -5834,7 +5832,7 @@ ${err.stack}`
|
|
|
5834
5832
|
return;
|
|
5835
5833
|
} catch (err) {
|
|
5836
5834
|
console.warn(
|
|
5837
|
-
`[
|
|
5835
|
+
`[rango] Dev prerender failed for ${pathname}: ${err.message}`
|
|
5838
5836
|
);
|
|
5839
5837
|
}
|
|
5840
5838
|
}
|
|
@@ -5918,7 +5916,7 @@ ${err.stack}`
|
|
|
5918
5916
|
at: Date.now()
|
|
5919
5917
|
};
|
|
5920
5918
|
console.warn(
|
|
5921
|
-
`[
|
|
5919
|
+
`[rango] Runtime re-discovery failed: ${err.message}`
|
|
5922
5920
|
);
|
|
5923
5921
|
debugDiscovery?.(
|
|
5924
5922
|
"hmr: lastDiscoveryError set (%s) \u2014 manifest preserved at last-good; recovery mode active (any in-scan source change will trigger rediscovery)",
|
|
@@ -5951,9 +5949,7 @@ ${err.stack}`
|
|
|
5951
5949
|
}
|
|
5952
5950
|
}
|
|
5953
5951
|
} catch (err) {
|
|
5954
|
-
console.error(
|
|
5955
|
-
`[rsc-router] Route regeneration error: ${err.message}`
|
|
5956
|
-
);
|
|
5952
|
+
console.error(`[rango] Route regeneration error: ${err.message}`);
|
|
5957
5953
|
}
|
|
5958
5954
|
debugDiscovery?.(
|
|
5959
5955
|
"watcher: regenerated gen files (%sms)",
|
|
@@ -5962,7 +5958,7 @@ ${err.stack}`
|
|
|
5962
5958
|
if (s.perRouterManifests.length > 0) {
|
|
5963
5959
|
refreshRuntimeDiscovery().catch((err) => {
|
|
5964
5960
|
console.warn(
|
|
5965
|
-
`[
|
|
5961
|
+
`[rango] Runtime re-discovery error: ${err.message}`
|
|
5966
5962
|
);
|
|
5967
5963
|
resolveDiscoveryGate();
|
|
5968
5964
|
});
|
|
@@ -6088,7 +6084,7 @@ ${err.stack}`
|
|
|
6088
6084
|
const rscEnv = tempServer.environments?.rsc;
|
|
6089
6085
|
if (!rscEnv?.runner) {
|
|
6090
6086
|
console.warn(
|
|
6091
|
-
"[
|
|
6087
|
+
"[rango] RSC environment runner not available during build, skipping manifest generation"
|
|
6092
6088
|
);
|
|
6093
6089
|
return;
|
|
6094
6090
|
}
|
|
@@ -6120,7 +6116,7 @@ ${err.stack}`
|
|
|
6120
6116
|
${err.stack}` : null
|
|
6121
6117
|
].filter(Boolean).join("\n");
|
|
6122
6118
|
throw new Error(
|
|
6123
|
-
`[
|
|
6119
|
+
`[rango] Build-time router discovery failed:
|
|
6124
6120
|
${details}`,
|
|
6125
6121
|
{ cause: err }
|
|
6126
6122
|
);
|
|
@@ -6150,7 +6146,7 @@ ${details}`,
|
|
|
6150
6146
|
// `consumeSelfGenWrite` inside `maybeHandleGeneratedRouteFileMutation`),
|
|
6151
6147
|
// AND vite's own HMR pipeline (which invalidates the gen file's
|
|
6152
6148
|
// importers and triggers a second workerd full reload — visible to the
|
|
6153
|
-
// user as a duplicate "[
|
|
6149
|
+
// user as a duplicate "[Rango] HMR: version changed" on the client).
|
|
6154
6150
|
//
|
|
6155
6151
|
// `peekSelfGenWrite` is the authoritative filter: its map only contains
|
|
6156
6152
|
// paths that `markSelfGenWrite` has registered, so it natively works
|
|
@@ -6345,7 +6341,7 @@ async function rango(options) {
|
|
|
6345
6341
|
// This ensures the same Context instance is used by both browser entry and RSC proxy modules
|
|
6346
6342
|
optimizeDeps: {
|
|
6347
6343
|
exclude: excludeDeps,
|
|
6348
|
-
|
|
6344
|
+
rolldownOptions: sharedRolldownOptions
|
|
6349
6345
|
},
|
|
6350
6346
|
resolve: {
|
|
6351
6347
|
alias: rangoAliases,
|
|
@@ -6375,7 +6371,7 @@ async function rango(options) {
|
|
|
6375
6371
|
optimizeDeps: {
|
|
6376
6372
|
include: [nested("rsc-html-stream/client")],
|
|
6377
6373
|
exclude: excludeDeps,
|
|
6378
|
-
|
|
6374
|
+
rolldownOptions: sharedRolldownOptions
|
|
6379
6375
|
}
|
|
6380
6376
|
},
|
|
6381
6377
|
ssr: {
|
|
@@ -6400,7 +6396,7 @@ async function rango(options) {
|
|
|
6400
6396
|
)
|
|
6401
6397
|
],
|
|
6402
6398
|
exclude: excludeDeps,
|
|
6403
|
-
|
|
6399
|
+
rolldownOptions: sharedRolldownOptions
|
|
6404
6400
|
}
|
|
6405
6401
|
},
|
|
6406
6402
|
rsc: {
|
|
@@ -6417,7 +6413,7 @@ async function rango(options) {
|
|
|
6417
6413
|
)
|
|
6418
6414
|
],
|
|
6419
6415
|
exclude: excludeDeps,
|
|
6420
|
-
|
|
6416
|
+
rolldownOptions: sharedRolldownOptions
|
|
6421
6417
|
}
|
|
6422
6418
|
}
|
|
6423
6419
|
}
|
|
@@ -6453,7 +6449,7 @@ async function rango(options) {
|
|
|
6453
6449
|
const list = candidates.map(
|
|
6454
6450
|
(f) => " - " + (f.startsWith(root) ? f.slice(root.length + 1) : f)
|
|
6455
6451
|
).join("\n");
|
|
6456
|
-
throw new Error(`[
|
|
6452
|
+
throw new Error(`[rango] Multiple routers found:
|
|
6457
6453
|
${list}`);
|
|
6458
6454
|
}
|
|
6459
6455
|
}
|
|
@@ -6472,7 +6468,7 @@ ${list}`);
|
|
|
6472
6468
|
return {
|
|
6473
6469
|
optimizeDeps: {
|
|
6474
6470
|
exclude: excludeDeps,
|
|
6475
|
-
|
|
6471
|
+
rolldownOptions: sharedRolldownOptions
|
|
6476
6472
|
},
|
|
6477
6473
|
build: {
|
|
6478
6474
|
rollupOptions: { onwarn }
|
|
@@ -6506,7 +6502,7 @@ ${list}`);
|
|
|
6506
6502
|
nested("rsc-html-stream/client")
|
|
6507
6503
|
],
|
|
6508
6504
|
exclude: excludeDeps,
|
|
6509
|
-
|
|
6505
|
+
rolldownOptions: sharedRolldownOptions,
|
|
6510
6506
|
entries: [VIRTUAL_IDS.browser]
|
|
6511
6507
|
}
|
|
6512
6508
|
},
|
|
@@ -6525,7 +6521,7 @@ ${list}`);
|
|
|
6525
6521
|
)
|
|
6526
6522
|
],
|
|
6527
6523
|
exclude: excludeDeps,
|
|
6528
|
-
|
|
6524
|
+
rolldownOptions: sharedRolldownOptions
|
|
6529
6525
|
}
|
|
6530
6526
|
},
|
|
6531
6527
|
rsc: {
|
|
@@ -6539,7 +6535,7 @@ ${list}`);
|
|
|
6539
6535
|
"@vitejs/plugin-rsc/vendor/react-server-dom/server.edge"
|
|
6540
6536
|
)
|
|
6541
6537
|
],
|
|
6542
|
-
|
|
6538
|
+
rolldownOptions: sharedRolldownOptions
|
|
6543
6539
|
}
|
|
6544
6540
|
}
|
|
6545
6541
|
}
|
|
@@ -6556,7 +6552,7 @@ ${list}`);
|
|
|
6556
6552
|
if (rscMinimalCount > 1 && !hasWarnedDuplicate) {
|
|
6557
6553
|
hasWarnedDuplicate = true;
|
|
6558
6554
|
console.warn(
|
|
6559
|
-
"[
|
|
6555
|
+
"[rango] Duplicate @vitejs/plugin-rsc detected. Remove rsc() from your vite config \u2014 rango() includes it automatically."
|
|
6560
6556
|
);
|
|
6561
6557
|
}
|
|
6562
6558
|
}
|