@react-router/dev 0.0.0-experimental-4cf5bd08c → 0.0.0-experimental-61f2749d7
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/CHANGELOG.md +8 -0
- package/dist/cli/index.js +1 -1
- package/dist/config.js +1 -1
- package/dist/internal.d.ts +9 -0
- package/dist/internal.js +2307 -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 -965
- 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-61f2749d7
|
|
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
|
|
|
@@ -247,7 +246,7 @@ function validateRouteConfig({
|
|
|
247
246
|
`Route config in "${routeConfigFile}" is invalid.`,
|
|
248
247
|
root ? `${root}` : [],
|
|
249
248
|
nested ? Object.entries(nested).map(
|
|
250
|
-
([
|
|
249
|
+
([path7, message]) => `Path: routes.${path7}
|
|
251
250
|
${message}`
|
|
252
251
|
) : []
|
|
253
252
|
].flat().join("\n\n")
|
|
@@ -618,12 +617,12 @@ async function createConfigLoader({
|
|
|
618
617
|
if (!fsWatcher) {
|
|
619
618
|
fsWatcher = import_chokidar.default.watch([root, appDirectory], {
|
|
620
619
|
ignoreInitial: true,
|
|
621
|
-
ignored: (
|
|
622
|
-
let
|
|
623
|
-
return !
|
|
620
|
+
ignored: (path7) => {
|
|
621
|
+
let dirname4 = import_pathe3.default.dirname(path7);
|
|
622
|
+
return !dirname4.startsWith(appDirectory) && // Ensure we're only watching files outside of the app directory
|
|
624
623
|
// that are at the root level, not nested in subdirectories
|
|
625
|
-
|
|
626
|
-
|
|
624
|
+
path7 !== root && // Watch the root directory itself
|
|
625
|
+
dirname4 !== root;
|
|
627
626
|
}
|
|
628
627
|
});
|
|
629
628
|
fsWatcher.on("all", async (...args) => {
|
|
@@ -883,7 +882,7 @@ function fullpath(lineage2) {
|
|
|
883
882
|
if (lineage2.length === 1 && route?.id === "root") return "/";
|
|
884
883
|
const isLayout = route && route.index !== true && route.path === void 0;
|
|
885
884
|
if (isLayout) return void 0;
|
|
886
|
-
return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((
|
|
885
|
+
return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path7) => path7 !== void 0 && path7 !== "").join("/");
|
|
887
886
|
}
|
|
888
887
|
|
|
889
888
|
// typegen/generate.ts
|
|
@@ -1039,8 +1038,8 @@ function routeFilesType({
|
|
|
1039
1038
|
);
|
|
1040
1039
|
}
|
|
1041
1040
|
function isInAppDirectory(ctx, routeFile) {
|
|
1042
|
-
const
|
|
1043
|
-
return
|
|
1041
|
+
const path7 = Path3.resolve(ctx.config.appDirectory, routeFile);
|
|
1042
|
+
return path7.startsWith(ctx.config.appDirectory);
|
|
1044
1043
|
}
|
|
1045
1044
|
function getRouteAnnotations({
|
|
1046
1045
|
ctx,
|
|
@@ -1152,21 +1151,21 @@ function getRouteAnnotations({
|
|
|
1152
1151
|
return { filename: filename2, content };
|
|
1153
1152
|
}
|
|
1154
1153
|
function relativeImportSource(from, to) {
|
|
1155
|
-
let
|
|
1156
|
-
let extension = Path3.extname(
|
|
1157
|
-
|
|
1158
|
-
if (!
|
|
1154
|
+
let path7 = Path3.relative(Path3.dirname(from), to);
|
|
1155
|
+
let extension = Path3.extname(path7);
|
|
1156
|
+
path7 = Path3.join(Path3.dirname(path7), Pathe.filename(path7));
|
|
1157
|
+
if (!path7.startsWith("../")) path7 = "./" + path7;
|
|
1159
1158
|
if (!extension || /\.(js|ts)x?$/.test(extension)) {
|
|
1160
1159
|
extension = ".js";
|
|
1161
1160
|
}
|
|
1162
|
-
return
|
|
1161
|
+
return path7 + extension;
|
|
1163
1162
|
}
|
|
1164
1163
|
function rootDirsPath(ctx, typesPath) {
|
|
1165
1164
|
const rel = Path3.relative(typesDirectory(ctx), typesPath);
|
|
1166
1165
|
return Path3.join(ctx.rootDirectory, rel);
|
|
1167
1166
|
}
|
|
1168
|
-
function paramsType(
|
|
1169
|
-
const params = parse2(
|
|
1167
|
+
function paramsType(path7) {
|
|
1168
|
+
const params = parse2(path7);
|
|
1170
1169
|
return t2.tsTypeLiteral(
|
|
1171
1170
|
Object.entries(params).map(([param, isRequired]) => {
|
|
1172
1171
|
const property = t2.tsPropertySignature(
|
|
@@ -1502,11 +1501,11 @@ var getCssStringFromViteDevModuleCode = (code) => {
|
|
|
1502
1501
|
let cssContent = void 0;
|
|
1503
1502
|
const ast = import_parser.parse(code, { sourceType: "module" });
|
|
1504
1503
|
traverse(ast, {
|
|
1505
|
-
VariableDeclaration(
|
|
1506
|
-
const declaration =
|
|
1504
|
+
VariableDeclaration(path7) {
|
|
1505
|
+
const declaration = path7.node.declarations[0];
|
|
1507
1506
|
if (declaration?.id?.type === "Identifier" && declaration.id.name === "__vite__css" && declaration.init?.type === "StringLiteral") {
|
|
1508
1507
|
cssContent = declaration.init.value;
|
|
1509
|
-
|
|
1508
|
+
path7.stop();
|
|
1510
1509
|
}
|
|
1511
1510
|
}
|
|
1512
1511
|
});
|
|
@@ -1545,10 +1544,10 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1545
1544
|
let markedForRemoval = /* @__PURE__ */ new Set();
|
|
1546
1545
|
let removedExportLocalNames = /* @__PURE__ */ new Set();
|
|
1547
1546
|
traverse(ast, {
|
|
1548
|
-
ExportDeclaration(
|
|
1549
|
-
if (
|
|
1550
|
-
if (
|
|
1551
|
-
|
|
1547
|
+
ExportDeclaration(path7) {
|
|
1548
|
+
if (path7.node.type === "ExportNamedDeclaration") {
|
|
1549
|
+
if (path7.node.specifiers.length) {
|
|
1550
|
+
path7.node.specifiers = path7.node.specifiers.filter((specifier) => {
|
|
1552
1551
|
if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier") {
|
|
1553
1552
|
if (exportsToRemove.includes(specifier.exported.name)) {
|
|
1554
1553
|
exportsFiltered = true;
|
|
@@ -1560,12 +1559,12 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1560
1559
|
}
|
|
1561
1560
|
return true;
|
|
1562
1561
|
});
|
|
1563
|
-
if (
|
|
1564
|
-
markedForRemoval.add(
|
|
1562
|
+
if (path7.node.specifiers.length === 0) {
|
|
1563
|
+
markedForRemoval.add(path7);
|
|
1565
1564
|
}
|
|
1566
1565
|
}
|
|
1567
|
-
if (
|
|
1568
|
-
let declaration =
|
|
1566
|
+
if (path7.node.declaration?.type === "VariableDeclaration") {
|
|
1567
|
+
let declaration = path7.node.declaration;
|
|
1569
1568
|
declaration.declarations = declaration.declarations.filter(
|
|
1570
1569
|
(declaration2) => {
|
|
1571
1570
|
if (declaration2.id.type === "Identifier" && exportsToRemove.includes(declaration2.id.name)) {
|
|
@@ -1579,30 +1578,30 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1579
1578
|
}
|
|
1580
1579
|
);
|
|
1581
1580
|
if (declaration.declarations.length === 0) {
|
|
1582
|
-
markedForRemoval.add(
|
|
1581
|
+
markedForRemoval.add(path7);
|
|
1583
1582
|
}
|
|
1584
1583
|
}
|
|
1585
|
-
if (
|
|
1586
|
-
let id =
|
|
1584
|
+
if (path7.node.declaration?.type === "FunctionDeclaration") {
|
|
1585
|
+
let id = path7.node.declaration.id;
|
|
1587
1586
|
if (id && exportsToRemove.includes(id.name)) {
|
|
1588
|
-
markedForRemoval.add(
|
|
1587
|
+
markedForRemoval.add(path7);
|
|
1589
1588
|
}
|
|
1590
1589
|
}
|
|
1591
|
-
if (
|
|
1592
|
-
let id =
|
|
1590
|
+
if (path7.node.declaration?.type === "ClassDeclaration") {
|
|
1591
|
+
let id = path7.node.declaration.id;
|
|
1593
1592
|
if (id && exportsToRemove.includes(id.name)) {
|
|
1594
|
-
markedForRemoval.add(
|
|
1593
|
+
markedForRemoval.add(path7);
|
|
1595
1594
|
}
|
|
1596
1595
|
}
|
|
1597
1596
|
}
|
|
1598
|
-
if (
|
|
1597
|
+
if (path7.node.type === "ExportDefaultDeclaration") {
|
|
1599
1598
|
if (exportsToRemove.includes("default")) {
|
|
1600
|
-
markedForRemoval.add(
|
|
1601
|
-
if (
|
|
1602
|
-
if (
|
|
1603
|
-
removedExportLocalNames.add(
|
|
1604
|
-
} else if ((
|
|
1605
|
-
removedExportLocalNames.add(
|
|
1599
|
+
markedForRemoval.add(path7);
|
|
1600
|
+
if (path7.node.declaration) {
|
|
1601
|
+
if (path7.node.declaration.type === "Identifier") {
|
|
1602
|
+
removedExportLocalNames.add(path7.node.declaration.name);
|
|
1603
|
+
} else if ((path7.node.declaration.type === "FunctionDeclaration" || path7.node.declaration.type === "ClassDeclaration") && path7.node.declaration.id) {
|
|
1604
|
+
removedExportLocalNames.add(path7.node.declaration.id.name);
|
|
1606
1605
|
}
|
|
1607
1606
|
}
|
|
1608
1607
|
}
|
|
@@ -1610,21 +1609,21 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1610
1609
|
}
|
|
1611
1610
|
});
|
|
1612
1611
|
traverse(ast, {
|
|
1613
|
-
ExpressionStatement(
|
|
1614
|
-
if (!
|
|
1612
|
+
ExpressionStatement(path7) {
|
|
1613
|
+
if (!path7.parentPath.isProgram()) {
|
|
1615
1614
|
return;
|
|
1616
1615
|
}
|
|
1617
|
-
if (
|
|
1618
|
-
const left =
|
|
1616
|
+
if (path7.node.expression.type === "AssignmentExpression") {
|
|
1617
|
+
const left = path7.node.expression.left;
|
|
1619
1618
|
if (left.type === "MemberExpression" && left.object.type === "Identifier" && (exportsToRemove.includes(left.object.name) || removedExportLocalNames.has(left.object.name))) {
|
|
1620
|
-
markedForRemoval.add(
|
|
1619
|
+
markedForRemoval.add(path7);
|
|
1621
1620
|
}
|
|
1622
1621
|
}
|
|
1623
1622
|
}
|
|
1624
1623
|
});
|
|
1625
1624
|
if (markedForRemoval.size > 0 || exportsFiltered) {
|
|
1626
|
-
for (let
|
|
1627
|
-
|
|
1625
|
+
for (let path7 of markedForRemoval) {
|
|
1626
|
+
path7.remove();
|
|
1628
1627
|
}
|
|
1629
1628
|
(0, import_babel_dead_code_elimination.deadCodeElimination)(ast, previouslyReferencedIdentifiers);
|
|
1630
1629
|
}
|
|
@@ -1707,28 +1706,28 @@ function codeToAst(code, cache, cacheKey) {
|
|
|
1707
1706
|
)
|
|
1708
1707
|
);
|
|
1709
1708
|
}
|
|
1710
|
-
function assertNodePath(
|
|
1709
|
+
function assertNodePath(path7) {
|
|
1711
1710
|
invariant(
|
|
1712
|
-
|
|
1713
|
-
`Expected a Path, but got ${Array.isArray(
|
|
1711
|
+
path7 && !Array.isArray(path7),
|
|
1712
|
+
`Expected a Path, but got ${Array.isArray(path7) ? "an array" : path7}`
|
|
1714
1713
|
);
|
|
1715
1714
|
}
|
|
1716
|
-
function assertNodePathIsStatement(
|
|
1715
|
+
function assertNodePathIsStatement(path7) {
|
|
1717
1716
|
invariant(
|
|
1718
|
-
|
|
1719
|
-
`Expected a Statement path, but got ${Array.isArray(
|
|
1717
|
+
path7 && !Array.isArray(path7) && t.isStatement(path7.node),
|
|
1718
|
+
`Expected a Statement path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
|
|
1720
1719
|
);
|
|
1721
1720
|
}
|
|
1722
|
-
function assertNodePathIsVariableDeclarator(
|
|
1721
|
+
function assertNodePathIsVariableDeclarator(path7) {
|
|
1723
1722
|
invariant(
|
|
1724
|
-
|
|
1725
|
-
`Expected an Identifier path, but got ${Array.isArray(
|
|
1723
|
+
path7 && !Array.isArray(path7) && t.isVariableDeclarator(path7.node),
|
|
1724
|
+
`Expected an Identifier path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
|
|
1726
1725
|
);
|
|
1727
1726
|
}
|
|
1728
|
-
function assertNodePathIsPattern(
|
|
1727
|
+
function assertNodePathIsPattern(path7) {
|
|
1729
1728
|
invariant(
|
|
1730
|
-
|
|
1731
|
-
`Expected a Pattern path, but got ${Array.isArray(
|
|
1729
|
+
path7 && !Array.isArray(path7) && t.isPattern(path7.node),
|
|
1730
|
+
`Expected a Pattern path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
|
|
1732
1731
|
);
|
|
1733
1732
|
}
|
|
1734
1733
|
function getExportDependencies(code, cache, cacheKey) {
|
|
@@ -1764,8 +1763,8 @@ function getExportDependencies(code, cache, cacheKey) {
|
|
|
1764
1763
|
}
|
|
1765
1764
|
let isWithinExportDestructuring = Boolean(
|
|
1766
1765
|
identifier.findParent(
|
|
1767
|
-
(
|
|
1768
|
-
|
|
1766
|
+
(path7) => Boolean(
|
|
1767
|
+
path7.isPattern() && path7.parentPath?.isVariableDeclarator() && path7.parentPath.parentPath?.parentPath?.isExportNamedDeclaration()
|
|
1769
1768
|
)
|
|
1770
1769
|
)
|
|
1771
1770
|
);
|
|
@@ -1843,7 +1842,7 @@ function getExportDependencies(code, cache, cacheKey) {
|
|
|
1843
1842
|
for (let specifier of node.specifiers) {
|
|
1844
1843
|
if (t.isIdentifier(specifier.exported)) {
|
|
1845
1844
|
let name = specifier.exported.name;
|
|
1846
|
-
let specifierPath = exportPath.get("specifiers").find((
|
|
1845
|
+
let specifierPath = exportPath.get("specifiers").find((path7) => path7.node === specifier);
|
|
1847
1846
|
invariant(
|
|
1848
1847
|
specifierPath,
|
|
1849
1848
|
`Expected to find specifier path for ${name}`
|
|
@@ -1860,22 +1859,22 @@ function getExportDependencies(code, cache, cacheKey) {
|
|
|
1860
1859
|
}
|
|
1861
1860
|
);
|
|
1862
1861
|
}
|
|
1863
|
-
function getDependentIdentifiersForPath(
|
|
1862
|
+
function getDependentIdentifiersForPath(path7, state) {
|
|
1864
1863
|
let { visited, identifiers } = state ?? {
|
|
1865
1864
|
visited: /* @__PURE__ */ new Set(),
|
|
1866
1865
|
identifiers: /* @__PURE__ */ new Set()
|
|
1867
1866
|
};
|
|
1868
|
-
if (visited.has(
|
|
1867
|
+
if (visited.has(path7)) {
|
|
1869
1868
|
return identifiers;
|
|
1870
1869
|
}
|
|
1871
|
-
visited.add(
|
|
1872
|
-
|
|
1873
|
-
Identifier(
|
|
1874
|
-
if (identifiers.has(
|
|
1870
|
+
visited.add(path7);
|
|
1871
|
+
path7.traverse({
|
|
1872
|
+
Identifier(path8) {
|
|
1873
|
+
if (identifiers.has(path8)) {
|
|
1875
1874
|
return;
|
|
1876
1875
|
}
|
|
1877
|
-
identifiers.add(
|
|
1878
|
-
let binding =
|
|
1876
|
+
identifiers.add(path8);
|
|
1877
|
+
let binding = path8.scope.getBinding(path8.node.name);
|
|
1879
1878
|
if (!binding) {
|
|
1880
1879
|
return;
|
|
1881
1880
|
}
|
|
@@ -1897,7 +1896,7 @@ function getDependentIdentifiersForPath(path9, state) {
|
|
|
1897
1896
|
}
|
|
1898
1897
|
}
|
|
1899
1898
|
});
|
|
1900
|
-
let topLevelStatement = getTopLevelStatementPathForPath(
|
|
1899
|
+
let topLevelStatement = getTopLevelStatementPathForPath(path7);
|
|
1901
1900
|
let withinImportStatement = topLevelStatement.isImportDeclaration();
|
|
1902
1901
|
let withinExportStatement = topLevelStatement.isExportDeclaration();
|
|
1903
1902
|
if (!withinImportStatement && !withinExportStatement) {
|
|
@@ -1906,9 +1905,9 @@ function getDependentIdentifiersForPath(path9, state) {
|
|
|
1906
1905
|
identifiers
|
|
1907
1906
|
});
|
|
1908
1907
|
}
|
|
1909
|
-
if (withinExportStatement &&
|
|
1910
|
-
t.isPattern(
|
|
1911
|
-
let variableDeclarator =
|
|
1908
|
+
if (withinExportStatement && path7.isIdentifier() && (t.isPattern(path7.parentPath.node) || // [foo]
|
|
1909
|
+
t.isPattern(path7.parentPath.parentPath?.node))) {
|
|
1910
|
+
let variableDeclarator = path7.findParent((p) => p.isVariableDeclarator());
|
|
1912
1911
|
assertNodePath(variableDeclarator);
|
|
1913
1912
|
getDependentIdentifiersForPath(variableDeclarator, {
|
|
1914
1913
|
visited,
|
|
@@ -1917,16 +1916,16 @@ function getDependentIdentifiersForPath(path9, state) {
|
|
|
1917
1916
|
}
|
|
1918
1917
|
return identifiers;
|
|
1919
1918
|
}
|
|
1920
|
-
function getTopLevelStatementPathForPath(
|
|
1921
|
-
let ancestry =
|
|
1919
|
+
function getTopLevelStatementPathForPath(path7) {
|
|
1920
|
+
let ancestry = path7.getAncestry();
|
|
1922
1921
|
let topLevelStatement = ancestry[ancestry.length - 2];
|
|
1923
1922
|
assertNodePathIsStatement(topLevelStatement);
|
|
1924
1923
|
return topLevelStatement;
|
|
1925
1924
|
}
|
|
1926
1925
|
function getTopLevelStatementsForPaths(paths) {
|
|
1927
1926
|
let topLevelStatements = /* @__PURE__ */ new Set();
|
|
1928
|
-
for (let
|
|
1929
|
-
let topLevelStatement = getTopLevelStatementPathForPath(
|
|
1927
|
+
for (let path7 of paths) {
|
|
1928
|
+
let topLevelStatement = getTopLevelStatementPathForPath(path7);
|
|
1930
1929
|
topLevelStatements.add(topLevelStatement.node);
|
|
1931
1930
|
}
|
|
1932
1931
|
return topLevelStatements;
|
|
@@ -2320,24 +2319,24 @@ function isNamedComponentExport(name) {
|
|
|
2320
2319
|
}
|
|
2321
2320
|
var decorateComponentExportsWithProps = (ast) => {
|
|
2322
2321
|
const hocs = [];
|
|
2323
|
-
function getHocUid(
|
|
2324
|
-
const uid =
|
|
2322
|
+
function getHocUid(path7, hocName) {
|
|
2323
|
+
const uid = path7.scope.generateUidIdentifier(hocName);
|
|
2325
2324
|
hocs.push([hocName, uid]);
|
|
2326
2325
|
return uid;
|
|
2327
2326
|
}
|
|
2328
2327
|
traverse(ast, {
|
|
2329
|
-
ExportDeclaration(
|
|
2330
|
-
if (
|
|
2331
|
-
const declaration =
|
|
2328
|
+
ExportDeclaration(path7) {
|
|
2329
|
+
if (path7.isExportDefaultDeclaration()) {
|
|
2330
|
+
const declaration = path7.get("declaration");
|
|
2332
2331
|
const expr = declaration.isExpression() ? declaration.node : declaration.isFunctionDeclaration() ? toFunctionExpression(declaration.node) : void 0;
|
|
2333
2332
|
if (expr) {
|
|
2334
|
-
const uid = getHocUid(
|
|
2333
|
+
const uid = getHocUid(path7, "UNSAFE_withComponentProps");
|
|
2335
2334
|
declaration.replaceWith(t.callExpression(uid, [expr]));
|
|
2336
2335
|
}
|
|
2337
2336
|
return;
|
|
2338
2337
|
}
|
|
2339
|
-
if (
|
|
2340
|
-
const decl =
|
|
2338
|
+
if (path7.isExportNamedDeclaration()) {
|
|
2339
|
+
const decl = path7.get("declaration");
|
|
2341
2340
|
if (decl.isVariableDeclaration()) {
|
|
2342
2341
|
decl.get("declarations").forEach((varDeclarator) => {
|
|
2343
2342
|
const id = varDeclarator.get("id");
|
|
@@ -2347,7 +2346,7 @@ var decorateComponentExportsWithProps = (ast) => {
|
|
|
2347
2346
|
if (!id.isIdentifier()) return;
|
|
2348
2347
|
const { name } = id.node;
|
|
2349
2348
|
if (!isNamedComponentExport(name)) return;
|
|
2350
|
-
const uid = getHocUid(
|
|
2349
|
+
const uid = getHocUid(path7, `UNSAFE_with${name}Props`);
|
|
2351
2350
|
init.replaceWith(t.callExpression(uid, [expr]));
|
|
2352
2351
|
});
|
|
2353
2352
|
return;
|
|
@@ -2357,7 +2356,7 @@ var decorateComponentExportsWithProps = (ast) => {
|
|
|
2357
2356
|
if (!id) return;
|
|
2358
2357
|
const { name } = id;
|
|
2359
2358
|
if (!isNamedComponentExport(name)) return;
|
|
2360
|
-
const uid = getHocUid(
|
|
2359
|
+
const uid = getHocUid(path7, `UNSAFE_with${name}Props`);
|
|
2361
2360
|
decl.replaceWith(
|
|
2362
2361
|
t.variableDeclaration("const", [
|
|
2363
2362
|
t.variableDeclarator(
|
|
@@ -4236,17 +4235,17 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4236
4235
|
serverBuildPath
|
|
4237
4236
|
);
|
|
4238
4237
|
let routes = createPrerenderRoutes(reactRouterConfig.routes);
|
|
4239
|
-
for (let
|
|
4240
|
-
let matches = (0, import_react_router2.matchRoutes)(routes, `/${
|
|
4238
|
+
for (let path7 of build.prerender) {
|
|
4239
|
+
let matches = (0, import_react_router2.matchRoutes)(routes, `/${path7}/`.replace(/^\/\/+/, "/"));
|
|
4241
4240
|
if (!matches) {
|
|
4242
4241
|
throw new Error(
|
|
4243
|
-
`Unable to prerender path because it does not match any routes: ${
|
|
4242
|
+
`Unable to prerender path because it does not match any routes: ${path7}`
|
|
4244
4243
|
);
|
|
4245
4244
|
}
|
|
4246
4245
|
}
|
|
4247
4246
|
let buildRoutes = createPrerenderRoutes(build.routes);
|
|
4248
|
-
for (let
|
|
4249
|
-
let matches = (0, import_react_router2.matchRoutes)(buildRoutes, `/${
|
|
4247
|
+
for (let path7 of build.prerender) {
|
|
4248
|
+
let matches = (0, import_react_router2.matchRoutes)(buildRoutes, `/${path7}/`.replace(/^\/\/+/, "/"));
|
|
4250
4249
|
if (!matches) {
|
|
4251
4250
|
continue;
|
|
4252
4251
|
}
|
|
@@ -4259,7 +4258,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4259
4258
|
if (manifestRoute.loader) {
|
|
4260
4259
|
await prerenderData(
|
|
4261
4260
|
handler,
|
|
4262
|
-
|
|
4261
|
+
path7,
|
|
4263
4262
|
[leafRoute.id],
|
|
4264
4263
|
clientBuildDirectory,
|
|
4265
4264
|
reactRouterConfig,
|
|
@@ -4267,7 +4266,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4267
4266
|
);
|
|
4268
4267
|
await prerenderResourceRoute(
|
|
4269
4268
|
handler,
|
|
4270
|
-
|
|
4269
|
+
path7,
|
|
4271
4270
|
clientBuildDirectory,
|
|
4272
4271
|
reactRouterConfig,
|
|
4273
4272
|
viteConfig
|
|
@@ -4285,7 +4284,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4285
4284
|
if (!isResourceRoute && hasLoaders) {
|
|
4286
4285
|
data = await prerenderData(
|
|
4287
4286
|
handler,
|
|
4288
|
-
|
|
4287
|
+
path7,
|
|
4289
4288
|
null,
|
|
4290
4289
|
clientBuildDirectory,
|
|
4291
4290
|
reactRouterConfig,
|
|
@@ -4294,7 +4293,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4294
4293
|
}
|
|
4295
4294
|
await prerenderRoute(
|
|
4296
4295
|
handler,
|
|
4297
|
-
|
|
4296
|
+
path7,
|
|
4298
4297
|
clientBuildDirectory,
|
|
4299
4298
|
reactRouterConfig,
|
|
4300
4299
|
viteConfig,
|
|
@@ -4490,14 +4489,14 @@ async function validateSsrFalsePrerenderExports(viteConfig, ctx, manifest, viteC
|
|
|
4490
4489
|
}
|
|
4491
4490
|
let prerenderRoutes = createPrerenderRoutes(manifest.routes);
|
|
4492
4491
|
let prerenderedRoutes = /* @__PURE__ */ new Set();
|
|
4493
|
-
for (let
|
|
4492
|
+
for (let path7 of prerenderPaths) {
|
|
4494
4493
|
let matches = (0, import_react_router2.matchRoutes)(
|
|
4495
4494
|
prerenderRoutes,
|
|
4496
|
-
`/${
|
|
4495
|
+
`/${path7}/`.replace(/^\/\/+/, "/")
|
|
4497
4496
|
);
|
|
4498
4497
|
invariant(
|
|
4499
4498
|
matches,
|
|
4500
|
-
`Unable to prerender path because it does not match any routes: ${
|
|
4499
|
+
`Unable to prerender path because it does not match any routes: ${path7}`
|
|
4501
4500
|
);
|
|
4502
4501
|
matches.forEach((m) => prerenderedRoutes.add(m.route.id));
|
|
4503
4502
|
}
|
|
@@ -4945,867 +4944,7 @@ async function asyncFlatten(arr) {
|
|
|
4945
4944
|
} while (arr.some((v2) => v2?.then));
|
|
4946
4945
|
return arr;
|
|
4947
4946
|
}
|
|
4948
|
-
|
|
4949
|
-
// vite/rsc/plugin.ts
|
|
4950
|
-
var import_es_module_lexer3 = require("es-module-lexer");
|
|
4951
|
-
var Path5 = __toESM(require("pathe"));
|
|
4952
|
-
var babel2 = __toESM(require("@babel/core"));
|
|
4953
|
-
var import_picocolors5 = __toESM(require("picocolors"));
|
|
4954
|
-
var import_fs = require("fs");
|
|
4955
|
-
var import_promises3 = require("fs/promises");
|
|
4956
|
-
var import_pathe6 = __toESM(require("pathe"));
|
|
4957
|
-
|
|
4958
|
-
// vite/rsc/virtual-route-config.ts
|
|
4959
|
-
var import_pathe5 = __toESM(require("pathe"));
|
|
4960
|
-
function createVirtualRouteConfig({
|
|
4961
|
-
appDirectory,
|
|
4962
|
-
routeConfig
|
|
4963
|
-
}) {
|
|
4964
|
-
let routeIdByFile = /* @__PURE__ */ new Map();
|
|
4965
|
-
let code = "export default [";
|
|
4966
|
-
const closeRouteSymbol = Symbol("CLOSE_ROUTE");
|
|
4967
|
-
let stack = [
|
|
4968
|
-
...routeConfig
|
|
4969
|
-
];
|
|
4970
|
-
while (stack.length > 0) {
|
|
4971
|
-
const route = stack.pop();
|
|
4972
|
-
if (!route) break;
|
|
4973
|
-
if (route === closeRouteSymbol) {
|
|
4974
|
-
code += "]},";
|
|
4975
|
-
continue;
|
|
4976
|
-
}
|
|
4977
|
-
code += "{";
|
|
4978
|
-
const routeFile = import_pathe5.default.resolve(appDirectory, route.file);
|
|
4979
|
-
const routeId = route.id || createRouteId2(route.file, appDirectory);
|
|
4980
|
-
routeIdByFile.set(routeFile, routeId);
|
|
4981
|
-
code += `lazy: () => import(${JSON.stringify(
|
|
4982
|
-
`${routeFile}?route-module`
|
|
4983
|
-
)}),`;
|
|
4984
|
-
code += `id: ${JSON.stringify(routeId)},`;
|
|
4985
|
-
if (typeof route.path === "string") {
|
|
4986
|
-
code += `path: ${JSON.stringify(route.path)},`;
|
|
4987
|
-
}
|
|
4988
|
-
if (route.index) {
|
|
4989
|
-
code += `index: true,`;
|
|
4990
|
-
}
|
|
4991
|
-
if (route.caseSensitive) {
|
|
4992
|
-
code += `caseSensitive: true,`;
|
|
4993
|
-
}
|
|
4994
|
-
if (route.children) {
|
|
4995
|
-
code += ["children:["];
|
|
4996
|
-
stack.push(closeRouteSymbol);
|
|
4997
|
-
stack.push(...[...route.children].reverse());
|
|
4998
|
-
} else {
|
|
4999
|
-
code += "},";
|
|
5000
|
-
}
|
|
5001
|
-
}
|
|
5002
|
-
code += "];\n";
|
|
5003
|
-
return { code, routeIdByFile };
|
|
5004
|
-
}
|
|
5005
|
-
function createRouteId2(file, appDirectory) {
|
|
5006
|
-
return import_pathe5.default.relative(appDirectory, file).replace(/\\+/, "/").slice(0, -import_pathe5.default.extname(file).length);
|
|
5007
|
-
}
|
|
5008
|
-
|
|
5009
|
-
// vite/rsc/virtual-route-modules.ts
|
|
5010
|
-
var import_es_module_lexer2 = require("es-module-lexer");
|
|
5011
|
-
var SERVER_ONLY_COMPONENT_EXPORTS = ["ServerComponent"];
|
|
5012
|
-
var SERVER_ONLY_ROUTE_EXPORTS2 = [
|
|
5013
|
-
...SERVER_ONLY_COMPONENT_EXPORTS,
|
|
5014
|
-
"loader",
|
|
5015
|
-
"action",
|
|
5016
|
-
"middleware",
|
|
5017
|
-
"headers"
|
|
5018
|
-
];
|
|
5019
|
-
var SERVER_ONLY_ROUTE_EXPORTS_SET = new Set(SERVER_ONLY_ROUTE_EXPORTS2);
|
|
5020
|
-
function isServerOnlyRouteExport(name) {
|
|
5021
|
-
return SERVER_ONLY_ROUTE_EXPORTS_SET.has(name);
|
|
5022
|
-
}
|
|
5023
|
-
var COMMON_COMPONENT_EXPORTS = [
|
|
5024
|
-
"ErrorBoundary",
|
|
5025
|
-
"HydrateFallback",
|
|
5026
|
-
"Layout"
|
|
5027
|
-
];
|
|
5028
|
-
var SERVER_FIRST_COMPONENT_EXPORTS = [
|
|
5029
|
-
...COMMON_COMPONENT_EXPORTS,
|
|
5030
|
-
...SERVER_ONLY_COMPONENT_EXPORTS
|
|
5031
|
-
];
|
|
5032
|
-
var SERVER_FIRST_COMPONENT_EXPORTS_SET = new Set(
|
|
5033
|
-
SERVER_FIRST_COMPONENT_EXPORTS
|
|
5034
|
-
);
|
|
5035
|
-
function isServerFirstComponentExport(name) {
|
|
5036
|
-
return SERVER_FIRST_COMPONENT_EXPORTS_SET.has(
|
|
5037
|
-
name
|
|
5038
|
-
);
|
|
5039
|
-
}
|
|
5040
|
-
var CLIENT_COMPONENT_EXPORTS = [
|
|
5041
|
-
...COMMON_COMPONENT_EXPORTS,
|
|
5042
|
-
"default"
|
|
5043
|
-
];
|
|
5044
|
-
var CLIENT_NON_COMPONENT_EXPORTS2 = [
|
|
5045
|
-
"clientAction",
|
|
5046
|
-
"clientLoader",
|
|
5047
|
-
"clientMiddleware",
|
|
5048
|
-
"handle",
|
|
5049
|
-
"meta",
|
|
5050
|
-
"links",
|
|
5051
|
-
"shouldRevalidate"
|
|
5052
|
-
];
|
|
5053
|
-
var CLIENT_NON_COMPONENT_EXPORTS_SET = new Set(CLIENT_NON_COMPONENT_EXPORTS2);
|
|
5054
|
-
function isClientNonComponentExport(name) {
|
|
5055
|
-
return CLIENT_NON_COMPONENT_EXPORTS_SET.has(name);
|
|
5056
|
-
}
|
|
5057
|
-
var CLIENT_ROUTE_EXPORTS2 = [
|
|
5058
|
-
...CLIENT_NON_COMPONENT_EXPORTS2,
|
|
5059
|
-
...CLIENT_COMPONENT_EXPORTS
|
|
5060
|
-
];
|
|
5061
|
-
var CLIENT_ROUTE_EXPORTS_SET = new Set(CLIENT_ROUTE_EXPORTS2);
|
|
5062
|
-
function isClientRouteExport(name) {
|
|
5063
|
-
return CLIENT_ROUTE_EXPORTS_SET.has(name);
|
|
5064
|
-
}
|
|
5065
|
-
var ROUTE_EXPORTS = [
|
|
5066
|
-
...SERVER_ONLY_ROUTE_EXPORTS2,
|
|
5067
|
-
...CLIENT_ROUTE_EXPORTS2
|
|
5068
|
-
];
|
|
5069
|
-
var ROUTE_EXPORTS_SET = new Set(ROUTE_EXPORTS);
|
|
5070
|
-
function isRouteExport(name) {
|
|
5071
|
-
return ROUTE_EXPORTS_SET.has(name);
|
|
5072
|
-
}
|
|
5073
|
-
function isCustomRouteExport(name) {
|
|
5074
|
-
return !isRouteExport(name);
|
|
5075
|
-
}
|
|
5076
|
-
function hasReactServerCondition(viteEnvironment) {
|
|
5077
|
-
return viteEnvironment.config.resolve.conditions.includes("react-server");
|
|
5078
|
-
}
|
|
5079
|
-
function transformVirtualRouteModules({
|
|
5080
|
-
id,
|
|
5081
|
-
code,
|
|
5082
|
-
viteCommand,
|
|
5083
|
-
routeIdByFile,
|
|
5084
|
-
rootRouteFile,
|
|
5085
|
-
viteEnvironment
|
|
5086
|
-
}) {
|
|
5087
|
-
if (isVirtualRouteModuleId(id) || routeIdByFile.has(id)) {
|
|
5088
|
-
return createVirtualRouteModuleCode({
|
|
5089
|
-
id,
|
|
5090
|
-
code,
|
|
5091
|
-
rootRouteFile,
|
|
5092
|
-
viteCommand,
|
|
5093
|
-
viteEnvironment
|
|
5094
|
-
});
|
|
5095
|
-
}
|
|
5096
|
-
if (isVirtualServerRouteModuleId(id)) {
|
|
5097
|
-
return createVirtualServerRouteModuleCode({
|
|
5098
|
-
id,
|
|
5099
|
-
code,
|
|
5100
|
-
viteEnvironment
|
|
5101
|
-
});
|
|
5102
|
-
}
|
|
5103
|
-
if (isVirtualClientRouteModuleId(id)) {
|
|
5104
|
-
return createVirtualClientRouteModuleCode({
|
|
5105
|
-
id,
|
|
5106
|
-
code,
|
|
5107
|
-
rootRouteFile,
|
|
5108
|
-
viteCommand
|
|
5109
|
-
});
|
|
5110
|
-
}
|
|
5111
|
-
}
|
|
5112
|
-
async function createVirtualRouteModuleCode({
|
|
5113
|
-
id,
|
|
5114
|
-
code: routeSource,
|
|
5115
|
-
rootRouteFile,
|
|
5116
|
-
viteCommand,
|
|
5117
|
-
viteEnvironment
|
|
5118
|
-
}) {
|
|
5119
|
-
const isReactServer = hasReactServerCondition(viteEnvironment);
|
|
5120
|
-
const { staticExports, isServerFirstRoute, hasClientExports } = parseRouteExports(routeSource);
|
|
5121
|
-
const clientModuleId = getVirtualClientModuleId(id);
|
|
5122
|
-
const serverModuleId = getVirtualServerModuleId(id);
|
|
5123
|
-
let code = "";
|
|
5124
|
-
if (isServerFirstRoute) {
|
|
5125
|
-
if (staticExports.some(isServerFirstComponentExport)) {
|
|
5126
|
-
code += `import React from "react";
|
|
5127
|
-
`;
|
|
5128
|
-
}
|
|
5129
|
-
for (const staticExport of staticExports) {
|
|
5130
|
-
if (isClientNonComponentExport(staticExport)) {
|
|
5131
|
-
code += `export { ${staticExport} } from "${clientModuleId}";
|
|
5132
|
-
`;
|
|
5133
|
-
} else if (isReactServer && isServerFirstComponentExport(staticExport) && // Layout wraps all other component exports so doesn't need CSS injected
|
|
5134
|
-
staticExport !== "Layout") {
|
|
5135
|
-
code += `import { ${staticExport} as ${staticExport}WithoutCss } from "${serverModuleId}";
|
|
5136
|
-
`;
|
|
5137
|
-
code += `export ${staticExport === "ServerComponent" ? "default " : " "}function ${staticExport}(props) {
|
|
5138
|
-
`;
|
|
5139
|
-
code += ` return React.createElement(React.Fragment, null,
|
|
5140
|
-
`;
|
|
5141
|
-
code += ` import.meta.viteRsc.loadCss(),
|
|
5142
|
-
`;
|
|
5143
|
-
code += ` React.createElement(${staticExport}WithoutCss, props),
|
|
5144
|
-
`;
|
|
5145
|
-
code += ` );
|
|
5146
|
-
`;
|
|
5147
|
-
code += `}
|
|
5148
|
-
`;
|
|
5149
|
-
} else if (isReactServer && isRouteExport(staticExport)) {
|
|
5150
|
-
code += `export { ${staticExport} } from "${serverModuleId}";
|
|
5151
|
-
`;
|
|
5152
|
-
} else if (isCustomRouteExport(staticExport)) {
|
|
5153
|
-
code += `export { ${staticExport} } from "${isReactServer ? serverModuleId : clientModuleId}";
|
|
5154
|
-
`;
|
|
5155
|
-
}
|
|
5156
|
-
}
|
|
5157
|
-
if (viteCommand === "serve" && !hasClientExports) {
|
|
5158
|
-
code += `export { __ensureClientRouteModuleForHMR } from "${clientModuleId}";
|
|
5159
|
-
`;
|
|
5160
|
-
}
|
|
5161
|
-
} else {
|
|
5162
|
-
for (const staticExport of staticExports) {
|
|
5163
|
-
if (isClientRouteExport(staticExport)) {
|
|
5164
|
-
code += `export { ${staticExport} } from "${clientModuleId}";
|
|
5165
|
-
`;
|
|
5166
|
-
} else if (isReactServer && isServerOnlyRouteExport(staticExport)) {
|
|
5167
|
-
code += `export { ${staticExport} } from "${serverModuleId}";
|
|
5168
|
-
`;
|
|
5169
|
-
} else if (isCustomRouteExport(staticExport)) {
|
|
5170
|
-
code += `export { ${staticExport} } from "${isReactServer ? serverModuleId : clientModuleId}";
|
|
5171
|
-
`;
|
|
5172
|
-
}
|
|
5173
|
-
}
|
|
5174
|
-
}
|
|
5175
|
-
if (isRootRouteFile({ id, rootRouteFile }) && !staticExports.includes("ErrorBoundary")) {
|
|
5176
|
-
code += `export { ErrorBoundary } from "${clientModuleId}";
|
|
5177
|
-
`;
|
|
5178
|
-
}
|
|
5179
|
-
return code;
|
|
5180
|
-
}
|
|
5181
|
-
function createVirtualServerRouteModuleCode({
|
|
5182
|
-
id,
|
|
5183
|
-
code: routeSource,
|
|
5184
|
-
viteEnvironment
|
|
5185
|
-
}) {
|
|
5186
|
-
if (!hasReactServerCondition(viteEnvironment)) {
|
|
5187
|
-
throw new Error(
|
|
5188
|
-
[
|
|
5189
|
-
"Virtual server route module was loaded outside of the RSC environment.",
|
|
5190
|
-
`Environment Name: ${viteEnvironment.name}`,
|
|
5191
|
-
`Module ID: ${id}`
|
|
5192
|
-
].join("\n")
|
|
5193
|
-
);
|
|
5194
|
-
}
|
|
5195
|
-
const { staticExports, isServerFirstRoute } = parseRouteExports(routeSource);
|
|
5196
|
-
const clientModuleId = getVirtualClientModuleId(id);
|
|
5197
|
-
const serverRouteModuleAst = import_parser.parse(routeSource, {
|
|
5198
|
-
sourceType: "module"
|
|
5199
|
-
});
|
|
5200
|
-
removeExports(
|
|
5201
|
-
serverRouteModuleAst,
|
|
5202
|
-
isServerFirstRoute ? CLIENT_NON_COMPONENT_EXPORTS2 : CLIENT_ROUTE_EXPORTS2
|
|
5203
|
-
);
|
|
5204
|
-
const generatorResult = generate(serverRouteModuleAst);
|
|
5205
|
-
if (!isServerFirstRoute) {
|
|
5206
|
-
for (const staticExport of staticExports) {
|
|
5207
|
-
if (isClientRouteExport(staticExport)) {
|
|
5208
|
-
generatorResult.code += "\n";
|
|
5209
|
-
generatorResult.code += `export { ${staticExport} } from "${clientModuleId}";
|
|
5210
|
-
`;
|
|
5211
|
-
}
|
|
5212
|
-
}
|
|
5213
|
-
}
|
|
5214
|
-
return generatorResult;
|
|
5215
|
-
}
|
|
5216
|
-
function createVirtualClientRouteModuleCode({
|
|
5217
|
-
id,
|
|
5218
|
-
code: routeSource,
|
|
5219
|
-
rootRouteFile,
|
|
5220
|
-
viteCommand
|
|
5221
|
-
}) {
|
|
5222
|
-
const { staticExports, isServerFirstRoute, hasClientExports } = parseRouteExports(routeSource);
|
|
5223
|
-
const exportsToRemove = isServerFirstRoute ? [...SERVER_ONLY_ROUTE_EXPORTS2, ...CLIENT_COMPONENT_EXPORTS] : SERVER_ONLY_ROUTE_EXPORTS2;
|
|
5224
|
-
const clientRouteModuleAst = import_parser.parse(routeSource, {
|
|
5225
|
-
sourceType: "module"
|
|
5226
|
-
});
|
|
5227
|
-
removeExports(clientRouteModuleAst, exportsToRemove);
|
|
5228
|
-
const generatorResult = generate(clientRouteModuleAst);
|
|
5229
|
-
generatorResult.code = '"use client";' + generatorResult.code;
|
|
5230
|
-
if (isRootRouteFile({ id, rootRouteFile }) && !staticExports.includes("ErrorBoundary")) {
|
|
5231
|
-
const hasRootLayout = staticExports.includes("Layout");
|
|
5232
|
-
generatorResult.code += `
|
|
5233
|
-
import { createElement as __rr_createElement } from "react";
|
|
5234
|
-
`;
|
|
5235
|
-
generatorResult.code += `import { UNSAFE_RSCDefaultRootErrorBoundary } from "react-router";
|
|
5236
|
-
`;
|
|
5237
|
-
generatorResult.code += `export function ErrorBoundary() {
|
|
5238
|
-
`;
|
|
5239
|
-
generatorResult.code += ` return __rr_createElement(UNSAFE_RSCDefaultRootErrorBoundary, { hasRootLayout: ${hasRootLayout} });
|
|
5240
|
-
`;
|
|
5241
|
-
generatorResult.code += `}
|
|
5242
|
-
`;
|
|
5243
|
-
}
|
|
5244
|
-
if (viteCommand === "serve" && isServerFirstRoute && !hasClientExports) {
|
|
5245
|
-
generatorResult.code += `
|
|
5246
|
-
export const __ensureClientRouteModuleForHMR = true;`;
|
|
5247
|
-
}
|
|
5248
|
-
return generatorResult;
|
|
5249
|
-
}
|
|
5250
|
-
function parseRouteExports(code) {
|
|
5251
|
-
const [, exportSpecifiers] = (0, import_es_module_lexer2.parse)(code);
|
|
5252
|
-
const staticExports = exportSpecifiers.map(({ n: name }) => name);
|
|
5253
|
-
const isServerFirstRoute = staticExports.some(
|
|
5254
|
-
(staticExport) => staticExport === "ServerComponent"
|
|
5255
|
-
);
|
|
5256
|
-
return {
|
|
5257
|
-
staticExports,
|
|
5258
|
-
isServerFirstRoute,
|
|
5259
|
-
hasClientExports: staticExports.some(
|
|
5260
|
-
isServerFirstRoute ? isClientNonComponentExport : isClientRouteExport
|
|
5261
|
-
)
|
|
5262
|
-
};
|
|
5263
|
-
}
|
|
5264
|
-
function getVirtualClientModuleId(id) {
|
|
5265
|
-
return `${id.split("?")[0]}?client-route-module`;
|
|
5266
|
-
}
|
|
5267
|
-
function getVirtualServerModuleId(id) {
|
|
5268
|
-
return `${id.split("?")[0]}?server-route-module`;
|
|
5269
|
-
}
|
|
5270
|
-
function isVirtualRouteModuleId(id) {
|
|
5271
|
-
return /(\?|&)route-module(&|$)/.test(id);
|
|
5272
|
-
}
|
|
5273
|
-
function isVirtualClientRouteModuleId(id) {
|
|
5274
|
-
return /(\?|&)client-route-module(&|$)/.test(id);
|
|
5275
|
-
}
|
|
5276
|
-
function isVirtualServerRouteModuleId(id) {
|
|
5277
|
-
return /(\?|&)server-route-module(&|$)/.test(id);
|
|
5278
|
-
}
|
|
5279
|
-
function isRootRouteFile({
|
|
5280
|
-
id,
|
|
5281
|
-
rootRouteFile
|
|
5282
|
-
}) {
|
|
5283
|
-
const filePath = id.split("?")[0];
|
|
5284
|
-
return filePath === rootRouteFile;
|
|
5285
|
-
}
|
|
5286
|
-
|
|
5287
|
-
// vite/rsc/plugin.ts
|
|
5288
|
-
function reactRouterRSCVitePlugin() {
|
|
5289
|
-
let configLoader;
|
|
5290
|
-
let typegenWatcherPromise;
|
|
5291
|
-
let viteCommand;
|
|
5292
|
-
let routeIdByFile;
|
|
5293
|
-
let logger;
|
|
5294
|
-
const defaultEntries2 = getDefaultEntries();
|
|
5295
|
-
let config;
|
|
5296
|
-
let rootRouteFile;
|
|
5297
|
-
function updateConfig(newConfig) {
|
|
5298
|
-
config = newConfig;
|
|
5299
|
-
rootRouteFile = Path5.resolve(
|
|
5300
|
-
newConfig.appDirectory,
|
|
5301
|
-
newConfig.routes.root.file
|
|
5302
|
-
);
|
|
5303
|
-
}
|
|
5304
|
-
return [
|
|
5305
|
-
{
|
|
5306
|
-
name: "react-router/rsc",
|
|
5307
|
-
async config(viteUserConfig, { command, mode }) {
|
|
5308
|
-
await import_es_module_lexer3.init;
|
|
5309
|
-
await preloadVite();
|
|
5310
|
-
viteCommand = command;
|
|
5311
|
-
const rootDirectory = getRootDirectory(viteUserConfig);
|
|
5312
|
-
const watch2 = command === "serve";
|
|
5313
|
-
configLoader = await createConfigLoader({
|
|
5314
|
-
rootDirectory,
|
|
5315
|
-
mode,
|
|
5316
|
-
watch: watch2,
|
|
5317
|
-
validateConfig: (userConfig) => {
|
|
5318
|
-
let errors = [];
|
|
5319
|
-
if (userConfig.buildEnd) errors.push("buildEnd");
|
|
5320
|
-
if (userConfig.prerender) errors.push("prerender");
|
|
5321
|
-
if (userConfig.presets?.length) errors.push("presets");
|
|
5322
|
-
if (userConfig.routeDiscovery) errors.push("routeDiscovery");
|
|
5323
|
-
if (userConfig.serverBundles) errors.push("serverBundles");
|
|
5324
|
-
if (userConfig.ssr === false) errors.push("ssr: false");
|
|
5325
|
-
if (userConfig.future?.unstable_splitRouteModules)
|
|
5326
|
-
errors.push("future.unstable_splitRouteModules");
|
|
5327
|
-
if (userConfig.future?.unstable_viteEnvironmentApi === false)
|
|
5328
|
-
errors.push("future.unstable_viteEnvironmentApi: false");
|
|
5329
|
-
if (userConfig.future?.v8_middleware === false)
|
|
5330
|
-
errors.push("future.v8_middleware: false");
|
|
5331
|
-
if (userConfig.future?.unstable_subResourceIntegrity)
|
|
5332
|
-
errors.push("future.unstable_subResourceIntegrity");
|
|
5333
|
-
if (errors.length) {
|
|
5334
|
-
return `RSC Framework Mode does not currently support the following React Router config:
|
|
5335
|
-
${errors.map((x) => ` - ${x}`).join("\n")}
|
|
5336
|
-
`;
|
|
5337
|
-
}
|
|
5338
|
-
}
|
|
5339
|
-
});
|
|
5340
|
-
const configResult = await configLoader.getConfig();
|
|
5341
|
-
if (!configResult.ok) throw new Error(configResult.error);
|
|
5342
|
-
updateConfig(configResult.value);
|
|
5343
|
-
if (viteUserConfig.base && config.basename !== "/" && viteCommand === "serve" && !viteUserConfig.server?.middlewareMode && !config.basename.startsWith(viteUserConfig.base)) {
|
|
5344
|
-
throw new Error(
|
|
5345
|
-
"When using the React Router `basename` and the Vite `base` config, the `basename` config must begin with `base` for the default Vite dev server."
|
|
5346
|
-
);
|
|
5347
|
-
}
|
|
5348
|
-
await loadDotenv({
|
|
5349
|
-
rootDirectory,
|
|
5350
|
-
viteUserConfig,
|
|
5351
|
-
mode
|
|
5352
|
-
});
|
|
5353
|
-
const vite2 = await import("vite");
|
|
5354
|
-
logger = vite2.createLogger(viteUserConfig.logLevel, {
|
|
5355
|
-
prefix: "[react-router]"
|
|
5356
|
-
});
|
|
5357
|
-
return {
|
|
5358
|
-
resolve: {
|
|
5359
|
-
dedupe: [
|
|
5360
|
-
// https://react.dev/warnings/invalid-hook-call-warning#duplicate-react
|
|
5361
|
-
"react",
|
|
5362
|
-
"react-dom",
|
|
5363
|
-
// Avoid router duplicates since mismatching routers cause `Error:
|
|
5364
|
-
// You must render this element inside a <Remix> element`.
|
|
5365
|
-
"react-router",
|
|
5366
|
-
"react-router/dom",
|
|
5367
|
-
...hasDependency({ name: "react-router-dom", rootDirectory }) ? ["react-router-dom"] : []
|
|
5368
|
-
]
|
|
5369
|
-
},
|
|
5370
|
-
optimizeDeps: {
|
|
5371
|
-
entries: getOptimizeDepsEntries({
|
|
5372
|
-
entryClientFilePath: defaultEntries2.client,
|
|
5373
|
-
reactRouterConfig: config
|
|
5374
|
-
}),
|
|
5375
|
-
esbuildOptions: {
|
|
5376
|
-
jsx: "automatic"
|
|
5377
|
-
},
|
|
5378
|
-
include: [
|
|
5379
|
-
// Pre-bundle React dependencies to avoid React duplicates,
|
|
5380
|
-
// even if React dependencies are not direct dependencies.
|
|
5381
|
-
// https://react.dev/warnings/invalid-hook-call-warning#duplicate-react
|
|
5382
|
-
"react",
|
|
5383
|
-
"react/jsx-runtime",
|
|
5384
|
-
"react/jsx-dev-runtime",
|
|
5385
|
-
"react-dom",
|
|
5386
|
-
"react-dom/client",
|
|
5387
|
-
"react-router/internal/react-server-client"
|
|
5388
|
-
]
|
|
5389
|
-
},
|
|
5390
|
-
esbuild: {
|
|
5391
|
-
jsx: "automatic",
|
|
5392
|
-
jsxDev: viteCommand !== "build"
|
|
5393
|
-
},
|
|
5394
|
-
environments: {
|
|
5395
|
-
client: {
|
|
5396
|
-
build: {
|
|
5397
|
-
rollupOptions: {
|
|
5398
|
-
input: {
|
|
5399
|
-
index: defaultEntries2.client
|
|
5400
|
-
}
|
|
5401
|
-
},
|
|
5402
|
-
outDir: (0, import_pathe6.join)(config.buildDirectory, "client")
|
|
5403
|
-
}
|
|
5404
|
-
},
|
|
5405
|
-
rsc: {
|
|
5406
|
-
build: {
|
|
5407
|
-
rollupOptions: {
|
|
5408
|
-
input: {
|
|
5409
|
-
// We use a virtual entry here so that consumers can import
|
|
5410
|
-
// it as `virtual:react-router/unstable_rsc/rsc-entry`
|
|
5411
|
-
// without needing to know the actual file path, which is
|
|
5412
|
-
// important when using the default entries.
|
|
5413
|
-
index: defaultEntries2.rsc
|
|
5414
|
-
},
|
|
5415
|
-
output: {
|
|
5416
|
-
entryFileNames: config.serverBuildFile,
|
|
5417
|
-
format: config.serverModuleFormat
|
|
5418
|
-
}
|
|
5419
|
-
},
|
|
5420
|
-
outDir: (0, import_pathe6.join)(config.buildDirectory, "server")
|
|
5421
|
-
}
|
|
5422
|
-
},
|
|
5423
|
-
ssr: {
|
|
5424
|
-
build: {
|
|
5425
|
-
rollupOptions: {
|
|
5426
|
-
input: {
|
|
5427
|
-
index: defaultEntries2.ssr
|
|
5428
|
-
},
|
|
5429
|
-
output: {
|
|
5430
|
-
// Note: We don't set `entryFileNames` here because it's
|
|
5431
|
-
// considered private to the RSC environment build, and
|
|
5432
|
-
// @vitejs/plugin-rsc currently breaks if it's set to
|
|
5433
|
-
// something other than `index.js`.
|
|
5434
|
-
format: config.serverModuleFormat
|
|
5435
|
-
}
|
|
5436
|
-
},
|
|
5437
|
-
outDir: (0, import_pathe6.join)(config.buildDirectory, "server/__ssr_build")
|
|
5438
|
-
}
|
|
5439
|
-
}
|
|
5440
|
-
},
|
|
5441
|
-
build: {
|
|
5442
|
-
rollupOptions: {
|
|
5443
|
-
// Copied from https://github.com/vitejs/vite-plugin-react/blob/c602225271d4acf462ba00f8d6d8a2e42492c5cd/packages/common/warning.ts
|
|
5444
|
-
onwarn(warning, defaultHandler) {
|
|
5445
|
-
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && (warning.message.includes("use client") || warning.message.includes("use server"))) {
|
|
5446
|
-
return;
|
|
5447
|
-
}
|
|
5448
|
-
if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
|
|
5449
|
-
return;
|
|
5450
|
-
}
|
|
5451
|
-
if (viteUserConfig.build?.rollupOptions?.onwarn) {
|
|
5452
|
-
viteUserConfig.build.rollupOptions.onwarn(
|
|
5453
|
-
warning,
|
|
5454
|
-
defaultHandler
|
|
5455
|
-
);
|
|
5456
|
-
} else {
|
|
5457
|
-
defaultHandler(warning);
|
|
5458
|
-
}
|
|
5459
|
-
}
|
|
5460
|
-
}
|
|
5461
|
-
}
|
|
5462
|
-
};
|
|
5463
|
-
},
|
|
5464
|
-
async configureServer(viteDevServer) {
|
|
5465
|
-
configLoader.onChange(
|
|
5466
|
-
async ({
|
|
5467
|
-
result,
|
|
5468
|
-
configCodeChanged,
|
|
5469
|
-
routeConfigCodeChanged,
|
|
5470
|
-
configChanged,
|
|
5471
|
-
routeConfigChanged
|
|
5472
|
-
}) => {
|
|
5473
|
-
if (!result.ok) {
|
|
5474
|
-
invalidateVirtualModules2(viteDevServer);
|
|
5475
|
-
logger.error(result.error, {
|
|
5476
|
-
clear: true,
|
|
5477
|
-
timestamp: true
|
|
5478
|
-
});
|
|
5479
|
-
return;
|
|
5480
|
-
}
|
|
5481
|
-
let message = configChanged ? "Config changed." : routeConfigChanged ? "Route config changed." : configCodeChanged ? "Config saved." : routeConfigCodeChanged ? " Route config saved." : "Config saved";
|
|
5482
|
-
logger.info(import_picocolors5.default.green(message), {
|
|
5483
|
-
clear: true,
|
|
5484
|
-
timestamp: true
|
|
5485
|
-
});
|
|
5486
|
-
updateConfig(result.value);
|
|
5487
|
-
if (configChanged || routeConfigChanged) {
|
|
5488
|
-
invalidateVirtualModules2(viteDevServer);
|
|
5489
|
-
}
|
|
5490
|
-
}
|
|
5491
|
-
);
|
|
5492
|
-
},
|
|
5493
|
-
async buildEnd() {
|
|
5494
|
-
await configLoader.close();
|
|
5495
|
-
}
|
|
5496
|
-
},
|
|
5497
|
-
{
|
|
5498
|
-
name: "react-router/rsc/typegen",
|
|
5499
|
-
async config(viteUserConfig, { command, mode }) {
|
|
5500
|
-
if (command === "serve") {
|
|
5501
|
-
const vite2 = await import("vite");
|
|
5502
|
-
typegenWatcherPromise = watch(
|
|
5503
|
-
getRootDirectory(viteUserConfig),
|
|
5504
|
-
{
|
|
5505
|
-
mode,
|
|
5506
|
-
rsc: true,
|
|
5507
|
-
// ignore `info` logs from typegen since they are
|
|
5508
|
-
// redundant when Vite plugin logs are active
|
|
5509
|
-
logger: vite2.createLogger("warn", {
|
|
5510
|
-
prefix: "[react-router]"
|
|
5511
|
-
})
|
|
5512
|
-
}
|
|
5513
|
-
);
|
|
5514
|
-
}
|
|
5515
|
-
},
|
|
5516
|
-
async buildEnd() {
|
|
5517
|
-
(await typegenWatcherPromise)?.close();
|
|
5518
|
-
}
|
|
5519
|
-
},
|
|
5520
|
-
{
|
|
5521
|
-
name: "react-router/rsc/virtual-rsc-entry",
|
|
5522
|
-
resolveId(id) {
|
|
5523
|
-
if (id === virtual2.rscEntry.id) return defaultEntries2.rsc;
|
|
5524
|
-
}
|
|
5525
|
-
},
|
|
5526
|
-
{
|
|
5527
|
-
name: "react-router/rsc/virtual-route-config",
|
|
5528
|
-
resolveId(id) {
|
|
5529
|
-
if (id === virtual2.routeConfig.id) {
|
|
5530
|
-
return virtual2.routeConfig.resolvedId;
|
|
5531
|
-
}
|
|
5532
|
-
},
|
|
5533
|
-
load(id) {
|
|
5534
|
-
if (id === virtual2.routeConfig.resolvedId) {
|
|
5535
|
-
const result = createVirtualRouteConfig({
|
|
5536
|
-
appDirectory: config.appDirectory,
|
|
5537
|
-
routeConfig: config.unstable_routeConfig
|
|
5538
|
-
});
|
|
5539
|
-
routeIdByFile = result.routeIdByFile;
|
|
5540
|
-
return result.code;
|
|
5541
|
-
}
|
|
5542
|
-
}
|
|
5543
|
-
},
|
|
5544
|
-
{
|
|
5545
|
-
name: "react-router/rsc/virtual-route-modules",
|
|
5546
|
-
transform(code, id) {
|
|
5547
|
-
if (!routeIdByFile) return;
|
|
5548
|
-
return transformVirtualRouteModules({
|
|
5549
|
-
code,
|
|
5550
|
-
id,
|
|
5551
|
-
viteCommand,
|
|
5552
|
-
routeIdByFile,
|
|
5553
|
-
rootRouteFile,
|
|
5554
|
-
viteEnvironment: this.environment
|
|
5555
|
-
});
|
|
5556
|
-
}
|
|
5557
|
-
},
|
|
5558
|
-
{
|
|
5559
|
-
name: "react-router/rsc/virtual-basename",
|
|
5560
|
-
resolveId(id) {
|
|
5561
|
-
if (id === virtual2.basename.id) {
|
|
5562
|
-
return virtual2.basename.resolvedId;
|
|
5563
|
-
}
|
|
5564
|
-
},
|
|
5565
|
-
load(id) {
|
|
5566
|
-
if (id === virtual2.basename.resolvedId) {
|
|
5567
|
-
return `export default ${JSON.stringify(config.basename)};`;
|
|
5568
|
-
}
|
|
5569
|
-
}
|
|
5570
|
-
},
|
|
5571
|
-
{
|
|
5572
|
-
name: "react-router/rsc/hmr/inject-runtime",
|
|
5573
|
-
enforce: "pre",
|
|
5574
|
-
resolveId(id) {
|
|
5575
|
-
if (id === virtual2.injectHmrRuntime.id) {
|
|
5576
|
-
return virtual2.injectHmrRuntime.resolvedId;
|
|
5577
|
-
}
|
|
5578
|
-
},
|
|
5579
|
-
async load(id) {
|
|
5580
|
-
if (id !== virtual2.injectHmrRuntime.resolvedId) return;
|
|
5581
|
-
return viteCommand === "serve" ? [
|
|
5582
|
-
`import RefreshRuntime from "${virtual2.hmrRuntime.id}"`,
|
|
5583
|
-
"RefreshRuntime.injectIntoGlobalHook(window)",
|
|
5584
|
-
"window.$RefreshReg$ = () => {}",
|
|
5585
|
-
"window.$RefreshSig$ = () => (type) => type",
|
|
5586
|
-
"window.__vite_plugin_react_preamble_installed__ = true"
|
|
5587
|
-
].join("\n") : "";
|
|
5588
|
-
}
|
|
5589
|
-
},
|
|
5590
|
-
{
|
|
5591
|
-
name: "react-router/rsc/hmr/runtime",
|
|
5592
|
-
enforce: "pre",
|
|
5593
|
-
resolveId(id) {
|
|
5594
|
-
if (id === virtual2.hmrRuntime.id) return virtual2.hmrRuntime.resolvedId;
|
|
5595
|
-
},
|
|
5596
|
-
async load(id) {
|
|
5597
|
-
if (id !== virtual2.hmrRuntime.resolvedId) return;
|
|
5598
|
-
const reactRefreshDir = import_pathe6.default.dirname(
|
|
5599
|
-
require.resolve("react-refresh/package.json")
|
|
5600
|
-
);
|
|
5601
|
-
const reactRefreshRuntimePath = import_pathe6.default.join(
|
|
5602
|
-
reactRefreshDir,
|
|
5603
|
-
"cjs/react-refresh-runtime.development.js"
|
|
5604
|
-
);
|
|
5605
|
-
return [
|
|
5606
|
-
"const exports = {}",
|
|
5607
|
-
await (0, import_promises3.readFile)(reactRefreshRuntimePath, "utf8"),
|
|
5608
|
-
await (0, import_promises3.readFile)(
|
|
5609
|
-
require.resolve("./static/rsc-refresh-utils.mjs"),
|
|
5610
|
-
"utf8"
|
|
5611
|
-
),
|
|
5612
|
-
"export default exports"
|
|
5613
|
-
].join("\n");
|
|
5614
|
-
}
|
|
5615
|
-
},
|
|
5616
|
-
{
|
|
5617
|
-
name: "react-router/rsc/hmr/react-refresh",
|
|
5618
|
-
async transform(code, id, options) {
|
|
5619
|
-
if (viteCommand !== "serve") return;
|
|
5620
|
-
if (id.includes("/node_modules/")) return;
|
|
5621
|
-
const filepath = id.split("?")[0];
|
|
5622
|
-
const extensionsRE = /\.(jsx?|tsx?|mdx?)$/;
|
|
5623
|
-
if (!extensionsRE.test(filepath)) return;
|
|
5624
|
-
const devRuntime = "react/jsx-dev-runtime";
|
|
5625
|
-
const ssr = options?.ssr === true;
|
|
5626
|
-
const isJSX = filepath.endsWith("x");
|
|
5627
|
-
const useFastRefresh = !ssr && (isJSX || code.includes(devRuntime));
|
|
5628
|
-
if (!useFastRefresh) return;
|
|
5629
|
-
if (isVirtualClientRouteModuleId(id)) {
|
|
5630
|
-
const routeId = routeIdByFile?.get(filepath);
|
|
5631
|
-
return { code: addRefreshWrapper2({ routeId, code, id }) };
|
|
5632
|
-
}
|
|
5633
|
-
const result = await babel2.transformAsync(code, {
|
|
5634
|
-
babelrc: false,
|
|
5635
|
-
configFile: false,
|
|
5636
|
-
filename: id,
|
|
5637
|
-
sourceFileName: filepath,
|
|
5638
|
-
parserOpts: {
|
|
5639
|
-
sourceType: "module",
|
|
5640
|
-
allowAwaitOutsideFunction: true
|
|
5641
|
-
},
|
|
5642
|
-
plugins: [[require("react-refresh/babel"), { skipEnvCheck: true }]],
|
|
5643
|
-
sourceMaps: true
|
|
5644
|
-
});
|
|
5645
|
-
if (result === null) return;
|
|
5646
|
-
code = result.code;
|
|
5647
|
-
const refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
5648
|
-
if (refreshContentRE.test(code)) {
|
|
5649
|
-
code = addRefreshWrapper2({ code, id });
|
|
5650
|
-
}
|
|
5651
|
-
return { code, map: result.map };
|
|
5652
|
-
}
|
|
5653
|
-
},
|
|
5654
|
-
{
|
|
5655
|
-
name: "react-router/rsc/hmr/updates",
|
|
5656
|
-
async hotUpdate({ server, file, modules }) {
|
|
5657
|
-
if (this.environment.name !== "rsc") return;
|
|
5658
|
-
const clientModules = server.environments.client.moduleGraph.getModulesByFile(file);
|
|
5659
|
-
const vite2 = await import("vite");
|
|
5660
|
-
const isServerOnlyChange = !clientModules || clientModules.size === 0 || // Handle CSS injected from server-first routes (with ?direct query
|
|
5661
|
-
// string) since the client graph has a reference to the CSS
|
|
5662
|
-
vite2.isCSSRequest(file) && Array.from(clientModules).some(
|
|
5663
|
-
(mod) => mod.id?.includes("?direct")
|
|
5664
|
-
);
|
|
5665
|
-
for (const mod of getModulesWithImporters(modules)) {
|
|
5666
|
-
if (!mod.file) continue;
|
|
5667
|
-
const normalizedPath = import_pathe6.default.normalize(mod.file);
|
|
5668
|
-
const routeId = routeIdByFile?.get(normalizedPath);
|
|
5669
|
-
if (routeId !== void 0) {
|
|
5670
|
-
const routeSource = await (0, import_promises3.readFile)(normalizedPath, "utf8");
|
|
5671
|
-
const virtualRouteModuleCode = (await server.environments.rsc.pluginContainer.transform(
|
|
5672
|
-
routeSource,
|
|
5673
|
-
`${normalizedPath}?route-module`
|
|
5674
|
-
)).code;
|
|
5675
|
-
const { staticExports } = parseRouteExports(virtualRouteModuleCode);
|
|
5676
|
-
const hasAction = staticExports.includes("action");
|
|
5677
|
-
const hasComponent = staticExports.includes("default");
|
|
5678
|
-
const hasErrorBoundary = staticExports.includes("ErrorBoundary");
|
|
5679
|
-
const hasLoader = staticExports.includes("loader");
|
|
5680
|
-
server.hot.send({
|
|
5681
|
-
type: "custom",
|
|
5682
|
-
event: "react-router:hmr",
|
|
5683
|
-
data: {
|
|
5684
|
-
routeId,
|
|
5685
|
-
isServerOnlyChange,
|
|
5686
|
-
hasAction,
|
|
5687
|
-
hasComponent,
|
|
5688
|
-
hasErrorBoundary,
|
|
5689
|
-
hasLoader
|
|
5690
|
-
}
|
|
5691
|
-
});
|
|
5692
|
-
}
|
|
5693
|
-
}
|
|
5694
|
-
return modules;
|
|
5695
|
-
}
|
|
5696
|
-
},
|
|
5697
|
-
validatePluginOrder(),
|
|
5698
|
-
warnOnClientSourceMaps()
|
|
5699
|
-
];
|
|
5700
|
-
}
|
|
5701
|
-
var virtual2 = {
|
|
5702
|
-
routeConfig: create("unstable_rsc/routes"),
|
|
5703
|
-
injectHmrRuntime: create("unstable_rsc/inject-hmr-runtime"),
|
|
5704
|
-
hmrRuntime: create("unstable_rsc/runtime"),
|
|
5705
|
-
basename: create("unstable_rsc/basename"),
|
|
5706
|
-
rscEntry: create("unstable_rsc/rsc-entry")
|
|
5707
|
-
};
|
|
5708
|
-
function invalidateVirtualModules2(viteDevServer) {
|
|
5709
|
-
for (const vmod of Object.values(virtual2)) {
|
|
5710
|
-
for (const env of Object.values(viteDevServer.environments)) {
|
|
5711
|
-
const mod = env.moduleGraph.getModuleById(vmod.resolvedId);
|
|
5712
|
-
if (mod) {
|
|
5713
|
-
env.moduleGraph.invalidateModule(mod);
|
|
5714
|
-
}
|
|
5715
|
-
}
|
|
5716
|
-
}
|
|
5717
|
-
}
|
|
5718
|
-
function getRootDirectory(viteUserConfig) {
|
|
5719
|
-
return viteUserConfig.root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();
|
|
5720
|
-
}
|
|
5721
|
-
function getDevPackageRoot() {
|
|
5722
|
-
const currentDir = (0, import_pathe6.dirname)(__dirname);
|
|
5723
|
-
let dir = currentDir;
|
|
5724
|
-
while (dir !== (0, import_pathe6.dirname)(dir)) {
|
|
5725
|
-
try {
|
|
5726
|
-
const packageJsonPath = (0, import_pathe6.join)(dir, "package.json");
|
|
5727
|
-
(0, import_fs.readFileSync)(packageJsonPath, "utf-8");
|
|
5728
|
-
return dir;
|
|
5729
|
-
} catch {
|
|
5730
|
-
dir = (0, import_pathe6.dirname)(dir);
|
|
5731
|
-
}
|
|
5732
|
-
}
|
|
5733
|
-
throw new Error("Could not find package.json");
|
|
5734
|
-
}
|
|
5735
|
-
function getDefaultEntries() {
|
|
5736
|
-
const defaultEntriesDir2 = (0, import_pathe6.join)(
|
|
5737
|
-
getDevPackageRoot(),
|
|
5738
|
-
"dist",
|
|
5739
|
-
"config",
|
|
5740
|
-
"default-rsc-entries"
|
|
5741
|
-
);
|
|
5742
|
-
return {
|
|
5743
|
-
rsc: (0, import_pathe6.join)(defaultEntriesDir2, "entry.rsc.tsx"),
|
|
5744
|
-
ssr: (0, import_pathe6.join)(defaultEntriesDir2, "entry.ssr.tsx"),
|
|
5745
|
-
client: (0, import_pathe6.join)(defaultEntriesDir2, "entry.client.tsx")
|
|
5746
|
-
};
|
|
5747
|
-
}
|
|
5748
|
-
function getModulesWithImporters(modules) {
|
|
5749
|
-
const visited = /* @__PURE__ */ new Set();
|
|
5750
|
-
const result = /* @__PURE__ */ new Set();
|
|
5751
|
-
function walk(module2) {
|
|
5752
|
-
if (visited.has(module2)) return;
|
|
5753
|
-
visited.add(module2);
|
|
5754
|
-
result.add(module2);
|
|
5755
|
-
for (const importer of module2.importers) {
|
|
5756
|
-
walk(importer);
|
|
5757
|
-
}
|
|
5758
|
-
}
|
|
5759
|
-
for (const module2 of modules) {
|
|
5760
|
-
walk(module2);
|
|
5761
|
-
}
|
|
5762
|
-
return result;
|
|
5763
|
-
}
|
|
5764
|
-
function addRefreshWrapper2({
|
|
5765
|
-
routeId,
|
|
5766
|
-
code,
|
|
5767
|
-
id
|
|
5768
|
-
}) {
|
|
5769
|
-
const acceptExports = routeId !== void 0 ? CLIENT_NON_COMPONENT_EXPORTS2 : [];
|
|
5770
|
-
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));
|
|
5771
|
-
}
|
|
5772
|
-
var REACT_REFRESH_HEADER2 = `
|
|
5773
|
-
import RefreshRuntime from "${virtual2.hmrRuntime.id}";
|
|
5774
|
-
|
|
5775
|
-
const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
|
|
5776
|
-
let prevRefreshReg;
|
|
5777
|
-
let prevRefreshSig;
|
|
5778
|
-
|
|
5779
|
-
if (import.meta.hot && !inWebWorker) {
|
|
5780
|
-
if (!window.__vite_plugin_react_preamble_installed__) {
|
|
5781
|
-
throw new Error(
|
|
5782
|
-
"React Router Vite plugin can't detect preamble. Something is wrong."
|
|
5783
|
-
);
|
|
5784
|
-
}
|
|
5785
|
-
|
|
5786
|
-
prevRefreshReg = window.$RefreshReg$;
|
|
5787
|
-
prevRefreshSig = window.$RefreshSig$;
|
|
5788
|
-
window.$RefreshReg$ = (type, id) => {
|
|
5789
|
-
RefreshRuntime.register(type, __SOURCE__ + " " + id)
|
|
5790
|
-
};
|
|
5791
|
-
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
5792
|
-
}`.replaceAll("\n", "");
|
|
5793
|
-
var REACT_REFRESH_FOOTER2 = `
|
|
5794
|
-
if (import.meta.hot && !inWebWorker) {
|
|
5795
|
-
window.$RefreshReg$ = prevRefreshReg;
|
|
5796
|
-
window.$RefreshSig$ = prevRefreshSig;
|
|
5797
|
-
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
|
5798
|
-
RefreshRuntime.registerExportsForReactRefresh(__SOURCE__, currentExports);
|
|
5799
|
-
import.meta.hot.accept((nextExports) => {
|
|
5800
|
-
if (!nextExports) return;
|
|
5801
|
-
__ROUTE_ID__ && window.__reactRouterRouteModuleUpdates.set(__ROUTE_ID__, nextExports);
|
|
5802
|
-
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(currentExports, nextExports, __ACCEPT_EXPORTS__);
|
|
5803
|
-
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
|
5804
|
-
});
|
|
5805
|
-
});
|
|
5806
|
-
}`;
|
|
5807
4947
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5808
4948
|
0 && (module.exports = {
|
|
5809
|
-
reactRouter
|
|
5810
|
-
unstable_reactRouterRSC
|
|
4949
|
+
reactRouter
|
|
5811
4950
|
});
|