@rangojs/router 0.0.0-experimental.cb54cbba → 0.0.0-experimental.debug-cache-2383ca26
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/AGENTS.md +4 -0
- package/dist/bin/rango.js +8 -3
- package/dist/vite/index.js +139 -200
- package/package.json +15 -14
- package/skills/caching/SKILL.md +37 -4
- package/skills/parallel/SKILL.md +126 -0
- package/src/browser/event-controller.ts +5 -0
- package/src/browser/navigation-bridge.ts +1 -3
- package/src/browser/navigation-client.ts +60 -27
- package/src/browser/navigation-transaction.ts +11 -9
- package/src/browser/partial-update.ts +50 -9
- package/src/browser/prefetch/cache.ts +57 -5
- package/src/browser/prefetch/fetch.ts +30 -21
- package/src/browser/prefetch/queue.ts +53 -13
- package/src/browser/react/Link.tsx +9 -1
- package/src/browser/react/NavigationProvider.tsx +27 -0
- package/src/browser/rsc-router.tsx +109 -57
- package/src/browser/scroll-restoration.ts +31 -34
- package/src/browser/segment-reconciler.ts +6 -1
- package/src/browser/types.ts +9 -0
- package/src/build/route-types/router-processing.ts +12 -2
- package/src/cache/cache-runtime.ts +15 -11
- package/src/cache/cache-scope.ts +43 -3
- package/src/cache/cf/cf-cache-store.ts +453 -11
- package/src/cache/cf/index.ts +5 -1
- package/src/cache/document-cache.ts +17 -7
- package/src/cache/index.ts +1 -0
- package/src/debug.ts +2 -2
- package/src/route-definition/dsl-helpers.ts +32 -7
- package/src/route-definition/redirect.ts +2 -2
- package/src/route-map-builder.ts +7 -1
- package/src/router/find-match.ts +4 -2
- package/src/router/intercept-resolution.ts +2 -0
- package/src/router/lazy-includes.ts +4 -1
- package/src/router/logging.ts +5 -2
- package/src/router/manifest.ts +9 -3
- package/src/router/match-middleware/background-revalidation.ts +30 -2
- package/src/router/match-middleware/cache-lookup.ts +66 -9
- package/src/router/match-middleware/cache-store.ts +53 -10
- package/src/router/match-middleware/intercept-resolution.ts +9 -7
- package/src/router/match-middleware/segment-resolution.ts +8 -5
- package/src/router/match-result.ts +22 -6
- package/src/router/metrics.ts +6 -1
- package/src/router/middleware.ts +2 -1
- package/src/router/router-context.ts +6 -1
- package/src/router/segment-resolution/fresh.ts +122 -15
- package/src/router/segment-resolution/loader-cache.ts +1 -0
- package/src/router/segment-resolution/revalidation.ts +347 -290
- package/src/router/segment-wrappers.ts +2 -0
- package/src/router.ts +5 -1
- package/src/segment-system.tsx +140 -4
- package/src/server/context.ts +90 -13
- package/src/server/request-context.ts +10 -4
- package/src/ssr/index.tsx +1 -0
- package/src/types/handler-context.ts +103 -17
- package/src/types/route-entry.ts +7 -0
- package/src/types/segments.ts +2 -0
- package/src/urls/path-helper.ts +1 -1
- package/src/vite/discovery/state.ts +0 -2
- package/src/vite/plugin-types.ts +0 -83
- package/src/vite/plugins/expose-action-id.ts +1 -3
- package/src/vite/plugins/version-plugin.ts +13 -1
- package/src/vite/rango.ts +144 -209
- package/src/vite/router-discovery.ts +0 -8
- package/src/vite/utils/banner.ts +3 -3
package/src/vite/plugin-types.ts
CHANGED
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RSC plugin entry points configuration.
|
|
3
|
-
* All entries use virtual modules by default. Specify a path to use a custom entry file.
|
|
4
|
-
*/
|
|
5
|
-
export interface RscEntries {
|
|
6
|
-
/**
|
|
7
|
-
* Path to a custom browser/client entry file.
|
|
8
|
-
* If not specified, a default virtual entry is used.
|
|
9
|
-
*/
|
|
10
|
-
client?: string;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Path to a custom SSR entry file.
|
|
14
|
-
* If not specified, a default virtual entry is used.
|
|
15
|
-
*/
|
|
16
|
-
ssr?: string;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Path to a custom RSC entry file.
|
|
20
|
-
* If not specified, a default virtual entry is used that imports the router from the `entry` option.
|
|
21
|
-
*/
|
|
22
|
-
rsc?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Options for @vitejs/plugin-rsc integration
|
|
27
|
-
*/
|
|
28
|
-
export interface RscPluginOptions {
|
|
29
|
-
/**
|
|
30
|
-
* Entry points for client, ssr, and rsc environments.
|
|
31
|
-
* All entries use virtual modules by default.
|
|
32
|
-
* Specify paths only when you need custom entry files.
|
|
33
|
-
*/
|
|
34
|
-
entries?: RscEntries;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
1
|
/**
|
|
38
2
|
* Base options shared by all presets
|
|
39
3
|
*/
|
|
@@ -51,21 +15,6 @@ interface RangoBaseOptions {
|
|
|
51
15
|
* @default true
|
|
52
16
|
*/
|
|
53
17
|
staticRouteTypesGeneration?: boolean;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Glob patterns for files to include in route type scanning.
|
|
57
|
-
* Only files matching at least one pattern will be scanned.
|
|
58
|
-
* Patterns are relative to the project root.
|
|
59
|
-
* When unset, all .ts/.tsx files are scanned.
|
|
60
|
-
*/
|
|
61
|
-
include?: string[];
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Glob patterns for files to exclude from route type scanning.
|
|
65
|
-
* Takes precedence over `include`. Patterns are relative to the project root.
|
|
66
|
-
* Defaults to common test/build directories.
|
|
67
|
-
*/
|
|
68
|
-
exclude?: string[];
|
|
69
18
|
}
|
|
70
19
|
|
|
71
20
|
/**
|
|
@@ -76,38 +25,6 @@ export interface RangoNodeOptions extends RangoBaseOptions {
|
|
|
76
25
|
* Deployment preset. Defaults to 'node' when not specified.
|
|
77
26
|
*/
|
|
78
27
|
preset?: "node";
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Path to your router configuration file that exports the route tree.
|
|
82
|
-
* This file must export a `router` object created with `createRouter()`.
|
|
83
|
-
*
|
|
84
|
-
* When omitted, auto-discovers the router by scanning for files containing
|
|
85
|
-
* `createRouter`. If exactly one is found, it is used automatically.
|
|
86
|
-
* If multiple are found, an error is thrown with the list of candidates.
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* ```ts
|
|
90
|
-
* rango({ router: './src/router.tsx' })
|
|
91
|
-
* // or simply:
|
|
92
|
-
* rango()
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
router?: string;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* RSC plugin configuration. By default, rsc-router includes @vitejs/plugin-rsc
|
|
99
|
-
* with sensible defaults.
|
|
100
|
-
*
|
|
101
|
-
* Entry files (browser, ssr, rsc) are optional - if they don't exist,
|
|
102
|
-
* virtual defaults are used.
|
|
103
|
-
*
|
|
104
|
-
* - Omit or pass `true`/`{}` to use defaults (recommended)
|
|
105
|
-
* - Pass `{ entries: {...} }` to customize entry paths
|
|
106
|
-
* - Pass `false` to disable (for manual @vitejs/plugin-rsc configuration)
|
|
107
|
-
*
|
|
108
|
-
* @default true
|
|
109
|
-
*/
|
|
110
|
-
rsc?: boolean | RscPluginOptions;
|
|
111
28
|
}
|
|
112
29
|
|
|
113
30
|
/**
|
|
@@ -278,9 +278,7 @@ export function exposeActionId(): Plugin {
|
|
|
278
278
|
if (!rscPluginApi) {
|
|
279
279
|
throw new Error(
|
|
280
280
|
"[rsc-router] Could not find @vitejs/plugin-rsc. " +
|
|
281
|
-
"@rangojs/router requires the Vite RSC plugin
|
|
282
|
-
"The RSC plugin should be included automatically. If you disabled it with\n" +
|
|
283
|
-
"rango({ rsc: false }), add rsc() before rango() in your config.",
|
|
281
|
+
"@rangojs/router requires the Vite RSC plugin, which is included automatically by rango().",
|
|
284
282
|
);
|
|
285
283
|
}
|
|
286
284
|
|
|
@@ -135,8 +135,11 @@ export function createVersionPlugin(): Plugin {
|
|
|
135
135
|
let server: any = null;
|
|
136
136
|
const clientModuleSignatures = new Map<string, ClientModuleSignature>();
|
|
137
137
|
|
|
138
|
+
let versionCounter = 0;
|
|
138
139
|
const bumpVersion = (reason: string) => {
|
|
139
|
-
|
|
140
|
+
// Use timestamp + counter to guarantee uniqueness even when multiple
|
|
141
|
+
// bumps happen within the same millisecond (e.g. cascading HMR events).
|
|
142
|
+
currentVersion = Date.now().toString(16) + String(++versionCounter);
|
|
140
143
|
console.log(`[rsc-router] ${reason}, version updated: ${currentVersion}`);
|
|
141
144
|
|
|
142
145
|
const rscEnv = server?.environments?.rsc;
|
|
@@ -211,6 +214,15 @@ export function createVersionPlugin(): Plugin {
|
|
|
211
214
|
|
|
212
215
|
if (!isRscModule) return;
|
|
213
216
|
|
|
217
|
+
// Skip re-bumping when the version virtual module itself is invalidated
|
|
218
|
+
// (our own bumpVersion() invalidates it, which re-triggers hotUpdate).
|
|
219
|
+
if (
|
|
220
|
+
ctx.modules.length === 1 &&
|
|
221
|
+
ctx.modules[0].id === "\0" + VIRTUAL_IDS.version
|
|
222
|
+
) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
214
226
|
if (isCodeModule(ctx.file)) {
|
|
215
227
|
const filePath = normalizeModuleId(ctx.file);
|
|
216
228
|
const previousSignature = clientModuleSignatures.get(filePath);
|
package/src/vite/rango.ts
CHANGED
|
@@ -13,10 +13,7 @@ import {
|
|
|
13
13
|
getExcludeDeps,
|
|
14
14
|
getPackageAliases,
|
|
15
15
|
} from "./utils/package-resolution.js";
|
|
16
|
-
import {
|
|
17
|
-
createScanFilter,
|
|
18
|
-
findRouterFiles,
|
|
19
|
-
} from "../build/generate-route-types.js";
|
|
16
|
+
import { findRouterFiles } from "../build/generate-route-types.js";
|
|
20
17
|
import { createVersionPlugin } from "./plugins/version-plugin.js";
|
|
21
18
|
import {
|
|
22
19
|
sharedEsbuildOptions,
|
|
@@ -24,11 +21,7 @@ import {
|
|
|
24
21
|
onwarn,
|
|
25
22
|
getManualChunks,
|
|
26
23
|
} from "./utils/shared-utils.js";
|
|
27
|
-
import type {
|
|
28
|
-
RangoOptions,
|
|
29
|
-
RangoNodeOptions,
|
|
30
|
-
RscPluginOptions,
|
|
31
|
-
} from "./plugin-types.js";
|
|
24
|
+
import type { RangoOptions } from "./plugin-types.js";
|
|
32
25
|
import { printBanner, rangoVersion } from "./utils/banner.js";
|
|
33
26
|
import { createVersionInjectorPlugin } from "./plugins/version-injector.js";
|
|
34
27
|
import { createCjsToEsmPlugin } from "./plugins/cjs-to-esm.js";
|
|
@@ -43,7 +36,7 @@ import { createRouterDiscoveryPlugin } from "./router-discovery.js";
|
|
|
43
36
|
* @example Node.js (default)
|
|
44
37
|
* ```ts
|
|
45
38
|
* export default defineConfig({
|
|
46
|
-
* plugins: [react(), rango(
|
|
39
|
+
* plugins: [react(), rango()],
|
|
47
40
|
* });
|
|
48
41
|
* ```
|
|
49
42
|
*
|
|
@@ -69,9 +62,6 @@ export async function rango(options?: RangoOptions): Promise<PluginOption[]> {
|
|
|
69
62
|
const rangoAliases = getPackageAliases();
|
|
70
63
|
const excludeDeps = getExcludeDeps();
|
|
71
64
|
|
|
72
|
-
// Track RSC entry path for version injection
|
|
73
|
-
let rscEntryPath: string | null = null;
|
|
74
|
-
|
|
75
65
|
// Mutable ref for router path (node preset only).
|
|
76
66
|
// Set immediately when user-specified, or populated by the auto-discover
|
|
77
67
|
// config() hook using Vite's resolved root.
|
|
@@ -207,198 +197,148 @@ export async function rango(options?: RangoOptions): Promise<PluginOption[]> {
|
|
|
207
197
|
// packages that are also imported directly by client components.
|
|
208
198
|
plugins.push(clientRefDedup());
|
|
209
199
|
} else {
|
|
210
|
-
//
|
|
211
|
-
|
|
200
|
+
// Auto-discover router using Vite's resolved root (not process.cwd())
|
|
201
|
+
plugins.push({
|
|
202
|
+
name: "@rangojs/router:auto-discover",
|
|
203
|
+
config(userConfig) {
|
|
204
|
+
if (routerRef.path) return;
|
|
205
|
+
const root = userConfig.root
|
|
206
|
+
? resolve(process.cwd(), userConfig.root)
|
|
207
|
+
: process.cwd();
|
|
208
|
+
const candidates = findRouterFiles(root);
|
|
209
|
+
if (candidates.length === 1) {
|
|
210
|
+
const abs = candidates[0];
|
|
211
|
+
routerRef.path = (
|
|
212
|
+
abs.startsWith(root) ? "./" + abs.slice(root.length + 1) : abs
|
|
213
|
+
).replaceAll("\\", "/");
|
|
214
|
+
} else if (candidates.length > 1) {
|
|
215
|
+
const list = candidates
|
|
216
|
+
.map(
|
|
217
|
+
(f) =>
|
|
218
|
+
" - " + (f.startsWith(root) ? f.slice(root.length + 1) : f),
|
|
219
|
+
)
|
|
220
|
+
.join("\n");
|
|
221
|
+
throw new Error(`[rsc-router] Multiple routers found:\n${list}`);
|
|
222
|
+
}
|
|
223
|
+
// 0 found: routerRef.path stays undefined, warn at startup via discovery plugin
|
|
224
|
+
},
|
|
225
|
+
});
|
|
212
226
|
|
|
213
|
-
|
|
227
|
+
// Always use virtual entries for client, ssr, and rsc
|
|
228
|
+
const finalEntries = {
|
|
229
|
+
client: VIRTUAL_IDS.browser,
|
|
230
|
+
ssr: VIRTUAL_IDS.ssr,
|
|
231
|
+
rsc: VIRTUAL_IDS.rsc,
|
|
232
|
+
};
|
|
214
233
|
|
|
215
|
-
//
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
`[rsc-router] Multiple routers found. Specify \`router\` to choose one:\n${list}`,
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
// 0 found: routerRef.path stays undefined, warn at startup via discovery plugin
|
|
246
|
-
},
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const rscOption = nodeOptions.rsc ?? true;
|
|
251
|
-
|
|
252
|
-
// Add RSC plugin by default (can be disabled with rsc: false)
|
|
253
|
-
if (rscOption !== false) {
|
|
254
|
-
// Dynamically import @vitejs/plugin-rsc
|
|
255
|
-
const { default: rsc } = await import("@vitejs/plugin-rsc");
|
|
256
|
-
|
|
257
|
-
// Resolve entry paths: use explicit config or virtual modules
|
|
258
|
-
const userEntries =
|
|
259
|
-
typeof rscOption === "boolean" ? {} : rscOption.entries || {};
|
|
260
|
-
const finalEntries = {
|
|
261
|
-
client: userEntries.client ?? VIRTUAL_IDS.browser,
|
|
262
|
-
ssr: userEntries.ssr ?? VIRTUAL_IDS.ssr,
|
|
263
|
-
rsc: userEntries.rsc ?? VIRTUAL_IDS.rsc,
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
// Track RSC entry for version injection (only if custom entry provided)
|
|
267
|
-
rscEntryPath = userEntries.rsc ?? null;
|
|
268
|
-
|
|
269
|
-
// Create wrapper plugin that checks for duplicates
|
|
270
|
-
let hasWarnedDuplicate = false;
|
|
271
|
-
|
|
272
|
-
plugins.push({
|
|
273
|
-
name: "@rangojs/router:rsc-integration",
|
|
274
|
-
enforce: "pre",
|
|
275
|
-
|
|
276
|
-
config() {
|
|
277
|
-
// Configure environments for RSC
|
|
278
|
-
// When using virtual entries, we need to explicitly configure optimizeDeps
|
|
279
|
-
// so Vite pre-bundles React before processing the virtual modules.
|
|
280
|
-
// Without this, the dep optimizer may run multiple times with different hashes,
|
|
281
|
-
// causing React instance mismatches.
|
|
282
|
-
const useVirtualClient = finalEntries.client === VIRTUAL_IDS.browser;
|
|
283
|
-
const useVirtualSSR = finalEntries.ssr === VIRTUAL_IDS.ssr;
|
|
284
|
-
const useVirtualRSC = finalEntries.rsc === VIRTUAL_IDS.rsc;
|
|
285
|
-
|
|
286
|
-
return {
|
|
287
|
-
// Exclude rsc-router modules from optimization to prevent module duplication
|
|
288
|
-
// This ensures the same Context instance is used by both browser entry and RSC proxy modules
|
|
289
|
-
optimizeDeps: {
|
|
290
|
-
exclude: excludeDeps,
|
|
291
|
-
esbuildOptions: sharedEsbuildOptions,
|
|
292
|
-
},
|
|
293
|
-
build: {
|
|
294
|
-
rollupOptions: { onwarn },
|
|
295
|
-
},
|
|
296
|
-
resolve: {
|
|
297
|
-
alias: rangoAliases,
|
|
298
|
-
},
|
|
299
|
-
environments: {
|
|
300
|
-
client: {
|
|
301
|
-
build: {
|
|
302
|
-
rollupOptions: {
|
|
303
|
-
output: {
|
|
304
|
-
manualChunks: getManualChunks,
|
|
305
|
-
},
|
|
234
|
+
// Dynamically import @vitejs/plugin-rsc
|
|
235
|
+
const { default: rsc } = await import("@vitejs/plugin-rsc");
|
|
236
|
+
|
|
237
|
+
let hasWarnedDuplicate = false;
|
|
238
|
+
|
|
239
|
+
plugins.push({
|
|
240
|
+
name: "@rangojs/router:rsc-integration",
|
|
241
|
+
enforce: "pre",
|
|
242
|
+
|
|
243
|
+
config() {
|
|
244
|
+
return {
|
|
245
|
+
optimizeDeps: {
|
|
246
|
+
exclude: excludeDeps,
|
|
247
|
+
esbuildOptions: sharedEsbuildOptions,
|
|
248
|
+
},
|
|
249
|
+
build: {
|
|
250
|
+
rollupOptions: { onwarn },
|
|
251
|
+
},
|
|
252
|
+
resolve: {
|
|
253
|
+
alias: rangoAliases,
|
|
254
|
+
},
|
|
255
|
+
environments: {
|
|
256
|
+
client: {
|
|
257
|
+
build: {
|
|
258
|
+
rollupOptions: {
|
|
259
|
+
output: {
|
|
260
|
+
manualChunks: getManualChunks,
|
|
306
261
|
},
|
|
307
262
|
},
|
|
308
|
-
// Always exclude rsc-router modules, conditionally add virtual entry
|
|
309
|
-
optimizeDeps: {
|
|
310
|
-
// Pre-bundle React and rsc-html-stream to prevent late discovery
|
|
311
|
-
// triggering ERR_OUTDATED_OPTIMIZED_DEP on cold starts
|
|
312
|
-
include: [
|
|
313
|
-
"react",
|
|
314
|
-
"react-dom",
|
|
315
|
-
"react/jsx-runtime",
|
|
316
|
-
"react/jsx-dev-runtime",
|
|
317
|
-
"rsc-html-stream/client",
|
|
318
|
-
],
|
|
319
|
-
exclude: excludeDeps,
|
|
320
|
-
esbuildOptions: sharedEsbuildOptions,
|
|
321
|
-
...(useVirtualClient && {
|
|
322
|
-
// Tell Vite to scan the virtual entry for dependencies
|
|
323
|
-
entries: [VIRTUAL_IDS.browser],
|
|
324
|
-
}),
|
|
325
|
-
},
|
|
326
263
|
},
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
264
|
+
optimizeDeps: {
|
|
265
|
+
include: [
|
|
266
|
+
"react",
|
|
267
|
+
"react-dom",
|
|
268
|
+
"react/jsx-runtime",
|
|
269
|
+
"react/jsx-dev-runtime",
|
|
270
|
+
"rsc-html-stream/client",
|
|
271
|
+
],
|
|
272
|
+
exclude: excludeDeps,
|
|
273
|
+
esbuildOptions: sharedEsbuildOptions,
|
|
274
|
+
entries: [VIRTUAL_IDS.browser],
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
ssr: {
|
|
278
|
+
optimizeDeps: {
|
|
279
|
+
entries: [VIRTUAL_IDS.ssr],
|
|
280
|
+
include: [
|
|
281
|
+
"react",
|
|
282
|
+
"react-dom",
|
|
283
|
+
"react-dom/server.edge",
|
|
284
|
+
"react-dom/static.edge",
|
|
285
|
+
"react/jsx-runtime",
|
|
286
|
+
"react/jsx-dev-runtime",
|
|
287
|
+
"@vitejs/plugin-rsc/vendor/react-server-dom/client.edge",
|
|
288
|
+
],
|
|
289
|
+
exclude: excludeDeps,
|
|
290
|
+
esbuildOptions: sharedEsbuildOptions,
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
rsc: {
|
|
294
|
+
optimizeDeps: {
|
|
295
|
+
entries: [VIRTUAL_IDS.rsc],
|
|
296
|
+
include: [
|
|
297
|
+
"react",
|
|
298
|
+
"react/jsx-runtime",
|
|
299
|
+
"react/jsx-dev-runtime",
|
|
300
|
+
"@vitejs/plugin-rsc/vendor/react-server-dom/server.edge",
|
|
301
|
+
],
|
|
302
|
+
esbuildOptions: sharedEsbuildOptions,
|
|
303
|
+
},
|
|
361
304
|
},
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
: "
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}) as PluginOption,
|
|
400
|
-
);
|
|
401
|
-
}
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
},
|
|
308
|
+
|
|
309
|
+
configResolved(config) {
|
|
310
|
+
if (showBanner) {
|
|
311
|
+
const mode =
|
|
312
|
+
config.command === "serve"
|
|
313
|
+
? process.argv.includes("preview")
|
|
314
|
+
? "preview"
|
|
315
|
+
: "dev"
|
|
316
|
+
: "build";
|
|
317
|
+
printBanner(mode, "node", rangoVersion);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const rscMinimalCount = config.plugins.filter(
|
|
321
|
+
(p) => p.name === "rsc:minimal",
|
|
322
|
+
).length;
|
|
323
|
+
|
|
324
|
+
if (rscMinimalCount > 1 && !hasWarnedDuplicate) {
|
|
325
|
+
hasWarnedDuplicate = true;
|
|
326
|
+
console.warn(
|
|
327
|
+
"[rsc-router] Duplicate @vitejs/plugin-rsc detected. " +
|
|
328
|
+
"Remove rsc() from your vite config — rango() includes it automatically.",
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// Add virtual entries plugin (RSC entry generated lazily from routerRef)
|
|
335
|
+
plugins.push(createVirtualEntriesPlugin(finalEntries, routerRef));
|
|
336
|
+
|
|
337
|
+
plugins.push(
|
|
338
|
+
rsc({
|
|
339
|
+
entries: finalEntries,
|
|
340
|
+
}) as PluginOption,
|
|
341
|
+
);
|
|
402
342
|
|
|
403
343
|
// Deduplicate client references from third-party packages in dev mode.
|
|
404
344
|
// Prevents module duplication when server components import "use client"
|
|
@@ -479,14 +419,11 @@ export async function rango(options?: RangoOptions): Promise<PluginOption[]> {
|
|
|
479
419
|
// Ref for deferred auto-discovery (node preset only, undefined for cloudflare)
|
|
480
420
|
const discoveryRouterRef = preset !== "cloudflare" ? routerRef : undefined;
|
|
481
421
|
|
|
482
|
-
// Version injector: auto-injects VERSION and routes-manifest into
|
|
483
|
-
//
|
|
484
|
-
//
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
rscEntryPath ?? (preset === "cloudflare" ? undefined : null);
|
|
488
|
-
if (injectorEntryPath !== null) {
|
|
489
|
-
plugins.push(createVersionInjectorPlugin(injectorEntryPath));
|
|
422
|
+
// Version injector: auto-injects VERSION and routes-manifest into the RSC entry.
|
|
423
|
+
// For cloudflare preset, the entry is resolved lazily in configResolved.
|
|
424
|
+
// For node preset, the virtual entry already includes these imports.
|
|
425
|
+
if (preset === "cloudflare") {
|
|
426
|
+
plugins.push(createVersionInjectorPlugin(undefined));
|
|
490
427
|
}
|
|
491
428
|
|
|
492
429
|
// Transform CJS vendor files to ESM for browser compatibility
|
|
@@ -501,8 +438,6 @@ export async function rango(options?: RangoOptions): Promise<PluginOption[]> {
|
|
|
501
438
|
routerPathRef: discoveryRouterRef,
|
|
502
439
|
enableBuildPrerender: prerenderEnabled,
|
|
503
440
|
staticRouteTypesGeneration: resolvedOptions.staticRouteTypesGeneration,
|
|
504
|
-
include: resolvedOptions.include,
|
|
505
|
-
exclude: resolvedOptions.exclude,
|
|
506
441
|
}),
|
|
507
442
|
);
|
|
508
443
|
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
formatNestedRouterConflictError,
|
|
15
15
|
findNestedRouterConflict,
|
|
16
16
|
findRouterFiles,
|
|
17
|
-
createScanFilter,
|
|
18
17
|
} from "../build/generate-route-types.js";
|
|
19
18
|
import { createVersionPlugin } from "./plugins/version-plugin.js";
|
|
20
19
|
import { createVirtualStubPlugin } from "./plugins/virtual-stub-plugin.js";
|
|
@@ -168,13 +167,6 @@ export function createRouterDiscoveryPlugin(
|
|
|
168
167
|
s.resolvedEntryPath = entries[0];
|
|
169
168
|
}
|
|
170
169
|
}
|
|
171
|
-
// Compile include/exclude patterns into a scan filter
|
|
172
|
-
if (opts?.include || opts?.exclude) {
|
|
173
|
-
s.scanFilter = createScanFilter(s.projectRoot, {
|
|
174
|
-
include: opts.include,
|
|
175
|
-
exclude: opts.exclude,
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
170
|
// Generate combined named-routes.gen.ts from static source parsing.
|
|
179
171
|
// Runs before the dev server starts so the gen file exists immediately for IDE.
|
|
180
172
|
// In build mode, the runtime discovery in buildStart produces the definitive
|
package/src/vite/utils/banner.ts
CHANGED
|
@@ -23,11 +23,11 @@ ${dim} ╱${reset} ${bold}╔═╗${reset}${dim} * ╱
|
|
|
23
23
|
${dim} ${reset}${bold}║ ║${reset} ${bold}╔═╗${reset}${dim} * ✧. ╱${reset}
|
|
24
24
|
${dim} ${reset}${bold}╔╗ ║ ║ ║ ║${reset}${dim} * ╱${reset}
|
|
25
25
|
${dim} ${reset}${bold}║║ ║ ║ ║ ║ ╦═╗╔═╗╔╗╔╔═╗╔═╗${reset}${dim} ✧ ✦${reset}
|
|
26
|
-
${dim}
|
|
26
|
+
${dim} ${reset}${bold}║║ ║ ╠═╝ ║ ╠╦╝╠═╣║║║║ ╦║ ║${reset}${dim} * ✧${reset}
|
|
27
27
|
${dim} ${reset}${bold}║╚═╝ ╔═══╝ ╩╚═╩ ╩╝╚╝╚═╝╚═╝${reset}${dim} ✦ . *${reset}
|
|
28
28
|
${dim} ${reset}${bold}╚══╗ ║${reset}${dim} * RSC Wrangler ✧ ✦${reset}
|
|
29
|
-
${dim} * ${reset}${bold}║
|
|
30
|
-
${bold}
|
|
29
|
+
${dim} * ${reset}${bold}║ ║${reset}${dim} * ✧. ╱${reset}
|
|
30
|
+
${dim} ${reset}${bold}═══╝ ╚════${reset}${dim} ✦ *${reset}
|
|
31
31
|
|
|
32
32
|
v${version} · ${preset} · ${mode}
|
|
33
33
|
`;
|