@react-router/dev 0.0.0-experimental-fbc98d36c → 0.0.0-experimental-6336d71a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +1 -1
- package/dist/config.js +1 -1
- package/dist/internal.d.ts +9 -0
- package/dist/internal.js +2358 -0
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +1 -1
- package/dist/vite.d.ts +1 -3
- package/dist/vite.js +104 -1010
- package/package.json +10 -6
package/dist/vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-6336d71a9
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -40,8 +40,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
40
40
|
// vite.ts
|
|
41
41
|
var vite_exports = {};
|
|
42
42
|
__export(vite_exports, {
|
|
43
|
-
reactRouter: () => reactRouterVitePlugin
|
|
44
|
-
unstable_reactRouterRSC: () => reactRouterRSCVitePlugin
|
|
43
|
+
reactRouter: () => reactRouterVitePlugin
|
|
45
44
|
});
|
|
46
45
|
module.exports = __toCommonJS(vite_exports);
|
|
47
46
|
|
|
@@ -248,7 +247,7 @@ function validateRouteConfig({
|
|
|
248
247
|
`Route config in "${routeConfigFile}" is invalid.`,
|
|
249
248
|
root ? `${root}` : [],
|
|
250
249
|
nested ? Object.entries(nested).map(
|
|
251
|
-
([
|
|
250
|
+
([path7, message]) => `Path: routes.${path7}
|
|
252
251
|
${message}`
|
|
253
252
|
) : []
|
|
254
253
|
].flat().join("\n\n")
|
|
@@ -619,12 +618,12 @@ async function createConfigLoader({
|
|
|
619
618
|
if (!fsWatcher) {
|
|
620
619
|
fsWatcher = import_chokidar.default.watch([root, appDirectory], {
|
|
621
620
|
ignoreInitial: true,
|
|
622
|
-
ignored: (
|
|
623
|
-
let
|
|
624
|
-
return !
|
|
621
|
+
ignored: (path7) => {
|
|
622
|
+
let dirname4 = import_pathe3.default.dirname(path7);
|
|
623
|
+
return !dirname4.startsWith(appDirectory) && // Ensure we're only watching files outside of the app directory
|
|
625
624
|
// that are at the root level, not nested in subdirectories
|
|
626
|
-
|
|
627
|
-
|
|
625
|
+
path7 !== root && // Watch the root directory itself
|
|
626
|
+
dirname4 !== root;
|
|
628
627
|
}
|
|
629
628
|
});
|
|
630
629
|
fsWatcher.on("all", async (...args) => {
|
|
@@ -884,7 +883,7 @@ function fullpath(lineage2) {
|
|
|
884
883
|
if (lineage2.length === 1 && route?.id === "root") return "/";
|
|
885
884
|
const isLayout = route && route.index !== true && route.path === void 0;
|
|
886
885
|
if (isLayout) return void 0;
|
|
887
|
-
return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((
|
|
886
|
+
return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path7) => path7 !== void 0 && path7 !== "").join("/");
|
|
888
887
|
}
|
|
889
888
|
|
|
890
889
|
// typegen/generate.ts
|
|
@@ -1040,8 +1039,8 @@ function routeFilesType({
|
|
|
1040
1039
|
);
|
|
1041
1040
|
}
|
|
1042
1041
|
function isInAppDirectory(ctx, routeFile) {
|
|
1043
|
-
const
|
|
1044
|
-
return
|
|
1042
|
+
const path7 = Path3.resolve(ctx.config.appDirectory, routeFile);
|
|
1043
|
+
return path7.startsWith(ctx.config.appDirectory);
|
|
1045
1044
|
}
|
|
1046
1045
|
function getRouteAnnotations({
|
|
1047
1046
|
ctx,
|
|
@@ -1153,21 +1152,21 @@ function getRouteAnnotations({
|
|
|
1153
1152
|
return { filename: filename2, content };
|
|
1154
1153
|
}
|
|
1155
1154
|
function relativeImportSource(from, to) {
|
|
1156
|
-
let
|
|
1157
|
-
let extension = Path3.extname(
|
|
1158
|
-
|
|
1159
|
-
if (!
|
|
1155
|
+
let path7 = Path3.relative(Path3.dirname(from), to);
|
|
1156
|
+
let extension = Path3.extname(path7);
|
|
1157
|
+
path7 = Path3.join(Path3.dirname(path7), Pathe.filename(path7));
|
|
1158
|
+
if (!path7.startsWith("../")) path7 = "./" + path7;
|
|
1160
1159
|
if (!extension || /\.(js|ts)x?$/.test(extension)) {
|
|
1161
1160
|
extension = ".js";
|
|
1162
1161
|
}
|
|
1163
|
-
return
|
|
1162
|
+
return path7 + extension;
|
|
1164
1163
|
}
|
|
1165
1164
|
function rootDirsPath(ctx, typesPath) {
|
|
1166
1165
|
const rel = Path3.relative(typesDirectory(ctx), typesPath);
|
|
1167
1166
|
return Path3.join(ctx.rootDirectory, rel);
|
|
1168
1167
|
}
|
|
1169
|
-
function paramsType(
|
|
1170
|
-
const params = parse2(
|
|
1168
|
+
function paramsType(path7) {
|
|
1169
|
+
const params = parse2(path7);
|
|
1171
1170
|
return t2.tsTypeLiteral(
|
|
1172
1171
|
Object.entries(params).map(([param, isRequired]) => {
|
|
1173
1172
|
const property = t2.tsPropertySignature(
|
|
@@ -1436,11 +1435,11 @@ var getCssStringFromViteDevModuleCode = (code) => {
|
|
|
1436
1435
|
let cssContent = void 0;
|
|
1437
1436
|
const ast = import_parser.parse(code, { sourceType: "module" });
|
|
1438
1437
|
traverse(ast, {
|
|
1439
|
-
VariableDeclaration(
|
|
1440
|
-
const declaration =
|
|
1438
|
+
VariableDeclaration(path7) {
|
|
1439
|
+
const declaration = path7.node.declarations[0];
|
|
1441
1440
|
if (declaration?.id?.type === "Identifier" && declaration.id.name === "__vite__css" && declaration.init?.type === "StringLiteral") {
|
|
1442
1441
|
cssContent = declaration.init.value;
|
|
1443
|
-
|
|
1442
|
+
path7.stop();
|
|
1444
1443
|
}
|
|
1445
1444
|
}
|
|
1446
1445
|
});
|
|
@@ -1479,10 +1478,10 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1479
1478
|
let markedForRemoval = /* @__PURE__ */ new Set();
|
|
1480
1479
|
let removedExportLocalNames = /* @__PURE__ */ new Set();
|
|
1481
1480
|
traverse(ast, {
|
|
1482
|
-
ExportDeclaration(
|
|
1483
|
-
if (
|
|
1484
|
-
if (
|
|
1485
|
-
|
|
1481
|
+
ExportDeclaration(path7) {
|
|
1482
|
+
if (path7.node.type === "ExportNamedDeclaration") {
|
|
1483
|
+
if (path7.node.specifiers.length) {
|
|
1484
|
+
path7.node.specifiers = path7.node.specifiers.filter((specifier) => {
|
|
1486
1485
|
if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier") {
|
|
1487
1486
|
if (exportsToRemove.includes(specifier.exported.name)) {
|
|
1488
1487
|
exportsFiltered = true;
|
|
@@ -1494,12 +1493,12 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1494
1493
|
}
|
|
1495
1494
|
return true;
|
|
1496
1495
|
});
|
|
1497
|
-
if (
|
|
1498
|
-
markedForRemoval.add(
|
|
1496
|
+
if (path7.node.specifiers.length === 0) {
|
|
1497
|
+
markedForRemoval.add(path7);
|
|
1499
1498
|
}
|
|
1500
1499
|
}
|
|
1501
|
-
if (
|
|
1502
|
-
let declaration =
|
|
1500
|
+
if (path7.node.declaration?.type === "VariableDeclaration") {
|
|
1501
|
+
let declaration = path7.node.declaration;
|
|
1503
1502
|
declaration.declarations = declaration.declarations.filter(
|
|
1504
1503
|
(declaration2) => {
|
|
1505
1504
|
if (declaration2.id.type === "Identifier" && exportsToRemove.includes(declaration2.id.name)) {
|
|
@@ -1513,30 +1512,30 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1513
1512
|
}
|
|
1514
1513
|
);
|
|
1515
1514
|
if (declaration.declarations.length === 0) {
|
|
1516
|
-
markedForRemoval.add(
|
|
1515
|
+
markedForRemoval.add(path7);
|
|
1517
1516
|
}
|
|
1518
1517
|
}
|
|
1519
|
-
if (
|
|
1520
|
-
let id =
|
|
1518
|
+
if (path7.node.declaration?.type === "FunctionDeclaration") {
|
|
1519
|
+
let id = path7.node.declaration.id;
|
|
1521
1520
|
if (id && exportsToRemove.includes(id.name)) {
|
|
1522
|
-
markedForRemoval.add(
|
|
1521
|
+
markedForRemoval.add(path7);
|
|
1523
1522
|
}
|
|
1524
1523
|
}
|
|
1525
|
-
if (
|
|
1526
|
-
let id =
|
|
1524
|
+
if (path7.node.declaration?.type === "ClassDeclaration") {
|
|
1525
|
+
let id = path7.node.declaration.id;
|
|
1527
1526
|
if (id && exportsToRemove.includes(id.name)) {
|
|
1528
|
-
markedForRemoval.add(
|
|
1527
|
+
markedForRemoval.add(path7);
|
|
1529
1528
|
}
|
|
1530
1529
|
}
|
|
1531
1530
|
}
|
|
1532
|
-
if (
|
|
1531
|
+
if (path7.node.type === "ExportDefaultDeclaration") {
|
|
1533
1532
|
if (exportsToRemove.includes("default")) {
|
|
1534
|
-
markedForRemoval.add(
|
|
1535
|
-
if (
|
|
1536
|
-
if (
|
|
1537
|
-
removedExportLocalNames.add(
|
|
1538
|
-
} else if ((
|
|
1539
|
-
removedExportLocalNames.add(
|
|
1533
|
+
markedForRemoval.add(path7);
|
|
1534
|
+
if (path7.node.declaration) {
|
|
1535
|
+
if (path7.node.declaration.type === "Identifier") {
|
|
1536
|
+
removedExportLocalNames.add(path7.node.declaration.name);
|
|
1537
|
+
} else if ((path7.node.declaration.type === "FunctionDeclaration" || path7.node.declaration.type === "ClassDeclaration") && path7.node.declaration.id) {
|
|
1538
|
+
removedExportLocalNames.add(path7.node.declaration.id.name);
|
|
1540
1539
|
}
|
|
1541
1540
|
}
|
|
1542
1541
|
}
|
|
@@ -1544,21 +1543,21 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1544
1543
|
}
|
|
1545
1544
|
});
|
|
1546
1545
|
traverse(ast, {
|
|
1547
|
-
ExpressionStatement(
|
|
1548
|
-
if (!
|
|
1546
|
+
ExpressionStatement(path7) {
|
|
1547
|
+
if (!path7.parentPath.isProgram()) {
|
|
1549
1548
|
return;
|
|
1550
1549
|
}
|
|
1551
|
-
if (
|
|
1552
|
-
const left =
|
|
1550
|
+
if (path7.node.expression.type === "AssignmentExpression") {
|
|
1551
|
+
const left = path7.node.expression.left;
|
|
1553
1552
|
if (left.type === "MemberExpression" && left.object.type === "Identifier" && (exportsToRemove.includes(left.object.name) || removedExportLocalNames.has(left.object.name))) {
|
|
1554
|
-
markedForRemoval.add(
|
|
1553
|
+
markedForRemoval.add(path7);
|
|
1555
1554
|
}
|
|
1556
1555
|
}
|
|
1557
1556
|
}
|
|
1558
1557
|
});
|
|
1559
1558
|
if (markedForRemoval.size > 0 || exportsFiltered) {
|
|
1560
|
-
for (let
|
|
1561
|
-
|
|
1559
|
+
for (let path7 of markedForRemoval) {
|
|
1560
|
+
path7.remove();
|
|
1562
1561
|
}
|
|
1563
1562
|
(0, import_babel_dead_code_elimination.deadCodeElimination)(ast, previouslyReferencedIdentifiers);
|
|
1564
1563
|
}
|
|
@@ -1641,28 +1640,28 @@ function codeToAst(code, cache, cacheKey) {
|
|
|
1641
1640
|
)
|
|
1642
1641
|
);
|
|
1643
1642
|
}
|
|
1644
|
-
function assertNodePath(
|
|
1643
|
+
function assertNodePath(path7) {
|
|
1645
1644
|
invariant(
|
|
1646
|
-
|
|
1647
|
-
`Expected a Path, but got ${Array.isArray(
|
|
1645
|
+
path7 && !Array.isArray(path7),
|
|
1646
|
+
`Expected a Path, but got ${Array.isArray(path7) ? "an array" : path7}`
|
|
1648
1647
|
);
|
|
1649
1648
|
}
|
|
1650
|
-
function assertNodePathIsStatement(
|
|
1649
|
+
function assertNodePathIsStatement(path7) {
|
|
1651
1650
|
invariant(
|
|
1652
|
-
|
|
1653
|
-
`Expected a Statement path, but got ${Array.isArray(
|
|
1651
|
+
path7 && !Array.isArray(path7) && t.isStatement(path7.node),
|
|
1652
|
+
`Expected a Statement path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
|
|
1654
1653
|
);
|
|
1655
1654
|
}
|
|
1656
|
-
function assertNodePathIsVariableDeclarator(
|
|
1655
|
+
function assertNodePathIsVariableDeclarator(path7) {
|
|
1657
1656
|
invariant(
|
|
1658
|
-
|
|
1659
|
-
`Expected an Identifier path, but got ${Array.isArray(
|
|
1657
|
+
path7 && !Array.isArray(path7) && t.isVariableDeclarator(path7.node),
|
|
1658
|
+
`Expected an Identifier path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
|
|
1660
1659
|
);
|
|
1661
1660
|
}
|
|
1662
|
-
function assertNodePathIsPattern(
|
|
1661
|
+
function assertNodePathIsPattern(path7) {
|
|
1663
1662
|
invariant(
|
|
1664
|
-
|
|
1665
|
-
`Expected a Pattern path, but got ${Array.isArray(
|
|
1663
|
+
path7 && !Array.isArray(path7) && t.isPattern(path7.node),
|
|
1664
|
+
`Expected a Pattern path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
|
|
1666
1665
|
);
|
|
1667
1666
|
}
|
|
1668
1667
|
function getExportDependencies(code, cache, cacheKey) {
|
|
@@ -1698,8 +1697,8 @@ function getExportDependencies(code, cache, cacheKey) {
|
|
|
1698
1697
|
}
|
|
1699
1698
|
let isWithinExportDestructuring = Boolean(
|
|
1700
1699
|
identifier.findParent(
|
|
1701
|
-
(
|
|
1702
|
-
|
|
1700
|
+
(path7) => Boolean(
|
|
1701
|
+
path7.isPattern() && path7.parentPath?.isVariableDeclarator() && path7.parentPath.parentPath?.parentPath?.isExportNamedDeclaration()
|
|
1703
1702
|
)
|
|
1704
1703
|
)
|
|
1705
1704
|
);
|
|
@@ -1777,7 +1776,7 @@ function getExportDependencies(code, cache, cacheKey) {
|
|
|
1777
1776
|
for (let specifier of node.specifiers) {
|
|
1778
1777
|
if (t.isIdentifier(specifier.exported)) {
|
|
1779
1778
|
let name = specifier.exported.name;
|
|
1780
|
-
let specifierPath = exportPath.get("specifiers").find((
|
|
1779
|
+
let specifierPath = exportPath.get("specifiers").find((path7) => path7.node === specifier);
|
|
1781
1780
|
invariant(
|
|
1782
1781
|
specifierPath,
|
|
1783
1782
|
`Expected to find specifier path for ${name}`
|
|
@@ -1794,22 +1793,22 @@ function getExportDependencies(code, cache, cacheKey) {
|
|
|
1794
1793
|
}
|
|
1795
1794
|
);
|
|
1796
1795
|
}
|
|
1797
|
-
function getDependentIdentifiersForPath(
|
|
1796
|
+
function getDependentIdentifiersForPath(path7, state) {
|
|
1798
1797
|
let { visited, identifiers } = state ?? {
|
|
1799
1798
|
visited: /* @__PURE__ */ new Set(),
|
|
1800
1799
|
identifiers: /* @__PURE__ */ new Set()
|
|
1801
1800
|
};
|
|
1802
|
-
if (visited.has(
|
|
1801
|
+
if (visited.has(path7)) {
|
|
1803
1802
|
return identifiers;
|
|
1804
1803
|
}
|
|
1805
|
-
visited.add(
|
|
1806
|
-
|
|
1807
|
-
Identifier(
|
|
1808
|
-
if (identifiers.has(
|
|
1804
|
+
visited.add(path7);
|
|
1805
|
+
path7.traverse({
|
|
1806
|
+
Identifier(path8) {
|
|
1807
|
+
if (identifiers.has(path8)) {
|
|
1809
1808
|
return;
|
|
1810
1809
|
}
|
|
1811
|
-
identifiers.add(
|
|
1812
|
-
let binding =
|
|
1810
|
+
identifiers.add(path8);
|
|
1811
|
+
let binding = path8.scope.getBinding(path8.node.name);
|
|
1813
1812
|
if (!binding) {
|
|
1814
1813
|
return;
|
|
1815
1814
|
}
|
|
@@ -1831,7 +1830,7 @@ function getDependentIdentifiersForPath(path9, state) {
|
|
|
1831
1830
|
}
|
|
1832
1831
|
}
|
|
1833
1832
|
});
|
|
1834
|
-
let topLevelStatement = getTopLevelStatementPathForPath(
|
|
1833
|
+
let topLevelStatement = getTopLevelStatementPathForPath(path7);
|
|
1835
1834
|
let withinImportStatement = topLevelStatement.isImportDeclaration();
|
|
1836
1835
|
let withinExportStatement = topLevelStatement.isExportDeclaration();
|
|
1837
1836
|
if (!withinImportStatement && !withinExportStatement) {
|
|
@@ -1840,9 +1839,9 @@ function getDependentIdentifiersForPath(path9, state) {
|
|
|
1840
1839
|
identifiers
|
|
1841
1840
|
});
|
|
1842
1841
|
}
|
|
1843
|
-
if (withinExportStatement &&
|
|
1844
|
-
t.isPattern(
|
|
1845
|
-
let variableDeclarator =
|
|
1842
|
+
if (withinExportStatement && path7.isIdentifier() && (t.isPattern(path7.parentPath.node) || // [foo]
|
|
1843
|
+
t.isPattern(path7.parentPath.parentPath?.node))) {
|
|
1844
|
+
let variableDeclarator = path7.findParent((p) => p.isVariableDeclarator());
|
|
1846
1845
|
assertNodePath(variableDeclarator);
|
|
1847
1846
|
getDependentIdentifiersForPath(variableDeclarator, {
|
|
1848
1847
|
visited,
|
|
@@ -1851,16 +1850,16 @@ function getDependentIdentifiersForPath(path9, state) {
|
|
|
1851
1850
|
}
|
|
1852
1851
|
return identifiers;
|
|
1853
1852
|
}
|
|
1854
|
-
function getTopLevelStatementPathForPath(
|
|
1855
|
-
let ancestry =
|
|
1853
|
+
function getTopLevelStatementPathForPath(path7) {
|
|
1854
|
+
let ancestry = path7.getAncestry();
|
|
1856
1855
|
let topLevelStatement = ancestry[ancestry.length - 2];
|
|
1857
1856
|
assertNodePathIsStatement(topLevelStatement);
|
|
1858
1857
|
return topLevelStatement;
|
|
1859
1858
|
}
|
|
1860
1859
|
function getTopLevelStatementsForPaths(paths) {
|
|
1861
1860
|
let topLevelStatements = /* @__PURE__ */ new Set();
|
|
1862
|
-
for (let
|
|
1863
|
-
let topLevelStatement = getTopLevelStatementPathForPath(
|
|
1861
|
+
for (let path7 of paths) {
|
|
1862
|
+
let topLevelStatement = getTopLevelStatementPathForPath(path7);
|
|
1864
1863
|
topLevelStatements.add(topLevelStatement.node);
|
|
1865
1864
|
}
|
|
1866
1865
|
return topLevelStatements;
|
|
@@ -2254,24 +2253,24 @@ function isNamedComponentExport(name) {
|
|
|
2254
2253
|
}
|
|
2255
2254
|
var decorateComponentExportsWithProps = (ast) => {
|
|
2256
2255
|
const hocs = [];
|
|
2257
|
-
function getHocUid(
|
|
2258
|
-
const uid =
|
|
2256
|
+
function getHocUid(path7, hocName) {
|
|
2257
|
+
const uid = path7.scope.generateUidIdentifier(hocName);
|
|
2259
2258
|
hocs.push([hocName, uid]);
|
|
2260
2259
|
return uid;
|
|
2261
2260
|
}
|
|
2262
2261
|
traverse(ast, {
|
|
2263
|
-
ExportDeclaration(
|
|
2264
|
-
if (
|
|
2265
|
-
const declaration =
|
|
2262
|
+
ExportDeclaration(path7) {
|
|
2263
|
+
if (path7.isExportDefaultDeclaration()) {
|
|
2264
|
+
const declaration = path7.get("declaration");
|
|
2266
2265
|
const expr = declaration.isExpression() ? declaration.node : declaration.isFunctionDeclaration() ? toFunctionExpression(declaration.node) : void 0;
|
|
2267
2266
|
if (expr) {
|
|
2268
|
-
const uid = getHocUid(
|
|
2267
|
+
const uid = getHocUid(path7, "UNSAFE_withComponentProps");
|
|
2269
2268
|
declaration.replaceWith(t.callExpression(uid, [expr]));
|
|
2270
2269
|
}
|
|
2271
2270
|
return;
|
|
2272
2271
|
}
|
|
2273
|
-
if (
|
|
2274
|
-
const decl =
|
|
2272
|
+
if (path7.isExportNamedDeclaration()) {
|
|
2273
|
+
const decl = path7.get("declaration");
|
|
2275
2274
|
if (decl.isVariableDeclaration()) {
|
|
2276
2275
|
decl.get("declarations").forEach((varDeclarator) => {
|
|
2277
2276
|
const id = varDeclarator.get("id");
|
|
@@ -2281,7 +2280,7 @@ var decorateComponentExportsWithProps = (ast) => {
|
|
|
2281
2280
|
if (!id.isIdentifier()) return;
|
|
2282
2281
|
const { name } = id.node;
|
|
2283
2282
|
if (!isNamedComponentExport(name)) return;
|
|
2284
|
-
const uid = getHocUid(
|
|
2283
|
+
const uid = getHocUid(path7, `UNSAFE_with${name}Props`);
|
|
2285
2284
|
init.replaceWith(t.callExpression(uid, [expr]));
|
|
2286
2285
|
});
|
|
2287
2286
|
return;
|
|
@@ -2291,7 +2290,7 @@ var decorateComponentExportsWithProps = (ast) => {
|
|
|
2291
2290
|
if (!id) return;
|
|
2292
2291
|
const { name } = id;
|
|
2293
2292
|
if (!isNamedComponentExport(name)) return;
|
|
2294
|
-
const uid = getHocUid(
|
|
2293
|
+
const uid = getHocUid(path7, `UNSAFE_with${name}Props`);
|
|
2295
2294
|
decl.replaceWith(
|
|
2296
2295
|
t.variableDeclaration("const", [
|
|
2297
2296
|
t.variableDeclarator(
|
|
@@ -4170,17 +4169,17 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4170
4169
|
serverBuildPath
|
|
4171
4170
|
);
|
|
4172
4171
|
let routes = createPrerenderRoutes(reactRouterConfig.routes);
|
|
4173
|
-
for (let
|
|
4174
|
-
let matches = (0, import_react_router2.matchRoutes)(routes, `/${
|
|
4172
|
+
for (let path7 of build.prerender) {
|
|
4173
|
+
let matches = (0, import_react_router2.matchRoutes)(routes, `/${path7}/`.replace(/^\/\/+/, "/"));
|
|
4175
4174
|
if (!matches) {
|
|
4176
4175
|
throw new Error(
|
|
4177
|
-
`Unable to prerender path because it does not match any routes: ${
|
|
4176
|
+
`Unable to prerender path because it does not match any routes: ${path7}`
|
|
4178
4177
|
);
|
|
4179
4178
|
}
|
|
4180
4179
|
}
|
|
4181
4180
|
let buildRoutes = createPrerenderRoutes(build.routes);
|
|
4182
|
-
for (let
|
|
4183
|
-
let matches = (0, import_react_router2.matchRoutes)(buildRoutes, `/${
|
|
4181
|
+
for (let path7 of build.prerender) {
|
|
4182
|
+
let matches = (0, import_react_router2.matchRoutes)(buildRoutes, `/${path7}/`.replace(/^\/\/+/, "/"));
|
|
4184
4183
|
if (!matches) {
|
|
4185
4184
|
continue;
|
|
4186
4185
|
}
|
|
@@ -4193,7 +4192,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4193
4192
|
if (manifestRoute.loader) {
|
|
4194
4193
|
await prerenderData(
|
|
4195
4194
|
handler,
|
|
4196
|
-
|
|
4195
|
+
path7,
|
|
4197
4196
|
[leafRoute.id],
|
|
4198
4197
|
clientBuildDirectory,
|
|
4199
4198
|
reactRouterConfig,
|
|
@@ -4201,7 +4200,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4201
4200
|
);
|
|
4202
4201
|
await prerenderResourceRoute(
|
|
4203
4202
|
handler,
|
|
4204
|
-
|
|
4203
|
+
path7,
|
|
4205
4204
|
clientBuildDirectory,
|
|
4206
4205
|
reactRouterConfig,
|
|
4207
4206
|
viteConfig
|
|
@@ -4219,7 +4218,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4219
4218
|
if (!isResourceRoute && hasLoaders) {
|
|
4220
4219
|
data = await prerenderData(
|
|
4221
4220
|
handler,
|
|
4222
|
-
|
|
4221
|
+
path7,
|
|
4223
4222
|
null,
|
|
4224
4223
|
clientBuildDirectory,
|
|
4225
4224
|
reactRouterConfig,
|
|
@@ -4228,7 +4227,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4228
4227
|
}
|
|
4229
4228
|
await prerenderRoute(
|
|
4230
4229
|
handler,
|
|
4231
|
-
|
|
4230
|
+
path7,
|
|
4232
4231
|
clientBuildDirectory,
|
|
4233
4232
|
reactRouterConfig,
|
|
4234
4233
|
viteConfig,
|
|
@@ -4424,14 +4423,14 @@ async function validateSsrFalsePrerenderExports(viteConfig, ctx, manifest, viteC
|
|
|
4424
4423
|
}
|
|
4425
4424
|
let prerenderRoutes = createPrerenderRoutes(manifest.routes);
|
|
4426
4425
|
let prerenderedRoutes = /* @__PURE__ */ new Set();
|
|
4427
|
-
for (let
|
|
4426
|
+
for (let path7 of prerenderPaths) {
|
|
4428
4427
|
let matches = (0, import_react_router2.matchRoutes)(
|
|
4429
4428
|
prerenderRoutes,
|
|
4430
|
-
`/${
|
|
4429
|
+
`/${path7}/`.replace(/^\/\/+/, "/")
|
|
4431
4430
|
);
|
|
4432
4431
|
invariant(
|
|
4433
4432
|
matches,
|
|
4434
|
-
`Unable to prerender path because it does not match any routes: ${
|
|
4433
|
+
`Unable to prerender path because it does not match any routes: ${path7}`
|
|
4435
4434
|
);
|
|
4436
4435
|
matches.forEach((m) => prerenderedRoutes.add(m.route.id));
|
|
4437
4436
|
}
|
|
@@ -4879,912 +4878,7 @@ async function asyncFlatten(arr) {
|
|
|
4879
4878
|
} while (arr.some((v2) => v2?.then));
|
|
4880
4879
|
return arr;
|
|
4881
4880
|
}
|
|
4882
|
-
|
|
4883
|
-
// vite/rsc/plugin.ts
|
|
4884
|
-
var import_es_module_lexer3 = require("es-module-lexer");
|
|
4885
|
-
var Path5 = __toESM(require("pathe"));
|
|
4886
|
-
var babel2 = __toESM(require("@babel/core"));
|
|
4887
|
-
var import_picocolors5 = __toESM(require("picocolors"));
|
|
4888
|
-
var import_fs = require("fs");
|
|
4889
|
-
var import_promises3 = require("fs/promises");
|
|
4890
|
-
var import_pathe6 = __toESM(require("pathe"));
|
|
4891
|
-
|
|
4892
|
-
// vite/rsc/virtual-route-config.ts
|
|
4893
|
-
var import_pathe5 = __toESM(require("pathe"));
|
|
4894
|
-
function createVirtualRouteConfig({
|
|
4895
|
-
appDirectory,
|
|
4896
|
-
routeConfig
|
|
4897
|
-
}) {
|
|
4898
|
-
let routeIdByFile = /* @__PURE__ */ new Map();
|
|
4899
|
-
let code = "export default [";
|
|
4900
|
-
const closeRouteSymbol = Symbol("CLOSE_ROUTE");
|
|
4901
|
-
let stack = [
|
|
4902
|
-
...routeConfig
|
|
4903
|
-
];
|
|
4904
|
-
while (stack.length > 0) {
|
|
4905
|
-
const route = stack.pop();
|
|
4906
|
-
if (!route) break;
|
|
4907
|
-
if (route === closeRouteSymbol) {
|
|
4908
|
-
code += "]},";
|
|
4909
|
-
continue;
|
|
4910
|
-
}
|
|
4911
|
-
code += "{";
|
|
4912
|
-
const routeFile = import_pathe5.default.resolve(appDirectory, route.file);
|
|
4913
|
-
const routeId = route.id || createRouteId2(route.file, appDirectory);
|
|
4914
|
-
routeIdByFile.set(routeFile, routeId);
|
|
4915
|
-
code += `lazy: () => import(${JSON.stringify(
|
|
4916
|
-
`${routeFile}?route-module`
|
|
4917
|
-
)}),`;
|
|
4918
|
-
code += `id: ${JSON.stringify(routeId)},`;
|
|
4919
|
-
if (typeof route.path === "string") {
|
|
4920
|
-
code += `path: ${JSON.stringify(route.path)},`;
|
|
4921
|
-
}
|
|
4922
|
-
if (route.index) {
|
|
4923
|
-
code += `index: true,`;
|
|
4924
|
-
}
|
|
4925
|
-
if (route.caseSensitive) {
|
|
4926
|
-
code += `caseSensitive: true,`;
|
|
4927
|
-
}
|
|
4928
|
-
if (route.children) {
|
|
4929
|
-
code += ["children:["];
|
|
4930
|
-
stack.push(closeRouteSymbol);
|
|
4931
|
-
stack.push(...[...route.children].reverse());
|
|
4932
|
-
} else {
|
|
4933
|
-
code += "},";
|
|
4934
|
-
}
|
|
4935
|
-
}
|
|
4936
|
-
code += "];\n";
|
|
4937
|
-
return { code, routeIdByFile };
|
|
4938
|
-
}
|
|
4939
|
-
function createRouteId2(file, appDirectory) {
|
|
4940
|
-
return import_pathe5.default.relative(appDirectory, file).replace(/\\+/, "/").slice(0, -import_pathe5.default.extname(file).length);
|
|
4941
|
-
}
|
|
4942
|
-
|
|
4943
|
-
// vite/rsc/virtual-route-modules.ts
|
|
4944
|
-
var import_es_module_lexer2 = require("es-module-lexer");
|
|
4945
|
-
var SERVER_ONLY_COMPONENT_EXPORTS = ["ServerComponent"];
|
|
4946
|
-
var SERVER_ONLY_ROUTE_EXPORTS2 = [
|
|
4947
|
-
...SERVER_ONLY_COMPONENT_EXPORTS,
|
|
4948
|
-
"loader",
|
|
4949
|
-
"action",
|
|
4950
|
-
"middleware",
|
|
4951
|
-
"headers"
|
|
4952
|
-
];
|
|
4953
|
-
var SERVER_ONLY_ROUTE_EXPORTS_SET = new Set(SERVER_ONLY_ROUTE_EXPORTS2);
|
|
4954
|
-
function isServerOnlyRouteExport(name) {
|
|
4955
|
-
return SERVER_ONLY_ROUTE_EXPORTS_SET.has(name);
|
|
4956
|
-
}
|
|
4957
|
-
var COMMON_COMPONENT_EXPORTS = [
|
|
4958
|
-
"ErrorBoundary",
|
|
4959
|
-
"HydrateFallback",
|
|
4960
|
-
"Layout"
|
|
4961
|
-
];
|
|
4962
|
-
var SERVER_FIRST_COMPONENT_EXPORTS = [
|
|
4963
|
-
...COMMON_COMPONENT_EXPORTS,
|
|
4964
|
-
...SERVER_ONLY_COMPONENT_EXPORTS
|
|
4965
|
-
];
|
|
4966
|
-
var SERVER_FIRST_COMPONENT_EXPORTS_SET = new Set(
|
|
4967
|
-
SERVER_FIRST_COMPONENT_EXPORTS
|
|
4968
|
-
);
|
|
4969
|
-
function isServerFirstComponentExport(name) {
|
|
4970
|
-
return SERVER_FIRST_COMPONENT_EXPORTS_SET.has(
|
|
4971
|
-
name
|
|
4972
|
-
);
|
|
4973
|
-
}
|
|
4974
|
-
var CLIENT_COMPONENT_EXPORTS = [
|
|
4975
|
-
...COMMON_COMPONENT_EXPORTS,
|
|
4976
|
-
"default"
|
|
4977
|
-
];
|
|
4978
|
-
var CLIENT_NON_COMPONENT_EXPORTS2 = [
|
|
4979
|
-
"clientAction",
|
|
4980
|
-
"clientLoader",
|
|
4981
|
-
"clientMiddleware",
|
|
4982
|
-
"handle",
|
|
4983
|
-
"meta",
|
|
4984
|
-
"links",
|
|
4985
|
-
"shouldRevalidate"
|
|
4986
|
-
];
|
|
4987
|
-
var CLIENT_NON_COMPONENT_EXPORTS_SET = new Set(CLIENT_NON_COMPONENT_EXPORTS2);
|
|
4988
|
-
function isClientNonComponentExport(name) {
|
|
4989
|
-
return CLIENT_NON_COMPONENT_EXPORTS_SET.has(name);
|
|
4990
|
-
}
|
|
4991
|
-
var CLIENT_ROUTE_EXPORTS2 = [
|
|
4992
|
-
...CLIENT_NON_COMPONENT_EXPORTS2,
|
|
4993
|
-
...CLIENT_COMPONENT_EXPORTS
|
|
4994
|
-
];
|
|
4995
|
-
var CLIENT_ROUTE_EXPORTS_SET = new Set(CLIENT_ROUTE_EXPORTS2);
|
|
4996
|
-
function isClientRouteExport(name) {
|
|
4997
|
-
return CLIENT_ROUTE_EXPORTS_SET.has(name);
|
|
4998
|
-
}
|
|
4999
|
-
var ROUTE_EXPORTS = [
|
|
5000
|
-
...SERVER_ONLY_ROUTE_EXPORTS2,
|
|
5001
|
-
...CLIENT_ROUTE_EXPORTS2
|
|
5002
|
-
];
|
|
5003
|
-
var ROUTE_EXPORTS_SET = new Set(ROUTE_EXPORTS);
|
|
5004
|
-
function isRouteExport(name) {
|
|
5005
|
-
return ROUTE_EXPORTS_SET.has(name);
|
|
5006
|
-
}
|
|
5007
|
-
function isCustomRouteExport(name) {
|
|
5008
|
-
return !isRouteExport(name);
|
|
5009
|
-
}
|
|
5010
|
-
function hasReactServerCondition(viteEnvironment) {
|
|
5011
|
-
return viteEnvironment.config.resolve.conditions.includes("react-server");
|
|
5012
|
-
}
|
|
5013
|
-
function transformVirtualRouteModules({
|
|
5014
|
-
id,
|
|
5015
|
-
code,
|
|
5016
|
-
viteCommand,
|
|
5017
|
-
routeIdByFile,
|
|
5018
|
-
rootRouteFile,
|
|
5019
|
-
viteEnvironment
|
|
5020
|
-
}) {
|
|
5021
|
-
if (isVirtualRouteModuleId(id) || routeIdByFile.has(id)) {
|
|
5022
|
-
return createVirtualRouteModuleCode({
|
|
5023
|
-
id,
|
|
5024
|
-
code,
|
|
5025
|
-
rootRouteFile,
|
|
5026
|
-
viteCommand,
|
|
5027
|
-
viteEnvironment
|
|
5028
|
-
});
|
|
5029
|
-
}
|
|
5030
|
-
if (isVirtualServerRouteModuleId(id)) {
|
|
5031
|
-
return createVirtualServerRouteModuleCode({
|
|
5032
|
-
id,
|
|
5033
|
-
code,
|
|
5034
|
-
viteEnvironment
|
|
5035
|
-
});
|
|
5036
|
-
}
|
|
5037
|
-
if (isVirtualClientRouteModuleId(id)) {
|
|
5038
|
-
return createVirtualClientRouteModuleCode({
|
|
5039
|
-
id,
|
|
5040
|
-
code,
|
|
5041
|
-
rootRouteFile,
|
|
5042
|
-
viteCommand
|
|
5043
|
-
});
|
|
5044
|
-
}
|
|
5045
|
-
}
|
|
5046
|
-
async function createVirtualRouteModuleCode({
|
|
5047
|
-
id,
|
|
5048
|
-
code: routeSource,
|
|
5049
|
-
rootRouteFile,
|
|
5050
|
-
viteCommand,
|
|
5051
|
-
viteEnvironment
|
|
5052
|
-
}) {
|
|
5053
|
-
const isReactServer = hasReactServerCondition(viteEnvironment);
|
|
5054
|
-
const { staticExports, isServerFirstRoute, hasClientExports } = parseRouteExports(routeSource);
|
|
5055
|
-
const clientModuleId = getVirtualClientModuleId(id);
|
|
5056
|
-
const serverModuleId = getVirtualServerModuleId(id);
|
|
5057
|
-
let code = "";
|
|
5058
|
-
if (isServerFirstRoute) {
|
|
5059
|
-
if (staticExports.some(isServerFirstComponentExport)) {
|
|
5060
|
-
code += `import React from "react";
|
|
5061
|
-
`;
|
|
5062
|
-
}
|
|
5063
|
-
for (const staticExport of staticExports) {
|
|
5064
|
-
if (isClientNonComponentExport(staticExport)) {
|
|
5065
|
-
code += `export { ${staticExport} } from "${clientModuleId}";
|
|
5066
|
-
`;
|
|
5067
|
-
} else if (isReactServer && isServerFirstComponentExport(staticExport) && // Layout wraps all other component exports so doesn't need CSS injected
|
|
5068
|
-
staticExport !== "Layout") {
|
|
5069
|
-
code += `import { ${staticExport} as ${staticExport}WithoutCss } from "${serverModuleId}";
|
|
5070
|
-
`;
|
|
5071
|
-
code += `export ${staticExport === "ServerComponent" ? "default " : " "}function ${staticExport}(props) {
|
|
5072
|
-
`;
|
|
5073
|
-
code += ` return React.createElement(React.Fragment, null,
|
|
5074
|
-
`;
|
|
5075
|
-
code += ` import.meta.viteRsc.loadCss(),
|
|
5076
|
-
`;
|
|
5077
|
-
code += ` React.createElement(${staticExport}WithoutCss, props),
|
|
5078
|
-
`;
|
|
5079
|
-
code += ` );
|
|
5080
|
-
`;
|
|
5081
|
-
code += `}
|
|
5082
|
-
`;
|
|
5083
|
-
} else if (isReactServer && isRouteExport(staticExport)) {
|
|
5084
|
-
code += `export { ${staticExport} } from "${serverModuleId}";
|
|
5085
|
-
`;
|
|
5086
|
-
} else if (isCustomRouteExport(staticExport)) {
|
|
5087
|
-
code += `export { ${staticExport} } from "${isReactServer ? serverModuleId : clientModuleId}";
|
|
5088
|
-
`;
|
|
5089
|
-
}
|
|
5090
|
-
}
|
|
5091
|
-
if (viteCommand === "serve" && !hasClientExports) {
|
|
5092
|
-
code += `export { __ensureClientRouteModuleForHMR } from "${clientModuleId}";
|
|
5093
|
-
`;
|
|
5094
|
-
}
|
|
5095
|
-
} else {
|
|
5096
|
-
for (const staticExport of staticExports) {
|
|
5097
|
-
if (isClientRouteExport(staticExport)) {
|
|
5098
|
-
code += `export { ${staticExport} } from "${clientModuleId}";
|
|
5099
|
-
`;
|
|
5100
|
-
} else if (isReactServer && isServerOnlyRouteExport(staticExport)) {
|
|
5101
|
-
code += `export { ${staticExport} } from "${serverModuleId}";
|
|
5102
|
-
`;
|
|
5103
|
-
} else if (isCustomRouteExport(staticExport)) {
|
|
5104
|
-
code += `export { ${staticExport} } from "${isReactServer ? serverModuleId : clientModuleId}";
|
|
5105
|
-
`;
|
|
5106
|
-
}
|
|
5107
|
-
}
|
|
5108
|
-
}
|
|
5109
|
-
if (isRootRouteFile({ id, rootRouteFile }) && !staticExports.includes("ErrorBoundary")) {
|
|
5110
|
-
code += `export { ErrorBoundary } from "${clientModuleId}";
|
|
5111
|
-
`;
|
|
5112
|
-
}
|
|
5113
|
-
return code;
|
|
5114
|
-
}
|
|
5115
|
-
function createVirtualServerRouteModuleCode({
|
|
5116
|
-
id,
|
|
5117
|
-
code: routeSource,
|
|
5118
|
-
viteEnvironment
|
|
5119
|
-
}) {
|
|
5120
|
-
if (!hasReactServerCondition(viteEnvironment)) {
|
|
5121
|
-
throw new Error(
|
|
5122
|
-
[
|
|
5123
|
-
"Virtual server route module was loaded outside of the RSC environment.",
|
|
5124
|
-
`Environment Name: ${viteEnvironment.name}`,
|
|
5125
|
-
`Module ID: ${id}`
|
|
5126
|
-
].join("\n")
|
|
5127
|
-
);
|
|
5128
|
-
}
|
|
5129
|
-
const { staticExports, isServerFirstRoute } = parseRouteExports(routeSource);
|
|
5130
|
-
const clientModuleId = getVirtualClientModuleId(id);
|
|
5131
|
-
const serverRouteModuleAst = import_parser.parse(routeSource, {
|
|
5132
|
-
sourceType: "module"
|
|
5133
|
-
});
|
|
5134
|
-
removeExports(
|
|
5135
|
-
serverRouteModuleAst,
|
|
5136
|
-
isServerFirstRoute ? CLIENT_NON_COMPONENT_EXPORTS2 : CLIENT_ROUTE_EXPORTS2
|
|
5137
|
-
);
|
|
5138
|
-
const generatorResult = generate(serverRouteModuleAst);
|
|
5139
|
-
if (!isServerFirstRoute) {
|
|
5140
|
-
for (const staticExport of staticExports) {
|
|
5141
|
-
if (isClientRouteExport(staticExport)) {
|
|
5142
|
-
generatorResult.code += "\n";
|
|
5143
|
-
generatorResult.code += `export { ${staticExport} } from "${clientModuleId}";
|
|
5144
|
-
`;
|
|
5145
|
-
}
|
|
5146
|
-
}
|
|
5147
|
-
}
|
|
5148
|
-
return generatorResult;
|
|
5149
|
-
}
|
|
5150
|
-
function createVirtualClientRouteModuleCode({
|
|
5151
|
-
id,
|
|
5152
|
-
code: routeSource,
|
|
5153
|
-
rootRouteFile,
|
|
5154
|
-
viteCommand
|
|
5155
|
-
}) {
|
|
5156
|
-
const { staticExports, isServerFirstRoute, hasClientExports } = parseRouteExports(routeSource);
|
|
5157
|
-
const exportsToRemove = isServerFirstRoute ? [...SERVER_ONLY_ROUTE_EXPORTS2, ...CLIENT_COMPONENT_EXPORTS] : SERVER_ONLY_ROUTE_EXPORTS2;
|
|
5158
|
-
const clientRouteModuleAst = import_parser.parse(routeSource, {
|
|
5159
|
-
sourceType: "module"
|
|
5160
|
-
});
|
|
5161
|
-
removeExports(clientRouteModuleAst, exportsToRemove);
|
|
5162
|
-
const generatorResult = generate(clientRouteModuleAst);
|
|
5163
|
-
generatorResult.code = '"use client";' + generatorResult.code;
|
|
5164
|
-
if (isRootRouteFile({ id, rootRouteFile }) && !staticExports.includes("ErrorBoundary")) {
|
|
5165
|
-
const hasRootLayout = staticExports.includes("Layout");
|
|
5166
|
-
generatorResult.code += `
|
|
5167
|
-
import { createElement as __rr_createElement } from "react";
|
|
5168
|
-
`;
|
|
5169
|
-
generatorResult.code += `import { UNSAFE_RSCDefaultRootErrorBoundary } from "react-router";
|
|
5170
|
-
`;
|
|
5171
|
-
generatorResult.code += `export function ErrorBoundary() {
|
|
5172
|
-
`;
|
|
5173
|
-
generatorResult.code += ` return __rr_createElement(UNSAFE_RSCDefaultRootErrorBoundary, { hasRootLayout: ${hasRootLayout} });
|
|
5174
|
-
`;
|
|
5175
|
-
generatorResult.code += `}
|
|
5176
|
-
`;
|
|
5177
|
-
}
|
|
5178
|
-
if (viteCommand === "serve" && isServerFirstRoute && !hasClientExports) {
|
|
5179
|
-
generatorResult.code += `
|
|
5180
|
-
export const __ensureClientRouteModuleForHMR = true;`;
|
|
5181
|
-
}
|
|
5182
|
-
return generatorResult;
|
|
5183
|
-
}
|
|
5184
|
-
function parseRouteExports(code) {
|
|
5185
|
-
const [, exportSpecifiers] = (0, import_es_module_lexer2.parse)(code);
|
|
5186
|
-
const staticExports = exportSpecifiers.map(({ n: name }) => name);
|
|
5187
|
-
const isServerFirstRoute = staticExports.some(
|
|
5188
|
-
(staticExport) => staticExport === "ServerComponent"
|
|
5189
|
-
);
|
|
5190
|
-
return {
|
|
5191
|
-
staticExports,
|
|
5192
|
-
isServerFirstRoute,
|
|
5193
|
-
hasClientExports: staticExports.some(
|
|
5194
|
-
isServerFirstRoute ? isClientNonComponentExport : isClientRouteExport
|
|
5195
|
-
)
|
|
5196
|
-
};
|
|
5197
|
-
}
|
|
5198
|
-
function getVirtualClientModuleId(id) {
|
|
5199
|
-
return `${id.split("?")[0]}?client-route-module`;
|
|
5200
|
-
}
|
|
5201
|
-
function getVirtualServerModuleId(id) {
|
|
5202
|
-
return `${id.split("?")[0]}?server-route-module`;
|
|
5203
|
-
}
|
|
5204
|
-
function isVirtualRouteModuleId(id) {
|
|
5205
|
-
return /(\?|&)route-module(&|$)/.test(id);
|
|
5206
|
-
}
|
|
5207
|
-
function isVirtualClientRouteModuleId(id) {
|
|
5208
|
-
return /(\?|&)client-route-module(&|$)/.test(id);
|
|
5209
|
-
}
|
|
5210
|
-
function isVirtualServerRouteModuleId(id) {
|
|
5211
|
-
return /(\?|&)server-route-module(&|$)/.test(id);
|
|
5212
|
-
}
|
|
5213
|
-
function isRootRouteFile({
|
|
5214
|
-
id,
|
|
5215
|
-
rootRouteFile
|
|
5216
|
-
}) {
|
|
5217
|
-
const filePath = id.split("?")[0];
|
|
5218
|
-
return filePath === rootRouteFile;
|
|
5219
|
-
}
|
|
5220
|
-
|
|
5221
|
-
// vite/rsc/plugin.ts
|
|
5222
|
-
function reactRouterRSCVitePlugin() {
|
|
5223
|
-
let configLoader;
|
|
5224
|
-
let typegenWatcherPromise;
|
|
5225
|
-
let viteCommand;
|
|
5226
|
-
let resolvedViteConfig;
|
|
5227
|
-
let routeIdByFile;
|
|
5228
|
-
let logger;
|
|
5229
|
-
const defaultEntries2 = getDefaultEntries();
|
|
5230
|
-
let config;
|
|
5231
|
-
let rootRouteFile;
|
|
5232
|
-
function updateConfig(newConfig) {
|
|
5233
|
-
config = newConfig;
|
|
5234
|
-
rootRouteFile = Path5.resolve(
|
|
5235
|
-
newConfig.appDirectory,
|
|
5236
|
-
newConfig.routes.root.file
|
|
5237
|
-
);
|
|
5238
|
-
}
|
|
5239
|
-
return [
|
|
5240
|
-
{
|
|
5241
|
-
name: "react-router/rsc",
|
|
5242
|
-
async config(viteUserConfig, { command, mode }) {
|
|
5243
|
-
await import_es_module_lexer3.init;
|
|
5244
|
-
await preloadVite();
|
|
5245
|
-
viteCommand = command;
|
|
5246
|
-
const rootDirectory = getRootDirectory(viteUserConfig);
|
|
5247
|
-
const watch2 = command === "serve";
|
|
5248
|
-
configLoader = await createConfigLoader({
|
|
5249
|
-
rootDirectory,
|
|
5250
|
-
mode,
|
|
5251
|
-
watch: watch2,
|
|
5252
|
-
validateConfig: (userConfig) => {
|
|
5253
|
-
let errors = [];
|
|
5254
|
-
if (userConfig.buildEnd) errors.push("buildEnd");
|
|
5255
|
-
if (userConfig.prerender) errors.push("prerender");
|
|
5256
|
-
if (userConfig.presets?.length) errors.push("presets");
|
|
5257
|
-
if (userConfig.routeDiscovery) errors.push("routeDiscovery");
|
|
5258
|
-
if (userConfig.serverBundles) errors.push("serverBundles");
|
|
5259
|
-
if (userConfig.ssr === false) errors.push("ssr: false");
|
|
5260
|
-
if (userConfig.future?.unstable_splitRouteModules)
|
|
5261
|
-
errors.push("future.unstable_splitRouteModules");
|
|
5262
|
-
if (userConfig.future?.unstable_viteEnvironmentApi === false)
|
|
5263
|
-
errors.push("future.unstable_viteEnvironmentApi: false");
|
|
5264
|
-
if (userConfig.future?.v8_middleware === false)
|
|
5265
|
-
errors.push("future.v8_middleware: false");
|
|
5266
|
-
if (userConfig.future?.unstable_subResourceIntegrity)
|
|
5267
|
-
errors.push("future.unstable_subResourceIntegrity");
|
|
5268
|
-
if (errors.length) {
|
|
5269
|
-
return `RSC Framework Mode does not currently support the following React Router config:
|
|
5270
|
-
${errors.map((x) => ` - ${x}`).join("\n")}
|
|
5271
|
-
`;
|
|
5272
|
-
}
|
|
5273
|
-
}
|
|
5274
|
-
});
|
|
5275
|
-
const configResult = await configLoader.getConfig();
|
|
5276
|
-
if (!configResult.ok) throw new Error(configResult.error);
|
|
5277
|
-
updateConfig(configResult.value);
|
|
5278
|
-
if (viteUserConfig.base && config.basename !== "/" && viteCommand === "serve" && !viteUserConfig.server?.middlewareMode && !config.basename.startsWith(viteUserConfig.base)) {
|
|
5279
|
-
throw new Error(
|
|
5280
|
-
"When using the React Router `basename` and the Vite `base` config, the `basename` config must begin with `base` for the default Vite dev server."
|
|
5281
|
-
);
|
|
5282
|
-
}
|
|
5283
|
-
await loadDotenv({
|
|
5284
|
-
rootDirectory,
|
|
5285
|
-
viteUserConfig,
|
|
5286
|
-
mode
|
|
5287
|
-
});
|
|
5288
|
-
const vite2 = await import("vite");
|
|
5289
|
-
logger = vite2.createLogger(viteUserConfig.logLevel, {
|
|
5290
|
-
prefix: "[react-router]"
|
|
5291
|
-
});
|
|
5292
|
-
return {
|
|
5293
|
-
resolve: {
|
|
5294
|
-
dedupe: [
|
|
5295
|
-
// https://react.dev/warnings/invalid-hook-call-warning#duplicate-react
|
|
5296
|
-
"react",
|
|
5297
|
-
"react-dom",
|
|
5298
|
-
// Avoid router duplicates since mismatching routers cause `Error:
|
|
5299
|
-
// You must render this element inside a <Remix> element`.
|
|
5300
|
-
"react-router",
|
|
5301
|
-
"react-router/dom",
|
|
5302
|
-
...hasDependency({ name: "react-router-dom", rootDirectory }) ? ["react-router-dom"] : []
|
|
5303
|
-
]
|
|
5304
|
-
},
|
|
5305
|
-
optimizeDeps: {
|
|
5306
|
-
entries: getOptimizeDepsEntries({
|
|
5307
|
-
entryClientFilePath: defaultEntries2.client,
|
|
5308
|
-
reactRouterConfig: config
|
|
5309
|
-
}),
|
|
5310
|
-
esbuildOptions: {
|
|
5311
|
-
jsx: "automatic"
|
|
5312
|
-
},
|
|
5313
|
-
include: [
|
|
5314
|
-
// Pre-bundle React dependencies to avoid React duplicates,
|
|
5315
|
-
// even if React dependencies are not direct dependencies.
|
|
5316
|
-
// https://react.dev/warnings/invalid-hook-call-warning#duplicate-react
|
|
5317
|
-
"react",
|
|
5318
|
-
"react/jsx-runtime",
|
|
5319
|
-
"react/jsx-dev-runtime",
|
|
5320
|
-
"react-dom",
|
|
5321
|
-
"react-dom/client",
|
|
5322
|
-
"react-router/internal/react-server-client"
|
|
5323
|
-
]
|
|
5324
|
-
},
|
|
5325
|
-
esbuild: {
|
|
5326
|
-
jsx: "automatic",
|
|
5327
|
-
jsxDev: viteCommand !== "build"
|
|
5328
|
-
},
|
|
5329
|
-
environments: {
|
|
5330
|
-
client: {
|
|
5331
|
-
build: {
|
|
5332
|
-
rollupOptions: {
|
|
5333
|
-
input: {
|
|
5334
|
-
index: defaultEntries2.client
|
|
5335
|
-
}
|
|
5336
|
-
},
|
|
5337
|
-
outDir: (0, import_pathe6.join)(config.buildDirectory, "client")
|
|
5338
|
-
}
|
|
5339
|
-
},
|
|
5340
|
-
rsc: {
|
|
5341
|
-
build: {
|
|
5342
|
-
rollupOptions: {
|
|
5343
|
-
input: {
|
|
5344
|
-
// We use a virtual entry here so that consumers can import
|
|
5345
|
-
// it as `virtual:react-router/unstable_rsc/rsc-entry`
|
|
5346
|
-
// without needing to know the actual file path, which is
|
|
5347
|
-
// important when using the default entries.
|
|
5348
|
-
index: defaultEntries2.rsc
|
|
5349
|
-
},
|
|
5350
|
-
output: {
|
|
5351
|
-
entryFileNames: config.serverBuildFile,
|
|
5352
|
-
format: config.serverModuleFormat
|
|
5353
|
-
}
|
|
5354
|
-
},
|
|
5355
|
-
outDir: (0, import_pathe6.join)(config.buildDirectory, "server")
|
|
5356
|
-
}
|
|
5357
|
-
},
|
|
5358
|
-
ssr: {
|
|
5359
|
-
build: {
|
|
5360
|
-
rollupOptions: {
|
|
5361
|
-
input: {
|
|
5362
|
-
index: defaultEntries2.ssr
|
|
5363
|
-
},
|
|
5364
|
-
output: {
|
|
5365
|
-
// Note: We don't set `entryFileNames` here because it's
|
|
5366
|
-
// considered private to the RSC environment build, and
|
|
5367
|
-
// @vitejs/plugin-rsc currently breaks if it's set to
|
|
5368
|
-
// something other than `index.js`.
|
|
5369
|
-
format: config.serverModuleFormat
|
|
5370
|
-
}
|
|
5371
|
-
},
|
|
5372
|
-
outDir: (0, import_pathe6.join)(config.buildDirectory, "server/__ssr_build")
|
|
5373
|
-
}
|
|
5374
|
-
}
|
|
5375
|
-
},
|
|
5376
|
-
build: {
|
|
5377
|
-
rollupOptions: {
|
|
5378
|
-
// Copied from https://github.com/vitejs/vite-plugin-react/blob/c602225271d4acf462ba00f8d6d8a2e42492c5cd/packages/common/warning.ts
|
|
5379
|
-
onwarn(warning, defaultHandler) {
|
|
5380
|
-
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && (warning.message.includes("use client") || warning.message.includes("use server"))) {
|
|
5381
|
-
return;
|
|
5382
|
-
}
|
|
5383
|
-
if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
|
|
5384
|
-
return;
|
|
5385
|
-
}
|
|
5386
|
-
if (viteUserConfig.build?.rollupOptions?.onwarn) {
|
|
5387
|
-
viteUserConfig.build.rollupOptions.onwarn(
|
|
5388
|
-
warning,
|
|
5389
|
-
defaultHandler
|
|
5390
|
-
);
|
|
5391
|
-
} else {
|
|
5392
|
-
defaultHandler(warning);
|
|
5393
|
-
}
|
|
5394
|
-
}
|
|
5395
|
-
}
|
|
5396
|
-
}
|
|
5397
|
-
};
|
|
5398
|
-
},
|
|
5399
|
-
configResolved(viteConfig) {
|
|
5400
|
-
resolvedViteConfig = viteConfig;
|
|
5401
|
-
},
|
|
5402
|
-
async configureServer(viteDevServer) {
|
|
5403
|
-
configLoader.onChange(
|
|
5404
|
-
async ({
|
|
5405
|
-
result,
|
|
5406
|
-
configCodeChanged,
|
|
5407
|
-
routeConfigCodeChanged,
|
|
5408
|
-
configChanged,
|
|
5409
|
-
routeConfigChanged
|
|
5410
|
-
}) => {
|
|
5411
|
-
if (!result.ok) {
|
|
5412
|
-
invalidateVirtualModules2(viteDevServer);
|
|
5413
|
-
logger.error(result.error, {
|
|
5414
|
-
clear: true,
|
|
5415
|
-
timestamp: true
|
|
5416
|
-
});
|
|
5417
|
-
return;
|
|
5418
|
-
}
|
|
5419
|
-
let message = configChanged ? "Config changed." : routeConfigChanged ? "Route config changed." : configCodeChanged ? "Config saved." : routeConfigCodeChanged ? " Route config saved." : "Config saved";
|
|
5420
|
-
logger.info(import_picocolors5.default.green(message), {
|
|
5421
|
-
clear: true,
|
|
5422
|
-
timestamp: true
|
|
5423
|
-
});
|
|
5424
|
-
updateConfig(result.value);
|
|
5425
|
-
if (configChanged || routeConfigChanged) {
|
|
5426
|
-
invalidateVirtualModules2(viteDevServer);
|
|
5427
|
-
}
|
|
5428
|
-
}
|
|
5429
|
-
);
|
|
5430
|
-
},
|
|
5431
|
-
async buildEnd() {
|
|
5432
|
-
await configLoader.close();
|
|
5433
|
-
}
|
|
5434
|
-
},
|
|
5435
|
-
/* @__PURE__ */ (() => {
|
|
5436
|
-
let logged = false;
|
|
5437
|
-
function logExperimentalNotice() {
|
|
5438
|
-
if (logged) return;
|
|
5439
|
-
logged = true;
|
|
5440
|
-
logger.info(
|
|
5441
|
-
import_picocolors5.default.yellow(
|
|
5442
|
-
`${viteCommand === "serve" ? " " : ""}\u{1F9EA} Using React Router's RSC Framework Mode (experimental)`
|
|
5443
|
-
)
|
|
5444
|
-
);
|
|
5445
|
-
}
|
|
5446
|
-
return {
|
|
5447
|
-
name: "react-router/rsc/log-experimental-notice",
|
|
5448
|
-
sharedDuringBuild: true,
|
|
5449
|
-
buildStart: logExperimentalNotice,
|
|
5450
|
-
configureServer: logExperimentalNotice
|
|
5451
|
-
};
|
|
5452
|
-
})(),
|
|
5453
|
-
{
|
|
5454
|
-
name: "react-router/rsc/typegen",
|
|
5455
|
-
async config(viteUserConfig, { command, mode }) {
|
|
5456
|
-
if (command === "serve") {
|
|
5457
|
-
const vite2 = await import("vite");
|
|
5458
|
-
typegenWatcherPromise = watch(
|
|
5459
|
-
getRootDirectory(viteUserConfig),
|
|
5460
|
-
{
|
|
5461
|
-
mode,
|
|
5462
|
-
rsc: true,
|
|
5463
|
-
// ignore `info` logs from typegen since they are
|
|
5464
|
-
// redundant when Vite plugin logs are active
|
|
5465
|
-
logger: vite2.createLogger("warn", {
|
|
5466
|
-
prefix: "[react-router]"
|
|
5467
|
-
})
|
|
5468
|
-
}
|
|
5469
|
-
);
|
|
5470
|
-
}
|
|
5471
|
-
},
|
|
5472
|
-
async buildEnd() {
|
|
5473
|
-
(await typegenWatcherPromise)?.close();
|
|
5474
|
-
}
|
|
5475
|
-
},
|
|
5476
|
-
{
|
|
5477
|
-
name: "react-router/rsc/virtual-rsc-entry",
|
|
5478
|
-
resolveId(id) {
|
|
5479
|
-
if (id === virtual2.rscEntry.id) return defaultEntries2.rsc;
|
|
5480
|
-
}
|
|
5481
|
-
},
|
|
5482
|
-
{
|
|
5483
|
-
name: "react-router/rsc/virtual-route-config",
|
|
5484
|
-
resolveId(id) {
|
|
5485
|
-
if (id === virtual2.routeConfig.id) {
|
|
5486
|
-
return virtual2.routeConfig.resolvedId;
|
|
5487
|
-
}
|
|
5488
|
-
},
|
|
5489
|
-
load(id) {
|
|
5490
|
-
if (id === virtual2.routeConfig.resolvedId) {
|
|
5491
|
-
const result = createVirtualRouteConfig({
|
|
5492
|
-
appDirectory: config.appDirectory,
|
|
5493
|
-
routeConfig: config.unstable_routeConfig
|
|
5494
|
-
});
|
|
5495
|
-
routeIdByFile = result.routeIdByFile;
|
|
5496
|
-
return result.code;
|
|
5497
|
-
}
|
|
5498
|
-
}
|
|
5499
|
-
},
|
|
5500
|
-
{
|
|
5501
|
-
name: "react-router/rsc/virtual-route-modules",
|
|
5502
|
-
transform(code, id) {
|
|
5503
|
-
if (!routeIdByFile) return;
|
|
5504
|
-
return transformVirtualRouteModules({
|
|
5505
|
-
code,
|
|
5506
|
-
id,
|
|
5507
|
-
viteCommand,
|
|
5508
|
-
routeIdByFile,
|
|
5509
|
-
rootRouteFile,
|
|
5510
|
-
viteEnvironment: this.environment
|
|
5511
|
-
});
|
|
5512
|
-
}
|
|
5513
|
-
},
|
|
5514
|
-
{
|
|
5515
|
-
name: "react-router/rsc/virtual-basename",
|
|
5516
|
-
resolveId(id) {
|
|
5517
|
-
if (id === virtual2.basename.id) {
|
|
5518
|
-
return virtual2.basename.resolvedId;
|
|
5519
|
-
}
|
|
5520
|
-
},
|
|
5521
|
-
load(id) {
|
|
5522
|
-
if (id === virtual2.basename.resolvedId) {
|
|
5523
|
-
return `export default ${JSON.stringify(config.basename)};`;
|
|
5524
|
-
}
|
|
5525
|
-
}
|
|
5526
|
-
},
|
|
5527
|
-
{
|
|
5528
|
-
name: "react-router/rsc/hmr/inject-runtime",
|
|
5529
|
-
enforce: "pre",
|
|
5530
|
-
resolveId(id) {
|
|
5531
|
-
if (id === virtual2.injectHmrRuntime.id) {
|
|
5532
|
-
return virtual2.injectHmrRuntime.resolvedId;
|
|
5533
|
-
}
|
|
5534
|
-
},
|
|
5535
|
-
async load(id) {
|
|
5536
|
-
if (id !== virtual2.injectHmrRuntime.resolvedId) return;
|
|
5537
|
-
return viteCommand === "serve" ? [
|
|
5538
|
-
`import RefreshRuntime from "${virtual2.hmrRuntime.id}"`,
|
|
5539
|
-
"RefreshRuntime.injectIntoGlobalHook(window)",
|
|
5540
|
-
"window.$RefreshReg$ = () => {}",
|
|
5541
|
-
"window.$RefreshSig$ = () => (type) => type",
|
|
5542
|
-
"window.__vite_plugin_react_preamble_installed__ = true"
|
|
5543
|
-
].join("\n") : "";
|
|
5544
|
-
}
|
|
5545
|
-
},
|
|
5546
|
-
{
|
|
5547
|
-
name: "react-router/rsc/hmr/runtime",
|
|
5548
|
-
enforce: "pre",
|
|
5549
|
-
resolveId(id) {
|
|
5550
|
-
if (id === virtual2.hmrRuntime.id) return virtual2.hmrRuntime.resolvedId;
|
|
5551
|
-
},
|
|
5552
|
-
async load(id) {
|
|
5553
|
-
if (id !== virtual2.hmrRuntime.resolvedId) return;
|
|
5554
|
-
const reactRefreshDir = import_pathe6.default.dirname(
|
|
5555
|
-
require.resolve("react-refresh/package.json")
|
|
5556
|
-
);
|
|
5557
|
-
const reactRefreshRuntimePath = import_pathe6.default.join(
|
|
5558
|
-
reactRefreshDir,
|
|
5559
|
-
"cjs/react-refresh-runtime.development.js"
|
|
5560
|
-
);
|
|
5561
|
-
return [
|
|
5562
|
-
"const exports = {}",
|
|
5563
|
-
await (0, import_promises3.readFile)(reactRefreshRuntimePath, "utf8"),
|
|
5564
|
-
await (0, import_promises3.readFile)(
|
|
5565
|
-
require.resolve("./static/rsc-refresh-utils.mjs"),
|
|
5566
|
-
"utf8"
|
|
5567
|
-
),
|
|
5568
|
-
"export default exports"
|
|
5569
|
-
].join("\n");
|
|
5570
|
-
}
|
|
5571
|
-
},
|
|
5572
|
-
{
|
|
5573
|
-
name: "react-router/rsc/hmr/react-refresh",
|
|
5574
|
-
async transform(code, id, options) {
|
|
5575
|
-
if (viteCommand !== "serve") return;
|
|
5576
|
-
if (id.includes("/node_modules/")) return;
|
|
5577
|
-
const filepath = id.split("?")[0];
|
|
5578
|
-
const extensionsRE = /\.(jsx?|tsx?|mdx?)$/;
|
|
5579
|
-
if (!extensionsRE.test(filepath)) return;
|
|
5580
|
-
const devRuntime = "react/jsx-dev-runtime";
|
|
5581
|
-
const ssr = options?.ssr === true;
|
|
5582
|
-
const isJSX = filepath.endsWith("x");
|
|
5583
|
-
const useFastRefresh = !ssr && (isJSX || code.includes(devRuntime));
|
|
5584
|
-
if (!useFastRefresh) return;
|
|
5585
|
-
if (isVirtualClientRouteModuleId(id)) {
|
|
5586
|
-
const routeId = routeIdByFile?.get(filepath);
|
|
5587
|
-
return { code: addRefreshWrapper2({ routeId, code, id }) };
|
|
5588
|
-
}
|
|
5589
|
-
const result = await babel2.transformAsync(code, {
|
|
5590
|
-
babelrc: false,
|
|
5591
|
-
configFile: false,
|
|
5592
|
-
filename: id,
|
|
5593
|
-
sourceFileName: filepath,
|
|
5594
|
-
parserOpts: {
|
|
5595
|
-
sourceType: "module",
|
|
5596
|
-
allowAwaitOutsideFunction: true
|
|
5597
|
-
},
|
|
5598
|
-
plugins: [[require("react-refresh/babel"), { skipEnvCheck: true }]],
|
|
5599
|
-
sourceMaps: true
|
|
5600
|
-
});
|
|
5601
|
-
if (result === null) return;
|
|
5602
|
-
code = result.code;
|
|
5603
|
-
const refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
5604
|
-
if (refreshContentRE.test(code)) {
|
|
5605
|
-
code = addRefreshWrapper2({ code, id });
|
|
5606
|
-
}
|
|
5607
|
-
return { code, map: result.map };
|
|
5608
|
-
}
|
|
5609
|
-
},
|
|
5610
|
-
{
|
|
5611
|
-
name: "react-router/rsc/hmr/updates",
|
|
5612
|
-
async hotUpdate({ server, file, modules }) {
|
|
5613
|
-
if (this.environment.name !== "rsc") return;
|
|
5614
|
-
const clientModules = server.environments.client.moduleGraph.getModulesByFile(file);
|
|
5615
|
-
const vite2 = await import("vite");
|
|
5616
|
-
const isServerOnlyChange = !clientModules || clientModules.size === 0 || // Handle CSS injected from server-first routes (with ?direct query
|
|
5617
|
-
// string) since the client graph has a reference to the CSS
|
|
5618
|
-
vite2.isCSSRequest(file) && Array.from(clientModules).some(
|
|
5619
|
-
(mod) => mod.id?.includes("?direct")
|
|
5620
|
-
);
|
|
5621
|
-
for (const mod of getModulesWithImporters(modules)) {
|
|
5622
|
-
if (!mod.file) continue;
|
|
5623
|
-
const normalizedPath = import_pathe6.default.normalize(mod.file);
|
|
5624
|
-
const routeId = routeIdByFile?.get(normalizedPath);
|
|
5625
|
-
if (routeId !== void 0) {
|
|
5626
|
-
const routeSource = await (0, import_promises3.readFile)(normalizedPath, "utf8");
|
|
5627
|
-
const virtualRouteModuleCode = (await server.environments.rsc.pluginContainer.transform(
|
|
5628
|
-
routeSource,
|
|
5629
|
-
`${normalizedPath}?route-module`
|
|
5630
|
-
)).code;
|
|
5631
|
-
const { staticExports } = parseRouteExports(virtualRouteModuleCode);
|
|
5632
|
-
const hasAction = staticExports.includes("action");
|
|
5633
|
-
const hasComponent = staticExports.includes("default");
|
|
5634
|
-
const hasErrorBoundary = staticExports.includes("ErrorBoundary");
|
|
5635
|
-
const hasLoader = staticExports.includes("loader");
|
|
5636
|
-
server.hot.send({
|
|
5637
|
-
type: "custom",
|
|
5638
|
-
event: "react-router:hmr",
|
|
5639
|
-
data: {
|
|
5640
|
-
routeId,
|
|
5641
|
-
isServerOnlyChange,
|
|
5642
|
-
hasAction,
|
|
5643
|
-
hasComponent,
|
|
5644
|
-
hasErrorBoundary,
|
|
5645
|
-
hasLoader
|
|
5646
|
-
}
|
|
5647
|
-
});
|
|
5648
|
-
}
|
|
5649
|
-
}
|
|
5650
|
-
return modules;
|
|
5651
|
-
}
|
|
5652
|
-
},
|
|
5653
|
-
{
|
|
5654
|
-
name: "react-router/rsc/virtual-react-router-serve-config",
|
|
5655
|
-
resolveId(id) {
|
|
5656
|
-
if (id === virtual2.reactRouterServeConfig.id) {
|
|
5657
|
-
return virtual2.reactRouterServeConfig.resolvedId;
|
|
5658
|
-
}
|
|
5659
|
-
},
|
|
5660
|
-
load(id) {
|
|
5661
|
-
if (id === virtual2.reactRouterServeConfig.resolvedId) {
|
|
5662
|
-
const rscOutDir = resolvedViteConfig.environments.rsc?.build?.outDir;
|
|
5663
|
-
invariant(rscOutDir, "RSC build directory config not found");
|
|
5664
|
-
const clientOutDir = resolvedViteConfig.environments.client?.build?.outDir;
|
|
5665
|
-
invariant(clientOutDir, "Client build directory config not found");
|
|
5666
|
-
const assetsBuildDirectory = Path5.relative(rscOutDir, clientOutDir);
|
|
5667
|
-
const publicPath = resolvedViteConfig.base;
|
|
5668
|
-
return `export default ${JSON.stringify({
|
|
5669
|
-
assetsBuildDirectory,
|
|
5670
|
-
publicPath
|
|
5671
|
-
})};`;
|
|
5672
|
-
}
|
|
5673
|
-
}
|
|
5674
|
-
},
|
|
5675
|
-
validatePluginOrder(),
|
|
5676
|
-
warnOnClientSourceMaps()
|
|
5677
|
-
];
|
|
5678
|
-
}
|
|
5679
|
-
var virtual2 = {
|
|
5680
|
-
routeConfig: create("unstable_rsc/routes"),
|
|
5681
|
-
injectHmrRuntime: create("unstable_rsc/inject-hmr-runtime"),
|
|
5682
|
-
hmrRuntime: create("unstable_rsc/runtime"),
|
|
5683
|
-
basename: create("unstable_rsc/basename"),
|
|
5684
|
-
rscEntry: create("unstable_rsc/rsc-entry"),
|
|
5685
|
-
reactRouterServeConfig: create("unstable_rsc/react-router-serve-config")
|
|
5686
|
-
};
|
|
5687
|
-
function invalidateVirtualModules2(viteDevServer) {
|
|
5688
|
-
for (const vmod of Object.values(virtual2)) {
|
|
5689
|
-
for (const env of Object.values(viteDevServer.environments)) {
|
|
5690
|
-
const mod = env.moduleGraph.getModuleById(vmod.resolvedId);
|
|
5691
|
-
if (mod) {
|
|
5692
|
-
env.moduleGraph.invalidateModule(mod);
|
|
5693
|
-
}
|
|
5694
|
-
}
|
|
5695
|
-
}
|
|
5696
|
-
}
|
|
5697
|
-
function getRootDirectory(viteUserConfig) {
|
|
5698
|
-
return viteUserConfig.root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();
|
|
5699
|
-
}
|
|
5700
|
-
function getDevPackageRoot() {
|
|
5701
|
-
const currentDir = (0, import_pathe6.dirname)(__dirname);
|
|
5702
|
-
let dir = currentDir;
|
|
5703
|
-
while (dir !== (0, import_pathe6.dirname)(dir)) {
|
|
5704
|
-
try {
|
|
5705
|
-
const packageJsonPath = (0, import_pathe6.join)(dir, "package.json");
|
|
5706
|
-
(0, import_fs.readFileSync)(packageJsonPath, "utf-8");
|
|
5707
|
-
return dir;
|
|
5708
|
-
} catch {
|
|
5709
|
-
dir = (0, import_pathe6.dirname)(dir);
|
|
5710
|
-
}
|
|
5711
|
-
}
|
|
5712
|
-
throw new Error("Could not find package.json");
|
|
5713
|
-
}
|
|
5714
|
-
function getDefaultEntries() {
|
|
5715
|
-
const defaultEntriesDir2 = (0, import_pathe6.join)(
|
|
5716
|
-
getDevPackageRoot(),
|
|
5717
|
-
"dist",
|
|
5718
|
-
"config",
|
|
5719
|
-
"default-rsc-entries"
|
|
5720
|
-
);
|
|
5721
|
-
return {
|
|
5722
|
-
rsc: (0, import_pathe6.join)(defaultEntriesDir2, "entry.rsc.tsx"),
|
|
5723
|
-
ssr: (0, import_pathe6.join)(defaultEntriesDir2, "entry.ssr.tsx"),
|
|
5724
|
-
client: (0, import_pathe6.join)(defaultEntriesDir2, "entry.client.tsx")
|
|
5725
|
-
};
|
|
5726
|
-
}
|
|
5727
|
-
function getModulesWithImporters(modules) {
|
|
5728
|
-
const visited = /* @__PURE__ */ new Set();
|
|
5729
|
-
const result = /* @__PURE__ */ new Set();
|
|
5730
|
-
function walk(module2) {
|
|
5731
|
-
if (visited.has(module2)) return;
|
|
5732
|
-
visited.add(module2);
|
|
5733
|
-
result.add(module2);
|
|
5734
|
-
for (const importer of module2.importers) {
|
|
5735
|
-
walk(importer);
|
|
5736
|
-
}
|
|
5737
|
-
}
|
|
5738
|
-
for (const module2 of modules) {
|
|
5739
|
-
walk(module2);
|
|
5740
|
-
}
|
|
5741
|
-
return result;
|
|
5742
|
-
}
|
|
5743
|
-
function addRefreshWrapper2({
|
|
5744
|
-
routeId,
|
|
5745
|
-
code,
|
|
5746
|
-
id
|
|
5747
|
-
}) {
|
|
5748
|
-
const acceptExports = routeId !== void 0 ? CLIENT_NON_COMPONENT_EXPORTS2 : [];
|
|
5749
|
-
return REACT_REFRESH_HEADER2.replaceAll("__SOURCE__", JSON.stringify(id)) + code + REACT_REFRESH_FOOTER2.replaceAll("__SOURCE__", JSON.stringify(id)).replaceAll("__ACCEPT_EXPORTS__", JSON.stringify(acceptExports)).replaceAll("__ROUTE_ID__", JSON.stringify(routeId));
|
|
5750
|
-
}
|
|
5751
|
-
var REACT_REFRESH_HEADER2 = `
|
|
5752
|
-
import RefreshRuntime from "${virtual2.hmrRuntime.id}";
|
|
5753
|
-
|
|
5754
|
-
const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
|
|
5755
|
-
let prevRefreshReg;
|
|
5756
|
-
let prevRefreshSig;
|
|
5757
|
-
|
|
5758
|
-
if (import.meta.hot && !inWebWorker) {
|
|
5759
|
-
if (!window.__vite_plugin_react_preamble_installed__) {
|
|
5760
|
-
throw new Error(
|
|
5761
|
-
"React Router Vite plugin can't detect preamble. Something is wrong."
|
|
5762
|
-
);
|
|
5763
|
-
}
|
|
5764
|
-
|
|
5765
|
-
prevRefreshReg = window.$RefreshReg$;
|
|
5766
|
-
prevRefreshSig = window.$RefreshSig$;
|
|
5767
|
-
window.$RefreshReg$ = (type, id) => {
|
|
5768
|
-
RefreshRuntime.register(type, __SOURCE__ + " " + id)
|
|
5769
|
-
};
|
|
5770
|
-
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
5771
|
-
}`.replaceAll("\n", "");
|
|
5772
|
-
var REACT_REFRESH_FOOTER2 = `
|
|
5773
|
-
if (import.meta.hot && !inWebWorker) {
|
|
5774
|
-
window.$RefreshReg$ = prevRefreshReg;
|
|
5775
|
-
window.$RefreshSig$ = prevRefreshSig;
|
|
5776
|
-
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
|
5777
|
-
RefreshRuntime.registerExportsForReactRefresh(__SOURCE__, currentExports);
|
|
5778
|
-
import.meta.hot.accept((nextExports) => {
|
|
5779
|
-
if (!nextExports) return;
|
|
5780
|
-
__ROUTE_ID__ && window.__reactRouterRouteModuleUpdates.set(__ROUTE_ID__, nextExports);
|
|
5781
|
-
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(currentExports, nextExports, __ACCEPT_EXPORTS__);
|
|
5782
|
-
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
|
5783
|
-
});
|
|
5784
|
-
});
|
|
5785
|
-
}`;
|
|
5786
4881
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5787
4882
|
0 && (module.exports = {
|
|
5788
|
-
reactRouter
|
|
5789
|
-
unstable_reactRouterRSC
|
|
4883
|
+
reactRouter
|
|
5790
4884
|
});
|