@react-router/dev 0.0.0-experimental-795b50c5b → 0.0.0-experimental-ae6d61df4
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 +198 -85
- package/dist/config/default-rsc-entries/entry.rsc.tsx +6 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.js +1 -1
- package/dist/internal.js +365 -107
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +21 -6
- package/dist/vite.js +309 -240
- package/package.json +11 -7
package/dist/internal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-ae6d61df4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -45,9 +45,9 @@ __export(internal_exports, {
|
|
|
45
45
|
module.exports = __toCommonJS(internal_exports);
|
|
46
46
|
|
|
47
47
|
// vite/rsc/plugin.ts
|
|
48
|
-
var import_plugin_rsc = __toESM(require("@vitejs/plugin-rsc"));
|
|
49
48
|
var import_es_module_lexer2 = require("es-module-lexer");
|
|
50
49
|
var babel = __toESM(require("@babel/core"));
|
|
50
|
+
var import_picocolors4 = __toESM(require("picocolors"));
|
|
51
51
|
|
|
52
52
|
// vite/virtual-module.ts
|
|
53
53
|
function create(name) {
|
|
@@ -247,7 +247,7 @@ function validateRouteConfig({
|
|
|
247
247
|
`Route config in "${routeConfigFile}" is invalid.`,
|
|
248
248
|
root ? `${root}` : [],
|
|
249
249
|
nested ? Object.entries(nested).map(
|
|
250
|
-
([
|
|
250
|
+
([path6, message]) => `Path: routes.${path6}
|
|
251
251
|
${message}`
|
|
252
252
|
) : []
|
|
253
253
|
].flat().join("\n\n")
|
|
@@ -344,7 +344,8 @@ async function resolveConfig({
|
|
|
344
344
|
root,
|
|
345
345
|
viteNodeContext,
|
|
346
346
|
reactRouterConfigFile,
|
|
347
|
-
skipRoutes
|
|
347
|
+
skipRoutes,
|
|
348
|
+
validateConfig
|
|
348
349
|
}) {
|
|
349
350
|
let reactRouterUserConfig = {};
|
|
350
351
|
if (reactRouterConfigFile) {
|
|
@@ -362,6 +363,12 @@ async function resolveConfig({
|
|
|
362
363
|
return err(`${reactRouterConfigFile} must export a config`);
|
|
363
364
|
}
|
|
364
365
|
reactRouterUserConfig = configModule.default;
|
|
366
|
+
if (validateConfig) {
|
|
367
|
+
const error = validateConfig(reactRouterUserConfig);
|
|
368
|
+
if (error) {
|
|
369
|
+
return err(error);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
365
372
|
} catch (error) {
|
|
366
373
|
return err(`Error loading ${reactRouterConfigFile}: ${error}`);
|
|
367
374
|
}
|
|
@@ -450,7 +457,7 @@ async function resolveConfig({
|
|
|
450
457
|
}
|
|
451
458
|
let appDirectory = import_pathe3.default.resolve(root, userAppDirectory || "app");
|
|
452
459
|
let buildDirectory = import_pathe3.default.resolve(root, userBuildDirectory);
|
|
453
|
-
let rootRouteFile = findEntry(appDirectory, "root");
|
|
460
|
+
let rootRouteFile = findEntry(appDirectory, "root", { absolute: true });
|
|
454
461
|
if (!rootRouteFile) {
|
|
455
462
|
let rootRouteDisplayPath = import_pathe3.default.relative(
|
|
456
463
|
root,
|
|
@@ -491,7 +498,7 @@ async function resolveConfig({
|
|
|
491
498
|
{
|
|
492
499
|
id: "root",
|
|
493
500
|
path: "",
|
|
494
|
-
file: rootRouteFile,
|
|
501
|
+
file: import_pathe3.default.relative(appDirectory, rootRouteFile),
|
|
495
502
|
children: result.routeConfig
|
|
496
503
|
}
|
|
497
504
|
];
|
|
@@ -529,6 +536,7 @@ async function resolveConfig({
|
|
|
529
536
|
serverBundles,
|
|
530
537
|
serverModuleFormat,
|
|
531
538
|
ssr,
|
|
539
|
+
unstable_rootRouteFile: rootRouteFile,
|
|
532
540
|
unstable_routeConfig: routeConfig
|
|
533
541
|
});
|
|
534
542
|
for (let preset of reactRouterUserConfig.presets ?? []) {
|
|
@@ -540,7 +548,8 @@ async function createConfigLoader({
|
|
|
540
548
|
rootDirectory: root,
|
|
541
549
|
watch: watch2,
|
|
542
550
|
mode,
|
|
543
|
-
skipRoutes
|
|
551
|
+
skipRoutes,
|
|
552
|
+
validateConfig
|
|
544
553
|
}) {
|
|
545
554
|
root = import_pathe3.default.normalize(root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd());
|
|
546
555
|
let vite2 = await import("vite");
|
|
@@ -559,7 +568,13 @@ async function createConfigLoader({
|
|
|
559
568
|
});
|
|
560
569
|
};
|
|
561
570
|
updateReactRouterConfigFile();
|
|
562
|
-
let getConfig = () => resolveConfig({
|
|
571
|
+
let getConfig = () => resolveConfig({
|
|
572
|
+
root,
|
|
573
|
+
viteNodeContext,
|
|
574
|
+
reactRouterConfigFile,
|
|
575
|
+
skipRoutes,
|
|
576
|
+
validateConfig
|
|
577
|
+
});
|
|
563
578
|
let appDirectory;
|
|
564
579
|
let initialConfigResult = await getConfig();
|
|
565
580
|
if (!initialConfigResult.ok) {
|
|
@@ -581,11 +596,11 @@ async function createConfigLoader({
|
|
|
581
596
|
if (!fsWatcher) {
|
|
582
597
|
fsWatcher = import_chokidar.default.watch([root, appDirectory], {
|
|
583
598
|
ignoreInitial: true,
|
|
584
|
-
ignored: (
|
|
585
|
-
let dirname4 = import_pathe3.default.dirname(
|
|
599
|
+
ignored: (path6) => {
|
|
600
|
+
let dirname4 = import_pathe3.default.dirname(path6);
|
|
586
601
|
return !dirname4.startsWith(appDirectory) && // Ensure we're only watching files outside of the app directory
|
|
587
602
|
// that are at the root level, not nested in subdirectories
|
|
588
|
-
|
|
603
|
+
path6 !== root && // Watch the root directory itself
|
|
589
604
|
dirname4 !== root;
|
|
590
605
|
}
|
|
591
606
|
});
|
|
@@ -719,7 +734,8 @@ function isEntryFileDependency(moduleGraph, entryFilepath, filepath, visited = /
|
|
|
719
734
|
async function createContext2({
|
|
720
735
|
rootDirectory,
|
|
721
736
|
watch: watch2,
|
|
722
|
-
mode
|
|
737
|
+
mode,
|
|
738
|
+
rsc
|
|
723
739
|
}) {
|
|
724
740
|
const configLoader = await createConfigLoader({ rootDirectory, mode, watch: watch2 });
|
|
725
741
|
const configResult = await configLoader.getConfig();
|
|
@@ -730,7 +746,8 @@ async function createContext2({
|
|
|
730
746
|
return {
|
|
731
747
|
configLoader,
|
|
732
748
|
rootDirectory,
|
|
733
|
-
config
|
|
749
|
+
config,
|
|
750
|
+
rsc
|
|
734
751
|
};
|
|
735
752
|
}
|
|
736
753
|
|
|
@@ -785,7 +802,7 @@ function fullpath(lineage2) {
|
|
|
785
802
|
if (lineage2.length === 1 && route?.id === "root") return "/";
|
|
786
803
|
const isLayout = route && route.index !== true && route.path === void 0;
|
|
787
804
|
if (isLayout) return void 0;
|
|
788
|
-
return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((
|
|
805
|
+
return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path6) => path6 !== void 0 && path6 !== "").join("/");
|
|
789
806
|
}
|
|
790
807
|
|
|
791
808
|
// typegen/generate.ts
|
|
@@ -941,8 +958,8 @@ function routeFilesType({
|
|
|
941
958
|
);
|
|
942
959
|
}
|
|
943
960
|
function isInAppDirectory(ctx, routeFile) {
|
|
944
|
-
const
|
|
945
|
-
return
|
|
961
|
+
const path6 = Path3.resolve(ctx.config.appDirectory, routeFile);
|
|
962
|
+
return path6.startsWith(ctx.config.appDirectory);
|
|
946
963
|
}
|
|
947
964
|
function getRouteAnnotations({
|
|
948
965
|
ctx,
|
|
@@ -1007,7 +1024,7 @@ function getRouteAnnotations({
|
|
|
1007
1024
|
module: Module
|
|
1008
1025
|
}>
|
|
1009
1026
|
` + "\n\n" + generate(matchesType).code + "\n\n" + import_dedent.default`
|
|
1010
|
-
type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }>;
|
|
1027
|
+
type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }, ${ctx.rsc}>;
|
|
1011
1028
|
|
|
1012
1029
|
export namespace Route {
|
|
1013
1030
|
// links
|
|
@@ -1054,21 +1071,21 @@ function getRouteAnnotations({
|
|
|
1054
1071
|
return { filename: filename2, content };
|
|
1055
1072
|
}
|
|
1056
1073
|
function relativeImportSource(from, to) {
|
|
1057
|
-
let
|
|
1058
|
-
let extension = Path3.extname(
|
|
1059
|
-
|
|
1060
|
-
if (!
|
|
1074
|
+
let path6 = Path3.relative(Path3.dirname(from), to);
|
|
1075
|
+
let extension = Path3.extname(path6);
|
|
1076
|
+
path6 = Path3.join(Path3.dirname(path6), Pathe.filename(path6));
|
|
1077
|
+
if (!path6.startsWith("../")) path6 = "./" + path6;
|
|
1061
1078
|
if (!extension || /\.(js|ts)x?$/.test(extension)) {
|
|
1062
1079
|
extension = ".js";
|
|
1063
1080
|
}
|
|
1064
|
-
return
|
|
1081
|
+
return path6 + extension;
|
|
1065
1082
|
}
|
|
1066
1083
|
function rootDirsPath(ctx, typesPath) {
|
|
1067
1084
|
const rel = Path3.relative(typesDirectory(ctx), typesPath);
|
|
1068
1085
|
return Path3.join(ctx.rootDirectory, rel);
|
|
1069
1086
|
}
|
|
1070
|
-
function paramsType(
|
|
1071
|
-
const params = parse2(
|
|
1087
|
+
function paramsType(path6) {
|
|
1088
|
+
const params = parse2(path6);
|
|
1072
1089
|
return t2.tsTypeLiteral(
|
|
1073
1090
|
Object.entries(params).map(([param, isRequired]) => {
|
|
1074
1091
|
const property = t2.tsPropertySignature(
|
|
@@ -1118,8 +1135,8 @@ async function write(...files) {
|
|
|
1118
1135
|
})
|
|
1119
1136
|
);
|
|
1120
1137
|
}
|
|
1121
|
-
async function watch(rootDirectory, { mode, logger }) {
|
|
1122
|
-
const ctx = await createContext2({ rootDirectory, mode, watch: true });
|
|
1138
|
+
async function watch(rootDirectory, { mode, logger, rsc }) {
|
|
1139
|
+
const ctx = await createContext2({ rootDirectory, mode, rsc, watch: true });
|
|
1123
1140
|
await import_promises.default.rm(typesDirectory(ctx), { recursive: true, force: true });
|
|
1124
1141
|
await write(
|
|
1125
1142
|
generateFuture(ctx),
|
|
@@ -1159,10 +1176,58 @@ async function watch(rootDirectory, { mode, logger }) {
|
|
|
1159
1176
|
// vite/rsc/plugin.ts
|
|
1160
1177
|
var import_fs = require("fs");
|
|
1161
1178
|
var import_promises2 = require("fs/promises");
|
|
1162
|
-
var
|
|
1179
|
+
var import_pathe6 = __toESM(require("pathe"));
|
|
1163
1180
|
|
|
1164
|
-
// vite/
|
|
1181
|
+
// vite/has-dependency.ts
|
|
1182
|
+
function hasDependency({
|
|
1183
|
+
name,
|
|
1184
|
+
rootDirectory
|
|
1185
|
+
}) {
|
|
1186
|
+
try {
|
|
1187
|
+
return Boolean(require.resolve(name, { paths: [rootDirectory] }));
|
|
1188
|
+
} catch (err2) {
|
|
1189
|
+
return false;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
// vite/optimize-deps-entries.ts
|
|
1194
|
+
var import_tinyglobby = require("tinyglobby");
|
|
1195
|
+
|
|
1196
|
+
// vite/resolve-relative-route-file-path.ts
|
|
1165
1197
|
var import_pathe4 = __toESM(require("pathe"));
|
|
1198
|
+
function resolveRelativeRouteFilePath(route, reactRouterConfig) {
|
|
1199
|
+
let vite2 = getVite();
|
|
1200
|
+
let file = route.file;
|
|
1201
|
+
let fullPath = import_pathe4.default.resolve(reactRouterConfig.appDirectory, file);
|
|
1202
|
+
return vite2.normalizePath(fullPath);
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
// vite/optimize-deps-entries.ts
|
|
1206
|
+
function getOptimizeDepsEntries({
|
|
1207
|
+
entryClientFilePath,
|
|
1208
|
+
reactRouterConfig
|
|
1209
|
+
}) {
|
|
1210
|
+
if (!reactRouterConfig.future.unstable_optimizeDeps) {
|
|
1211
|
+
return [];
|
|
1212
|
+
}
|
|
1213
|
+
const vite2 = getVite();
|
|
1214
|
+
const viteMajorVersion = parseInt(vite2.version.split(".")[0], 10);
|
|
1215
|
+
return [
|
|
1216
|
+
vite2.normalizePath(entryClientFilePath),
|
|
1217
|
+
...Object.values(reactRouterConfig.routes).map(
|
|
1218
|
+
(route) => resolveRelativeRouteFilePath(route, reactRouterConfig)
|
|
1219
|
+
)
|
|
1220
|
+
].map(
|
|
1221
|
+
(entry) => (
|
|
1222
|
+
// In Vite 7, the `optimizeDeps.entries` option only accepts glob patterns.
|
|
1223
|
+
// In prior versions, absolute file paths were treated differently.
|
|
1224
|
+
viteMajorVersion >= 7 ? (0, import_tinyglobby.escapePath)(entry) : entry
|
|
1225
|
+
)
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// vite/rsc/virtual-route-config.ts
|
|
1230
|
+
var import_pathe5 = __toESM(require("pathe"));
|
|
1166
1231
|
function createVirtualRouteConfig({
|
|
1167
1232
|
appDirectory,
|
|
1168
1233
|
routeConfig
|
|
@@ -1181,11 +1246,11 @@ function createVirtualRouteConfig({
|
|
|
1181
1246
|
continue;
|
|
1182
1247
|
}
|
|
1183
1248
|
code += "{";
|
|
1184
|
-
const routeFile =
|
|
1249
|
+
const routeFile = import_pathe5.default.resolve(appDirectory, route.file);
|
|
1185
1250
|
const routeId = route.id || createRouteId2(route.file, appDirectory);
|
|
1186
1251
|
routeIdByFile.set(routeFile, routeId);
|
|
1187
1252
|
code += `lazy: () => import(${JSON.stringify(
|
|
1188
|
-
`${routeFile}?route-module
|
|
1253
|
+
`${routeFile}?route-module`
|
|
1189
1254
|
)}),`;
|
|
1190
1255
|
code += `id: ${JSON.stringify(routeId)},`;
|
|
1191
1256
|
if (typeof route.path === "string") {
|
|
@@ -1209,7 +1274,7 @@ function createVirtualRouteConfig({
|
|
|
1209
1274
|
return { code, routeIdByFile };
|
|
1210
1275
|
}
|
|
1211
1276
|
function createRouteId2(file, appDirectory) {
|
|
1212
|
-
return
|
|
1277
|
+
return import_pathe5.default.relative(appDirectory, file).replace(/\\+/, "/").slice(0, -import_pathe5.default.extname(file).length);
|
|
1213
1278
|
}
|
|
1214
1279
|
|
|
1215
1280
|
// vite/rsc/virtual-route-modules.ts
|
|
@@ -1223,10 +1288,10 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1223
1288
|
let markedForRemoval = /* @__PURE__ */ new Set();
|
|
1224
1289
|
let removedExportLocalNames = /* @__PURE__ */ new Set();
|
|
1225
1290
|
traverse(ast, {
|
|
1226
|
-
ExportDeclaration(
|
|
1227
|
-
if (
|
|
1228
|
-
if (
|
|
1229
|
-
|
|
1291
|
+
ExportDeclaration(path6) {
|
|
1292
|
+
if (path6.node.type === "ExportNamedDeclaration") {
|
|
1293
|
+
if (path6.node.specifiers.length) {
|
|
1294
|
+
path6.node.specifiers = path6.node.specifiers.filter((specifier) => {
|
|
1230
1295
|
if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier") {
|
|
1231
1296
|
if (exportsToRemove.includes(specifier.exported.name)) {
|
|
1232
1297
|
exportsFiltered = true;
|
|
@@ -1238,12 +1303,12 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1238
1303
|
}
|
|
1239
1304
|
return true;
|
|
1240
1305
|
});
|
|
1241
|
-
if (
|
|
1242
|
-
markedForRemoval.add(
|
|
1306
|
+
if (path6.node.specifiers.length === 0) {
|
|
1307
|
+
markedForRemoval.add(path6);
|
|
1243
1308
|
}
|
|
1244
1309
|
}
|
|
1245
|
-
if (
|
|
1246
|
-
let declaration =
|
|
1310
|
+
if (path6.node.declaration?.type === "VariableDeclaration") {
|
|
1311
|
+
let declaration = path6.node.declaration;
|
|
1247
1312
|
declaration.declarations = declaration.declarations.filter(
|
|
1248
1313
|
(declaration2) => {
|
|
1249
1314
|
if (declaration2.id.type === "Identifier" && exportsToRemove.includes(declaration2.id.name)) {
|
|
@@ -1257,30 +1322,30 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1257
1322
|
}
|
|
1258
1323
|
);
|
|
1259
1324
|
if (declaration.declarations.length === 0) {
|
|
1260
|
-
markedForRemoval.add(
|
|
1325
|
+
markedForRemoval.add(path6);
|
|
1261
1326
|
}
|
|
1262
1327
|
}
|
|
1263
|
-
if (
|
|
1264
|
-
let id =
|
|
1328
|
+
if (path6.node.declaration?.type === "FunctionDeclaration") {
|
|
1329
|
+
let id = path6.node.declaration.id;
|
|
1265
1330
|
if (id && exportsToRemove.includes(id.name)) {
|
|
1266
|
-
markedForRemoval.add(
|
|
1331
|
+
markedForRemoval.add(path6);
|
|
1267
1332
|
}
|
|
1268
1333
|
}
|
|
1269
|
-
if (
|
|
1270
|
-
let id =
|
|
1334
|
+
if (path6.node.declaration?.type === "ClassDeclaration") {
|
|
1335
|
+
let id = path6.node.declaration.id;
|
|
1271
1336
|
if (id && exportsToRemove.includes(id.name)) {
|
|
1272
|
-
markedForRemoval.add(
|
|
1337
|
+
markedForRemoval.add(path6);
|
|
1273
1338
|
}
|
|
1274
1339
|
}
|
|
1275
1340
|
}
|
|
1276
|
-
if (
|
|
1341
|
+
if (path6.node.type === "ExportDefaultDeclaration") {
|
|
1277
1342
|
if (exportsToRemove.includes("default")) {
|
|
1278
|
-
markedForRemoval.add(
|
|
1279
|
-
if (
|
|
1280
|
-
if (
|
|
1281
|
-
removedExportLocalNames.add(
|
|
1282
|
-
} else if ((
|
|
1283
|
-
removedExportLocalNames.add(
|
|
1343
|
+
markedForRemoval.add(path6);
|
|
1344
|
+
if (path6.node.declaration) {
|
|
1345
|
+
if (path6.node.declaration.type === "Identifier") {
|
|
1346
|
+
removedExportLocalNames.add(path6.node.declaration.name);
|
|
1347
|
+
} else if ((path6.node.declaration.type === "FunctionDeclaration" || path6.node.declaration.type === "ClassDeclaration") && path6.node.declaration.id) {
|
|
1348
|
+
removedExportLocalNames.add(path6.node.declaration.id.name);
|
|
1284
1349
|
}
|
|
1285
1350
|
}
|
|
1286
1351
|
}
|
|
@@ -1288,21 +1353,21 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1288
1353
|
}
|
|
1289
1354
|
});
|
|
1290
1355
|
traverse(ast, {
|
|
1291
|
-
ExpressionStatement(
|
|
1292
|
-
if (!
|
|
1356
|
+
ExpressionStatement(path6) {
|
|
1357
|
+
if (!path6.parentPath.isProgram()) {
|
|
1293
1358
|
return;
|
|
1294
1359
|
}
|
|
1295
|
-
if (
|
|
1296
|
-
const left =
|
|
1360
|
+
if (path6.node.expression.type === "AssignmentExpression") {
|
|
1361
|
+
const left = path6.node.expression.left;
|
|
1297
1362
|
if (left.type === "MemberExpression" && left.object.type === "Identifier" && (exportsToRemove.includes(left.object.name) || removedExportLocalNames.has(left.object.name))) {
|
|
1298
|
-
markedForRemoval.add(
|
|
1363
|
+
markedForRemoval.add(path6);
|
|
1299
1364
|
}
|
|
1300
1365
|
}
|
|
1301
1366
|
}
|
|
1302
1367
|
});
|
|
1303
1368
|
if (markedForRemoval.size > 0 || exportsFiltered) {
|
|
1304
|
-
for (let
|
|
1305
|
-
|
|
1369
|
+
for (let path6 of markedForRemoval) {
|
|
1370
|
+
path6.remove();
|
|
1306
1371
|
}
|
|
1307
1372
|
(0, import_babel_dead_code_elimination.deadCodeElimination)(ast, previouslyReferencedIdentifiers);
|
|
1308
1373
|
}
|
|
@@ -1421,26 +1486,38 @@ function transformVirtualRouteModules({
|
|
|
1421
1486
|
code,
|
|
1422
1487
|
viteCommand,
|
|
1423
1488
|
routeIdByFile,
|
|
1489
|
+
rootRouteFile,
|
|
1424
1490
|
viteEnvironment
|
|
1425
1491
|
}) {
|
|
1426
1492
|
if (isVirtualRouteModuleId(id) || routeIdByFile.has(id)) {
|
|
1427
1493
|
return createVirtualRouteModuleCode({
|
|
1428
1494
|
id,
|
|
1429
1495
|
code,
|
|
1496
|
+
rootRouteFile,
|
|
1430
1497
|
viteCommand,
|
|
1431
1498
|
viteEnvironment
|
|
1432
1499
|
});
|
|
1433
1500
|
}
|
|
1434
1501
|
if (isVirtualServerRouteModuleId(id)) {
|
|
1435
|
-
return createVirtualServerRouteModuleCode({
|
|
1502
|
+
return createVirtualServerRouteModuleCode({
|
|
1503
|
+
id,
|
|
1504
|
+
code,
|
|
1505
|
+
viteEnvironment
|
|
1506
|
+
});
|
|
1436
1507
|
}
|
|
1437
1508
|
if (isVirtualClientRouteModuleId(id)) {
|
|
1438
|
-
return createVirtualClientRouteModuleCode({
|
|
1509
|
+
return createVirtualClientRouteModuleCode({
|
|
1510
|
+
id,
|
|
1511
|
+
code,
|
|
1512
|
+
rootRouteFile,
|
|
1513
|
+
viteCommand
|
|
1514
|
+
});
|
|
1439
1515
|
}
|
|
1440
1516
|
}
|
|
1441
1517
|
async function createVirtualRouteModuleCode({
|
|
1442
1518
|
id,
|
|
1443
1519
|
code: routeSource,
|
|
1520
|
+
rootRouteFile,
|
|
1444
1521
|
viteCommand,
|
|
1445
1522
|
viteEnvironment
|
|
1446
1523
|
}) {
|
|
@@ -1500,7 +1577,7 @@ async function createVirtualRouteModuleCode({
|
|
|
1500
1577
|
}
|
|
1501
1578
|
}
|
|
1502
1579
|
}
|
|
1503
|
-
if (
|
|
1580
|
+
if (isRootRouteFile({ id, rootRouteFile }) && !staticExports.includes("ErrorBoundary")) {
|
|
1504
1581
|
code += `export { ErrorBoundary } from "${clientModuleId}";
|
|
1505
1582
|
`;
|
|
1506
1583
|
}
|
|
@@ -1544,6 +1621,7 @@ function createVirtualServerRouteModuleCode({
|
|
|
1544
1621
|
function createVirtualClientRouteModuleCode({
|
|
1545
1622
|
id,
|
|
1546
1623
|
code: routeSource,
|
|
1624
|
+
rootRouteFile,
|
|
1547
1625
|
viteCommand
|
|
1548
1626
|
}) {
|
|
1549
1627
|
const { staticExports, isServerFirstRoute, hasClientExports } = parseRouteExports(routeSource);
|
|
@@ -1554,7 +1632,7 @@ function createVirtualClientRouteModuleCode({
|
|
|
1554
1632
|
removeExports(clientRouteModuleAst, exportsToRemove);
|
|
1555
1633
|
const generatorResult = generate(clientRouteModuleAst);
|
|
1556
1634
|
generatorResult.code = '"use client";' + generatorResult.code;
|
|
1557
|
-
if (
|
|
1635
|
+
if (isRootRouteFile({ id, rootRouteFile }) && !staticExports.includes("ErrorBoundary")) {
|
|
1558
1636
|
const hasRootLayout = staticExports.includes("Layout");
|
|
1559
1637
|
generatorResult.code += `
|
|
1560
1638
|
import { createElement as __rr_createElement } from "react";
|
|
@@ -1589,13 +1667,10 @@ function parseRouteExports(code) {
|
|
|
1589
1667
|
};
|
|
1590
1668
|
}
|
|
1591
1669
|
function getVirtualClientModuleId(id) {
|
|
1592
|
-
return `${id.split("?")[0]}?client-route-module
|
|
1670
|
+
return `${id.split("?")[0]}?client-route-module`;
|
|
1593
1671
|
}
|
|
1594
1672
|
function getVirtualServerModuleId(id) {
|
|
1595
|
-
return `${id.split("?")[0]}?server-route-module
|
|
1596
|
-
}
|
|
1597
|
-
function isRootRouteId(id) {
|
|
1598
|
-
return /(\?|&)root-route=true(&|$)/.test(id);
|
|
1673
|
+
return `${id.split("?")[0]}?server-route-module`;
|
|
1599
1674
|
}
|
|
1600
1675
|
function isVirtualRouteModuleId(id) {
|
|
1601
1676
|
return /(\?|&)route-module(&|$)/.test(id);
|
|
@@ -1606,6 +1681,13 @@ function isVirtualClientRouteModuleId(id) {
|
|
|
1606
1681
|
function isVirtualServerRouteModuleId(id) {
|
|
1607
1682
|
return /(\?|&)server-route-module(&|$)/.test(id);
|
|
1608
1683
|
}
|
|
1684
|
+
function isRootRouteFile({
|
|
1685
|
+
id,
|
|
1686
|
+
rootRouteFile
|
|
1687
|
+
}) {
|
|
1688
|
+
const filePath = id.split("?")[0];
|
|
1689
|
+
return filePath === rootRouteFile;
|
|
1690
|
+
}
|
|
1609
1691
|
|
|
1610
1692
|
// vite/plugins/validate-plugin-order.ts
|
|
1611
1693
|
function validatePluginOrder() {
|
|
@@ -1618,16 +1700,57 @@ function validatePluginOrder() {
|
|
|
1618
1700
|
(plugin) => pluginName.includes(plugin.name)
|
|
1619
1701
|
);
|
|
1620
1702
|
};
|
|
1621
|
-
let
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1703
|
+
let reactRouterRscPluginIndex = pluginIndex("react-router/rsc");
|
|
1704
|
+
let viteRscPluginIndex = pluginIndex("rsc");
|
|
1705
|
+
if (reactRouterRscPluginIndex >= 0 && viteRscPluginIndex >= 0 && reactRouterRscPluginIndex > viteRscPluginIndex) {
|
|
1706
|
+
throw new Error(
|
|
1707
|
+
`The "@vitejs/plugin-rsc" plugin should be placed after the React Router RSC plugin in your Vite config`
|
|
1708
|
+
);
|
|
1709
|
+
}
|
|
1710
|
+
let reactRouterPluginIndex = pluginIndex([
|
|
1711
|
+
"react-router",
|
|
1712
|
+
"react-router/rsc"
|
|
1713
|
+
]);
|
|
1714
|
+
let mdxPluginIndex = pluginIndex("@mdx-js/rollup");
|
|
1715
|
+
if (mdxPluginIndex >= 0 && mdxPluginIndex > reactRouterPluginIndex) {
|
|
1716
|
+
throw new Error(
|
|
1717
|
+
`The "@mdx-js/rollup" plugin should be placed before the React Router plugin in your Vite config`
|
|
1718
|
+
);
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
// vite/plugins/warn-on-client-source-maps.ts
|
|
1725
|
+
var import_picocolors3 = __toESM(require("picocolors"));
|
|
1726
|
+
function warnOnClientSourceMaps() {
|
|
1727
|
+
let viteConfig;
|
|
1728
|
+
let viteCommand;
|
|
1729
|
+
let logged = false;
|
|
1730
|
+
return {
|
|
1731
|
+
name: "react-router:warn-on-client-source-maps",
|
|
1732
|
+
config(_, configEnv) {
|
|
1733
|
+
viteCommand = configEnv.command;
|
|
1734
|
+
},
|
|
1735
|
+
configResolved(config) {
|
|
1736
|
+
viteConfig = config;
|
|
1737
|
+
},
|
|
1738
|
+
buildStart() {
|
|
1739
|
+
invariant(viteConfig);
|
|
1740
|
+
if (!logged && viteCommand === "build" && viteConfig.mode === "production" && !viteConfig.build.ssr && (viteConfig.build.sourcemap || viteConfig.environments?.client?.build.sourcemap)) {
|
|
1741
|
+
viteConfig.logger.warn(
|
|
1742
|
+
import_picocolors3.default.yellow(
|
|
1743
|
+
"\n" + import_picocolors3.default.bold(" \u26A0\uFE0F Source maps are enabled in production\n") + [
|
|
1744
|
+
"This makes your server code publicly",
|
|
1745
|
+
"visible in the browser. This is highly",
|
|
1746
|
+
"discouraged! If you insist, ensure that",
|
|
1747
|
+
"you are using environment variables for",
|
|
1748
|
+
"secrets and not hard-coding them in",
|
|
1749
|
+
"your source code."
|
|
1750
|
+
].map((line) => " " + line).join("\n") + "\n"
|
|
1751
|
+
)
|
|
1752
|
+
);
|
|
1753
|
+
logged = true;
|
|
1631
1754
|
}
|
|
1632
1755
|
}
|
|
1633
1756
|
};
|
|
@@ -1640,18 +1763,56 @@ function reactRouterRSCVitePlugin() {
|
|
|
1640
1763
|
let typegenWatcherPromise;
|
|
1641
1764
|
let viteCommand;
|
|
1642
1765
|
let routeIdByFile;
|
|
1766
|
+
let logger;
|
|
1767
|
+
const defaultEntries = getDefaultEntries();
|
|
1643
1768
|
return [
|
|
1644
1769
|
{
|
|
1645
1770
|
name: "react-router/rsc",
|
|
1646
1771
|
async config(viteUserConfig, { command, mode }) {
|
|
1647
1772
|
await import_es_module_lexer2.init;
|
|
1773
|
+
await preloadVite();
|
|
1648
1774
|
viteCommand = command;
|
|
1649
1775
|
const rootDirectory = getRootDirectory(viteUserConfig);
|
|
1650
1776
|
const watch2 = command === "serve";
|
|
1651
|
-
configLoader = await createConfigLoader({
|
|
1777
|
+
configLoader = await createConfigLoader({
|
|
1778
|
+
rootDirectory,
|
|
1779
|
+
mode,
|
|
1780
|
+
watch: watch2,
|
|
1781
|
+
validateConfig: (userConfig) => {
|
|
1782
|
+
let errors = [];
|
|
1783
|
+
if (userConfig.buildEnd) errors.push("buildEnd");
|
|
1784
|
+
if (userConfig.prerender) errors.push("prerender");
|
|
1785
|
+
if (userConfig.presets?.length) errors.push("presets");
|
|
1786
|
+
if (userConfig.routeDiscovery) errors.push("routeDiscovery");
|
|
1787
|
+
if (userConfig.serverBundles) errors.push("serverBundles");
|
|
1788
|
+
if (userConfig.ssr === false) errors.push("ssr: false");
|
|
1789
|
+
if (userConfig.future?.unstable_splitRouteModules)
|
|
1790
|
+
errors.push("future.unstable_splitRouteModules");
|
|
1791
|
+
if (userConfig.future?.unstable_viteEnvironmentApi === false)
|
|
1792
|
+
errors.push("future.unstable_viteEnvironmentApi: false");
|
|
1793
|
+
if (userConfig.future?.v8_middleware === false)
|
|
1794
|
+
errors.push("future.v8_middleware: false");
|
|
1795
|
+
if (userConfig.future?.unstable_subResourceIntegrity)
|
|
1796
|
+
errors.push("future.unstable_subResourceIntegrity");
|
|
1797
|
+
if (errors.length) {
|
|
1798
|
+
return `RSC Framework Mode does not currently support the following React Router config:
|
|
1799
|
+
${errors.map((x) => ` - ${x}`).join("\n")}
|
|
1800
|
+
`;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
});
|
|
1652
1804
|
const configResult = await configLoader.getConfig();
|
|
1653
1805
|
if (!configResult.ok) throw new Error(configResult.error);
|
|
1654
1806
|
config = configResult.value;
|
|
1807
|
+
if (viteUserConfig.base && config.basename !== "/" && viteCommand === "serve" && !viteUserConfig.server?.middlewareMode && !config.basename.startsWith(viteUserConfig.base)) {
|
|
1808
|
+
throw new Error(
|
|
1809
|
+
"When using the React Router `basename` and the Vite `base` config, the `basename` config must begin with `base` for the default Vite dev server."
|
|
1810
|
+
);
|
|
1811
|
+
}
|
|
1812
|
+
const vite2 = await import("vite");
|
|
1813
|
+
logger = vite2.createLogger(viteUserConfig.logLevel, {
|
|
1814
|
+
prefix: "[react-router]"
|
|
1815
|
+
});
|
|
1655
1816
|
return {
|
|
1656
1817
|
resolve: {
|
|
1657
1818
|
dedupe: [
|
|
@@ -1662,10 +1823,14 @@ function reactRouterRSCVitePlugin() {
|
|
|
1662
1823
|
// You must render this element inside a <Remix> element`.
|
|
1663
1824
|
"react-router",
|
|
1664
1825
|
"react-router/dom",
|
|
1665
|
-
"react-router-dom"
|
|
1826
|
+
...hasDependency({ name: "react-router-dom", rootDirectory }) ? ["react-router-dom"] : []
|
|
1666
1827
|
]
|
|
1667
1828
|
},
|
|
1668
1829
|
optimizeDeps: {
|
|
1830
|
+
entries: getOptimizeDepsEntries({
|
|
1831
|
+
entryClientFilePath: defaultEntries.client,
|
|
1832
|
+
reactRouterConfig: config
|
|
1833
|
+
}),
|
|
1669
1834
|
esbuildOptions: {
|
|
1670
1835
|
jsx: "automatic"
|
|
1671
1836
|
},
|
|
@@ -1677,7 +1842,8 @@ function reactRouterRSCVitePlugin() {
|
|
|
1677
1842
|
"react/jsx-runtime",
|
|
1678
1843
|
"react/jsx-dev-runtime",
|
|
1679
1844
|
"react-dom",
|
|
1680
|
-
"react-dom/client"
|
|
1845
|
+
"react-dom/client",
|
|
1846
|
+
"react-router/internal/react-server-client"
|
|
1681
1847
|
]
|
|
1682
1848
|
},
|
|
1683
1849
|
esbuild: {
|
|
@@ -1687,17 +1853,47 @@ function reactRouterRSCVitePlugin() {
|
|
|
1687
1853
|
environments: {
|
|
1688
1854
|
client: {
|
|
1689
1855
|
build: {
|
|
1690
|
-
|
|
1856
|
+
rollupOptions: {
|
|
1857
|
+
input: {
|
|
1858
|
+
index: defaultEntries.client
|
|
1859
|
+
}
|
|
1860
|
+
},
|
|
1861
|
+
outDir: (0, import_pathe6.join)(config.buildDirectory, "client")
|
|
1691
1862
|
}
|
|
1692
1863
|
},
|
|
1693
1864
|
rsc: {
|
|
1694
1865
|
build: {
|
|
1695
|
-
|
|
1866
|
+
rollupOptions: {
|
|
1867
|
+
input: {
|
|
1868
|
+
// We use a virtual entry here so that consumers can import
|
|
1869
|
+
// it as `virtual:react-router/unstable_rsc/rsc-entry`
|
|
1870
|
+
// without needing to know the actual file path, which is
|
|
1871
|
+
// important when using the default entries.
|
|
1872
|
+
index: defaultEntries.rsc
|
|
1873
|
+
},
|
|
1874
|
+
output: {
|
|
1875
|
+
entryFileNames: config.serverBuildFile,
|
|
1876
|
+
format: config.serverModuleFormat
|
|
1877
|
+
}
|
|
1878
|
+
},
|
|
1879
|
+
outDir: (0, import_pathe6.join)(config.buildDirectory, "server")
|
|
1696
1880
|
}
|
|
1697
1881
|
},
|
|
1698
1882
|
ssr: {
|
|
1699
1883
|
build: {
|
|
1700
|
-
|
|
1884
|
+
rollupOptions: {
|
|
1885
|
+
input: {
|
|
1886
|
+
index: defaultEntries.ssr
|
|
1887
|
+
},
|
|
1888
|
+
output: {
|
|
1889
|
+
// Note: We don't set `entryFileNames` here because it's
|
|
1890
|
+
// considered private to the RSC environment build, and
|
|
1891
|
+
// @vitejs/plugin-rsc currently breaks if it's set to
|
|
1892
|
+
// something other than `index.js`.
|
|
1893
|
+
format: config.serverModuleFormat
|
|
1894
|
+
}
|
|
1895
|
+
},
|
|
1896
|
+
outDir: (0, import_pathe6.join)(config.buildDirectory, "server/__ssr_build")
|
|
1701
1897
|
}
|
|
1702
1898
|
}
|
|
1703
1899
|
},
|
|
@@ -1724,6 +1920,35 @@ function reactRouterRSCVitePlugin() {
|
|
|
1724
1920
|
}
|
|
1725
1921
|
};
|
|
1726
1922
|
},
|
|
1923
|
+
async configureServer(viteDevServer) {
|
|
1924
|
+
configLoader.onChange(
|
|
1925
|
+
async ({
|
|
1926
|
+
result,
|
|
1927
|
+
configCodeChanged,
|
|
1928
|
+
routeConfigCodeChanged,
|
|
1929
|
+
configChanged,
|
|
1930
|
+
routeConfigChanged
|
|
1931
|
+
}) => {
|
|
1932
|
+
if (!result.ok) {
|
|
1933
|
+
invalidateVirtualModules(viteDevServer);
|
|
1934
|
+
logger.error(result.error, {
|
|
1935
|
+
clear: true,
|
|
1936
|
+
timestamp: true
|
|
1937
|
+
});
|
|
1938
|
+
return;
|
|
1939
|
+
}
|
|
1940
|
+
let message = configChanged ? "Config changed." : routeConfigChanged ? "Route config changed." : configCodeChanged ? "Config saved." : routeConfigCodeChanged ? " Route config saved." : "Config saved";
|
|
1941
|
+
logger.info(import_picocolors4.default.green(message), {
|
|
1942
|
+
clear: true,
|
|
1943
|
+
timestamp: true
|
|
1944
|
+
});
|
|
1945
|
+
config = result.value;
|
|
1946
|
+
if (configChanged || routeConfigChanged) {
|
|
1947
|
+
invalidateVirtualModules(viteDevServer);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
);
|
|
1951
|
+
},
|
|
1727
1952
|
async buildEnd() {
|
|
1728
1953
|
await configLoader.close();
|
|
1729
1954
|
}
|
|
@@ -1737,6 +1962,7 @@ function reactRouterRSCVitePlugin() {
|
|
|
1737
1962
|
getRootDirectory(viteUserConfig),
|
|
1738
1963
|
{
|
|
1739
1964
|
mode,
|
|
1965
|
+
rsc: true,
|
|
1740
1966
|
// ignore `info` logs from typegen since they are
|
|
1741
1967
|
// redundant when Vite plugin logs are active
|
|
1742
1968
|
logger: vite2.createLogger("warn", {
|
|
@@ -1750,6 +1976,12 @@ function reactRouterRSCVitePlugin() {
|
|
|
1750
1976
|
(await typegenWatcherPromise)?.close();
|
|
1751
1977
|
}
|
|
1752
1978
|
},
|
|
1979
|
+
{
|
|
1980
|
+
name: "react-router/rsc/virtual-rsc-entry",
|
|
1981
|
+
resolveId(id) {
|
|
1982
|
+
if (id === virtual.rscEntry.id) return defaultEntries.rsc;
|
|
1983
|
+
}
|
|
1984
|
+
},
|
|
1753
1985
|
{
|
|
1754
1986
|
name: "react-router/rsc/virtual-route-config",
|
|
1755
1987
|
resolveId(id) {
|
|
@@ -1777,10 +2009,24 @@ function reactRouterRSCVitePlugin() {
|
|
|
1777
2009
|
id,
|
|
1778
2010
|
viteCommand,
|
|
1779
2011
|
routeIdByFile,
|
|
2012
|
+
rootRouteFile: config.unstable_rootRouteFile,
|
|
1780
2013
|
viteEnvironment: this.environment
|
|
1781
2014
|
});
|
|
1782
2015
|
}
|
|
1783
2016
|
},
|
|
2017
|
+
{
|
|
2018
|
+
name: "react-router/rsc/virtual-basename",
|
|
2019
|
+
resolveId(id) {
|
|
2020
|
+
if (id === virtual.basename.id) {
|
|
2021
|
+
return virtual.basename.resolvedId;
|
|
2022
|
+
}
|
|
2023
|
+
},
|
|
2024
|
+
load(id) {
|
|
2025
|
+
if (id === virtual.basename.resolvedId) {
|
|
2026
|
+
return `export default ${JSON.stringify(config.basename)};`;
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
},
|
|
1784
2030
|
{
|
|
1785
2031
|
name: "react-router/rsc/hmr/inject-runtime",
|
|
1786
2032
|
enforce: "pre",
|
|
@@ -1808,10 +2054,10 @@ function reactRouterRSCVitePlugin() {
|
|
|
1808
2054
|
},
|
|
1809
2055
|
async load(id) {
|
|
1810
2056
|
if (id !== virtual.hmrRuntime.resolvedId) return;
|
|
1811
|
-
const reactRefreshDir =
|
|
2057
|
+
const reactRefreshDir = import_pathe6.default.dirname(
|
|
1812
2058
|
require.resolve("react-refresh/package.json")
|
|
1813
2059
|
);
|
|
1814
|
-
const reactRefreshRuntimePath =
|
|
2060
|
+
const reactRefreshRuntimePath = import_pathe6.default.join(
|
|
1815
2061
|
reactRefreshDir,
|
|
1816
2062
|
"cjs/react-refresh-runtime.development.js"
|
|
1817
2063
|
);
|
|
@@ -1877,7 +2123,7 @@ function reactRouterRSCVitePlugin() {
|
|
|
1877
2123
|
);
|
|
1878
2124
|
for (const mod of getModulesWithImporters(modules)) {
|
|
1879
2125
|
if (!mod.file) continue;
|
|
1880
|
-
const normalizedPath =
|
|
2126
|
+
const normalizedPath = import_pathe6.default.normalize(mod.file);
|
|
1881
2127
|
const routeId = routeIdByFile?.get(normalizedPath);
|
|
1882
2128
|
if (routeId !== void 0) {
|
|
1883
2129
|
const routeSource = await (0, import_promises2.readFile)(normalizedPath, "utf8");
|
|
@@ -1908,44 +2154,56 @@ function reactRouterRSCVitePlugin() {
|
|
|
1908
2154
|
}
|
|
1909
2155
|
},
|
|
1910
2156
|
validatePluginOrder(),
|
|
1911
|
-
(
|
|
2157
|
+
warnOnClientSourceMaps()
|
|
1912
2158
|
];
|
|
1913
2159
|
}
|
|
1914
2160
|
var virtual = {
|
|
1915
2161
|
routeConfig: create("unstable_rsc/routes"),
|
|
1916
2162
|
injectHmrRuntime: create("unstable_rsc/inject-hmr-runtime"),
|
|
1917
|
-
hmrRuntime: create("unstable_rsc/runtime")
|
|
2163
|
+
hmrRuntime: create("unstable_rsc/runtime"),
|
|
2164
|
+
basename: create("unstable_rsc/basename"),
|
|
2165
|
+
rscEntry: create("unstable_rsc/rsc-entry")
|
|
1918
2166
|
};
|
|
2167
|
+
function invalidateVirtualModules(viteDevServer) {
|
|
2168
|
+
for (const vmod of Object.values(virtual)) {
|
|
2169
|
+
for (const env of Object.values(viteDevServer.environments)) {
|
|
2170
|
+
const mod = env.moduleGraph.getModuleById(vmod.resolvedId);
|
|
2171
|
+
if (mod) {
|
|
2172
|
+
env.moduleGraph.invalidateModule(mod);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
1919
2177
|
function getRootDirectory(viteUserConfig) {
|
|
1920
2178
|
return viteUserConfig.root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();
|
|
1921
2179
|
}
|
|
1922
|
-
function getRscEntries() {
|
|
1923
|
-
const entriesDir = (0, import_pathe5.join)(
|
|
1924
|
-
getDevPackageRoot(),
|
|
1925
|
-
"dist",
|
|
1926
|
-
"config",
|
|
1927
|
-
"default-rsc-entries"
|
|
1928
|
-
);
|
|
1929
|
-
return {
|
|
1930
|
-
client: (0, import_pathe5.join)(entriesDir, "entry.client.tsx"),
|
|
1931
|
-
rsc: (0, import_pathe5.join)(entriesDir, "entry.rsc.tsx"),
|
|
1932
|
-
ssr: (0, import_pathe5.join)(entriesDir, "entry.ssr.tsx")
|
|
1933
|
-
};
|
|
1934
|
-
}
|
|
1935
2180
|
function getDevPackageRoot() {
|
|
1936
|
-
const currentDir = (0,
|
|
2181
|
+
const currentDir = (0, import_pathe6.dirname)(__dirname);
|
|
1937
2182
|
let dir = currentDir;
|
|
1938
|
-
while (dir !== (0,
|
|
2183
|
+
while (dir !== (0, import_pathe6.dirname)(dir)) {
|
|
1939
2184
|
try {
|
|
1940
|
-
const packageJsonPath = (0,
|
|
2185
|
+
const packageJsonPath = (0, import_pathe6.join)(dir, "package.json");
|
|
1941
2186
|
(0, import_fs.readFileSync)(packageJsonPath, "utf-8");
|
|
1942
2187
|
return dir;
|
|
1943
2188
|
} catch {
|
|
1944
|
-
dir = (0,
|
|
2189
|
+
dir = (0, import_pathe6.dirname)(dir);
|
|
1945
2190
|
}
|
|
1946
2191
|
}
|
|
1947
2192
|
throw new Error("Could not find package.json");
|
|
1948
2193
|
}
|
|
2194
|
+
function getDefaultEntries() {
|
|
2195
|
+
const defaultEntriesDir = (0, import_pathe6.join)(
|
|
2196
|
+
getDevPackageRoot(),
|
|
2197
|
+
"dist",
|
|
2198
|
+
"config",
|
|
2199
|
+
"default-rsc-entries"
|
|
2200
|
+
);
|
|
2201
|
+
return {
|
|
2202
|
+
rsc: (0, import_pathe6.join)(defaultEntriesDir, "entry.rsc.tsx"),
|
|
2203
|
+
ssr: (0, import_pathe6.join)(defaultEntriesDir, "entry.ssr.tsx"),
|
|
2204
|
+
client: (0, import_pathe6.join)(defaultEntriesDir, "entry.client.tsx")
|
|
2205
|
+
};
|
|
2206
|
+
}
|
|
1949
2207
|
function getModulesWithImporters(modules) {
|
|
1950
2208
|
const visited = /* @__PURE__ */ new Set();
|
|
1951
2209
|
const result = /* @__PURE__ */ new Set();
|