@rangojs/router 0.0.0-experimental.67 → 0.0.0-experimental.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vite/index.js
CHANGED
|
@@ -1311,6 +1311,57 @@ ${lazyImports.join(",\n")}
|
|
|
1311
1311
|
);
|
|
1312
1312
|
if (wholeFile) return wholeFile;
|
|
1313
1313
|
}
|
|
1314
|
+
if (!isRscEnv) {
|
|
1315
|
+
const allBindings = [];
|
|
1316
|
+
if (hasLoaderCode) {
|
|
1317
|
+
allBindings.push(...getBindings(code, getFnNames("createLoader")));
|
|
1318
|
+
}
|
|
1319
|
+
if (hasHandleCode) {
|
|
1320
|
+
allBindings.push(...getBindings(code, getFnNames("createHandle")));
|
|
1321
|
+
}
|
|
1322
|
+
if (hasLocationStateCode) {
|
|
1323
|
+
allBindings.push(
|
|
1324
|
+
...getBindings(code, getFnNames("createLocationState"))
|
|
1325
|
+
);
|
|
1326
|
+
}
|
|
1327
|
+
if (hasPrerenderHandlerCode) {
|
|
1328
|
+
allBindings.push(
|
|
1329
|
+
...getBindings(code, getFnNames(PRERENDER_CONFIG.fnName))
|
|
1330
|
+
);
|
|
1331
|
+
}
|
|
1332
|
+
if (hasStaticHandlerCode) {
|
|
1333
|
+
allBindings.push(
|
|
1334
|
+
...getBindings(code, getFnNames(STATIC_CONFIG.fnName))
|
|
1335
|
+
);
|
|
1336
|
+
}
|
|
1337
|
+
if (allBindings.length > 0 && isExportOnlyFile(code, allBindings)) {
|
|
1338
|
+
const stubs = [];
|
|
1339
|
+
for (const binding of allBindings) {
|
|
1340
|
+
const name = binding.exportNames[0];
|
|
1341
|
+
const stubId = isBuild ? hashId(filePath, name) : `${filePath}#${name}`;
|
|
1342
|
+
const fnCall = code.slice(
|
|
1343
|
+
binding.callExprStart,
|
|
1344
|
+
binding.callOpenParenPos + 1
|
|
1345
|
+
);
|
|
1346
|
+
let brand = "loader";
|
|
1347
|
+
if (hasPrerenderHandlerCode && getFnNames(PRERENDER_CONFIG.fnName).some(
|
|
1348
|
+
(n) => fnCall.includes(n)
|
|
1349
|
+
)) {
|
|
1350
|
+
brand = PRERENDER_CONFIG.brand;
|
|
1351
|
+
} else if (hasStaticHandlerCode && getFnNames(STATIC_CONFIG.fnName).some((n) => fnCall.includes(n))) {
|
|
1352
|
+
brand = STATIC_CONFIG.brand;
|
|
1353
|
+
} else if (hasHandleCode && getFnNames("createHandle").some((n) => fnCall.includes(n))) {
|
|
1354
|
+
brand = "handle";
|
|
1355
|
+
} else if (hasLocationStateCode && getFnNames("createLocationState").some((n) => fnCall.includes(n))) {
|
|
1356
|
+
brand = "locationState";
|
|
1357
|
+
}
|
|
1358
|
+
stubs.push(
|
|
1359
|
+
`export const ${name} = { __brand: "${brand}", $$id: "${stubId}" };`
|
|
1360
|
+
);
|
|
1361
|
+
}
|
|
1362
|
+
return { code: stubs.join("\n") + "\n", map: null };
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1314
1365
|
if (hasStaticHandlerCode && isRscEnv && isBuild) {
|
|
1315
1366
|
const fnNames = getFnNames(STATIC_CONFIG.fnName);
|
|
1316
1367
|
const exportNames = getBindings(code, fnNames).map(
|
|
@@ -1733,7 +1784,7 @@ import { resolve } from "node:path";
|
|
|
1733
1784
|
// package.json
|
|
1734
1785
|
var package_default = {
|
|
1735
1786
|
name: "@rangojs/router",
|
|
1736
|
-
version: "0.0.0-experimental.
|
|
1787
|
+
version: "0.0.0-experimental.68",
|
|
1737
1788
|
description: "Django-inspired RSC router with composable URL patterns",
|
|
1738
1789
|
keywords: [
|
|
1739
1790
|
"react",
|
package/package.json
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
getImportedFnNames,
|
|
24
24
|
collectCreateExportBindings,
|
|
25
25
|
buildUnsupportedShapeWarning,
|
|
26
|
+
isExportOnlyFile,
|
|
26
27
|
} from "./expose-ids/export-analysis.js";
|
|
27
28
|
import {
|
|
28
29
|
hasCreateLoaderImport,
|
|
@@ -462,7 +463,6 @@ ${lazyImports.join(",\n")}
|
|
|
462
463
|
|
|
463
464
|
// --- StaticHandler: non-RSC whole-file stub replacement ---
|
|
464
465
|
// When ALL exports are Static() calls, replace the entire file.
|
|
465
|
-
// Mixed-export files are handled in the unified pipeline below.
|
|
466
466
|
if (hasStaticHandlerCode && !isRscEnv) {
|
|
467
467
|
const fnNames = getFnNames(STATIC_CONFIG.fnName);
|
|
468
468
|
const bindings = getBindings(code, fnNames);
|
|
@@ -476,6 +476,79 @@ ${lazyImports.join(",\n")}
|
|
|
476
476
|
if (wholeFile) return wholeFile;
|
|
477
477
|
}
|
|
478
478
|
|
|
479
|
+
// --- Mixed-type whole-file stub replacement (non-RSC) ---
|
|
480
|
+
// When the individual whole-file checks above fail (each only checks
|
|
481
|
+
// one type), the file has mixed exports (e.g. createLoader + Prerender).
|
|
482
|
+
// Gather ALL recognized bindings and check if they cover every export.
|
|
483
|
+
// If yes, replace the entire file with stubs — this strips server-only
|
|
484
|
+
// imports (node:fs, DB clients, etc.) that would crash in the browser.
|
|
485
|
+
if (!isRscEnv) {
|
|
486
|
+
const allBindings: CreateExportBinding[] = [];
|
|
487
|
+
if (hasLoaderCode) {
|
|
488
|
+
allBindings.push(...getBindings(code, getFnNames("createLoader")));
|
|
489
|
+
}
|
|
490
|
+
if (hasHandleCode) {
|
|
491
|
+
allBindings.push(...getBindings(code, getFnNames("createHandle")));
|
|
492
|
+
}
|
|
493
|
+
if (hasLocationStateCode) {
|
|
494
|
+
allBindings.push(
|
|
495
|
+
...getBindings(code, getFnNames("createLocationState")),
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
if (hasPrerenderHandlerCode) {
|
|
499
|
+
allBindings.push(
|
|
500
|
+
...getBindings(code, getFnNames(PRERENDER_CONFIG.fnName)),
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
if (hasStaticHandlerCode) {
|
|
504
|
+
allBindings.push(
|
|
505
|
+
...getBindings(code, getFnNames(STATIC_CONFIG.fnName)),
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
if (allBindings.length > 0 && isExportOnlyFile(code, allBindings)) {
|
|
509
|
+
const stubs: string[] = [];
|
|
510
|
+
for (const binding of allBindings) {
|
|
511
|
+
const name = binding.exportNames[0];
|
|
512
|
+
const stubId = isBuild
|
|
513
|
+
? hashId(filePath, name)
|
|
514
|
+
: `${filePath}#${name}`;
|
|
515
|
+
// Determine brand from which type this binding belongs to
|
|
516
|
+
const fnCall = code.slice(
|
|
517
|
+
binding.callExprStart,
|
|
518
|
+
binding.callOpenParenPos + 1,
|
|
519
|
+
);
|
|
520
|
+
let brand = "loader";
|
|
521
|
+
if (
|
|
522
|
+
hasPrerenderHandlerCode &&
|
|
523
|
+
getFnNames(PRERENDER_CONFIG.fnName).some((n) =>
|
|
524
|
+
fnCall.includes(n),
|
|
525
|
+
)
|
|
526
|
+
) {
|
|
527
|
+
brand = PRERENDER_CONFIG.brand;
|
|
528
|
+
} else if (
|
|
529
|
+
hasStaticHandlerCode &&
|
|
530
|
+
getFnNames(STATIC_CONFIG.fnName).some((n) => fnCall.includes(n))
|
|
531
|
+
) {
|
|
532
|
+
brand = STATIC_CONFIG.brand;
|
|
533
|
+
} else if (
|
|
534
|
+
hasHandleCode &&
|
|
535
|
+
getFnNames("createHandle").some((n) => fnCall.includes(n))
|
|
536
|
+
) {
|
|
537
|
+
brand = "handle";
|
|
538
|
+
} else if (
|
|
539
|
+
hasLocationStateCode &&
|
|
540
|
+
getFnNames("createLocationState").some((n) => fnCall.includes(n))
|
|
541
|
+
) {
|
|
542
|
+
brand = "locationState";
|
|
543
|
+
}
|
|
544
|
+
stubs.push(
|
|
545
|
+
`export const ${name} = { __brand: "${brand}", $$id: "${stubId}" };`,
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
return { code: stubs.join("\n") + "\n", map: null };
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
479
552
|
// --- StaticHandler: RSC build module tracking ---
|
|
480
553
|
if (hasStaticHandlerCode && isRscEnv && isBuild) {
|
|
481
554
|
const fnNames = getFnNames(STATIC_CONFIG.fnName);
|