@react-router/dev 0.0.0-experimental-303421afa → 0.0.0-experimental-bfc808d6c
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 +38 -0
- package/dist/cli/index.js +27 -17
- package/dist/config.d.ts +5 -5
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +16 -6
- package/dist/vite.js +73 -34
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# `@react-router/dev`
|
|
2
2
|
|
|
3
|
+
## 7.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Stabilize `future.v8_splitRouteModules`, replacing `future.unstable_splitRouteModules` ([#14595](https://github.com/remix-run/react-router/pull/14595))
|
|
8
|
+
- ⚠️ This is a breaking change if you have begun using `future.unstable_splitRouteModules`. Please update your `react-router.config.ts`.
|
|
9
|
+
|
|
10
|
+
- Stabilize `future.v8_viteEnvironmentApi`, replacing `future.unstable_viteEnvironmentApi` ([#14595](https://github.com/remix-run/react-router/pull/14595))
|
|
11
|
+
- ⚠️ This is a breaking change if you have begun using `future.unstable_viteEnvironmentApi`. Please update your `react-router.config.ts`.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Load environment variables before evaluating `routes.ts` ([#14446](https://github.com/remix-run/react-router/pull/14446))
|
|
16
|
+
|
|
17
|
+
For example, you can now compute your routes based on [`VITE_`-prefixed environment variables](https://vite.dev/guide/env-and-mode#env-variables):
|
|
18
|
+
|
|
19
|
+
```txt
|
|
20
|
+
# .env
|
|
21
|
+
VITE_ENV_ROUTE=my-route
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// app/routes.ts
|
|
26
|
+
import { type RouteConfig, route } from "@react-router/dev/routes";
|
|
27
|
+
|
|
28
|
+
const routes: RouteConfig = [];
|
|
29
|
+
if (import.meta.env.VITE_ENV_ROUTE === "my-route") {
|
|
30
|
+
routes.push(route("my-route", "routes/my-route.tsx"));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default routes;
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- Updated dependencies:
|
|
37
|
+
- `react-router@7.10.0`
|
|
38
|
+
- `@react-router/node@7.10.0`
|
|
39
|
+
- `@react-router/serve@7.10.0`
|
|
40
|
+
|
|
3
41
|
## 7.9.6
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @react-router/dev v0.0.0-experimental-
|
|
3
|
+
* @react-router/dev v0.0.0-experimental-bfc808d6c
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -492,12 +492,23 @@ async function resolveConfig({
|
|
|
492
492
|
);
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
|
+
let futureConfig = userAndPresetConfigs.future;
|
|
496
|
+
if (futureConfig?.unstable_splitRouteModules !== void 0) {
|
|
497
|
+
return err(
|
|
498
|
+
'The "future.unstable_splitRouteModules" flag has been stabilized as "future.v8_splitRouteModules"'
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
if (futureConfig?.unstable_viteEnvironmentApi !== void 0) {
|
|
502
|
+
return err(
|
|
503
|
+
'The "future.unstable_viteEnvironmentApi" flag has been stabilized as "future.v8_viteEnvironmentApi"'
|
|
504
|
+
);
|
|
505
|
+
}
|
|
495
506
|
let future = {
|
|
496
|
-
v8_middleware: userAndPresetConfigs.future?.v8_middleware ?? false,
|
|
497
507
|
unstable_optimizeDeps: userAndPresetConfigs.future?.unstable_optimizeDeps ?? false,
|
|
498
|
-
unstable_splitRouteModules: userAndPresetConfigs.future?.unstable_splitRouteModules ?? false,
|
|
499
508
|
unstable_subResourceIntegrity: userAndPresetConfigs.future?.unstable_subResourceIntegrity ?? false,
|
|
500
|
-
|
|
509
|
+
v8_middleware: userAndPresetConfigs.future?.v8_middleware ?? false,
|
|
510
|
+
v8_splitRouteModules: userAndPresetConfigs.future?.v8_splitRouteModules ?? false,
|
|
511
|
+
v8_viteEnvironmentApi: userAndPresetConfigs.future?.v8_viteEnvironmentApi ?? false
|
|
501
512
|
};
|
|
502
513
|
let reactRouterConfig = deepFreeze({
|
|
503
514
|
appDirectory,
|
|
@@ -718,7 +729,7 @@ function isEntryFileDependency(moduleGraph, entryFilepath, filepath, visited = /
|
|
|
718
729
|
}
|
|
719
730
|
return false;
|
|
720
731
|
}
|
|
721
|
-
var import_node_fs, import_node_child_process, import_pathe3, import_chokidar, import_picocolors,
|
|
732
|
+
var import_node_fs, import_node_child_process, import_pathe3, import_chokidar, import_picocolors, import_pick2, import_omit, import_cloneDeep, import_isEqual, excludedConfigPresetKeys, mergeReactRouterConfig, deepFreeze, entryExts;
|
|
722
733
|
var init_config = __esm({
|
|
723
734
|
"config/config.ts"() {
|
|
724
735
|
"use strict";
|
|
@@ -728,7 +739,6 @@ var init_config = __esm({
|
|
|
728
739
|
import_pathe3 = __toESM(require("pathe"));
|
|
729
740
|
import_chokidar = __toESM(require("chokidar"));
|
|
730
741
|
import_picocolors = __toESM(require("picocolors"));
|
|
731
|
-
import_pkg_types = require("pkg-types");
|
|
732
742
|
import_pick2 = __toESM(require("lodash/pick"));
|
|
733
743
|
import_omit = __toESM(require("lodash/omit"));
|
|
734
744
|
import_cloneDeep = __toESM(require("lodash/cloneDeep"));
|
|
@@ -1673,8 +1683,8 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
1673
1683
|
return mergeEnvironmentOptions(getBaseOptions({ viteUserConfig }), {
|
|
1674
1684
|
resolve: {
|
|
1675
1685
|
external: (
|
|
1676
|
-
// If `
|
|
1677
|
-
ctx.reactRouterConfig.future.
|
|
1686
|
+
// If `v8_viteEnvironmentApi` is `true`, `resolve.external` is set in the `configEnvironment` hook
|
|
1687
|
+
ctx.reactRouterConfig.future.v8_viteEnvironmentApi ? void 0 : ssrExternals
|
|
1678
1688
|
),
|
|
1679
1689
|
conditions: [...baseConditions, ...maybeDefaultServerConditions],
|
|
1680
1690
|
externalConditions: [...baseConditions, ...defaultExternalConditions]
|
|
@@ -1689,7 +1699,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
1689
1699
|
copyPublicDir: false,
|
|
1690
1700
|
// The client only uses assets in the public directory
|
|
1691
1701
|
rollupOptions: {
|
|
1692
|
-
input: (ctx.reactRouterConfig.future.
|
|
1702
|
+
input: (ctx.reactRouterConfig.future.v8_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual.serverBuild.id,
|
|
1693
1703
|
output: {
|
|
1694
1704
|
entryFileNames: serverBuildFile,
|
|
1695
1705
|
format: serverModuleFormat
|
|
@@ -1714,14 +1724,14 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
1714
1724
|
let code = (0, import_node_fs3.readFileSync)(routeFilePath, "utf-8");
|
|
1715
1725
|
return [
|
|
1716
1726
|
`${routeFilePath}${BUILD_CLIENT_ROUTE_QUERY_STRING}`,
|
|
1717
|
-
...ctx.reactRouterConfig.future.
|
|
1727
|
+
...ctx.reactRouterConfig.future.v8_splitRouteModules && !isRootRoute ? routeChunkExportNames.map(
|
|
1718
1728
|
(exportName) => code.includes(exportName) ? getRouteChunkModuleId(routeFilePath, exportName) : null
|
|
1719
1729
|
) : []
|
|
1720
1730
|
].filter(isNonNullable);
|
|
1721
1731
|
}
|
|
1722
1732
|
)
|
|
1723
1733
|
],
|
|
1724
|
-
output: (ctx.reactRouterConfig.future.
|
|
1734
|
+
output: (ctx.reactRouterConfig.future.v8_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.rollupOptions?.output : viteUserConfig?.build?.rollupOptions?.output) ?? {
|
|
1725
1735
|
entryFileNames: ({ moduleIds }) => {
|
|
1726
1736
|
let routeChunkModuleId = moduleIds.find(isRouteChunkModuleId);
|
|
1727
1737
|
let routeChunkName = routeChunkModuleId ? getRouteChunkNameFromModuleId(routeChunkModuleId)?.replace(
|
|
@@ -1729,7 +1739,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
1729
1739
|
""
|
|
1730
1740
|
) : null;
|
|
1731
1741
|
let routeChunkSuffix = routeChunkName ? `-${(0, import_kebabCase.default)(routeChunkName)}` : "";
|
|
1732
|
-
let assetsDir = (ctx.reactRouterConfig.future.
|
|
1742
|
+
let assetsDir = (ctx.reactRouterConfig.future.v8_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.assetsDir : null) ?? viteUserConfig?.build?.assetsDir ?? "assets";
|
|
1733
1743
|
return path7.posix.join(
|
|
1734
1744
|
assetsDir,
|
|
1735
1745
|
`[name]${routeChunkSuffix}-[hash].js`
|
|
@@ -1902,12 +1912,12 @@ async function build(root, viteBuildOptions) {
|
|
|
1902
1912
|
}
|
|
1903
1913
|
let config = configResult.value;
|
|
1904
1914
|
let viteMajor = parseInt(vite2.version.split(".")[0], 10);
|
|
1905
|
-
if (config.future.
|
|
1915
|
+
if (config.future.v8_viteEnvironmentApi && viteMajor === 5) {
|
|
1906
1916
|
throw new Error(
|
|
1907
|
-
"The future.
|
|
1917
|
+
"The future.v8_viteEnvironmentApi option is not supported in Vite 5"
|
|
1908
1918
|
);
|
|
1909
1919
|
}
|
|
1910
|
-
const useViteEnvironmentApi = config.future.
|
|
1920
|
+
const useViteEnvironmentApi = config.future.v8_viteEnvironmentApi || await hasReactRouterRscPlugin({ root, viteBuildOptions });
|
|
1911
1921
|
return await (useViteEnvironmentApi ? viteAppBuild(root, viteBuildOptions) : viteBuild(root, viteBuildOptions));
|
|
1912
1922
|
}
|
|
1913
1923
|
async function viteAppBuild(root, {
|
|
@@ -2144,7 +2154,6 @@ var import_promises3 = require("fs/promises");
|
|
|
2144
2154
|
var path8 = __toESM(require("path"));
|
|
2145
2155
|
var import_exit_hook = __toESM(require("exit-hook"));
|
|
2146
2156
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
2147
|
-
var import_pkg_types2 = require("pkg-types");
|
|
2148
2157
|
var import_react_router3 = require("react-router");
|
|
2149
2158
|
init_config();
|
|
2150
2159
|
|
|
@@ -2308,7 +2317,8 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2308
2317
|
);
|
|
2309
2318
|
return;
|
|
2310
2319
|
}
|
|
2311
|
-
let
|
|
2320
|
+
let { readPackageJSON } = await import("pkg-types");
|
|
2321
|
+
let pkgJson = await readPackageJSON(rootDirectory);
|
|
2312
2322
|
let deps = pkgJson.dependencies ?? {};
|
|
2313
2323
|
if (!deps["@react-router/node"]) {
|
|
2314
2324
|
console.error(import_picocolors8.default.red(`No default server entry detected.`));
|
package/dist/config.d.ts
CHANGED
|
@@ -37,20 +37,20 @@ type ServerBundlesBuildManifest = BaseBuildManifest & {
|
|
|
37
37
|
};
|
|
38
38
|
type ServerModuleFormat = "esm" | "cjs";
|
|
39
39
|
interface FutureConfig {
|
|
40
|
+
unstable_optimizeDeps: boolean;
|
|
41
|
+
unstable_subResourceIntegrity: boolean;
|
|
40
42
|
/**
|
|
41
43
|
* Enable route middleware
|
|
42
44
|
*/
|
|
43
45
|
v8_middleware: boolean;
|
|
44
|
-
unstable_optimizeDeps: boolean;
|
|
45
46
|
/**
|
|
46
47
|
* Automatically split route modules into multiple chunks when possible.
|
|
47
48
|
*/
|
|
48
|
-
|
|
49
|
-
unstable_subResourceIntegrity: boolean;
|
|
49
|
+
v8_splitRouteModules: boolean | "enforce";
|
|
50
50
|
/**
|
|
51
|
-
* Use Vite Environment API
|
|
51
|
+
* Use Vite Environment API
|
|
52
52
|
*/
|
|
53
|
-
|
|
53
|
+
v8_viteEnvironmentApi: boolean;
|
|
54
54
|
}
|
|
55
55
|
type BuildManifest = DefaultBuildManifest | ServerBundlesBuildManifest;
|
|
56
56
|
type BuildEndHook = (args: {
|
package/dist/config.js
CHANGED
package/dist/routes.js
CHANGED
package/dist/vite/cloudflare.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-bfc808d6c
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -187,7 +187,6 @@ async function createContext({
|
|
|
187
187
|
var import_pathe3 = __toESM(require("pathe"));
|
|
188
188
|
var import_chokidar = __toESM(require("chokidar"));
|
|
189
189
|
var import_picocolors = __toESM(require("picocolors"));
|
|
190
|
-
var import_pkg_types = require("pkg-types");
|
|
191
190
|
var import_pick2 = __toESM(require("lodash/pick"));
|
|
192
191
|
var import_omit = __toESM(require("lodash/omit"));
|
|
193
192
|
var import_cloneDeep = __toESM(require("lodash/cloneDeep"));
|
|
@@ -522,12 +521,23 @@ async function resolveConfig({
|
|
|
522
521
|
);
|
|
523
522
|
}
|
|
524
523
|
}
|
|
524
|
+
let futureConfig = userAndPresetConfigs.future;
|
|
525
|
+
if (futureConfig?.unstable_splitRouteModules !== void 0) {
|
|
526
|
+
return err(
|
|
527
|
+
'The "future.unstable_splitRouteModules" flag has been stabilized as "future.v8_splitRouteModules"'
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
if (futureConfig?.unstable_viteEnvironmentApi !== void 0) {
|
|
531
|
+
return err(
|
|
532
|
+
'The "future.unstable_viteEnvironmentApi" flag has been stabilized as "future.v8_viteEnvironmentApi"'
|
|
533
|
+
);
|
|
534
|
+
}
|
|
525
535
|
let future = {
|
|
526
|
-
v8_middleware: userAndPresetConfigs.future?.v8_middleware ?? false,
|
|
527
536
|
unstable_optimizeDeps: userAndPresetConfigs.future?.unstable_optimizeDeps ?? false,
|
|
528
|
-
unstable_splitRouteModules: userAndPresetConfigs.future?.unstable_splitRouteModules ?? false,
|
|
529
537
|
unstable_subResourceIntegrity: userAndPresetConfigs.future?.unstable_subResourceIntegrity ?? false,
|
|
530
|
-
|
|
538
|
+
v8_middleware: userAndPresetConfigs.future?.v8_middleware ?? false,
|
|
539
|
+
v8_splitRouteModules: userAndPresetConfigs.future?.v8_splitRouteModules ?? false,
|
|
540
|
+
v8_viteEnvironmentApi: userAndPresetConfigs.future?.v8_viteEnvironmentApi ?? false
|
|
531
541
|
};
|
|
532
542
|
let reactRouterConfig = deepFreeze({
|
|
533
543
|
appDirectory,
|
|
@@ -786,7 +796,7 @@ var cloudflareDevProxyVitePlugin = (options = {}) => {
|
|
|
786
796
|
};
|
|
787
797
|
},
|
|
788
798
|
configEnvironment: async (name, options2) => {
|
|
789
|
-
if (!future.
|
|
799
|
+
if (!future.v8_viteEnvironmentApi) {
|
|
790
800
|
return;
|
|
791
801
|
}
|
|
792
802
|
if (name !== "client") {
|
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-bfc808d6c
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -191,7 +191,6 @@ async function createContext({
|
|
|
191
191
|
var import_pathe3 = __toESM(require("pathe"));
|
|
192
192
|
var import_chokidar = __toESM(require("chokidar"));
|
|
193
193
|
var import_picocolors = __toESM(require("picocolors"));
|
|
194
|
-
var import_pkg_types = require("pkg-types");
|
|
195
194
|
var import_pick2 = __toESM(require("lodash/pick"));
|
|
196
195
|
var import_omit = __toESM(require("lodash/omit"));
|
|
197
196
|
var import_cloneDeep = __toESM(require("lodash/cloneDeep"));
|
|
@@ -549,12 +548,23 @@ async function resolveConfig({
|
|
|
549
548
|
);
|
|
550
549
|
}
|
|
551
550
|
}
|
|
551
|
+
let futureConfig = userAndPresetConfigs.future;
|
|
552
|
+
if (futureConfig?.unstable_splitRouteModules !== void 0) {
|
|
553
|
+
return err(
|
|
554
|
+
'The "future.unstable_splitRouteModules" flag has been stabilized as "future.v8_splitRouteModules"'
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
if (futureConfig?.unstable_viteEnvironmentApi !== void 0) {
|
|
558
|
+
return err(
|
|
559
|
+
'The "future.unstable_viteEnvironmentApi" flag has been stabilized as "future.v8_viteEnvironmentApi"'
|
|
560
|
+
);
|
|
561
|
+
}
|
|
552
562
|
let future = {
|
|
553
|
-
v8_middleware: userAndPresetConfigs.future?.v8_middleware ?? false,
|
|
554
563
|
unstable_optimizeDeps: userAndPresetConfigs.future?.unstable_optimizeDeps ?? false,
|
|
555
|
-
unstable_splitRouteModules: userAndPresetConfigs.future?.unstable_splitRouteModules ?? false,
|
|
556
564
|
unstable_subResourceIntegrity: userAndPresetConfigs.future?.unstable_subResourceIntegrity ?? false,
|
|
557
|
-
|
|
565
|
+
v8_middleware: userAndPresetConfigs.future?.v8_middleware ?? false,
|
|
566
|
+
v8_splitRouteModules: userAndPresetConfigs.future?.v8_splitRouteModules ?? false,
|
|
567
|
+
v8_viteEnvironmentApi: userAndPresetConfigs.future?.v8_viteEnvironmentApi ?? false
|
|
558
568
|
};
|
|
559
569
|
let reactRouterConfig = deepFreeze({
|
|
560
570
|
appDirectory,
|
|
@@ -735,8 +745,9 @@ async function resolveEntryFiles({
|
|
|
735
745
|
`Could not find package.json in ${rootDirectory} or any of its parent directories. Please add a package.json, or provide a custom entry.server.tsx/jsx file in your app directory.`
|
|
736
746
|
);
|
|
737
747
|
}
|
|
748
|
+
let { readPackageJSON, sortPackage, updatePackage } = await import("pkg-types");
|
|
738
749
|
let packageJsonDirectory = import_pathe3.default.dirname(packageJsonPath);
|
|
739
|
-
let pkgJson = await
|
|
750
|
+
let pkgJson = await readPackageJSON(packageJsonDirectory);
|
|
740
751
|
let deps = pkgJson.dependencies ?? {};
|
|
741
752
|
if (!deps["@react-router/node"]) {
|
|
742
753
|
throw new Error(
|
|
@@ -747,10 +758,10 @@ async function resolveEntryFiles({
|
|
|
747
758
|
console.log(
|
|
748
759
|
"adding `isbot@5` to your package.json, you should commit this change"
|
|
749
760
|
);
|
|
750
|
-
await
|
|
761
|
+
await updatePackage(packageJsonPath, (pkg) => {
|
|
751
762
|
pkg.dependencies ??= {};
|
|
752
763
|
pkg.dependencies.isbot = "^5";
|
|
753
|
-
|
|
764
|
+
sortPackage(pkg);
|
|
754
765
|
});
|
|
755
766
|
let packageManager = detectPackageManager() ?? "npm";
|
|
756
767
|
(0, import_node_child_process.execSync)(`${packageManager} install`, {
|
|
@@ -2735,7 +2746,7 @@ var getServerBundleRouteIds = (vitePluginContext, ctx) => {
|
|
|
2735
2746
|
if (!ctx.buildManifest) {
|
|
2736
2747
|
return void 0;
|
|
2737
2748
|
}
|
|
2738
|
-
let environmentName = ctx.reactRouterConfig.future.
|
|
2749
|
+
let environmentName = ctx.reactRouterConfig.future.v8_viteEnvironmentApi ? vitePluginContext.environment.name : ctx.environmentBuildContext?.name;
|
|
2739
2750
|
if (!environmentName || !isSsrBundleEnvironmentName(environmentName)) {
|
|
2740
2751
|
return void 0;
|
|
2741
2752
|
}
|
|
@@ -2785,7 +2796,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2785
2796
|
}
|
|
2786
2797
|
return;
|
|
2787
2798
|
}
|
|
2788
|
-
let injectedPluginContext = !reactRouterConfig.future.
|
|
2799
|
+
let injectedPluginContext = !reactRouterConfig.future.v8_viteEnvironmentApi && viteCommand === "build" ? extractPluginContext(viteUserConfig) : void 0;
|
|
2789
2800
|
let { entryClientFilePath, entryServerFilePath } = await resolveEntryFiles({
|
|
2790
2801
|
rootDirectory,
|
|
2791
2802
|
reactRouterConfig
|
|
@@ -2879,7 +2890,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2879
2890
|
}`;
|
|
2880
2891
|
}).join(",\n ")}
|
|
2881
2892
|
};
|
|
2882
|
-
${ctx.reactRouterConfig.future.
|
|
2893
|
+
${ctx.reactRouterConfig.future.v8_viteEnvironmentApi && viteCommand === "serve" ? `
|
|
2883
2894
|
export const unstable_getCriticalCss = ({ pathname }) => {
|
|
2884
2895
|
return {
|
|
2885
2896
|
rel: "stylesheet",
|
|
@@ -2957,7 +2968,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2957
2968
|
viteChildCompiler,
|
|
2958
2969
|
ctx
|
|
2959
2970
|
);
|
|
2960
|
-
let enforceSplitRouteModules = ctx.reactRouterConfig.future.
|
|
2971
|
+
let enforceSplitRouteModules = ctx.reactRouterConfig.future.v8_splitRouteModules === "enforce";
|
|
2961
2972
|
for (let route of Object.values(ctx.reactRouterConfig.routes)) {
|
|
2962
2973
|
let routeFile = path6.join(ctx.reactRouterConfig.appDirectory, route.file);
|
|
2963
2974
|
let sourceExports = routeManifestExports[route.id];
|
|
@@ -3069,7 +3080,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3069
3080
|
viteChildCompiler,
|
|
3070
3081
|
ctx
|
|
3071
3082
|
);
|
|
3072
|
-
let enforceSplitRouteModules = ctx.reactRouterConfig.future.
|
|
3083
|
+
let enforceSplitRouteModules = ctx.reactRouterConfig.future.v8_splitRouteModules === "enforce";
|
|
3073
3084
|
for (let [key, route] of Object.entries(ctx.reactRouterConfig.routes)) {
|
|
3074
3085
|
let routeFile = route.file;
|
|
3075
3086
|
let sourceExports = routeManifestExports[key];
|
|
@@ -3264,7 +3275,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3264
3275
|
// will throw an error that the file is not allowed to be read.
|
|
3265
3276
|
// https://vitejs.dev/config/server-options#server-fs-allow
|
|
3266
3277
|
server: viteUserConfig.server?.fs?.allow ? { fs: { allow: defaultEntries } } : void 0,
|
|
3267
|
-
...ctx.reactRouterConfig.future.
|
|
3278
|
+
...ctx.reactRouterConfig.future.v8_viteEnvironmentApi ? {
|
|
3268
3279
|
environments,
|
|
3269
3280
|
build: {
|
|
3270
3281
|
// This isn't honored by the SSR environment config (which seems
|
|
@@ -3303,7 +3314,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3303
3314
|
};
|
|
3304
3315
|
},
|
|
3305
3316
|
configEnvironment(name, options) {
|
|
3306
|
-
if (ctx.reactRouterConfig.future.
|
|
3317
|
+
if (ctx.reactRouterConfig.future.v8_viteEnvironmentApi && (ctx.buildManifest?.serverBundles ? isSsrBundleEnvironmentName(name) : name === "ssr")) {
|
|
3307
3318
|
const vite2 = getVite();
|
|
3308
3319
|
return {
|
|
3309
3320
|
resolve: {
|
|
@@ -3439,7 +3450,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3439
3450
|
}
|
|
3440
3451
|
}
|
|
3441
3452
|
);
|
|
3442
|
-
if (ctx.reactRouterConfig.future.
|
|
3453
|
+
if (ctx.reactRouterConfig.future.v8_viteEnvironmentApi) {
|
|
3443
3454
|
viteDevServer.middlewares.use(async (req, res, next) => {
|
|
3444
3455
|
let [reqPathname, reqSearch] = (req.url ?? "").split("?");
|
|
3445
3456
|
if (reqPathname.endsWith("/@react-router/critical.css")) {
|
|
@@ -3467,7 +3478,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3467
3478
|
viteDevServer.middlewares.use(async (req, res, next) => {
|
|
3468
3479
|
try {
|
|
3469
3480
|
let build;
|
|
3470
|
-
if (ctx.reactRouterConfig.future.
|
|
3481
|
+
if (ctx.reactRouterConfig.future.v8_viteEnvironmentApi) {
|
|
3471
3482
|
let vite2 = getVite();
|
|
3472
3483
|
let ssrEnvironment = viteDevServer.environments.ssr;
|
|
3473
3484
|
if (!vite2.isRunnableDevEnvironment(ssrEnvironment)) {
|
|
@@ -3499,22 +3510,50 @@ var reactRouterVitePlugin = () => {
|
|
|
3499
3510
|
}
|
|
3500
3511
|
};
|
|
3501
3512
|
},
|
|
3513
|
+
configurePreviewServer(previewServer) {
|
|
3514
|
+
return () => {
|
|
3515
|
+
previewServer.middlewares.use(async (req, res, next) => {
|
|
3516
|
+
try {
|
|
3517
|
+
let serverBuildDirectory = getServerBuildDirectory(
|
|
3518
|
+
ctx.reactRouterConfig
|
|
3519
|
+
);
|
|
3520
|
+
let serverBuildFile = path6.resolve(
|
|
3521
|
+
serverBuildDirectory,
|
|
3522
|
+
"index.js"
|
|
3523
|
+
);
|
|
3524
|
+
let build = await import(url.pathToFileURL(serverBuildFile).href);
|
|
3525
|
+
let handler = (0, import_react_router2.createRequestHandler)(build, "production");
|
|
3526
|
+
let nodeHandler = async (nodeReq, nodeRes) => {
|
|
3527
|
+
let req2 = fromNodeRequest(nodeReq, nodeRes);
|
|
3528
|
+
let res2 = await handler(
|
|
3529
|
+
req2,
|
|
3530
|
+
await reactRouterDevLoadContext(req2)
|
|
3531
|
+
);
|
|
3532
|
+
await (0, import_node_fetch_server2.sendResponse)(nodeRes, res2);
|
|
3533
|
+
};
|
|
3534
|
+
await nodeHandler(req, res);
|
|
3535
|
+
} catch (error) {
|
|
3536
|
+
next(error);
|
|
3537
|
+
}
|
|
3538
|
+
});
|
|
3539
|
+
};
|
|
3540
|
+
},
|
|
3502
3541
|
writeBundle: {
|
|
3503
3542
|
// After the SSR build is finished, we inspect the Vite manifest for
|
|
3504
3543
|
// the SSR build and move server-only assets to client assets directory
|
|
3505
3544
|
async handler() {
|
|
3506
3545
|
let { future } = ctx.reactRouterConfig;
|
|
3507
|
-
if (future.
|
|
3546
|
+
if (future.v8_viteEnvironmentApi ? this.environment.name === "client" : !viteConfigEnv.isSsrBuild) {
|
|
3508
3547
|
return;
|
|
3509
3548
|
}
|
|
3510
3549
|
invariant(viteConfig);
|
|
3511
3550
|
let clientBuildDirectory = getClientBuildDirectory(
|
|
3512
3551
|
ctx.reactRouterConfig
|
|
3513
3552
|
);
|
|
3514
|
-
let serverBuildDirectory = future.
|
|
3553
|
+
let serverBuildDirectory = future.v8_viteEnvironmentApi ? this.environment.config?.build?.outDir : ctx.environmentBuildContext?.options.build?.outDir ?? getServerBuildDirectory(ctx.reactRouterConfig);
|
|
3515
3554
|
let ssrViteManifest = await loadViteManifest(serverBuildDirectory);
|
|
3516
3555
|
let ssrAssetPaths = getViteManifestAssetPaths(ssrViteManifest);
|
|
3517
|
-
let userSsrEmitAssets = (ctx.reactRouterConfig.future.
|
|
3556
|
+
let userSsrEmitAssets = (ctx.reactRouterConfig.future.v8_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.ssrEmitAssets ?? viteUserConfig.environments?.ssr?.build?.emitAssets : null) ?? viteUserConfig.build?.ssrEmitAssets ?? false;
|
|
3518
3557
|
let movedAssetPaths = [];
|
|
3519
3558
|
let removedAssetPaths = [];
|
|
3520
3559
|
let copiedAssetPaths = [];
|
|
@@ -3728,7 +3767,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3728
3767
|
reason: "Split round modules disabled"
|
|
3729
3768
|
});
|
|
3730
3769
|
}
|
|
3731
|
-
let enforceSplitRouteModules = ctx.reactRouterConfig.future.
|
|
3770
|
+
let enforceSplitRouteModules = ctx.reactRouterConfig.future.v8_splitRouteModules === "enforce";
|
|
3732
3771
|
if (enforceSplitRouteModules && chunkName === "main" && chunk) {
|
|
3733
3772
|
let exportNames = getExportNames(chunk.code);
|
|
3734
3773
|
validateRouteChunks({
|
|
@@ -4640,7 +4679,7 @@ async function detectRouteChunksIfEnabled(cache, ctx, id, input) {
|
|
|
4640
4679
|
}
|
|
4641
4680
|
};
|
|
4642
4681
|
}
|
|
4643
|
-
if (!ctx.reactRouterConfig.future.
|
|
4682
|
+
if (!ctx.reactRouterConfig.future.v8_splitRouteModules) {
|
|
4644
4683
|
return noRouteChunks();
|
|
4645
4684
|
}
|
|
4646
4685
|
if (isRootRouteModuleId(ctx, id)) {
|
|
@@ -4654,7 +4693,7 @@ async function detectRouteChunksIfEnabled(cache, ctx, id, input) {
|
|
|
4654
4693
|
return detectRouteChunks(code, cache, cacheKey);
|
|
4655
4694
|
}
|
|
4656
4695
|
async function getRouteChunkIfEnabled(cache, ctx, id, chunkName, input) {
|
|
4657
|
-
if (!ctx.reactRouterConfig.future.
|
|
4696
|
+
if (!ctx.reactRouterConfig.future.v8_splitRouteModules) {
|
|
4658
4697
|
return null;
|
|
4659
4698
|
}
|
|
4660
4699
|
let code = await resolveRouteFileCode(ctx, input);
|
|
@@ -4758,7 +4797,7 @@ async function getBuildManifest({
|
|
|
4758
4797
|
if (typeof serverBundleId !== "string") {
|
|
4759
4798
|
throw new Error(`The "serverBundles" function must return a string`);
|
|
4760
4799
|
}
|
|
4761
|
-
if (reactRouterConfig.future.
|
|
4800
|
+
if (reactRouterConfig.future.v8_viteEnvironmentApi) {
|
|
4762
4801
|
if (!/^[a-zA-Z0-9_]+$/.test(serverBundleId)) {
|
|
4763
4802
|
throw new Error(
|
|
4764
4803
|
`The "serverBundles" function must only return strings containing alphanumeric characters and underscores.`
|
|
@@ -4846,8 +4885,8 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
4846
4885
|
return mergeEnvironmentOptions(getBaseOptions({ viteUserConfig }), {
|
|
4847
4886
|
resolve: {
|
|
4848
4887
|
external: (
|
|
4849
|
-
// If `
|
|
4850
|
-
ctx.reactRouterConfig.future.
|
|
4888
|
+
// If `v8_viteEnvironmentApi` is `true`, `resolve.external` is set in the `configEnvironment` hook
|
|
4889
|
+
ctx.reactRouterConfig.future.v8_viteEnvironmentApi ? void 0 : ssrExternals
|
|
4851
4890
|
),
|
|
4852
4891
|
conditions: [...baseConditions, ...maybeDefaultServerConditions],
|
|
4853
4892
|
externalConditions: [...baseConditions, ...defaultExternalConditions]
|
|
@@ -4862,7 +4901,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
4862
4901
|
copyPublicDir: false,
|
|
4863
4902
|
// The client only uses assets in the public directory
|
|
4864
4903
|
rollupOptions: {
|
|
4865
|
-
input: (ctx.reactRouterConfig.future.
|
|
4904
|
+
input: (ctx.reactRouterConfig.future.v8_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual.serverBuild.id,
|
|
4866
4905
|
output: {
|
|
4867
4906
|
entryFileNames: serverBuildFile,
|
|
4868
4907
|
format: serverModuleFormat
|
|
@@ -4887,14 +4926,14 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
4887
4926
|
let code = (0, import_node_fs2.readFileSync)(routeFilePath, "utf-8");
|
|
4888
4927
|
return [
|
|
4889
4928
|
`${routeFilePath}${BUILD_CLIENT_ROUTE_QUERY_STRING}`,
|
|
4890
|
-
...ctx.reactRouterConfig.future.
|
|
4929
|
+
...ctx.reactRouterConfig.future.v8_splitRouteModules && !isRootRoute ? routeChunkExportNames.map(
|
|
4891
4930
|
(exportName) => code.includes(exportName) ? getRouteChunkModuleId(routeFilePath, exportName) : null
|
|
4892
4931
|
) : []
|
|
4893
4932
|
].filter(isNonNullable);
|
|
4894
4933
|
}
|
|
4895
4934
|
)
|
|
4896
4935
|
],
|
|
4897
|
-
output: (ctx.reactRouterConfig.future.
|
|
4936
|
+
output: (ctx.reactRouterConfig.future.v8_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.rollupOptions?.output : viteUserConfig?.build?.rollupOptions?.output) ?? {
|
|
4898
4937
|
entryFileNames: ({ moduleIds }) => {
|
|
4899
4938
|
let routeChunkModuleId = moduleIds.find(isRouteChunkModuleId);
|
|
4900
4939
|
let routeChunkName = routeChunkModuleId ? getRouteChunkNameFromModuleId(routeChunkModuleId)?.replace(
|
|
@@ -4902,7 +4941,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
4902
4941
|
""
|
|
4903
4942
|
) : null;
|
|
4904
4943
|
let routeChunkSuffix = routeChunkName ? `-${(0, import_kebabCase.default)(routeChunkName)}` : "";
|
|
4905
|
-
let assetsDir = (ctx.reactRouterConfig.future.
|
|
4944
|
+
let assetsDir = (ctx.reactRouterConfig.future.v8_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.assetsDir : null) ?? viteUserConfig?.build?.assetsDir ?? "assets";
|
|
4906
4945
|
return path6.posix.join(
|
|
4907
4946
|
assetsDir,
|
|
4908
4947
|
`[name]${routeChunkSuffix}-[hash].js`
|
|
@@ -5352,12 +5391,12 @@ function reactRouterRSCVitePlugin() {
|
|
|
5352
5391
|
if (userConfig.routeDiscovery) errors.push("routeDiscovery");
|
|
5353
5392
|
if (userConfig.serverBundles) errors.push("serverBundles");
|
|
5354
5393
|
if (userConfig.ssr === false) errors.push("ssr: false");
|
|
5355
|
-
if (userConfig.future?.unstable_splitRouteModules)
|
|
5356
|
-
errors.push("future.unstable_splitRouteModules");
|
|
5357
|
-
if (userConfig.future?.unstable_viteEnvironmentApi === false)
|
|
5358
|
-
errors.push("future.unstable_viteEnvironmentApi: false");
|
|
5359
5394
|
if (userConfig.future?.v8_middleware === false)
|
|
5360
5395
|
errors.push("future.v8_middleware: false");
|
|
5396
|
+
if (userConfig.future?.v8_splitRouteModules)
|
|
5397
|
+
errors.push("future.v8_splitRouteModules");
|
|
5398
|
+
if (userConfig.future?.v8_viteEnvironmentApi === false)
|
|
5399
|
+
errors.push("future.v8_viteEnvironmentApi: false");
|
|
5361
5400
|
if (userConfig.future?.unstable_subResourceIntegrity)
|
|
5362
5401
|
errors.push("future.unstable_subResourceIntegrity");
|
|
5363
5402
|
if (errors.length) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-router/dev",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-bfc808d6c",
|
|
4
4
|
"description": "Dev tools and CLI for React Router",
|
|
5
5
|
"homepage": "https://reactrouter.com",
|
|
6
6
|
"bugs": {
|
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
"react-refresh": "^0.14.0",
|
|
86
86
|
"semver": "^7.3.7",
|
|
87
87
|
"tinyglobby": "^0.2.14",
|
|
88
|
-
"valibot": "^1.
|
|
88
|
+
"valibot": "^1.2.0",
|
|
89
89
|
"vite-node": "^3.2.2",
|
|
90
|
-
"@react-router/node": "0.0.0-experimental-
|
|
90
|
+
"@react-router/node": "0.0.0-experimental-bfc808d6c"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@types/babel__core": "^7.20.5",
|
|
@@ -110,16 +110,16 @@
|
|
|
110
110
|
"vite": "^6.3.0",
|
|
111
111
|
"wireit": "0.14.9",
|
|
112
112
|
"wrangler": "^4.23.0",
|
|
113
|
-
"react-router": "
|
|
114
|
-
"
|
|
113
|
+
"@react-router/serve": "0.0.0-experimental-bfc808d6c",
|
|
114
|
+
"react-router": "^0.0.0-experimental-bfc808d6c"
|
|
115
115
|
},
|
|
116
116
|
"peerDependencies": {
|
|
117
117
|
"@vitejs/plugin-rsc": "*",
|
|
118
118
|
"typescript": "^5.1.0",
|
|
119
119
|
"vite": "^5.1.0 || ^6.0.0 || ^7.0.0",
|
|
120
120
|
"wrangler": "^3.28.2 || ^4.0.0",
|
|
121
|
-
"@react-router/serve": "^0.0.0-experimental-
|
|
122
|
-
"react-router": "^0.0.0-experimental-
|
|
121
|
+
"@react-router/serve": "^0.0.0-experimental-bfc808d6c",
|
|
122
|
+
"react-router": "^0.0.0-experimental-bfc808d6c"
|
|
123
123
|
},
|
|
124
124
|
"peerDependenciesMeta": {
|
|
125
125
|
"@vitejs/plugin-rsc": {
|