@react-router/dev 0.0.0-experimental-5bbc45fb6 → 0.0.0-experimental-2d7ec82d5
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 +0 -19
- package/dist/cli/index.js +345 -643
- package/dist/config.d.ts +0 -27
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +89 -232
- package/dist/vite.js +487 -758
- package/package.json +6 -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-2d7ec82d5
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -47,7 +47,7 @@ module.exports = __toCommonJS(vite_exports);
|
|
|
47
47
|
// vite/plugin.ts
|
|
48
48
|
var import_node_crypto = require("crypto");
|
|
49
49
|
var fs3 = __toESM(require("fs"));
|
|
50
|
-
var
|
|
50
|
+
var path6 = __toESM(require("path"));
|
|
51
51
|
var url = __toESM(require("url"));
|
|
52
52
|
var fse = __toESM(require("fs-extra"));
|
|
53
53
|
var babel = __toESM(require("@babel/core"));
|
|
@@ -59,9 +59,10 @@ var import_picocolors3 = __toESM(require("picocolors"));
|
|
|
59
59
|
var import_kebabCase = __toESM(require("lodash/kebabCase"));
|
|
60
60
|
|
|
61
61
|
// typegen/index.ts
|
|
62
|
-
var
|
|
62
|
+
var import_node_fs2 = __toESM(require("fs"));
|
|
63
|
+
var import_dedent2 = __toESM(require("dedent"));
|
|
63
64
|
var Path4 = __toESM(require("pathe"));
|
|
64
|
-
var import_picocolors2 = require("picocolors");
|
|
65
|
+
var import_picocolors2 = __toESM(require("picocolors"));
|
|
65
66
|
|
|
66
67
|
// config/config.ts
|
|
67
68
|
var import_node_fs = __toESM(require("fs"));
|
|
@@ -135,15 +136,13 @@ var ssrExternals = isReactRouterRepo() ? [
|
|
|
135
136
|
// vite/vite-node.ts
|
|
136
137
|
async function createContext({
|
|
137
138
|
root,
|
|
138
|
-
mode
|
|
139
|
-
customLogger
|
|
139
|
+
mode
|
|
140
140
|
}) {
|
|
141
141
|
await preloadVite();
|
|
142
142
|
const vite2 = getVite();
|
|
143
143
|
const devServer = await vite2.createServer({
|
|
144
144
|
root,
|
|
145
145
|
mode,
|
|
146
|
-
customLogger,
|
|
147
146
|
server: {
|
|
148
147
|
preTransformRequests: false,
|
|
149
148
|
hmr: false,
|
|
@@ -155,15 +154,6 @@ async function createContext({
|
|
|
155
154
|
optimizeDeps: {
|
|
156
155
|
noDiscovery: true
|
|
157
156
|
},
|
|
158
|
-
css: {
|
|
159
|
-
// This empty PostCSS config object prevents the PostCSS config file from
|
|
160
|
-
// being loaded. We don't need it in a React Router config context, and
|
|
161
|
-
// there's also an issue in Vite 5 when using a .ts PostCSS config file in
|
|
162
|
-
// an ESM project: https://github.com/vitejs/vite/issues/15869. Consumers
|
|
163
|
-
// can work around this in their own Vite config file, but they can't
|
|
164
|
-
// configure this internal usage of vite-node.
|
|
165
|
-
postcss: {}
|
|
166
|
-
},
|
|
167
157
|
configFile: false,
|
|
168
158
|
envFile: false,
|
|
169
159
|
plugins: []
|
|
@@ -241,7 +231,7 @@ function validateRouteConfig({
|
|
|
241
231
|
`Route config in "${routeConfigFile}" is invalid.`,
|
|
242
232
|
root ? `${root}` : [],
|
|
243
233
|
nested ? Object.entries(nested).map(
|
|
244
|
-
([
|
|
234
|
+
([path7, message]) => `Path: routes.${path7}
|
|
245
235
|
${message}`
|
|
246
236
|
) : []
|
|
247
237
|
].flat().join("\n\n")
|
|
@@ -357,8 +347,7 @@ function err(error) {
|
|
|
357
347
|
async function resolveConfig({
|
|
358
348
|
root,
|
|
359
349
|
viteNodeContext,
|
|
360
|
-
reactRouterConfigFile
|
|
361
|
-
skipRoutes
|
|
350
|
+
reactRouterConfigFile
|
|
362
351
|
}) {
|
|
363
352
|
let reactRouterUserConfig = {};
|
|
364
353
|
if (reactRouterConfigFile) {
|
|
@@ -407,17 +396,12 @@ async function resolveConfig({
|
|
|
407
396
|
serverModuleFormat: "esm",
|
|
408
397
|
ssr: true
|
|
409
398
|
};
|
|
410
|
-
let userAndPresetConfigs = mergeReactRouterConfig(
|
|
411
|
-
...presets,
|
|
412
|
-
reactRouterUserConfig
|
|
413
|
-
);
|
|
414
399
|
let {
|
|
415
400
|
appDirectory: userAppDirectory,
|
|
416
|
-
basename:
|
|
401
|
+
basename: basename2,
|
|
417
402
|
buildDirectory: userBuildDirectory,
|
|
418
403
|
buildEnd,
|
|
419
404
|
prerender,
|
|
420
|
-
routeDiscovery: userRouteDiscovery,
|
|
421
405
|
serverBuildFile,
|
|
422
406
|
serverBundles,
|
|
423
407
|
serverModuleFormat,
|
|
@@ -425,7 +409,7 @@ async function resolveConfig({
|
|
|
425
409
|
} = {
|
|
426
410
|
...defaults,
|
|
427
411
|
// Default values should be completely overridden by user/preset config, not merged
|
|
428
|
-
...
|
|
412
|
+
...mergeReactRouterConfig(...presets, reactRouterUserConfig)
|
|
429
413
|
};
|
|
430
414
|
if (!ssr && serverBundles) {
|
|
431
415
|
serverBundles = void 0;
|
|
@@ -436,32 +420,6 @@ async function resolveConfig({
|
|
|
436
420
|
"The `prerender` config must be a boolean, an array of string paths, or a function returning a boolean or array of string paths"
|
|
437
421
|
);
|
|
438
422
|
}
|
|
439
|
-
let routeDiscovery;
|
|
440
|
-
if (userRouteDiscovery == null) {
|
|
441
|
-
if (ssr) {
|
|
442
|
-
routeDiscovery = {
|
|
443
|
-
mode: "lazy",
|
|
444
|
-
manifestPath: "/__manifest"
|
|
445
|
-
};
|
|
446
|
-
} else {
|
|
447
|
-
routeDiscovery = { mode: "initial" };
|
|
448
|
-
}
|
|
449
|
-
} else if (userRouteDiscovery.mode === "initial") {
|
|
450
|
-
routeDiscovery = userRouteDiscovery;
|
|
451
|
-
} else if (userRouteDiscovery.mode === "lazy") {
|
|
452
|
-
if (!ssr) {
|
|
453
|
-
return err(
|
|
454
|
-
'The `routeDiscovery.mode` config cannot be set to "lazy" when setting `ssr:false`'
|
|
455
|
-
);
|
|
456
|
-
}
|
|
457
|
-
let { manifestPath } = userRouteDiscovery;
|
|
458
|
-
if (manifestPath != null && !manifestPath.startsWith("/")) {
|
|
459
|
-
return err(
|
|
460
|
-
'The `routeDiscovery.manifestPath` config must be a root-relative pathname beginning with a slash (i.e., "/__manifest")'
|
|
461
|
-
);
|
|
462
|
-
}
|
|
463
|
-
routeDiscovery = userRouteDiscovery;
|
|
464
|
-
}
|
|
465
423
|
let appDirectory = import_pathe3.default.resolve(root, userAppDirectory || "app");
|
|
466
424
|
let buildDirectory = import_pathe3.default.resolve(root, userBuildDirectory);
|
|
467
425
|
let rootRouteFile = findEntry(appDirectory, "root");
|
|
@@ -474,50 +432,45 @@ async function resolveConfig({
|
|
|
474
432
|
`Could not find a root route module in the app directory as "${rootRouteDisplayPath}"`
|
|
475
433
|
);
|
|
476
434
|
}
|
|
477
|
-
let routes = {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
root,
|
|
487
|
-
import_pathe3.default.join(appDirectory, "routes.ts")
|
|
488
|
-
);
|
|
489
|
-
return err(
|
|
490
|
-
`Route config file not found at "${routeConfigDisplayPath}".`
|
|
491
|
-
);
|
|
492
|
-
}
|
|
493
|
-
setAppDirectory(appDirectory);
|
|
494
|
-
let routeConfigExport = (await viteNodeContext.runner.executeFile(
|
|
495
|
-
import_pathe3.default.join(appDirectory, routeConfigFile)
|
|
496
|
-
)).default;
|
|
497
|
-
let routeConfig = await routeConfigExport;
|
|
498
|
-
let result = validateRouteConfig({
|
|
499
|
-
routeConfigFile,
|
|
500
|
-
routeConfig
|
|
501
|
-
});
|
|
502
|
-
if (!result.valid) {
|
|
503
|
-
return err(result.message);
|
|
504
|
-
}
|
|
505
|
-
routes = {
|
|
506
|
-
...routes,
|
|
507
|
-
...configRoutesToRouteManifest(appDirectory, routeConfig)
|
|
508
|
-
};
|
|
509
|
-
} catch (error) {
|
|
510
|
-
return err(
|
|
511
|
-
[
|
|
512
|
-
import_picocolors.default.red(`Route config in "${routeConfigFile}" is invalid.`),
|
|
513
|
-
"",
|
|
514
|
-
error.loc?.file && error.loc?.column && error.frame ? [
|
|
515
|
-
import_pathe3.default.relative(appDirectory, error.loc.file) + ":" + error.loc.line + ":" + error.loc.column,
|
|
516
|
-
error.frame.trim?.()
|
|
517
|
-
] : error.stack
|
|
518
|
-
].flat().join("\n")
|
|
435
|
+
let routes = {
|
|
436
|
+
root: { path: "", id: "root", file: rootRouteFile }
|
|
437
|
+
};
|
|
438
|
+
let routeConfigFile = findEntry(appDirectory, "routes");
|
|
439
|
+
try {
|
|
440
|
+
if (!routeConfigFile) {
|
|
441
|
+
let routeConfigDisplayPath = import_pathe3.default.relative(
|
|
442
|
+
root,
|
|
443
|
+
import_pathe3.default.join(appDirectory, "routes.ts")
|
|
519
444
|
);
|
|
445
|
+
return err(`Route config file not found at "${routeConfigDisplayPath}".`);
|
|
520
446
|
}
|
|
447
|
+
setAppDirectory(appDirectory);
|
|
448
|
+
let routeConfigExport = (await viteNodeContext.runner.executeFile(
|
|
449
|
+
import_pathe3.default.join(appDirectory, routeConfigFile)
|
|
450
|
+
)).default;
|
|
451
|
+
let routeConfig = await routeConfigExport;
|
|
452
|
+
let result = validateRouteConfig({
|
|
453
|
+
routeConfigFile,
|
|
454
|
+
routeConfig
|
|
455
|
+
});
|
|
456
|
+
if (!result.valid) {
|
|
457
|
+
return err(result.message);
|
|
458
|
+
}
|
|
459
|
+
routes = {
|
|
460
|
+
...routes,
|
|
461
|
+
...configRoutesToRouteManifest(appDirectory, routeConfig)
|
|
462
|
+
};
|
|
463
|
+
} catch (error) {
|
|
464
|
+
return err(
|
|
465
|
+
[
|
|
466
|
+
import_picocolors.default.red(`Route config in "${routeConfigFile}" is invalid.`),
|
|
467
|
+
"",
|
|
468
|
+
error.loc?.file && error.loc?.column && error.frame ? [
|
|
469
|
+
import_pathe3.default.relative(appDirectory, error.loc.file) + ":" + error.loc.line + ":" + error.loc.column,
|
|
470
|
+
error.frame.trim?.()
|
|
471
|
+
] : error.stack
|
|
472
|
+
].flat().join("\n")
|
|
473
|
+
);
|
|
521
474
|
}
|
|
522
475
|
let future = {
|
|
523
476
|
unstable_middleware: reactRouterUserConfig.future?.unstable_middleware ?? false,
|
|
@@ -528,13 +481,12 @@ async function resolveConfig({
|
|
|
528
481
|
};
|
|
529
482
|
let reactRouterConfig = deepFreeze({
|
|
530
483
|
appDirectory,
|
|
531
|
-
basename:
|
|
484
|
+
basename: basename2,
|
|
532
485
|
buildDirectory,
|
|
533
486
|
buildEnd,
|
|
534
487
|
future,
|
|
535
488
|
prerender,
|
|
536
489
|
routes,
|
|
537
|
-
routeDiscovery,
|
|
538
490
|
serverBuildFile,
|
|
539
491
|
serverBundles,
|
|
540
492
|
serverModuleFormat,
|
|
@@ -547,35 +499,24 @@ async function resolveConfig({
|
|
|
547
499
|
}
|
|
548
500
|
async function createConfigLoader({
|
|
549
501
|
rootDirectory: root,
|
|
550
|
-
watch: watch2
|
|
551
|
-
mode,
|
|
552
|
-
skipRoutes
|
|
502
|
+
watch: watch2
|
|
553
503
|
}) {
|
|
554
|
-
root =
|
|
555
|
-
let vite2 = await import("vite");
|
|
504
|
+
root = root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();
|
|
556
505
|
let viteNodeContext = await createContext({
|
|
557
506
|
root,
|
|
558
|
-
mode
|
|
559
|
-
// Filter out any info level logs from vite-node
|
|
560
|
-
customLogger: vite2.createLogger("warn", {
|
|
561
|
-
prefix: "[react-router]"
|
|
562
|
-
})
|
|
507
|
+
mode: watch2 ? "development" : "production"
|
|
563
508
|
});
|
|
564
|
-
let reactRouterConfigFile
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
});
|
|
569
|
-
};
|
|
570
|
-
updateReactRouterConfigFile();
|
|
571
|
-
let getConfig = () => resolveConfig({ root, viteNodeContext, reactRouterConfigFile, skipRoutes });
|
|
509
|
+
let reactRouterConfigFile = findEntry(root, "react-router.config", {
|
|
510
|
+
absolute: true
|
|
511
|
+
});
|
|
512
|
+
let getConfig = () => resolveConfig({ root, viteNodeContext, reactRouterConfigFile });
|
|
572
513
|
let appDirectory;
|
|
573
514
|
let initialConfigResult = await getConfig();
|
|
574
515
|
if (!initialConfigResult.ok) {
|
|
575
516
|
throw new Error(initialConfigResult.error);
|
|
576
517
|
}
|
|
577
|
-
appDirectory =
|
|
578
|
-
let
|
|
518
|
+
appDirectory = initialConfigResult.value.appDirectory;
|
|
519
|
+
let lastConfig = initialConfigResult.value;
|
|
579
520
|
let fsWatcher;
|
|
580
521
|
let changeHandlers = [];
|
|
581
522
|
return {
|
|
@@ -588,71 +529,41 @@ async function createConfigLoader({
|
|
|
588
529
|
}
|
|
589
530
|
changeHandlers.push(handler);
|
|
590
531
|
if (!fsWatcher) {
|
|
591
|
-
fsWatcher = import_chokidar.default.watch(
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
dirname4 !== root;
|
|
599
|
-
}
|
|
600
|
-
});
|
|
532
|
+
fsWatcher = import_chokidar.default.watch(
|
|
533
|
+
[
|
|
534
|
+
...reactRouterConfigFile ? [reactRouterConfigFile] : [],
|
|
535
|
+
appDirectory
|
|
536
|
+
],
|
|
537
|
+
{ ignoreInitial: true }
|
|
538
|
+
);
|
|
601
539
|
fsWatcher.on("all", async (...args) => {
|
|
602
540
|
let [event, rawFilepath] = args;
|
|
603
541
|
let filepath = import_pathe3.default.normalize(rawFilepath);
|
|
604
|
-
let
|
|
605
|
-
let
|
|
606
|
-
let rootRelativeFilepath = import_pathe3.default.relative(root, filepath);
|
|
607
|
-
let configFileAddedOrRemoved = fileAddedOrRemoved && isEntryFile("react-router.config", rootRelativeFilepath);
|
|
608
|
-
if (configFileAddedOrRemoved) {
|
|
609
|
-
updateReactRouterConfigFile();
|
|
610
|
-
}
|
|
611
|
-
let moduleGraphChanged = configFileAddedOrRemoved || Boolean(
|
|
542
|
+
let appFileAddedOrRemoved = appDirectory && (event === "add" || event === "unlink") && filepath.startsWith(import_pathe3.default.normalize(appDirectory));
|
|
543
|
+
let configCodeUpdated = Boolean(
|
|
612
544
|
viteNodeContext.devServer?.moduleGraph.getModuleById(filepath)
|
|
613
545
|
);
|
|
614
|
-
if (
|
|
615
|
-
|
|
546
|
+
if (configCodeUpdated || appFileAddedOrRemoved) {
|
|
547
|
+
viteNodeContext.devServer?.moduleGraph.invalidateAll();
|
|
548
|
+
viteNodeContext.runner?.moduleCache.clear();
|
|
616
549
|
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
absolute: true
|
|
635
|
-
}) : void 0;
|
|
636
|
-
let routeConfigCodeChanged = routeConfigFile !== void 0 && isEntryFileDependency(
|
|
637
|
-
viteNodeContext.devServer.moduleGraph,
|
|
638
|
-
routeConfigFile,
|
|
639
|
-
filepath
|
|
640
|
-
);
|
|
641
|
-
let configChanged = result.ok && !(0, import_isEqual.default)(omitRoutes(currentConfig), omitRoutes(result.value));
|
|
642
|
-
let routeConfigChanged = result.ok && !(0, import_isEqual.default)(currentConfig?.routes, result.value.routes);
|
|
643
|
-
for (let handler2 of changeHandlers) {
|
|
644
|
-
handler2({
|
|
645
|
-
result,
|
|
646
|
-
configCodeChanged,
|
|
647
|
-
routeConfigCodeChanged,
|
|
648
|
-
configChanged,
|
|
649
|
-
routeConfigChanged,
|
|
650
|
-
path: filepath,
|
|
651
|
-
event
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
if (result.ok) {
|
|
655
|
-
currentConfig = result.value;
|
|
550
|
+
if (appFileAddedOrRemoved || configCodeUpdated) {
|
|
551
|
+
let result = await getConfig();
|
|
552
|
+
let configChanged = result.ok && !(0, import_isEqual.default)(lastConfig, result.value);
|
|
553
|
+
let routeConfigChanged = result.ok && !(0, import_isEqual.default)(lastConfig?.routes, result.value.routes);
|
|
554
|
+
for (let handler2 of changeHandlers) {
|
|
555
|
+
handler2({
|
|
556
|
+
result,
|
|
557
|
+
configCodeUpdated,
|
|
558
|
+
configChanged,
|
|
559
|
+
routeConfigChanged,
|
|
560
|
+
path: filepath,
|
|
561
|
+
event
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
if (result.ok) {
|
|
565
|
+
lastConfig = result.value;
|
|
566
|
+
}
|
|
656
567
|
}
|
|
657
568
|
});
|
|
658
569
|
}
|
|
@@ -684,18 +595,7 @@ async function resolveEntryFiles({
|
|
|
684
595
|
let userEntryServerFile = findEntry(appDirectory, "entry.server");
|
|
685
596
|
let entryServerFile;
|
|
686
597
|
let entryClientFile = userEntryClientFile || "entry.client.tsx";
|
|
687
|
-
let
|
|
688
|
-
extensions: [".json"],
|
|
689
|
-
absolute: true,
|
|
690
|
-
walkParents: true
|
|
691
|
-
});
|
|
692
|
-
if (!packageJsonPath) {
|
|
693
|
-
throw new Error(
|
|
694
|
-
`Could not find package.json in ${rootDirectory} or any of its parent directories`
|
|
695
|
-
);
|
|
696
|
-
}
|
|
697
|
-
let packageJsonDirectory = import_pathe3.default.dirname(packageJsonPath);
|
|
698
|
-
let pkgJson = await import_package_json.default.load(packageJsonDirectory);
|
|
598
|
+
let pkgJson = await import_package_json.default.load(rootDirectory);
|
|
699
599
|
let deps = pkgJson.content.dependencies ?? {};
|
|
700
600
|
if (userEntryServerFile) {
|
|
701
601
|
entryServerFile = userEntryServerFile;
|
|
@@ -718,7 +618,7 @@ async function resolveEntryFiles({
|
|
|
718
618
|
await pkgJson.save();
|
|
719
619
|
let packageManager = detectPackageManager() ?? "npm";
|
|
720
620
|
(0, import_node_child_process.execSync)(`${packageManager} install`, {
|
|
721
|
-
cwd:
|
|
621
|
+
cwd: rootDirectory,
|
|
722
622
|
stdio: "inherit"
|
|
723
623
|
});
|
|
724
624
|
}
|
|
@@ -728,85 +628,17 @@ async function resolveEntryFiles({
|
|
|
728
628
|
let entryServerFilePath = userEntryServerFile ? import_pathe3.default.resolve(reactRouterConfig.appDirectory, userEntryServerFile) : import_pathe3.default.resolve(defaultsDirectory, entryServerFile);
|
|
729
629
|
return { entryClientFilePath, entryServerFilePath };
|
|
730
630
|
}
|
|
731
|
-
function omitRoutes(config) {
|
|
732
|
-
return {
|
|
733
|
-
...config,
|
|
734
|
-
routes: {}
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
631
|
var entryExts = [".js", ".jsx", ".ts", ".tsx"];
|
|
738
|
-
function
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
let { root } = import_pathe3.default.parse(currentDir);
|
|
744
|
-
while (true) {
|
|
745
|
-
for (let ext of options?.extensions ?? entryExts) {
|
|
746
|
-
let file = import_pathe3.default.resolve(currentDir, basename3 + ext);
|
|
747
|
-
if (import_node_fs.default.existsSync(file)) {
|
|
748
|
-
return options?.absolute ?? false ? file : import_pathe3.default.relative(dir, file);
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
if (!options?.walkParents) {
|
|
752
|
-
return void 0;
|
|
753
|
-
}
|
|
754
|
-
let parentDir = import_pathe3.default.dirname(currentDir);
|
|
755
|
-
if (currentDir === root || parentDir === currentDir) {
|
|
756
|
-
return void 0;
|
|
757
|
-
}
|
|
758
|
-
currentDir = parentDir;
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
function isEntryFileDependency(moduleGraph, entryFilepath, filepath, visited = /* @__PURE__ */ new Set()) {
|
|
762
|
-
entryFilepath = import_pathe3.default.normalize(entryFilepath);
|
|
763
|
-
filepath = import_pathe3.default.normalize(filepath);
|
|
764
|
-
if (visited.has(filepath)) {
|
|
765
|
-
return false;
|
|
766
|
-
}
|
|
767
|
-
visited.add(filepath);
|
|
768
|
-
if (filepath === entryFilepath) {
|
|
769
|
-
return true;
|
|
770
|
-
}
|
|
771
|
-
let mod = moduleGraph.getModuleById(filepath);
|
|
772
|
-
if (!mod) {
|
|
773
|
-
return false;
|
|
774
|
-
}
|
|
775
|
-
for (let importer of mod.importers) {
|
|
776
|
-
if (!importer.id) {
|
|
777
|
-
continue;
|
|
778
|
-
}
|
|
779
|
-
if (importer.id === entryFilepath || isEntryFileDependency(moduleGraph, entryFilepath, importer.id, visited)) {
|
|
780
|
-
return true;
|
|
632
|
+
function findEntry(dir, basename2, options) {
|
|
633
|
+
for (let ext of entryExts) {
|
|
634
|
+
let file = import_pathe3.default.resolve(dir, basename2 + ext);
|
|
635
|
+
if (import_node_fs.default.existsSync(file)) {
|
|
636
|
+
return options?.absolute ?? false ? file : import_pathe3.default.relative(dir, file);
|
|
781
637
|
}
|
|
782
638
|
}
|
|
783
|
-
return
|
|
639
|
+
return void 0;
|
|
784
640
|
}
|
|
785
641
|
|
|
786
|
-
// typegen/context.ts
|
|
787
|
-
async function createContext2({
|
|
788
|
-
rootDirectory,
|
|
789
|
-
watch: watch2,
|
|
790
|
-
mode
|
|
791
|
-
}) {
|
|
792
|
-
const configLoader = await createConfigLoader({ rootDirectory, mode, watch: watch2 });
|
|
793
|
-
const configResult = await configLoader.getConfig();
|
|
794
|
-
if (!configResult.ok) {
|
|
795
|
-
throw new Error(configResult.error);
|
|
796
|
-
}
|
|
797
|
-
const config = configResult.value;
|
|
798
|
-
return {
|
|
799
|
-
configLoader,
|
|
800
|
-
rootDirectory,
|
|
801
|
-
config
|
|
802
|
-
};
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
// typegen/generate.ts
|
|
806
|
-
var import_dedent = __toESM(require("dedent"));
|
|
807
|
-
var Path3 = __toESM(require("pathe"));
|
|
808
|
-
var Pathe = __toESM(require("pathe/utils"));
|
|
809
|
-
|
|
810
642
|
// vite/babel.ts
|
|
811
643
|
var babel_exports = {};
|
|
812
644
|
__export(babel_exports, {
|
|
@@ -820,6 +652,26 @@ var t = __toESM(require("@babel/types"));
|
|
|
820
652
|
var traverse = require("@babel/traverse").default;
|
|
821
653
|
var generate = require("@babel/generator").default;
|
|
822
654
|
|
|
655
|
+
// typegen/generate.ts
|
|
656
|
+
var import_dedent = __toESM(require("dedent"));
|
|
657
|
+
var Path3 = __toESM(require("pathe"));
|
|
658
|
+
var Pathe2 = __toESM(require("pathe/utils"));
|
|
659
|
+
|
|
660
|
+
// typegen/paths.ts
|
|
661
|
+
var Path2 = __toESM(require("pathe"));
|
|
662
|
+
var Pathe = __toESM(require("pathe/utils"));
|
|
663
|
+
function getTypesDir(ctx) {
|
|
664
|
+
return Path2.join(ctx.rootDirectory, ".react-router/types");
|
|
665
|
+
}
|
|
666
|
+
function getTypesPath(ctx, route) {
|
|
667
|
+
return Path2.join(
|
|
668
|
+
getTypesDir(ctx),
|
|
669
|
+
Path2.relative(ctx.rootDirectory, ctx.config.appDirectory),
|
|
670
|
+
Path2.dirname(route.file),
|
|
671
|
+
"+types/" + Pathe.filename(route.file) + ".ts"
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
|
|
823
675
|
// typegen/params.ts
|
|
824
676
|
function parse2(fullpath2) {
|
|
825
677
|
const result = {};
|
|
@@ -850,326 +702,194 @@ function lineage(routes, route) {
|
|
|
850
702
|
}
|
|
851
703
|
function fullpath(lineage2) {
|
|
852
704
|
if (lineage2.length === 1 && lineage2[0].id === "root") return "/";
|
|
853
|
-
return "/" + lineage2.map((route) => route.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((
|
|
705
|
+
return "/" + lineage2.map((route) => route.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path7) => path7 !== void 0 && path7 !== "").join("/");
|
|
854
706
|
}
|
|
855
707
|
|
|
856
708
|
// typegen/generate.ts
|
|
857
|
-
function
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
const
|
|
862
|
-
const
|
|
863
|
-
|
|
709
|
+
function generate2(ctx, route) {
|
|
710
|
+
const lineage2 = lineage(ctx.config.routes, route);
|
|
711
|
+
const fullpath2 = fullpath(lineage2);
|
|
712
|
+
const typesPath = getTypesPath(ctx, route);
|
|
713
|
+
const parents = lineage2.slice(0, -1);
|
|
714
|
+
const parentTypeImports = parents.map((parent, i) => {
|
|
715
|
+
const rel = Path3.relative(
|
|
716
|
+
Path3.dirname(typesPath),
|
|
717
|
+
getTypesPath(ctx, parent)
|
|
718
|
+
);
|
|
719
|
+
const indent = i === 0 ? "" : " ".repeat(2);
|
|
720
|
+
let source = noExtension(rel);
|
|
721
|
+
if (!source.startsWith("../")) source = "./" + source;
|
|
722
|
+
return `${indent}import type { Info as Parent${i} } from "${source}.js"`;
|
|
723
|
+
}).join("\n");
|
|
724
|
+
return import_dedent.default`
|
|
725
|
+
// React Router generated types for route:
|
|
726
|
+
// ${route.file}
|
|
864
727
|
|
|
865
|
-
import "react-router"
|
|
728
|
+
import type * as T from "react-router/route-module"
|
|
866
729
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
730
|
+
${parentTypeImports}
|
|
731
|
+
|
|
732
|
+
type Module = typeof import("../${Pathe2.filename(route.file)}.js")
|
|
733
|
+
|
|
734
|
+
export type Info = {
|
|
735
|
+
parents: [${parents.map((_, i) => `Parent${i}`).join(", ")}],
|
|
736
|
+
id: "${route.id}"
|
|
737
|
+
file: "${route.file}"
|
|
738
|
+
path: "${route.path}"
|
|
739
|
+
params: {${formatParamProperties(
|
|
740
|
+
fullpath2
|
|
741
|
+
)}} & { [key: string]: string | undefined }
|
|
742
|
+
module: Module
|
|
743
|
+
loaderData: T.CreateLoaderData<Module>
|
|
744
|
+
actionData: T.CreateActionData<Module>
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
export namespace Route {
|
|
748
|
+
export type LinkDescriptors = T.LinkDescriptors
|
|
749
|
+
export type LinksFunction = () => LinkDescriptors
|
|
750
|
+
|
|
751
|
+
export type MetaArgs = T.CreateMetaArgs<Info>
|
|
752
|
+
export type MetaDescriptors = T.MetaDescriptors
|
|
753
|
+
export type MetaFunction = (args: MetaArgs) => MetaDescriptors
|
|
754
|
+
|
|
755
|
+
export type HeadersArgs = T.HeadersArgs
|
|
756
|
+
export type HeadersFunction = (args: HeadersArgs) => Headers | HeadersInit
|
|
757
|
+
|
|
758
|
+
export type unstable_MiddlewareFunction = T.CreateServerMiddlewareFunction<Info>
|
|
759
|
+
export type unstable_ClientMiddlewareFunction = T.CreateClientMiddlewareFunction<Info>
|
|
760
|
+
export type LoaderArgs = T.CreateServerLoaderArgs<Info>
|
|
761
|
+
export type ClientLoaderArgs = T.CreateClientLoaderArgs<Info>
|
|
762
|
+
export type ActionArgs = T.CreateServerActionArgs<Info>
|
|
763
|
+
export type ClientActionArgs = T.CreateClientActionArgs<Info>
|
|
764
|
+
|
|
765
|
+
export type HydrateFallbackProps = T.CreateHydrateFallbackProps<Info>
|
|
766
|
+
export type ComponentProps = T.CreateComponentProps<Info>
|
|
767
|
+
export type ErrorBoundaryProps = T.CreateErrorBoundaryProps<Info>
|
|
871
768
|
}
|
|
872
769
|
`;
|
|
873
|
-
return { filename: filename2, content };
|
|
874
770
|
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
const
|
|
878
|
-
|
|
771
|
+
var noExtension = (path7) => Path3.join(Path3.dirname(path7), Pathe2.filename(path7));
|
|
772
|
+
function formatParamProperties(fullpath2) {
|
|
773
|
+
const params = parse2(fullpath2);
|
|
774
|
+
const properties = Object.entries(params).map(
|
|
775
|
+
([name, isRequired]) => isRequired ? `"${name}": string` : `"${name}"?: string`
|
|
776
|
+
);
|
|
777
|
+
return properties.join("; ");
|
|
778
|
+
}
|
|
879
779
|
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
export const publicPath: ServerBuild["publicPath"];
|
|
890
|
-
export const routeDiscovery: ServerBuild["routeDiscovery"];
|
|
891
|
-
export const routes: ServerBuild["routes"];
|
|
892
|
-
export const ssr: ServerBuild["ssr"];
|
|
893
|
-
export const unstable_getCriticalCss: ServerBuild["unstable_getCriticalCss"];
|
|
780
|
+
// typegen/index.ts
|
|
781
|
+
async function watch(rootDirectory, { logger } = {}) {
|
|
782
|
+
const ctx = await createContext2({ rootDirectory, watch: true });
|
|
783
|
+
await writeAll(ctx);
|
|
784
|
+
logger?.info(import_picocolors2.default.green("generated types"), { timestamp: true, clear: true });
|
|
785
|
+
ctx.configLoader.onChange(async ({ result, routeConfigChanged }) => {
|
|
786
|
+
if (!result.ok) {
|
|
787
|
+
logger?.error(import_picocolors2.default.red(result.error), { timestamp: true, clear: true });
|
|
788
|
+
return;
|
|
894
789
|
}
|
|
895
|
-
|
|
896
|
-
|
|
790
|
+
ctx.config = result.value;
|
|
791
|
+
if (routeConfigChanged) {
|
|
792
|
+
await writeAll(ctx);
|
|
793
|
+
logger?.info(import_picocolors2.default.green("regenerated types"), {
|
|
794
|
+
timestamp: true,
|
|
795
|
+
clear: true
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
});
|
|
799
|
+
return {
|
|
800
|
+
close: async () => await ctx.configLoader.close()
|
|
801
|
+
};
|
|
897
802
|
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
803
|
+
async function createContext2({
|
|
804
|
+
rootDirectory,
|
|
805
|
+
watch: watch2
|
|
806
|
+
}) {
|
|
807
|
+
const configLoader = await createConfigLoader({ rootDirectory, watch: watch2 });
|
|
808
|
+
const configResult = await configLoader.getConfig();
|
|
809
|
+
if (!configResult.ok) {
|
|
810
|
+
throw new Error(configResult.error);
|
|
811
|
+
}
|
|
812
|
+
const config = configResult.value;
|
|
813
|
+
return {
|
|
814
|
+
configLoader,
|
|
815
|
+
rootDirectory,
|
|
816
|
+
config
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
async function writeAll(ctx) {
|
|
820
|
+
const typegenDir = getTypesDir(ctx);
|
|
821
|
+
import_node_fs2.default.rmSync(typegenDir, { recursive: true, force: true });
|
|
902
822
|
Object.values(ctx.config.routes).forEach((route) => {
|
|
903
|
-
|
|
904
|
-
const
|
|
905
|
-
|
|
906
|
-
|
|
823
|
+
const typesPath = getTypesPath(ctx, route);
|
|
824
|
+
const content = generate2(ctx, route);
|
|
825
|
+
import_node_fs2.default.mkdirSync(Path4.dirname(typesPath), { recursive: true });
|
|
826
|
+
import_node_fs2.default.writeFileSync(typesPath, content);
|
|
907
827
|
});
|
|
908
|
-
const
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
t2.tsTypeLiteral([
|
|
917
|
-
t2.tsPropertySignature(
|
|
918
|
-
t2.identifier("params"),
|
|
919
|
-
t2.tsTypeAnnotation(paramsType(fullpath2))
|
|
920
|
-
)
|
|
921
|
-
])
|
|
922
|
-
)
|
|
923
|
-
);
|
|
924
|
-
})
|
|
925
|
-
)
|
|
926
|
-
);
|
|
927
|
-
const content = import_dedent.default`
|
|
928
|
-
// Generated by React Router
|
|
929
|
-
|
|
930
|
-
import "react-router"
|
|
828
|
+
const registerPath = Path4.join(typegenDir, "+register.ts");
|
|
829
|
+
import_node_fs2.default.writeFileSync(registerPath, register(ctx));
|
|
830
|
+
const virtualPath = Path4.join(typegenDir, "+virtual.d.ts");
|
|
831
|
+
import_node_fs2.default.writeFileSync(virtualPath, virtual);
|
|
832
|
+
}
|
|
833
|
+
function register(ctx) {
|
|
834
|
+
const register2 = import_dedent2.default`
|
|
835
|
+
import "react-router";
|
|
931
836
|
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
}
|
|
837
|
+
declare module "react-router" {
|
|
838
|
+
interface Register {
|
|
839
|
+
params: Params;
|
|
936
840
|
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
841
|
+
}
|
|
842
|
+
`;
|
|
843
|
+
const { t: t2 } = babel_exports;
|
|
844
|
+
const indexPaths = new Set(
|
|
845
|
+
Object.values(ctx.config.routes).filter((route) => route.index).map((route) => route.path)
|
|
846
|
+
);
|
|
847
|
+
const typeParams = t2.tsTypeAliasDeclaration(
|
|
848
|
+
t2.identifier("Params"),
|
|
944
849
|
null,
|
|
945
850
|
t2.tsTypeLiteral(
|
|
946
851
|
Object.values(ctx.config.routes).map((route) => {
|
|
852
|
+
if (route.id !== "root" && !route.path) return void 0;
|
|
853
|
+
if (!route.index && indexPaths.has(route.path)) return void 0;
|
|
854
|
+
const lineage2 = lineage(ctx.config.routes, route);
|
|
855
|
+
const fullpath2 = fullpath(lineage2);
|
|
856
|
+
const params = parse2(fullpath2);
|
|
947
857
|
return t2.tsPropertySignature(
|
|
948
|
-
t2.stringLiteral(
|
|
858
|
+
t2.stringLiteral(fullpath2),
|
|
949
859
|
t2.tsTypeAnnotation(
|
|
950
|
-
t2.tsTypeLiteral(
|
|
951
|
-
|
|
952
|
-
t2.
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
)
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
route.path ? t2.tsLiteralType(t2.stringLiteral(route.path)) : t2.tsUndefinedKeyword()
|
|
961
|
-
)
|
|
962
|
-
),
|
|
963
|
-
t2.tsPropertySignature(
|
|
964
|
-
t2.identifier("params"),
|
|
965
|
-
t2.tsTypeAnnotation(paramsType(route.path ?? ""))
|
|
966
|
-
),
|
|
967
|
-
t2.tsPropertySignature(
|
|
968
|
-
t2.identifier("index"),
|
|
969
|
-
t2.tsTypeAnnotation(
|
|
970
|
-
t2.tsLiteralType(t2.booleanLiteral(route.index ?? false))
|
|
971
|
-
)
|
|
972
|
-
),
|
|
973
|
-
t2.tsPropertySignature(
|
|
974
|
-
t2.identifier("file"),
|
|
975
|
-
t2.tsTypeAnnotation(t2.tsLiteralType(t2.stringLiteral(route.file)))
|
|
976
|
-
)
|
|
977
|
-
])
|
|
860
|
+
t2.tsTypeLiteral(
|
|
861
|
+
Object.entries(params).map(([param, isRequired]) => {
|
|
862
|
+
const property = t2.tsPropertySignature(
|
|
863
|
+
t2.stringLiteral(param),
|
|
864
|
+
t2.tsTypeAnnotation(t2.tsStringKeyword())
|
|
865
|
+
);
|
|
866
|
+
property.optional = !isRequired;
|
|
867
|
+
return property;
|
|
868
|
+
})
|
|
869
|
+
)
|
|
978
870
|
)
|
|
979
871
|
);
|
|
980
|
-
})
|
|
872
|
+
}).filter((x) => x !== void 0)
|
|
981
873
|
)
|
|
982
874
|
);
|
|
983
|
-
|
|
984
|
-
// Generated by React Router
|
|
985
|
-
|
|
986
|
-
import "react-router"
|
|
987
|
-
|
|
988
|
-
declare module "react-router" {
|
|
989
|
-
interface Register {
|
|
990
|
-
routesPre: routesPre
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
` + "\n\n" + generate(routesType).code;
|
|
994
|
-
return { filename: filename2, content };
|
|
995
|
-
}
|
|
996
|
-
function generateRouteModuleAnnotations(ctx) {
|
|
997
|
-
return Object.values(ctx.config.routes).map((route) => {
|
|
998
|
-
const filename2 = getRouteModuleAnnotationsFilepath(ctx, route);
|
|
999
|
-
const parents = getParents(ctx, route);
|
|
1000
|
-
const content = import_dedent.default`
|
|
1001
|
-
// Generated by React Router
|
|
1002
|
-
|
|
1003
|
-
import type {
|
|
1004
|
-
Params,
|
|
1005
|
-
RouteModuleAnnotations,
|
|
1006
|
-
CreateLoaderData,
|
|
1007
|
-
CreateActionData,
|
|
1008
|
-
} from "react-router/internal";
|
|
1009
|
-
|
|
1010
|
-
${parents.map((parent) => parent.import).join("\n" + " ".repeat(3))}
|
|
1011
|
-
type Parents = [${parents.map((parent) => parent.name).join(", ")}]
|
|
1012
|
-
|
|
1013
|
-
type Id = "${route.id}"
|
|
1014
|
-
type Module = typeof import("../${Pathe.filename(route.file)}.js")
|
|
1015
|
-
|
|
1016
|
-
export type unstable_Props = {
|
|
1017
|
-
params: Params[Id]
|
|
1018
|
-
loaderData: CreateLoaderData<Module>
|
|
1019
|
-
actionData: CreateActionData<Module>
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
type Annotations = RouteModuleAnnotations<unstable_Props & {
|
|
1023
|
-
parents: Parents,
|
|
1024
|
-
module: Module,
|
|
1025
|
-
}>;
|
|
1026
|
-
|
|
1027
|
-
export namespace Route {
|
|
1028
|
-
// links
|
|
1029
|
-
export type LinkDescriptors = Annotations["LinkDescriptors"];
|
|
1030
|
-
export type LinksFunction = Annotations["LinksFunction"];
|
|
1031
|
-
|
|
1032
|
-
// meta
|
|
1033
|
-
export type MetaArgs = Annotations["MetaArgs"];
|
|
1034
|
-
export type MetaDescriptors = Annotations["MetaDescriptors"];
|
|
1035
|
-
export type MetaFunction = Annotations["MetaFunction"];
|
|
1036
|
-
|
|
1037
|
-
// headers
|
|
1038
|
-
export type HeadersArgs = Annotations["HeadersArgs"];
|
|
1039
|
-
export type HeadersFunction = Annotations["HeadersFunction"];
|
|
1040
|
-
|
|
1041
|
-
// unstable_middleware
|
|
1042
|
-
export type unstable_MiddlewareFunction = Annotations["unstable_MiddlewareFunction"];
|
|
1043
|
-
|
|
1044
|
-
// unstable_clientMiddleware
|
|
1045
|
-
export type unstable_ClientMiddlewareFunction = Annotations["unstable_ClientMiddlewareFunction"];
|
|
1046
|
-
|
|
1047
|
-
// loader
|
|
1048
|
-
export type LoaderArgs = Annotations["LoaderArgs"];
|
|
1049
|
-
|
|
1050
|
-
// clientLoader
|
|
1051
|
-
export type ClientLoaderArgs = Annotations["ClientLoaderArgs"];
|
|
1052
|
-
|
|
1053
|
-
// action
|
|
1054
|
-
export type ActionArgs = Annotations["ActionArgs"];
|
|
1055
|
-
|
|
1056
|
-
// clientAction
|
|
1057
|
-
export type ClientActionArgs = Annotations["ClientActionArgs"];
|
|
1058
|
-
|
|
1059
|
-
// HydrateFallback
|
|
1060
|
-
export type HydrateFallbackProps = Annotations["HydrateFallbackProps"];
|
|
1061
|
-
|
|
1062
|
-
// Component
|
|
1063
|
-
export type ComponentProps = Annotations["ComponentProps"];
|
|
1064
|
-
|
|
1065
|
-
// ErrorBoundary
|
|
1066
|
-
export type ErrorBoundaryProps = Annotations["ErrorBoundaryProps"];
|
|
1067
|
-
}
|
|
1068
|
-
`;
|
|
1069
|
-
return { filename: filename2, content };
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
|
-
function getRouteModuleAnnotationsFilepath(ctx, route) {
|
|
1073
|
-
return Path3.join(
|
|
1074
|
-
typesDirectory(ctx),
|
|
1075
|
-
Path3.relative(ctx.rootDirectory, ctx.config.appDirectory),
|
|
1076
|
-
Path3.dirname(route.file),
|
|
1077
|
-
"+types/" + Pathe.filename(route.file) + ".ts"
|
|
1078
|
-
);
|
|
1079
|
-
}
|
|
1080
|
-
function getParents(ctx, route) {
|
|
1081
|
-
const typesPath = getRouteModuleAnnotationsFilepath(ctx, route);
|
|
1082
|
-
const lineage2 = lineage(ctx.config.routes, route);
|
|
1083
|
-
const parents = lineage2.slice(0, -1);
|
|
1084
|
-
return parents.map((parent, i) => {
|
|
1085
|
-
const rel = Path3.relative(
|
|
1086
|
-
Path3.dirname(typesPath),
|
|
1087
|
-
getRouteModuleAnnotationsFilepath(ctx, parent)
|
|
1088
|
-
);
|
|
1089
|
-
let source = noExtension(rel);
|
|
1090
|
-
if (!source.startsWith("../")) source = "./" + source;
|
|
1091
|
-
const name = `Parent${i}`;
|
|
1092
|
-
return {
|
|
1093
|
-
name,
|
|
1094
|
-
import: `import type { unstable_Props as ${name} } from "${source}.js"`
|
|
1095
|
-
};
|
|
1096
|
-
});
|
|
1097
|
-
}
|
|
1098
|
-
function noExtension(path6) {
|
|
1099
|
-
return Path3.join(Path3.dirname(path6), Pathe.filename(path6));
|
|
1100
|
-
}
|
|
1101
|
-
function paramsType(path6) {
|
|
1102
|
-
const params = parse2(path6);
|
|
1103
|
-
return t2.tsTypeLiteral(
|
|
1104
|
-
Object.entries(params).map(([param, isRequired]) => {
|
|
1105
|
-
const property = t2.tsPropertySignature(
|
|
1106
|
-
t2.stringLiteral(param),
|
|
1107
|
-
t2.tsTypeAnnotation(t2.tsStringKeyword())
|
|
1108
|
-
);
|
|
1109
|
-
property.optional = !isRequired;
|
|
1110
|
-
return property;
|
|
1111
|
-
})
|
|
1112
|
-
);
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
// typegen/index.ts
|
|
1116
|
-
async function clearRouteModuleAnnotations(ctx) {
|
|
1117
|
-
await import_promises.default.rm(
|
|
1118
|
-
Path4.join(typesDirectory(ctx), Path4.basename(ctx.config.appDirectory)),
|
|
1119
|
-
{ recursive: true, force: true }
|
|
1120
|
-
);
|
|
1121
|
-
}
|
|
1122
|
-
async function write(...files) {
|
|
1123
|
-
return Promise.all(
|
|
1124
|
-
files.map(async ({ filename: filename2, content }) => {
|
|
1125
|
-
await import_promises.default.mkdir(Path4.dirname(filename2), { recursive: true });
|
|
1126
|
-
await import_promises.default.writeFile(filename2, content);
|
|
1127
|
-
})
|
|
1128
|
-
);
|
|
1129
|
-
}
|
|
1130
|
-
async function watch(rootDirectory, { mode, logger }) {
|
|
1131
|
-
const ctx = await createContext2({ rootDirectory, mode, watch: true });
|
|
1132
|
-
await clearRouteModuleAnnotations(ctx);
|
|
1133
|
-
await write(
|
|
1134
|
-
generateFuture(ctx),
|
|
1135
|
-
generatePages(ctx),
|
|
1136
|
-
generateRoutes(ctx),
|
|
1137
|
-
generateServerBuild(ctx),
|
|
1138
|
-
...generateRouteModuleAnnotations(ctx)
|
|
1139
|
-
);
|
|
1140
|
-
logger?.info((0, import_picocolors2.green)("generated types"), { timestamp: true, clear: true });
|
|
1141
|
-
ctx.configLoader.onChange(
|
|
1142
|
-
async ({ result, configChanged, routeConfigChanged }) => {
|
|
1143
|
-
if (!result.ok) {
|
|
1144
|
-
logger?.error((0, import_picocolors2.red)(result.error), { timestamp: true, clear: true });
|
|
1145
|
-
return;
|
|
1146
|
-
}
|
|
1147
|
-
ctx.config = result.value;
|
|
1148
|
-
if (configChanged) {
|
|
1149
|
-
await write(generateFuture(ctx));
|
|
1150
|
-
logger?.info((0, import_picocolors2.green)("regenerated types"), {
|
|
1151
|
-
timestamp: true,
|
|
1152
|
-
clear: true
|
|
1153
|
-
});
|
|
1154
|
-
}
|
|
1155
|
-
if (routeConfigChanged) {
|
|
1156
|
-
await clearRouteModuleAnnotations(ctx);
|
|
1157
|
-
await write(
|
|
1158
|
-
generatePages(ctx),
|
|
1159
|
-
generateRoutes(ctx),
|
|
1160
|
-
...generateRouteModuleAnnotations(ctx)
|
|
1161
|
-
);
|
|
1162
|
-
logger?.info((0, import_picocolors2.green)("regenerated types"), {
|
|
1163
|
-
timestamp: true,
|
|
1164
|
-
clear: true
|
|
1165
|
-
});
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
);
|
|
1169
|
-
return {
|
|
1170
|
-
close: async () => await ctx.configLoader.close()
|
|
1171
|
-
};
|
|
875
|
+
return [register2, generate(typeParams).code].join("\n\n");
|
|
1172
876
|
}
|
|
877
|
+
var virtual = import_dedent2.default`
|
|
878
|
+
declare module "virtual:react-router/server-build" {
|
|
879
|
+
import { ServerBuild } from "react-router";
|
|
880
|
+
export const assets: ServerBuild["assets"];
|
|
881
|
+
export const assetsBuildDirectory: ServerBuild["assetsBuildDirectory"];
|
|
882
|
+
export const basename: ServerBuild["basename"];
|
|
883
|
+
export const entry: ServerBuild["entry"];
|
|
884
|
+
export const future: ServerBuild["future"];
|
|
885
|
+
export const isSpaMode: ServerBuild["isSpaMode"];
|
|
886
|
+
export const prerender: ServerBuild["prerender"];
|
|
887
|
+
export const publicPath: ServerBuild["publicPath"];
|
|
888
|
+
export const routes: ServerBuild["routes"];
|
|
889
|
+
export const ssr: ServerBuild["ssr"];
|
|
890
|
+
export const unstable_getCriticalCss: ServerBuild["unstable_getCriticalCss"];
|
|
891
|
+
}
|
|
892
|
+
`;
|
|
1173
893
|
|
|
1174
894
|
// vite/node-adapter.ts
|
|
1175
895
|
var import_node_events = require("events");
|
|
@@ -1225,9 +945,7 @@ function fromNodeRequest(nodeReq, nodeRes) {
|
|
|
1225
945
|
}
|
|
1226
946
|
async function toNodeRequest(res, nodeRes) {
|
|
1227
947
|
nodeRes.statusCode = res.status;
|
|
1228
|
-
|
|
1229
|
-
nodeRes.statusMessage = res.statusText;
|
|
1230
|
-
}
|
|
948
|
+
nodeRes.statusMessage = res.statusText;
|
|
1231
949
|
let cookiesStrings = [];
|
|
1232
950
|
for (let [name, value] of res.headers) {
|
|
1233
951
|
if (name === "set-cookie") {
|
|
@@ -1248,17 +966,17 @@ async function toNodeRequest(res, nodeRes) {
|
|
|
1248
966
|
}
|
|
1249
967
|
|
|
1250
968
|
// vite/styles.ts
|
|
1251
|
-
var
|
|
969
|
+
var path5 = __toESM(require("path"));
|
|
1252
970
|
var import_react_router = require("react-router");
|
|
1253
971
|
|
|
1254
972
|
// vite/resolve-file-url.ts
|
|
1255
|
-
var
|
|
973
|
+
var path4 = __toESM(require("path"));
|
|
1256
974
|
var resolveFileUrl = ({ rootDirectory }, filePath) => {
|
|
1257
975
|
let vite2 = getVite();
|
|
1258
|
-
let relativePath =
|
|
1259
|
-
let isWithinRoot = !relativePath.startsWith("..") && !
|
|
976
|
+
let relativePath = path4.relative(rootDirectory, filePath);
|
|
977
|
+
let isWithinRoot = !relativePath.startsWith("..") && !path4.isAbsolute(relativePath);
|
|
1260
978
|
if (!isWithinRoot) {
|
|
1261
|
-
return
|
|
979
|
+
return path4.posix.join("/@fs", vite2.normalizePath(filePath));
|
|
1262
980
|
}
|
|
1263
981
|
return "/" + vite2.normalizePath(relativePath);
|
|
1264
982
|
};
|
|
@@ -1295,7 +1013,7 @@ var getStylesForFiles = async ({
|
|
|
1295
1013
|
let deps = /* @__PURE__ */ new Set();
|
|
1296
1014
|
try {
|
|
1297
1015
|
for (let file of files) {
|
|
1298
|
-
let normalizedPath =
|
|
1016
|
+
let normalizedPath = path5.resolve(rootDirectory, file).replace(/\\/g, "/");
|
|
1299
1017
|
let node = await viteDevServer.moduleGraph.getModuleById(normalizedPath);
|
|
1300
1018
|
if (!node) {
|
|
1301
1019
|
try {
|
|
@@ -1396,9 +1114,9 @@ var getStylesForPathname = async ({
|
|
|
1396
1114
|
return void 0;
|
|
1397
1115
|
}
|
|
1398
1116
|
let routesWithChildren = createRoutesWithChildren(reactRouterConfig.routes);
|
|
1399
|
-
let appPath =
|
|
1117
|
+
let appPath = path5.relative(process.cwd(), reactRouterConfig.appDirectory);
|
|
1400
1118
|
let documentRouteFiles = (0, import_react_router.matchRoutes)(routesWithChildren, pathname, reactRouterConfig.basename)?.map(
|
|
1401
|
-
(match) =>
|
|
1119
|
+
(match) => path5.resolve(appPath, reactRouterConfig.routes[match.route.id].file)
|
|
1402
1120
|
) ?? [];
|
|
1403
1121
|
let styles = await getStylesForFiles({
|
|
1404
1122
|
viteDevServer,
|
|
@@ -1406,27 +1124,13 @@ var getStylesForPathname = async ({
|
|
|
1406
1124
|
loadCssContents,
|
|
1407
1125
|
files: [
|
|
1408
1126
|
// Always include the client entry file when crawling the module graph for CSS
|
|
1409
|
-
|
|
1127
|
+
path5.relative(rootDirectory, entryClientFilePath),
|
|
1410
1128
|
// Then include any styles from the matched routes
|
|
1411
1129
|
...documentRouteFiles
|
|
1412
1130
|
]
|
|
1413
1131
|
});
|
|
1414
1132
|
return styles;
|
|
1415
1133
|
};
|
|
1416
|
-
var getCssStringFromViteDevModuleCode = (code) => {
|
|
1417
|
-
let cssContent = void 0;
|
|
1418
|
-
const ast = import_parser.parse(code, { sourceType: "module" });
|
|
1419
|
-
traverse(ast, {
|
|
1420
|
-
VariableDeclaration(path6) {
|
|
1421
|
-
const declaration = path6.node.declarations[0];
|
|
1422
|
-
if (declaration?.id?.type === "Identifier" && declaration.id.name === "__vite__css" && declaration.init?.type === "StringLiteral") {
|
|
1423
|
-
cssContent = declaration.init.value;
|
|
1424
|
-
path6.stop();
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
});
|
|
1428
|
-
return cssContent;
|
|
1429
|
-
};
|
|
1430
1134
|
|
|
1431
1135
|
// vite/virtual-module.ts
|
|
1432
1136
|
function create(name) {
|
|
@@ -1450,10 +1154,10 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1450
1154
|
let exportsFiltered = false;
|
|
1451
1155
|
let markedForRemoval = /* @__PURE__ */ new Set();
|
|
1452
1156
|
traverse(ast, {
|
|
1453
|
-
ExportDeclaration(
|
|
1454
|
-
if (
|
|
1455
|
-
if (
|
|
1456
|
-
|
|
1157
|
+
ExportDeclaration(path7) {
|
|
1158
|
+
if (path7.node.type === "ExportNamedDeclaration") {
|
|
1159
|
+
if (path7.node.specifiers.length) {
|
|
1160
|
+
path7.node.specifiers = path7.node.specifiers.filter((specifier) => {
|
|
1457
1161
|
if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier") {
|
|
1458
1162
|
if (exportsToRemove.includes(specifier.exported.name)) {
|
|
1459
1163
|
exportsFiltered = true;
|
|
@@ -1462,12 +1166,12 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1462
1166
|
}
|
|
1463
1167
|
return true;
|
|
1464
1168
|
});
|
|
1465
|
-
if (
|
|
1466
|
-
markedForRemoval.add(
|
|
1169
|
+
if (path7.node.specifiers.length === 0) {
|
|
1170
|
+
markedForRemoval.add(path7);
|
|
1467
1171
|
}
|
|
1468
1172
|
}
|
|
1469
|
-
if (
|
|
1470
|
-
let declaration =
|
|
1173
|
+
if (path7.node.declaration?.type === "VariableDeclaration") {
|
|
1174
|
+
let declaration = path7.node.declaration;
|
|
1471
1175
|
declaration.declarations = declaration.declarations.filter(
|
|
1472
1176
|
(declaration2) => {
|
|
1473
1177
|
if (declaration2.id.type === "Identifier" && exportsToRemove.includes(declaration2.id.name)) {
|
|
@@ -1481,30 +1185,30 @@ var removeExports = (ast, exportsToRemove) => {
|
|
|
1481
1185
|
}
|
|
1482
1186
|
);
|
|
1483
1187
|
if (declaration.declarations.length === 0) {
|
|
1484
|
-
markedForRemoval.add(
|
|
1188
|
+
markedForRemoval.add(path7);
|
|
1485
1189
|
}
|
|
1486
1190
|
}
|
|
1487
|
-
if (
|
|
1488
|
-
let id =
|
|
1191
|
+
if (path7.node.declaration?.type === "FunctionDeclaration") {
|
|
1192
|
+
let id = path7.node.declaration.id;
|
|
1489
1193
|
if (id && exportsToRemove.includes(id.name)) {
|
|
1490
|
-
markedForRemoval.add(
|
|
1194
|
+
markedForRemoval.add(path7);
|
|
1491
1195
|
}
|
|
1492
1196
|
}
|
|
1493
|
-
if (
|
|
1494
|
-
let id =
|
|
1197
|
+
if (path7.node.declaration?.type === "ClassDeclaration") {
|
|
1198
|
+
let id = path7.node.declaration.id;
|
|
1495
1199
|
if (id && exportsToRemove.includes(id.name)) {
|
|
1496
|
-
markedForRemoval.add(
|
|
1200
|
+
markedForRemoval.add(path7);
|
|
1497
1201
|
}
|
|
1498
1202
|
}
|
|
1499
1203
|
}
|
|
1500
|
-
if (
|
|
1501
|
-
markedForRemoval.add(
|
|
1204
|
+
if (path7.node.type === "ExportDefaultDeclaration" && exportsToRemove.includes("default")) {
|
|
1205
|
+
markedForRemoval.add(path7);
|
|
1502
1206
|
}
|
|
1503
1207
|
}
|
|
1504
1208
|
});
|
|
1505
1209
|
if (markedForRemoval.size > 0 || exportsFiltered) {
|
|
1506
|
-
for (let
|
|
1507
|
-
|
|
1210
|
+
for (let path7 of markedForRemoval) {
|
|
1211
|
+
path7.remove();
|
|
1508
1212
|
}
|
|
1509
1213
|
(0, import_babel_dead_code_elimination.deadCodeElimination)(ast, previouslyReferencedIdentifiers);
|
|
1510
1214
|
}
|
|
@@ -1575,28 +1279,28 @@ function codeToAst(code, cache, cacheKey) {
|
|
|
1575
1279
|
)
|
|
1576
1280
|
);
|
|
1577
1281
|
}
|
|
1578
|
-
function assertNodePath(
|
|
1282
|
+
function assertNodePath(path7) {
|
|
1579
1283
|
invariant(
|
|
1580
|
-
|
|
1581
|
-
`Expected a Path, but got ${Array.isArray(
|
|
1284
|
+
path7 && !Array.isArray(path7),
|
|
1285
|
+
`Expected a Path, but got ${Array.isArray(path7) ? "an array" : path7}`
|
|
1582
1286
|
);
|
|
1583
1287
|
}
|
|
1584
|
-
function assertNodePathIsStatement(
|
|
1288
|
+
function assertNodePathIsStatement(path7) {
|
|
1585
1289
|
invariant(
|
|
1586
|
-
|
|
1587
|
-
`Expected a Statement path, but got ${Array.isArray(
|
|
1290
|
+
path7 && !Array.isArray(path7) && t.isStatement(path7.node),
|
|
1291
|
+
`Expected a Statement path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
|
|
1588
1292
|
);
|
|
1589
1293
|
}
|
|
1590
|
-
function assertNodePathIsVariableDeclarator(
|
|
1294
|
+
function assertNodePathIsVariableDeclarator(path7) {
|
|
1591
1295
|
invariant(
|
|
1592
|
-
|
|
1593
|
-
`Expected an Identifier path, but got ${Array.isArray(
|
|
1296
|
+
path7 && !Array.isArray(path7) && t.isVariableDeclarator(path7.node),
|
|
1297
|
+
`Expected an Identifier path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
|
|
1594
1298
|
);
|
|
1595
1299
|
}
|
|
1596
|
-
function assertNodePathIsPattern(
|
|
1300
|
+
function assertNodePathIsPattern(path7) {
|
|
1597
1301
|
invariant(
|
|
1598
|
-
|
|
1599
|
-
`Expected a Pattern path, but got ${Array.isArray(
|
|
1302
|
+
path7 && !Array.isArray(path7) && t.isPattern(path7.node),
|
|
1303
|
+
`Expected a Pattern path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
|
|
1600
1304
|
);
|
|
1601
1305
|
}
|
|
1602
1306
|
function getExportDependencies(code, cache, cacheKey) {
|
|
@@ -1632,8 +1336,8 @@ function getExportDependencies(code, cache, cacheKey) {
|
|
|
1632
1336
|
}
|
|
1633
1337
|
let isWithinExportDestructuring = Boolean(
|
|
1634
1338
|
identifier.findParent(
|
|
1635
|
-
(
|
|
1636
|
-
|
|
1339
|
+
(path7) => Boolean(
|
|
1340
|
+
path7.isPattern() && path7.parentPath?.isVariableDeclarator() && path7.parentPath.parentPath?.parentPath?.isExportNamedDeclaration()
|
|
1637
1341
|
)
|
|
1638
1342
|
)
|
|
1639
1343
|
);
|
|
@@ -1711,7 +1415,7 @@ function getExportDependencies(code, cache, cacheKey) {
|
|
|
1711
1415
|
for (let specifier of node.specifiers) {
|
|
1712
1416
|
if (t.isIdentifier(specifier.exported)) {
|
|
1713
1417
|
let name = specifier.exported.name;
|
|
1714
|
-
let specifierPath = exportPath.get("specifiers").find((
|
|
1418
|
+
let specifierPath = exportPath.get("specifiers").find((path7) => path7.node === specifier);
|
|
1715
1419
|
invariant(
|
|
1716
1420
|
specifierPath,
|
|
1717
1421
|
`Expected to find specifier path for ${name}`
|
|
@@ -1728,22 +1432,22 @@ function getExportDependencies(code, cache, cacheKey) {
|
|
|
1728
1432
|
}
|
|
1729
1433
|
);
|
|
1730
1434
|
}
|
|
1731
|
-
function getDependentIdentifiersForPath(
|
|
1435
|
+
function getDependentIdentifiersForPath(path7, state) {
|
|
1732
1436
|
let { visited, identifiers } = state ?? {
|
|
1733
1437
|
visited: /* @__PURE__ */ new Set(),
|
|
1734
1438
|
identifiers: /* @__PURE__ */ new Set()
|
|
1735
1439
|
};
|
|
1736
|
-
if (visited.has(
|
|
1440
|
+
if (visited.has(path7)) {
|
|
1737
1441
|
return identifiers;
|
|
1738
1442
|
}
|
|
1739
|
-
visited.add(
|
|
1740
|
-
|
|
1741
|
-
Identifier(
|
|
1742
|
-
if (identifiers.has(
|
|
1443
|
+
visited.add(path7);
|
|
1444
|
+
path7.traverse({
|
|
1445
|
+
Identifier(path8) {
|
|
1446
|
+
if (identifiers.has(path8)) {
|
|
1743
1447
|
return;
|
|
1744
1448
|
}
|
|
1745
|
-
identifiers.add(
|
|
1746
|
-
let binding =
|
|
1449
|
+
identifiers.add(path8);
|
|
1450
|
+
let binding = path8.scope.getBinding(path8.node.name);
|
|
1747
1451
|
if (!binding) {
|
|
1748
1452
|
return;
|
|
1749
1453
|
}
|
|
@@ -1765,7 +1469,7 @@ function getDependentIdentifiersForPath(path6, state) {
|
|
|
1765
1469
|
}
|
|
1766
1470
|
}
|
|
1767
1471
|
});
|
|
1768
|
-
let topLevelStatement = getTopLevelStatementPathForPath(
|
|
1472
|
+
let topLevelStatement = getTopLevelStatementPathForPath(path7);
|
|
1769
1473
|
let withinImportStatement = topLevelStatement.isImportDeclaration();
|
|
1770
1474
|
let withinExportStatement = topLevelStatement.isExportDeclaration();
|
|
1771
1475
|
if (!withinImportStatement && !withinExportStatement) {
|
|
@@ -1774,9 +1478,9 @@ function getDependentIdentifiersForPath(path6, state) {
|
|
|
1774
1478
|
identifiers
|
|
1775
1479
|
});
|
|
1776
1480
|
}
|
|
1777
|
-
if (withinExportStatement &&
|
|
1778
|
-
t.isPattern(
|
|
1779
|
-
let variableDeclarator =
|
|
1481
|
+
if (withinExportStatement && path7.isIdentifier() && (t.isPattern(path7.parentPath.node) || // [foo]
|
|
1482
|
+
t.isPattern(path7.parentPath.parentPath?.node))) {
|
|
1483
|
+
let variableDeclarator = path7.findParent((p) => p.isVariableDeclarator());
|
|
1780
1484
|
assertNodePath(variableDeclarator);
|
|
1781
1485
|
getDependentIdentifiersForPath(variableDeclarator, {
|
|
1782
1486
|
visited,
|
|
@@ -1785,16 +1489,16 @@ function getDependentIdentifiersForPath(path6, state) {
|
|
|
1785
1489
|
}
|
|
1786
1490
|
return identifiers;
|
|
1787
1491
|
}
|
|
1788
|
-
function getTopLevelStatementPathForPath(
|
|
1789
|
-
let ancestry =
|
|
1492
|
+
function getTopLevelStatementPathForPath(path7) {
|
|
1493
|
+
let ancestry = path7.getAncestry();
|
|
1790
1494
|
let topLevelStatement = ancestry[ancestry.length - 2];
|
|
1791
1495
|
assertNodePathIsStatement(topLevelStatement);
|
|
1792
1496
|
return topLevelStatement;
|
|
1793
1497
|
}
|
|
1794
1498
|
function getTopLevelStatementsForPaths(paths) {
|
|
1795
1499
|
let topLevelStatements = /* @__PURE__ */ new Set();
|
|
1796
|
-
for (let
|
|
1797
|
-
let topLevelStatement = getTopLevelStatementPathForPath(
|
|
1500
|
+
for (let path7 of paths) {
|
|
1501
|
+
let topLevelStatement = getTopLevelStatementPathForPath(path7);
|
|
1798
1502
|
topLevelStatements.add(topLevelStatement.node);
|
|
1799
1503
|
}
|
|
1800
1504
|
return topLevelStatements;
|
|
@@ -2157,7 +1861,7 @@ function getRouteChunkNameFromModuleId(id) {
|
|
|
2157
1861
|
}
|
|
2158
1862
|
|
|
2159
1863
|
// vite/with-props.ts
|
|
2160
|
-
var
|
|
1864
|
+
var import_dedent3 = __toESM(require("dedent"));
|
|
2161
1865
|
var vmod = create("with-props");
|
|
2162
1866
|
var NAMED_COMPONENT_EXPORTS = ["HydrateFallback", "ErrorBoundary"];
|
|
2163
1867
|
var plugin = {
|
|
@@ -2168,7 +1872,7 @@ var plugin = {
|
|
|
2168
1872
|
},
|
|
2169
1873
|
async load(id) {
|
|
2170
1874
|
if (id !== vmod.resolvedId) return;
|
|
2171
|
-
return
|
|
1875
|
+
return import_dedent3.default`
|
|
2172
1876
|
import { createElement as h } from "react";
|
|
2173
1877
|
import { useActionData, useLoaderData, useMatches, useParams, useRouteError } from "react-router";
|
|
2174
1878
|
|
|
@@ -2211,24 +1915,24 @@ var plugin = {
|
|
|
2211
1915
|
};
|
|
2212
1916
|
var transform = (ast) => {
|
|
2213
1917
|
const hocs = [];
|
|
2214
|
-
function getHocUid(
|
|
2215
|
-
const uid =
|
|
1918
|
+
function getHocUid(path7, hocName) {
|
|
1919
|
+
const uid = path7.scope.generateUidIdentifier(hocName);
|
|
2216
1920
|
hocs.push([hocName, uid]);
|
|
2217
1921
|
return uid;
|
|
2218
1922
|
}
|
|
2219
1923
|
traverse(ast, {
|
|
2220
|
-
ExportDeclaration(
|
|
2221
|
-
if (
|
|
2222
|
-
const declaration =
|
|
1924
|
+
ExportDeclaration(path7) {
|
|
1925
|
+
if (path7.isExportDefaultDeclaration()) {
|
|
1926
|
+
const declaration = path7.get("declaration");
|
|
2223
1927
|
const expr = declaration.isExpression() ? declaration.node : declaration.isFunctionDeclaration() ? toFunctionExpression(declaration.node) : void 0;
|
|
2224
1928
|
if (expr) {
|
|
2225
|
-
const uid = getHocUid(
|
|
1929
|
+
const uid = getHocUid(path7, "withComponentProps");
|
|
2226
1930
|
declaration.replaceWith(t.callExpression(uid, [expr]));
|
|
2227
1931
|
}
|
|
2228
1932
|
return;
|
|
2229
1933
|
}
|
|
2230
|
-
if (
|
|
2231
|
-
const decl =
|
|
1934
|
+
if (path7.isExportNamedDeclaration()) {
|
|
1935
|
+
const decl = path7.get("declaration");
|
|
2232
1936
|
if (decl.isVariableDeclaration()) {
|
|
2233
1937
|
decl.get("declarations").forEach((varDeclarator) => {
|
|
2234
1938
|
const id = varDeclarator.get("id");
|
|
@@ -2238,7 +1942,7 @@ var transform = (ast) => {
|
|
|
2238
1942
|
if (!id.isIdentifier()) return;
|
|
2239
1943
|
const { name } = id.node;
|
|
2240
1944
|
if (!NAMED_COMPONENT_EXPORTS.includes(name)) return;
|
|
2241
|
-
const uid = getHocUid(
|
|
1945
|
+
const uid = getHocUid(path7, `with${name}Props`);
|
|
2242
1946
|
init.replaceWith(t.callExpression(uid, [expr]));
|
|
2243
1947
|
});
|
|
2244
1948
|
return;
|
|
@@ -2248,7 +1952,7 @@ var transform = (ast) => {
|
|
|
2248
1952
|
if (!id) return;
|
|
2249
1953
|
const { name } = id;
|
|
2250
1954
|
if (!NAMED_COMPONENT_EXPORTS.includes(name)) return;
|
|
2251
|
-
const uid = getHocUid(
|
|
1955
|
+
const uid = getHocUid(path7, `with${name}Props`);
|
|
2252
1956
|
decl.replaceWith(
|
|
2253
1957
|
t.variableDeclaration("const", [
|
|
2254
1958
|
t.variableDeclarator(
|
|
@@ -2313,6 +2017,7 @@ var SSR_BUNDLE_PREFIX = "ssrBundle_";
|
|
|
2313
2017
|
function isSsrBundleEnvironmentName(name) {
|
|
2314
2018
|
return name.startsWith(SSR_BUNDLE_PREFIX);
|
|
2315
2019
|
}
|
|
2020
|
+
var CSS_DEV_HELPER_ENVIRONMENT_NAME = "__react_router_css_dev_helper__";
|
|
2316
2021
|
function getServerEnvironmentEntries(ctx, record) {
|
|
2317
2022
|
return Object.entries(record).filter(
|
|
2318
2023
|
([name]) => ctx.buildManifest?.serverBundles ? isSsrBundleEnvironmentName(name) : name === "ssr"
|
|
@@ -2328,7 +2033,7 @@ var isRouteVirtualModule = (id) => {
|
|
|
2328
2033
|
return isRouteEntryModuleId(id) || isRouteChunkModuleId(id);
|
|
2329
2034
|
};
|
|
2330
2035
|
var isServerBuildVirtualModuleId = (id) => {
|
|
2331
|
-
return id.split("?")[0] ===
|
|
2036
|
+
return id.split("?")[0] === virtual2.serverBuild.id;
|
|
2332
2037
|
};
|
|
2333
2038
|
var getServerBuildFile = (viteManifest) => {
|
|
2334
2039
|
let serverBuildIds = Object.keys(viteManifest).filter(
|
|
@@ -2348,23 +2053,23 @@ var virtualHmrRuntime = create("hmr-runtime");
|
|
|
2348
2053
|
var virtualInjectHmrRuntime = create("inject-hmr-runtime");
|
|
2349
2054
|
var normalizeRelativeFilePath = (file, reactRouterConfig) => {
|
|
2350
2055
|
let vite2 = getVite();
|
|
2351
|
-
let fullPath =
|
|
2352
|
-
let relativePath =
|
|
2056
|
+
let fullPath = path6.resolve(reactRouterConfig.appDirectory, file);
|
|
2057
|
+
let relativePath = path6.relative(reactRouterConfig.appDirectory, fullPath);
|
|
2353
2058
|
return vite2.normalizePath(relativePath).split("?")[0];
|
|
2354
2059
|
};
|
|
2355
2060
|
var resolveRelativeRouteFilePath = (route, reactRouterConfig) => {
|
|
2356
2061
|
let vite2 = getVite();
|
|
2357
2062
|
let file = route.file;
|
|
2358
|
-
let fullPath =
|
|
2063
|
+
let fullPath = path6.resolve(reactRouterConfig.appDirectory, file);
|
|
2359
2064
|
return vite2.normalizePath(fullPath);
|
|
2360
2065
|
};
|
|
2361
|
-
var
|
|
2066
|
+
var virtual2 = {
|
|
2362
2067
|
serverBuild: create("server-build"),
|
|
2363
2068
|
serverManifest: create("server-manifest"),
|
|
2364
2069
|
browserManifest: create("browser-manifest")
|
|
2365
2070
|
};
|
|
2366
2071
|
var invalidateVirtualModules = (viteDevServer) => {
|
|
2367
|
-
Object.values(
|
|
2072
|
+
Object.values(virtual2).forEach((vmod2) => {
|
|
2368
2073
|
let mod = viteDevServer.moduleGraph.getModuleById(vmod2.resolvedId);
|
|
2369
2074
|
if (mod) {
|
|
2370
2075
|
viteDevServer.moduleGraph.invalidateModule(mod);
|
|
@@ -2378,7 +2083,7 @@ var getHash = (source, maxLength) => {
|
|
|
2378
2083
|
var resolveChunk = (ctx, viteManifest, absoluteFilePath) => {
|
|
2379
2084
|
let vite2 = getVite();
|
|
2380
2085
|
let rootRelativeFilePath = vite2.normalizePath(
|
|
2381
|
-
|
|
2086
|
+
path6.relative(ctx.rootDirectory, absoluteFilePath)
|
|
2382
2087
|
);
|
|
2383
2088
|
let entryChunk = viteManifest[rootRelativeFilePath];
|
|
2384
2089
|
if (!entryChunk) {
|
|
@@ -2442,7 +2147,7 @@ function dedupe(array2) {
|
|
|
2442
2147
|
return [...new Set(array2)];
|
|
2443
2148
|
}
|
|
2444
2149
|
var writeFileSafe = async (file, contents) => {
|
|
2445
|
-
await fse.ensureDir(
|
|
2150
|
+
await fse.ensureDir(path6.dirname(file));
|
|
2446
2151
|
await fse.writeFile(file, contents);
|
|
2447
2152
|
};
|
|
2448
2153
|
var getExportNames = (code) => {
|
|
@@ -2468,7 +2173,7 @@ var compileRouteFile = async (viteChildCompiler, ctx, routeFile, readRouteFile)
|
|
|
2468
2173
|
}
|
|
2469
2174
|
let ssr = true;
|
|
2470
2175
|
let { pluginContainer, moduleGraph } = viteChildCompiler;
|
|
2471
|
-
let routePath =
|
|
2176
|
+
let routePath = path6.resolve(ctx.reactRouterConfig.appDirectory, routeFile);
|
|
2472
2177
|
let url2 = resolveFileUrl(ctx, routePath);
|
|
2473
2178
|
let resolveId = async () => {
|
|
2474
2179
|
let result = await pluginContainer.resolveId(url2, void 0, { ssr });
|
|
@@ -2510,12 +2215,12 @@ var resolveEnvironmentBuildContext = ({
|
|
|
2510
2215
|
};
|
|
2511
2216
|
return resolvedBuildContext;
|
|
2512
2217
|
};
|
|
2513
|
-
var getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) =>
|
|
2218
|
+
var getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) => path6.join(
|
|
2514
2219
|
reactRouterConfig.buildDirectory,
|
|
2515
2220
|
"server",
|
|
2516
2221
|
...serverBundleId ? [serverBundleId] : []
|
|
2517
2222
|
);
|
|
2518
|
-
var getClientBuildDirectory = (reactRouterConfig) =>
|
|
2223
|
+
var getClientBuildDirectory = (reactRouterConfig) => path6.join(reactRouterConfig.buildDirectory, "client");
|
|
2519
2224
|
var getServerBundleRouteIds = (vitePluginContext, ctx) => {
|
|
2520
2225
|
if (!ctx.buildManifest) {
|
|
2521
2226
|
return void 0;
|
|
@@ -2533,13 +2238,14 @@ var getServerBundleRouteIds = (vitePluginContext, ctx) => {
|
|
|
2533
2238
|
);
|
|
2534
2239
|
return Object.keys(serverBundleRoutes);
|
|
2535
2240
|
};
|
|
2536
|
-
var
|
|
2537
|
-
|
|
2241
|
+
var injectQuery = (url2, query) => url2.includes("?") ? url2.replace("?", `?${query}&`) : `${url2}?${query}`;
|
|
2242
|
+
var defaultEntriesDir = path6.resolve(
|
|
2243
|
+
path6.dirname(require.resolve("@react-router/dev/package.json")),
|
|
2538
2244
|
"dist",
|
|
2539
2245
|
"config",
|
|
2540
2246
|
"defaults"
|
|
2541
2247
|
);
|
|
2542
|
-
var defaultEntries = fse.readdirSync(defaultEntriesDir).map((
|
|
2248
|
+
var defaultEntries = fse.readdirSync(defaultEntriesDir).map((filename3) => path6.join(defaultEntriesDir, filename3));
|
|
2543
2249
|
invariant(defaultEntries.length > 0, "No default entries found");
|
|
2544
2250
|
var reactRouterDevLoadContext = () => void 0;
|
|
2545
2251
|
var reactRouterVitePlugin = () => {
|
|
@@ -2635,10 +2341,10 @@ var reactRouterVitePlugin = () => {
|
|
|
2635
2341
|
}
|
|
2636
2342
|
}).join("\n")}
|
|
2637
2343
|
export { default as assets } from ${JSON.stringify(
|
|
2638
|
-
|
|
2344
|
+
virtual2.serverManifest.id
|
|
2639
2345
|
)};
|
|
2640
2346
|
export const assetsBuildDirectory = ${JSON.stringify(
|
|
2641
|
-
|
|
2347
|
+
path6.relative(
|
|
2642
2348
|
ctx.rootDirectory,
|
|
2643
2349
|
getClientBuildDirectory(ctx.reactRouterConfig)
|
|
2644
2350
|
)
|
|
@@ -2648,9 +2354,6 @@ var reactRouterVitePlugin = () => {
|
|
|
2648
2354
|
export const ssr = ${ctx.reactRouterConfig.ssr};
|
|
2649
2355
|
export const isSpaMode = ${isSpaMode};
|
|
2650
2356
|
export const prerender = ${JSON.stringify(prerenderPaths)};
|
|
2651
|
-
export const routeDiscovery = ${JSON.stringify(
|
|
2652
|
-
ctx.reactRouterConfig.routeDiscovery
|
|
2653
|
-
)};
|
|
2654
2357
|
export const publicPath = ${JSON.stringify(ctx.publicPath)};
|
|
2655
2358
|
export const entry = { module: entryServer };
|
|
2656
2359
|
export const routes = {
|
|
@@ -2677,7 +2380,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2677
2380
|
};
|
|
2678
2381
|
let loadViteManifest = async (directory) => {
|
|
2679
2382
|
let manifestContents = await fse.readFile(
|
|
2680
|
-
|
|
2383
|
+
path6.resolve(directory, ".vite", "manifest.json"),
|
|
2681
2384
|
"utf-8"
|
|
2682
2385
|
);
|
|
2683
2386
|
return JSON.parse(manifestContents);
|
|
@@ -2708,7 +2411,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2708
2411
|
let contents;
|
|
2709
2412
|
try {
|
|
2710
2413
|
contents = await fse.readFile(
|
|
2711
|
-
|
|
2414
|
+
path6.join(entry.path, entry.name),
|
|
2712
2415
|
"utf-8"
|
|
2713
2416
|
);
|
|
2714
2417
|
} catch (e) {
|
|
@@ -2717,7 +2420,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2717
2420
|
}
|
|
2718
2421
|
let hash = (0, import_node_crypto.createHash)("sha384").update(contents).digest().toString("base64");
|
|
2719
2422
|
let filepath = getVite().normalizePath(
|
|
2720
|
-
|
|
2423
|
+
path6.relative(clientBuildDirectory, path6.join(entry.path, entry.name))
|
|
2721
2424
|
);
|
|
2722
2425
|
sriManifest[`${ctx2.publicPath}${filepath}`] = `sha384-${hash}`;
|
|
2723
2426
|
}
|
|
@@ -2744,7 +2447,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2744
2447
|
);
|
|
2745
2448
|
let enforceSplitRouteModules = ctx.reactRouterConfig.future.unstable_splitRouteModules === "enforce";
|
|
2746
2449
|
for (let route of Object.values(ctx.reactRouterConfig.routes)) {
|
|
2747
|
-
let routeFile =
|
|
2450
|
+
let routeFile = path6.join(ctx.reactRouterConfig.appDirectory, route.file);
|
|
2748
2451
|
let sourceExports = routeManifestExports[route.id];
|
|
2749
2452
|
let isRootRoute = route.parentId === void 0;
|
|
2750
2453
|
let hasClientAction = sourceExports.includes("clientAction");
|
|
@@ -2820,7 +2523,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2820
2523
|
}
|
|
2821
2524
|
let fingerprintedValues = { entry, routes: browserRoutes };
|
|
2822
2525
|
let version = getHash(JSON.stringify(fingerprintedValues), 8);
|
|
2823
|
-
let manifestPath =
|
|
2526
|
+
let manifestPath = path6.posix.join(
|
|
2824
2527
|
viteConfig.build.assetsDir,
|
|
2825
2528
|
`manifest-${version}.js`
|
|
2826
2529
|
);
|
|
@@ -2832,7 +2535,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2832
2535
|
sri: void 0
|
|
2833
2536
|
};
|
|
2834
2537
|
await writeFileSafe(
|
|
2835
|
-
|
|
2538
|
+
path6.join(getClientBuildDirectory(ctx.reactRouterConfig), manifestPath),
|
|
2836
2539
|
`window.__reactRouterManifest=${JSON.stringify(
|
|
2837
2540
|
reactRouterBrowserManifest
|
|
2838
2541
|
)};`
|
|
@@ -2917,7 +2620,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2917
2620
|
let sri = void 0;
|
|
2918
2621
|
let reactRouterManifestForDev = {
|
|
2919
2622
|
version: String(Math.random()),
|
|
2920
|
-
url: combineURLs(ctx.publicPath,
|
|
2623
|
+
url: combineURLs(ctx.publicPath, virtual2.browserManifest.url),
|
|
2921
2624
|
hmr: {
|
|
2922
2625
|
runtime: combineURLs(ctx.publicPath, virtualInjectHmrRuntime.url)
|
|
2923
2626
|
},
|
|
@@ -2942,17 +2645,31 @@ var reactRouterVitePlugin = () => {
|
|
|
2942
2645
|
if (dep.file && isCssModulesFile(dep.file)) {
|
|
2943
2646
|
return cssModulesManifest[dep.file];
|
|
2944
2647
|
}
|
|
2945
|
-
|
|
2648
|
+
const vite2 = getVite();
|
|
2649
|
+
const viteMajor = parseInt(vite2.version.split(".")[0], 10);
|
|
2650
|
+
const url2 = viteMajor >= 6 ? (
|
|
2651
|
+
// We need the ?inline query in Vite v6 when loading CSS in SSR
|
|
2652
|
+
// since it does not expose the default export for CSS in a
|
|
2653
|
+
// server environment. This is to align with non-SSR
|
|
2654
|
+
// environments. For backwards compatibility with v5 we keep
|
|
2655
|
+
// using the URL without ?inline query because the HMR code was
|
|
2656
|
+
// relying on the implicit SSR-client module graph relationship.
|
|
2657
|
+
injectQuery(dep.url, "inline")
|
|
2658
|
+
) : dep.url;
|
|
2659
|
+
let cssMod;
|
|
2660
|
+
if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi) {
|
|
2661
|
+
const cssDevHelperEnvironment = viteDevServer.environments[CSS_DEV_HELPER_ENVIRONMENT_NAME];
|
|
2662
|
+
invariant(cssDevHelperEnvironment, "Missing CSS dev helper environment");
|
|
2663
|
+
invariant(vite2.isRunnableDevEnvironment(cssDevHelperEnvironment));
|
|
2664
|
+
cssMod = await cssDevHelperEnvironment.runner.import(url2);
|
|
2665
|
+
} else {
|
|
2666
|
+
cssMod = await viteDevServer.ssrLoadModule(url2);
|
|
2667
|
+
}
|
|
2946
2668
|
invariant(
|
|
2947
|
-
|
|
2669
|
+
typeof cssMod === "object" && cssMod !== null && "default" in cssMod && typeof cssMod.default === "string",
|
|
2948
2670
|
`Failed to load CSS for ${dep.file ?? dep.url}`
|
|
2949
2671
|
);
|
|
2950
|
-
|
|
2951
|
-
invariant(
|
|
2952
|
-
typeof cssString === "string",
|
|
2953
|
-
`Failed to extract CSS for ${dep.file ?? dep.url}`
|
|
2954
|
-
);
|
|
2955
|
-
return cssString;
|
|
2672
|
+
return cssMod.default;
|
|
2956
2673
|
};
|
|
2957
2674
|
return [
|
|
2958
2675
|
{
|
|
@@ -2970,17 +2687,14 @@ var reactRouterVitePlugin = () => {
|
|
|
2970
2687
|
prefix: "[react-router]"
|
|
2971
2688
|
});
|
|
2972
2689
|
rootDirectory = viteUserConfig.root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();
|
|
2973
|
-
let mode = viteConfigEnv.mode;
|
|
2974
2690
|
if (viteCommand === "serve") {
|
|
2975
2691
|
typegenWatcherPromise = watch(rootDirectory, {
|
|
2976
|
-
mode,
|
|
2977
2692
|
// ignore `info` logs from typegen since they are redundant when Vite plugin logs are active
|
|
2978
2693
|
logger: vite2.createLogger("warn", { prefix: "[react-router]" })
|
|
2979
2694
|
});
|
|
2980
2695
|
}
|
|
2981
2696
|
reactRouterConfigLoader = await createConfigLoader({
|
|
2982
2697
|
rootDirectory,
|
|
2983
|
-
mode,
|
|
2984
2698
|
watch: viteCommand === "serve"
|
|
2985
2699
|
});
|
|
2986
2700
|
await updatePluginContext();
|
|
@@ -3238,8 +2952,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3238
2952
|
reactRouterConfigLoader.onChange(
|
|
3239
2953
|
async ({
|
|
3240
2954
|
result,
|
|
3241
|
-
|
|
3242
|
-
routeConfigCodeChanged,
|
|
2955
|
+
configCodeUpdated,
|
|
3243
2956
|
configChanged,
|
|
3244
2957
|
routeConfigChanged
|
|
3245
2958
|
}) => {
|
|
@@ -3251,13 +2964,19 @@ var reactRouterVitePlugin = () => {
|
|
|
3251
2964
|
});
|
|
3252
2965
|
return;
|
|
3253
2966
|
}
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
2967
|
+
if (routeConfigChanged) {
|
|
2968
|
+
logger.info(import_picocolors3.default.green("Route config changed."), {
|
|
2969
|
+
clear: true,
|
|
2970
|
+
timestamp: true
|
|
2971
|
+
});
|
|
2972
|
+
} else if (configCodeUpdated) {
|
|
2973
|
+
logger.info(import_picocolors3.default.green("Config updated."), {
|
|
2974
|
+
clear: true,
|
|
2975
|
+
timestamp: true
|
|
2976
|
+
});
|
|
2977
|
+
}
|
|
3259
2978
|
await updatePluginContext();
|
|
3260
|
-
if (configChanged
|
|
2979
|
+
if (configChanged) {
|
|
3261
2980
|
invalidateVirtualModules(viteDevServer);
|
|
3262
2981
|
}
|
|
3263
2982
|
}
|
|
@@ -3298,11 +3017,11 @@ var reactRouterVitePlugin = () => {
|
|
|
3298
3017
|
return;
|
|
3299
3018
|
}
|
|
3300
3019
|
build = await ssrEnvironment.runner.import(
|
|
3301
|
-
|
|
3020
|
+
virtual2.serverBuild.id
|
|
3302
3021
|
);
|
|
3303
3022
|
} else {
|
|
3304
3023
|
build = await viteDevServer.ssrLoadModule(
|
|
3305
|
-
|
|
3024
|
+
virtual2.serverBuild.id
|
|
3306
3025
|
);
|
|
3307
3026
|
}
|
|
3308
3027
|
let handler = (0, import_react_router2.createRequestHandler)(build, "development");
|
|
@@ -3339,8 +3058,8 @@ var reactRouterVitePlugin = () => {
|
|
|
3339
3058
|
let ssrAssetPaths = getViteManifestAssetPaths(ssrViteManifest);
|
|
3340
3059
|
let movedAssetPaths = [];
|
|
3341
3060
|
for (let ssrAssetPath of ssrAssetPaths) {
|
|
3342
|
-
let src =
|
|
3343
|
-
let dest =
|
|
3061
|
+
let src = path6.join(serverBuildDirectory, ssrAssetPath);
|
|
3062
|
+
let dest = path6.join(clientBuildDirectory, ssrAssetPath);
|
|
3344
3063
|
if (!fse.existsSync(dest)) {
|
|
3345
3064
|
await fse.move(src, dest);
|
|
3346
3065
|
movedAssetPaths.push(dest);
|
|
@@ -3353,7 +3072,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3353
3072
|
);
|
|
3354
3073
|
await Promise.all(
|
|
3355
3074
|
ssrCssPaths.map(
|
|
3356
|
-
(cssPath) => fse.remove(
|
|
3075
|
+
(cssPath) => fse.remove(path6.join(serverBuildDirectory, cssPath))
|
|
3357
3076
|
)
|
|
3358
3077
|
);
|
|
3359
3078
|
if (movedAssetPaths.length) {
|
|
@@ -3362,13 +3081,12 @@ var reactRouterVitePlugin = () => {
|
|
|
3362
3081
|
"",
|
|
3363
3082
|
`${import_picocolors3.default.green("\u2713")} ${movedAssetPaths.length} asset${movedAssetPaths.length > 1 ? "s" : ""} moved from React Router server build to client assets.`,
|
|
3364
3083
|
...movedAssetPaths.map(
|
|
3365
|
-
(movedAssetPath) => import_picocolors3.default.dim(
|
|
3084
|
+
(movedAssetPath) => import_picocolors3.default.dim(path6.relative(ctx.rootDirectory, movedAssetPath))
|
|
3366
3085
|
),
|
|
3367
3086
|
""
|
|
3368
3087
|
].join("\n")
|
|
3369
3088
|
);
|
|
3370
3089
|
}
|
|
3371
|
-
process.env.IS_RR_BUILD_REQUEST = "yes";
|
|
3372
3090
|
if (isPrerenderingEnabled(ctx.reactRouterConfig)) {
|
|
3373
3091
|
await handlePrerender(
|
|
3374
3092
|
viteConfig,
|
|
@@ -3441,7 +3159,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3441
3159
|
);
|
|
3442
3160
|
let isMainChunkExport = (name) => !chunkedExports.includes(name);
|
|
3443
3161
|
let mainChunkReexports = sourceExports.filter(isMainChunkExport).join(", ");
|
|
3444
|
-
let chunkBasePath = `./${
|
|
3162
|
+
let chunkBasePath = `./${path6.basename(id)}`;
|
|
3445
3163
|
return [
|
|
3446
3164
|
`export { ${mainChunkReexports} } from "${getRouteChunkModuleId(
|
|
3447
3165
|
chunkBasePath,
|
|
@@ -3461,7 +3179,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3461
3179
|
async transform(code, id, options) {
|
|
3462
3180
|
if (!id.endsWith(BUILD_CLIENT_ROUTE_QUERY_STRING)) return;
|
|
3463
3181
|
let routeModuleId = id.replace(BUILD_CLIENT_ROUTE_QUERY_STRING, "");
|
|
3464
|
-
let routeFileName =
|
|
3182
|
+
let routeFileName = path6.basename(routeModuleId);
|
|
3465
3183
|
let sourceExports = await getRouteModuleExports(
|
|
3466
3184
|
viteChildCompiler,
|
|
3467
3185
|
ctx,
|
|
@@ -3527,16 +3245,16 @@ var reactRouterVitePlugin = () => {
|
|
|
3527
3245
|
name: "react-router:virtual-modules",
|
|
3528
3246
|
enforce: "pre",
|
|
3529
3247
|
resolveId(id) {
|
|
3530
|
-
const vmod2 = Object.values(
|
|
3248
|
+
const vmod2 = Object.values(virtual2).find((vmod3) => vmod3.id === id);
|
|
3531
3249
|
if (vmod2) return vmod2.resolvedId;
|
|
3532
3250
|
},
|
|
3533
3251
|
async load(id) {
|
|
3534
3252
|
switch (id) {
|
|
3535
|
-
case
|
|
3253
|
+
case virtual2.serverBuild.resolvedId: {
|
|
3536
3254
|
let routeIds = getServerBundleRouteIds(this, ctx);
|
|
3537
3255
|
return await getServerEntry({ routeIds });
|
|
3538
3256
|
}
|
|
3539
|
-
case
|
|
3257
|
+
case virtual2.serverManifest.resolvedId: {
|
|
3540
3258
|
let routeIds = getServerBundleRouteIds(this, ctx);
|
|
3541
3259
|
let reactRouterManifest = viteCommand === "build" ? (await generateReactRouterManifestsForBuild({
|
|
3542
3260
|
routeIds
|
|
@@ -3554,7 +3272,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3554
3272
|
es6: true
|
|
3555
3273
|
})};`;
|
|
3556
3274
|
}
|
|
3557
|
-
case
|
|
3275
|
+
case virtual2.browserManifest.resolvedId: {
|
|
3558
3276
|
if (viteCommand === "build") {
|
|
3559
3277
|
throw new Error("This module only exists in development");
|
|
3560
3278
|
}
|
|
@@ -3588,7 +3306,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3588
3306
|
}
|
|
3589
3307
|
let vite2 = getVite();
|
|
3590
3308
|
let importerShort = vite2.normalizePath(
|
|
3591
|
-
|
|
3309
|
+
path6.relative(ctx.rootDirectory, importer)
|
|
3592
3310
|
);
|
|
3593
3311
|
if (isRoute(ctx.reactRouterConfig, importer)) {
|
|
3594
3312
|
let serverOnlyExports = SERVER_ONLY_ROUTE_EXPORTS.map(
|
|
@@ -3711,10 +3429,10 @@ var reactRouterVitePlugin = () => {
|
|
|
3711
3429
|
},
|
|
3712
3430
|
async load(id) {
|
|
3713
3431
|
if (id !== virtualHmrRuntime.resolvedId) return;
|
|
3714
|
-
let reactRefreshDir =
|
|
3432
|
+
let reactRefreshDir = path6.dirname(
|
|
3715
3433
|
require.resolve("react-refresh/package.json")
|
|
3716
3434
|
);
|
|
3717
|
-
let reactRefreshRuntimePath =
|
|
3435
|
+
let reactRefreshRuntimePath = path6.join(
|
|
3718
3436
|
reactRefreshDir,
|
|
3719
3437
|
"cjs/react-refresh-runtime.development.js"
|
|
3720
3438
|
);
|
|
@@ -3895,7 +3613,7 @@ if (import.meta.hot && !inWebWorker) {
|
|
|
3895
3613
|
function getRoute(pluginConfig, file) {
|
|
3896
3614
|
let vite2 = getVite();
|
|
3897
3615
|
let routePath = vite2.normalizePath(
|
|
3898
|
-
|
|
3616
|
+
path6.relative(pluginConfig.appDirectory, file)
|
|
3899
3617
|
);
|
|
3900
3618
|
let route = Object.values(pluginConfig.routes).find(
|
|
3901
3619
|
(r) => vite2.normalizePath(r.file) === routePath
|
|
@@ -3934,7 +3652,7 @@ async function getRouteMetadata(cache, ctx, viteChildCompiler, route, readRouteF
|
|
|
3934
3652
|
caseSensitive: route.caseSensitive,
|
|
3935
3653
|
url: combineURLs(
|
|
3936
3654
|
ctx.publicPath,
|
|
3937
|
-
"/" +
|
|
3655
|
+
"/" + path6.relative(
|
|
3938
3656
|
ctx.rootDirectory,
|
|
3939
3657
|
resolveRelativeRouteFilePath(route, ctx.reactRouterConfig)
|
|
3940
3658
|
)
|
|
@@ -3962,7 +3680,7 @@ function isSpaModeEnabled(reactRouterConfig) {
|
|
|
3962
3680
|
return reactRouterConfig.ssr === false && !isPrerenderingEnabled(reactRouterConfig);
|
|
3963
3681
|
}
|
|
3964
3682
|
async function getPrerenderBuildAndHandler(viteConfig, serverBuildDirectory, serverBuildFile) {
|
|
3965
|
-
let serverBuildPath =
|
|
3683
|
+
let serverBuildPath = path6.join(serverBuildDirectory, serverBuildFile);
|
|
3966
3684
|
let build = await import(url.pathToFileURL(serverBuildPath).toString());
|
|
3967
3685
|
let { createRequestHandler: createHandler } = await import("react-router");
|
|
3968
3686
|
return {
|
|
@@ -3985,16 +3703,16 @@ async function handleSpaMode(viteConfig, reactRouterConfig, serverBuildDirectory
|
|
|
3985
3703
|
let response = await handler(request);
|
|
3986
3704
|
let html = await response.text();
|
|
3987
3705
|
let isPrerenderSpaFallback = build.prerender.includes("/");
|
|
3988
|
-
let
|
|
3706
|
+
let filename3 = isPrerenderSpaFallback ? "__spa-fallback.html" : "index.html";
|
|
3989
3707
|
if (response.status !== 200) {
|
|
3990
3708
|
if (isPrerenderSpaFallback) {
|
|
3991
3709
|
throw new Error(
|
|
3992
|
-
`Prerender: Received a ${response.status} status code from \`entry.server.tsx\` while prerendering your \`${
|
|
3710
|
+
`Prerender: Received a ${response.status} status code from \`entry.server.tsx\` while prerendering your \`${filename3}\` file.
|
|
3993
3711
|
` + html
|
|
3994
3712
|
);
|
|
3995
3713
|
} else {
|
|
3996
3714
|
throw new Error(
|
|
3997
|
-
`SPA Mode: Received a ${response.status} status code from \`entry.server.tsx\` while prerendering your \`${
|
|
3715
|
+
`SPA Mode: Received a ${response.status} status code from \`entry.server.tsx\` while prerendering your \`${filename3}\` file.
|
|
3998
3716
|
` + html
|
|
3999
3717
|
);
|
|
4000
3718
|
}
|
|
@@ -4004,9 +3722,9 @@ async function handleSpaMode(viteConfig, reactRouterConfig, serverBuildDirectory
|
|
|
4004
3722
|
"SPA Mode: Did you forget to include `<Scripts/>` in your root route? Your pre-rendered HTML cannot hydrate without `<Scripts />`."
|
|
4005
3723
|
);
|
|
4006
3724
|
}
|
|
4007
|
-
await fse.writeFile(
|
|
4008
|
-
let prettyDir =
|
|
4009
|
-
let prettyPath =
|
|
3725
|
+
await fse.writeFile(path6.join(clientBuildDirectory, filename3), html);
|
|
3726
|
+
let prettyDir = path6.relative(process.cwd(), clientBuildDirectory);
|
|
3727
|
+
let prettyPath = path6.join(prettyDir, filename3);
|
|
4010
3728
|
if (build.prerender.length > 0) {
|
|
4011
3729
|
viteConfig.logger.info(
|
|
4012
3730
|
`Prerender (html): SPA Fallback -> ${import_picocolors3.default.bold(prettyPath)}`
|
|
@@ -4022,17 +3740,22 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4022
3740
|
serverBuildPath
|
|
4023
3741
|
);
|
|
4024
3742
|
let routes = createPrerenderRoutes(reactRouterConfig.routes);
|
|
4025
|
-
for (let
|
|
4026
|
-
let matches = (0, import_react_router2.matchRoutes)(routes, `/${
|
|
3743
|
+
for (let path7 of build.prerender) {
|
|
3744
|
+
let matches = (0, import_react_router2.matchRoutes)(routes, `/${path7}/`.replace(/^\/\/+/, "/"));
|
|
4027
3745
|
if (!matches) {
|
|
4028
3746
|
throw new Error(
|
|
4029
|
-
`Unable to prerender path because it does not match any routes: ${
|
|
3747
|
+
`Unable to prerender path because it does not match any routes: ${path7}`
|
|
4030
3748
|
);
|
|
4031
3749
|
}
|
|
4032
3750
|
}
|
|
4033
3751
|
let buildRoutes = createPrerenderRoutes(build.routes);
|
|
4034
|
-
|
|
4035
|
-
|
|
3752
|
+
let headers = {
|
|
3753
|
+
// Header that can be used in the loader to know if you're running at
|
|
3754
|
+
// build time or runtime
|
|
3755
|
+
"X-React-Router-Prerender": "yes"
|
|
3756
|
+
};
|
|
3757
|
+
for (let path7 of build.prerender) {
|
|
3758
|
+
let matches = (0, import_react_router2.matchRoutes)(buildRoutes, `/${path7}/`.replace(/^\/\/+/, "/"));
|
|
4036
3759
|
if (!matches) {
|
|
4037
3760
|
continue;
|
|
4038
3761
|
}
|
|
@@ -4045,18 +3768,20 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4045
3768
|
if (manifestRoute.loader) {
|
|
4046
3769
|
await prerenderData(
|
|
4047
3770
|
handler,
|
|
4048
|
-
|
|
3771
|
+
path7,
|
|
4049
3772
|
[leafRoute.id],
|
|
4050
3773
|
clientBuildDirectory,
|
|
4051
3774
|
reactRouterConfig,
|
|
4052
|
-
viteConfig
|
|
3775
|
+
viteConfig,
|
|
3776
|
+
{ headers }
|
|
4053
3777
|
);
|
|
4054
3778
|
await prerenderResourceRoute(
|
|
4055
3779
|
handler,
|
|
4056
|
-
|
|
3780
|
+
path7,
|
|
4057
3781
|
clientBuildDirectory,
|
|
4058
3782
|
reactRouterConfig,
|
|
4059
|
-
viteConfig
|
|
3783
|
+
viteConfig,
|
|
3784
|
+
{ headers }
|
|
4060
3785
|
);
|
|
4061
3786
|
} else {
|
|
4062
3787
|
viteConfig.logger.warn(
|
|
@@ -4071,24 +3796,26 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4071
3796
|
if (!isResourceRoute && hasLoaders) {
|
|
4072
3797
|
data = await prerenderData(
|
|
4073
3798
|
handler,
|
|
4074
|
-
|
|
3799
|
+
path7,
|
|
4075
3800
|
null,
|
|
4076
3801
|
clientBuildDirectory,
|
|
4077
3802
|
reactRouterConfig,
|
|
4078
|
-
viteConfig
|
|
3803
|
+
viteConfig,
|
|
3804
|
+
{ headers }
|
|
4079
3805
|
);
|
|
4080
3806
|
}
|
|
4081
3807
|
await prerenderRoute(
|
|
4082
3808
|
handler,
|
|
4083
|
-
|
|
3809
|
+
path7,
|
|
4084
3810
|
clientBuildDirectory,
|
|
4085
3811
|
reactRouterConfig,
|
|
4086
3812
|
viteConfig,
|
|
4087
3813
|
data ? {
|
|
4088
3814
|
headers: {
|
|
3815
|
+
...headers,
|
|
4089
3816
|
"X-React-Router-Prerender-Data": encodeURI(data)
|
|
4090
3817
|
}
|
|
4091
|
-
} :
|
|
3818
|
+
} : { headers }
|
|
4092
3819
|
);
|
|
4093
3820
|
}
|
|
4094
3821
|
}
|
|
@@ -4133,9 +3860,9 @@ async function prerenderData(handler, prerenderPath, onlyRoutes, clientBuildDire
|
|
|
4133
3860
|
${normalizedPath}`
|
|
4134
3861
|
);
|
|
4135
3862
|
}
|
|
4136
|
-
let outdir =
|
|
4137
|
-
let outfile =
|
|
4138
|
-
await fse.ensureDir(
|
|
3863
|
+
let outdir = path6.relative(process.cwd(), clientBuildDirectory);
|
|
3864
|
+
let outfile = path6.join(outdir, ...normalizedPath.split("/"));
|
|
3865
|
+
await fse.ensureDir(path6.dirname(outfile));
|
|
4139
3866
|
await fse.outputFile(outfile, data);
|
|
4140
3867
|
viteConfig.logger.info(
|
|
4141
3868
|
`Prerender (data): ${prerenderPath} -> ${import_picocolors3.default.bold(outfile)}`
|
|
@@ -4172,9 +3899,9 @@ async function prerenderRoute(handler, prerenderPath, clientBuildDirectory, reac
|
|
|
4172
3899
|
${html}`
|
|
4173
3900
|
);
|
|
4174
3901
|
}
|
|
4175
|
-
let outdir =
|
|
4176
|
-
let outfile =
|
|
4177
|
-
await fse.ensureDir(
|
|
3902
|
+
let outdir = path6.relative(process.cwd(), clientBuildDirectory);
|
|
3903
|
+
let outfile = path6.join(outdir, ...normalizedPath.split("/"), "index.html");
|
|
3904
|
+
await fse.ensureDir(path6.dirname(outfile));
|
|
4178
3905
|
await fse.outputFile(outfile, html);
|
|
4179
3906
|
viteConfig.logger.info(
|
|
4180
3907
|
`Prerender (html): ${prerenderPath} -> ${import_picocolors3.default.bold(outfile)}`
|
|
@@ -4191,9 +3918,9 @@ async function prerenderResourceRoute(handler, prerenderPath, clientBuildDirecto
|
|
|
4191
3918
|
${content.toString("utf8")}`
|
|
4192
3919
|
);
|
|
4193
3920
|
}
|
|
4194
|
-
let outdir =
|
|
4195
|
-
let outfile =
|
|
4196
|
-
await fse.ensureDir(
|
|
3921
|
+
let outdir = path6.relative(process.cwd(), clientBuildDirectory);
|
|
3922
|
+
let outfile = path6.join(outdir, ...normalizedPath.split("/"));
|
|
3923
|
+
await fse.ensureDir(path6.dirname(outfile));
|
|
4197
3924
|
await fse.outputFile(outfile, content);
|
|
4198
3925
|
viteConfig.logger.info(
|
|
4199
3926
|
`Prerender (resource): ${prerenderPath} -> ${import_picocolors3.default.bold(outfile)}`
|
|
@@ -4269,14 +3996,14 @@ async function validateSsrFalsePrerenderExports(viteConfig, ctx, manifest, viteC
|
|
|
4269
3996
|
}
|
|
4270
3997
|
let prerenderRoutes = createPrerenderRoutes(manifest.routes);
|
|
4271
3998
|
let prerenderedRoutes = /* @__PURE__ */ new Set();
|
|
4272
|
-
for (let
|
|
3999
|
+
for (let path7 of prerenderPaths) {
|
|
4273
4000
|
let matches = (0, import_react_router2.matchRoutes)(
|
|
4274
4001
|
prerenderRoutes,
|
|
4275
|
-
`/${
|
|
4002
|
+
`/${path7}/`.replace(/^\/\/+/, "/")
|
|
4276
4003
|
);
|
|
4277
4004
|
invariant(
|
|
4278
4005
|
matches,
|
|
4279
|
-
`Unable to prerender path because it does not match any routes: ${
|
|
4006
|
+
`Unable to prerender path because it does not match any routes: ${path7}`
|
|
4280
4007
|
);
|
|
4281
4008
|
matches.forEach((m) => prerenderedRoutes.add(m.route.id));
|
|
4282
4009
|
}
|
|
@@ -4443,8 +4170,8 @@ function validateRouteChunks({
|
|
|
4443
4170
|
async function cleanBuildDirectory(viteConfig, ctx) {
|
|
4444
4171
|
let buildDirectory = ctx.reactRouterConfig.buildDirectory;
|
|
4445
4172
|
let isWithinRoot = () => {
|
|
4446
|
-
let relativePath =
|
|
4447
|
-
return !relativePath.startsWith("..") && !
|
|
4173
|
+
let relativePath = path6.relative(ctx.rootDirectory, buildDirectory);
|
|
4174
|
+
return !relativePath.startsWith("..") && !path6.isAbsolute(relativePath);
|
|
4448
4175
|
};
|
|
4449
4176
|
if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
|
|
4450
4177
|
await fse.remove(buildDirectory);
|
|
@@ -4455,7 +4182,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
|
|
|
4455
4182
|
([environmentName, options]) => {
|
|
4456
4183
|
let outDir = options.build?.outDir;
|
|
4457
4184
|
invariant(outDir, `Expected build.outDir for ${environmentName}`);
|
|
4458
|
-
return
|
|
4185
|
+
return path6.join(outDir, ".vite/manifest.json");
|
|
4459
4186
|
}
|
|
4460
4187
|
);
|
|
4461
4188
|
await Promise.all(
|
|
@@ -4465,7 +4192,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
|
|
|
4465
4192
|
if (!ctx.viteManifestEnabled) {
|
|
4466
4193
|
await fse.remove(viteManifestPath);
|
|
4467
4194
|
}
|
|
4468
|
-
let viteDir =
|
|
4195
|
+
let viteDir = path6.dirname(viteManifestPath);
|
|
4469
4196
|
let viteDirFiles = await fse.readdir(viteDir);
|
|
4470
4197
|
if (viteDirFiles.length === 0) {
|
|
4471
4198
|
await fse.remove(viteDir);
|
|
@@ -4483,12 +4210,12 @@ async function getBuildManifest({
|
|
|
4483
4210
|
}
|
|
4484
4211
|
let { normalizePath } = await import("vite");
|
|
4485
4212
|
let serverBuildDirectory = getServerBuildDirectory(reactRouterConfig);
|
|
4486
|
-
let resolvedAppDirectory =
|
|
4213
|
+
let resolvedAppDirectory = path6.resolve(rootDirectory, appDirectory);
|
|
4487
4214
|
let rootRelativeRoutes = Object.fromEntries(
|
|
4488
4215
|
Object.entries(routes).map(([id, route]) => {
|
|
4489
|
-
let filePath =
|
|
4216
|
+
let filePath = path6.join(resolvedAppDirectory, route.file);
|
|
4490
4217
|
let rootRelativeFilePath = normalizePath(
|
|
4491
|
-
|
|
4218
|
+
path6.relative(rootDirectory, filePath)
|
|
4492
4219
|
);
|
|
4493
4220
|
return [id, { ...route, file: rootRelativeFilePath }];
|
|
4494
4221
|
})
|
|
@@ -4506,7 +4233,7 @@ async function getBuildManifest({
|
|
|
4506
4233
|
(route2) => configRouteToBranchRoute({
|
|
4507
4234
|
...route2,
|
|
4508
4235
|
// Ensure absolute paths are passed to the serverBundles function
|
|
4509
|
-
file:
|
|
4236
|
+
file: path6.join(resolvedAppDirectory, route2.file)
|
|
4510
4237
|
})
|
|
4511
4238
|
)
|
|
4512
4239
|
});
|
|
@@ -4530,10 +4257,10 @@ async function getBuildManifest({
|
|
|
4530
4257
|
buildManifest.serverBundles[serverBundleId] ??= {
|
|
4531
4258
|
id: serverBundleId,
|
|
4532
4259
|
file: normalizePath(
|
|
4533
|
-
|
|
4534
|
-
|
|
4260
|
+
path6.join(
|
|
4261
|
+
path6.relative(
|
|
4535
4262
|
rootDirectory,
|
|
4536
|
-
|
|
4263
|
+
path6.join(serverBuildDirectory, serverBundleId)
|
|
4537
4264
|
),
|
|
4538
4265
|
reactRouterConfig.serverBuildFile
|
|
4539
4266
|
)
|
|
@@ -4552,10 +4279,10 @@ function mergeEnvironmentOptions(base, ...overrides) {
|
|
|
4552
4279
|
}
|
|
4553
4280
|
async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
4554
4281
|
let { serverBuildFile, serverModuleFormat } = ctx.reactRouterConfig;
|
|
4555
|
-
let packageRoot =
|
|
4282
|
+
let packageRoot = path6.dirname(
|
|
4556
4283
|
require.resolve("@react-router/dev/package.json")
|
|
4557
4284
|
);
|
|
4558
|
-
let { moduleSyncEnabled } = await import(`file:///${
|
|
4285
|
+
let { moduleSyncEnabled } = await import(`file:///${path6.join(packageRoot, "module-sync-enabled/index.mjs")}`);
|
|
4559
4286
|
let vite2 = getVite();
|
|
4560
4287
|
let viteServerConditions = [
|
|
4561
4288
|
...vite2.defaultServerConditions ?? [],
|
|
@@ -4612,7 +4339,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
4612
4339
|
copyPublicDir: false,
|
|
4613
4340
|
// Assets in the public directory are only used by the client
|
|
4614
4341
|
rollupOptions: {
|
|
4615
|
-
input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ??
|
|
4342
|
+
input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual2.serverBuild.id,
|
|
4616
4343
|
output: {
|
|
4617
4344
|
entryFileNames: serverBuildFile,
|
|
4618
4345
|
format: serverModuleFormat
|
|
@@ -4629,7 +4356,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
4629
4356
|
ctx.entryClientFilePath,
|
|
4630
4357
|
...Object.values(ctx.reactRouterConfig.routes).flatMap(
|
|
4631
4358
|
(route) => {
|
|
4632
|
-
let routeFilePath =
|
|
4359
|
+
let routeFilePath = path6.resolve(
|
|
4633
4360
|
ctx.reactRouterConfig.appDirectory,
|
|
4634
4361
|
route.file
|
|
4635
4362
|
);
|
|
@@ -4652,9 +4379,8 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
4652
4379
|
""
|
|
4653
4380
|
) : null;
|
|
4654
4381
|
let routeChunkSuffix = routeChunkName ? `-${(0, import_kebabCase.default)(routeChunkName)}` : "";
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
assetsDir,
|
|
4382
|
+
return path6.posix.join(
|
|
4383
|
+
(ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.assetsDir : viteUserConfig?.build?.assetsDir) ?? "assets",
|
|
4658
4384
|
`[name]${routeChunkSuffix}-[hash].js`
|
|
4659
4385
|
);
|
|
4660
4386
|
}
|
|
@@ -4689,6 +4415,9 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
4689
4415
|
}
|
|
4690
4416
|
});
|
|
4691
4417
|
}
|
|
4418
|
+
if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi && viteCommand === "serve") {
|
|
4419
|
+
environmentOptionsResolvers[CSS_DEV_HELPER_ENVIRONMENT_NAME] = () => ({});
|
|
4420
|
+
}
|
|
4692
4421
|
return environmentOptionsResolvers;
|
|
4693
4422
|
}
|
|
4694
4423
|
function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
|