@react-router/dev 0.0.0-experimental-58b44aa83 → 0.0.0-experimental-689d76079
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 +86 -0
- package/dist/cli/index.js +2 -2
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +1 -1
- package/dist/vite.js +425 -502
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,91 @@
|
|
|
1
1
|
# `@react-router/dev`
|
|
2
2
|
|
|
3
|
+
## v7.14.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add TypeScript 6 support to peer dependency ranges
|
|
8
|
+
- Updated dependencies:
|
|
9
|
+
- [`react-router@7.14.1`](https://github.com/remix-run/react-router/releases/tag/react-router@7.14.1)
|
|
10
|
+
- [`@react-router/node@7.14.1`](https://github.com/remix-run/react-router/releases/tag/@react-router/node@7.14.1)
|
|
11
|
+
- [`@react-router/serve@7.14.1`](https://github.com/remix-run/react-router/releases/tag/@react-router/serve@7.14.1)
|
|
12
|
+
|
|
13
|
+
## 7.14.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- Add support for Vite 8 ([#14876](https://github.com/remix-run/react-router/pull/14876))
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- support for prerendering multiple server bundles with v8_viteEnvironmentApi ([#14921](https://github.com/remix-run/react-router/pull/14921))
|
|
22
|
+
|
|
23
|
+
- rsc framework mode prerender / spa mode support ([#14907](https://github.com/remix-run/react-router/pull/14907))
|
|
24
|
+
|
|
25
|
+
- UNSTABLE RSC FRAMEWORK MODE BREAKING CHANGE - Existing route module exports remain unchanged from stable v7 non-RSC mode, but new exports are added for RSC mode. If you want to use RSC features, you will need to update your route modules to export the new annotations. ([#14901](https://github.com/remix-run/react-router/pull/14901))
|
|
26
|
+
|
|
27
|
+
If you are using RSC framework mode currently, you will need to update your route modules to the new conventions. The following route module components have their own mutually exclusive server component counterparts:
|
|
28
|
+
|
|
29
|
+
| Server Component Export | Client Component |
|
|
30
|
+
| ----------------------- | ----------------- |
|
|
31
|
+
| `ServerComponent` | `default` |
|
|
32
|
+
| `ServerErrorBoundary` | `ErrorBoundary` |
|
|
33
|
+
| `ServerLayout` | `Layout` |
|
|
34
|
+
| `ServerHydrateFallback` | `HydrateFallback` |
|
|
35
|
+
|
|
36
|
+
If you were previously exporting a `ServerComponent`, your `ErrorBoundary`, `Layout`, and `HydrateFallback` were also server components. If you want to keep those as server components, you can rename them and prefix them with `Server`. If you were previously importing the implementations of those components from a client module, you can simply inline them.
|
|
37
|
+
|
|
38
|
+
Example:
|
|
39
|
+
|
|
40
|
+
Before
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { ErrorBoundary as ClientErrorBoundary } from "./client";
|
|
44
|
+
|
|
45
|
+
export function ServerComponent() {
|
|
46
|
+
// ...
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function ErrorBoundary() {
|
|
50
|
+
return <ClientErrorBoundary />;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function Layout() {
|
|
54
|
+
// ...
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function HydrateFallback() {
|
|
58
|
+
// ...
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
After
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
export function ServerComponent() {
|
|
66
|
+
// ...
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function ErrorBoundary() {
|
|
70
|
+
// previous implementation of ClientErrorBoundary, this is now a client component
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function ServerLayout() {
|
|
74
|
+
// rename previous Layout export to ServerLayout to make it a server component
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function ServerHydrateFallback() {
|
|
78
|
+
// rename previous HydrateFallback export to ServerHydrateFallback to make it a server component
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- update the reveal command to support rsc for `entry.client`, `entry.rsc`, `entry.ssr` ([#14904](https://github.com/remix-run/react-router/pull/14904))
|
|
83
|
+
|
|
84
|
+
- Updated dependencies:
|
|
85
|
+
- `react-router@7.14.0`
|
|
86
|
+
- `@react-router/node@7.14.0`
|
|
87
|
+
- `@react-router/serve@7.14.0`
|
|
88
|
+
|
|
3
89
|
## 7.13.2
|
|
4
90
|
|
|
5
91
|
### 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-689d76079
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -1078,7 +1078,7 @@ function routeFilesType({
|
|
|
1078
1078
|
t2.tsPropertySignature(
|
|
1079
1079
|
t2.identifier("page"),
|
|
1080
1080
|
t2.tsTypeAnnotation(
|
|
1081
|
-
pages ? t2.tsUnionType(
|
|
1081
|
+
pages.size > 0 ? t2.tsUnionType(
|
|
1082
1082
|
Array.from(pages).map(
|
|
1083
1083
|
(page) => t2.tsLiteralType(t2.stringLiteral(page))
|
|
1084
1084
|
)
|
package/dist/config.js
CHANGED
package/dist/routes.js
CHANGED
package/dist/vite/cloudflare.js
CHANGED
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-689d76079
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1096,7 +1096,7 @@ function routeFilesType({
|
|
|
1096
1096
|
t2.tsPropertySignature(
|
|
1097
1097
|
t2.identifier("page"),
|
|
1098
1098
|
t2.tsTypeAnnotation(
|
|
1099
|
-
pages ? t2.tsUnionType(
|
|
1099
|
+
pages.size > 0 ? t2.tsUnionType(
|
|
1100
1100
|
Array.from(pages).map(
|
|
1101
1101
|
(page) => t2.tsLiteralType(t2.stringLiteral(page))
|
|
1102
1102
|
)
|
|
@@ -5677,6 +5677,7 @@ function escapeHtml(html) {
|
|
|
5677
5677
|
// vite/rsc/plugin.ts
|
|
5678
5678
|
var import_es_module_lexer3 = require("es-module-lexer");
|
|
5679
5679
|
var Path5 = __toESM(require("pathe"));
|
|
5680
|
+
var babel2 = __toESM(require("@babel/core"));
|
|
5680
5681
|
var import_picocolors5 = __toESM(require("picocolors"));
|
|
5681
5682
|
var import_fs = require("fs");
|
|
5682
5683
|
var import_promises4 = require("fs/promises");
|
|
@@ -5684,91 +5685,12 @@ var import_pathe6 = __toESM(require("pathe"));
|
|
|
5684
5685
|
|
|
5685
5686
|
// vite/rsc/virtual-route-config.ts
|
|
5686
5687
|
var import_pathe5 = __toESM(require("pathe"));
|
|
5687
|
-
var js = String.raw;
|
|
5688
5688
|
function createVirtualRouteConfig({
|
|
5689
5689
|
appDirectory,
|
|
5690
5690
|
routeConfig
|
|
5691
5691
|
}) {
|
|
5692
5692
|
let routeIdByFile = /* @__PURE__ */ new Map();
|
|
5693
|
-
let code =
|
|
5694
|
-
function frameworkRoute(lazy) {
|
|
5695
|
-
return async () => {
|
|
5696
|
-
const mod = await lazy();
|
|
5697
|
-
let Component;
|
|
5698
|
-
let Layout;
|
|
5699
|
-
let ErrorBoundary;
|
|
5700
|
-
let HydrateFallback;
|
|
5701
|
-
if ("default" in mod && mod.default) {
|
|
5702
|
-
if ("ServerComponent" in mod && mod.ServerComponent) {
|
|
5703
|
-
throw new Error("Module cannot have both a default export and a ServerComponent export");
|
|
5704
|
-
}
|
|
5705
|
-
Component = mod.default;
|
|
5706
|
-
} else if ("ServerComponent" in mod && mod.ServerComponent) {
|
|
5707
|
-
Component = mod.ServerComponent;
|
|
5708
|
-
}
|
|
5709
|
-
if ("Layout" in mod && mod.Layout) {
|
|
5710
|
-
if ("ServerLayout" in mod && mod.ServerLayout) {
|
|
5711
|
-
throw new Error("Module cannot have both a Layout export and a ServerLayout export");
|
|
5712
|
-
}
|
|
5713
|
-
Layout = mod.Layout;
|
|
5714
|
-
} else if ("ServerLayout" in mod && mod.ServerLayout) {
|
|
5715
|
-
Layout = mod.ServerLayout;
|
|
5716
|
-
}
|
|
5717
|
-
if ("ErrorBoundary" in mod && mod.ErrorBoundary) {
|
|
5718
|
-
if ("ServerErrorBoundary" in mod && mod.ServerErrorBoundary) {
|
|
5719
|
-
throw new Error(
|
|
5720
|
-
"Module cannot have both an ErrorBoundary export and a ServerErrorBoundary export",
|
|
5721
|
-
);
|
|
5722
|
-
}
|
|
5723
|
-
ErrorBoundary = mod.ErrorBoundary;
|
|
5724
|
-
} else if ("ServerErrorBoundary" in mod && mod.ServerErrorBoundary) {
|
|
5725
|
-
ErrorBoundary = mod.ServerErrorBoundary;
|
|
5726
|
-
}
|
|
5727
|
-
if ("HydrateFallback" in mod && mod.HydrateFallback) {
|
|
5728
|
-
if ("ServerHydrateFallback" in mod && mod.ServerHydrateFallback) {
|
|
5729
|
-
throw new Error(
|
|
5730
|
-
"Module cannot have both a HydrateFallback export and a ServerHydrateFallback export",
|
|
5731
|
-
);
|
|
5732
|
-
}
|
|
5733
|
-
HydrateFallback = mod.HydrateFallback;
|
|
5734
|
-
} else if ("ServerHydrateFallback" in mod && mod.ServerHydrateFallback) {
|
|
5735
|
-
HydrateFallback = mod.ServerHydrateFallback;
|
|
5736
|
-
}
|
|
5737
|
-
|
|
5738
|
-
const {
|
|
5739
|
-
action,
|
|
5740
|
-
clientAction,
|
|
5741
|
-
clientLoader,
|
|
5742
|
-
clientMiddleware,
|
|
5743
|
-
handle,
|
|
5744
|
-
headers,
|
|
5745
|
-
links,
|
|
5746
|
-
loader,
|
|
5747
|
-
meta,
|
|
5748
|
-
middleware,
|
|
5749
|
-
shouldRevalidate,
|
|
5750
|
-
} = mod;
|
|
5751
|
-
|
|
5752
|
-
return {
|
|
5753
|
-
Component,
|
|
5754
|
-
ErrorBoundary,
|
|
5755
|
-
HydrateFallback,
|
|
5756
|
-
Layout,
|
|
5757
|
-
action,
|
|
5758
|
-
clientAction,
|
|
5759
|
-
clientLoader,
|
|
5760
|
-
clientMiddleware,
|
|
5761
|
-
handle,
|
|
5762
|
-
headers,
|
|
5763
|
-
links,
|
|
5764
|
-
loader,
|
|
5765
|
-
meta,
|
|
5766
|
-
middleware,
|
|
5767
|
-
shouldRevalidate,
|
|
5768
|
-
};
|
|
5769
|
-
};
|
|
5770
|
-
}
|
|
5771
|
-
export default [`;
|
|
5693
|
+
let code = "export default [";
|
|
5772
5694
|
const closeRouteSymbol = Symbol("CLOSE_ROUTE");
|
|
5773
5695
|
let stack = [
|
|
5774
5696
|
...routeConfig
|
|
@@ -5784,9 +5706,9 @@ export default [`;
|
|
|
5784
5706
|
const routeFile = import_pathe5.default.resolve(appDirectory, route.file);
|
|
5785
5707
|
const routeId = route.id || createRouteId2(route.file, appDirectory);
|
|
5786
5708
|
routeIdByFile.set(routeFile, routeId);
|
|
5787
|
-
code += `lazy:
|
|
5788
|
-
`${routeFile}`
|
|
5789
|
-
)})
|
|
5709
|
+
code += `lazy: () => import(${JSON.stringify(
|
|
5710
|
+
`${routeFile}?route-module`
|
|
5711
|
+
)}),`;
|
|
5790
5712
|
code += `id: ${JSON.stringify(routeId)},`;
|
|
5791
5713
|
if (typeof route.path === "string") {
|
|
5792
5714
|
code += `path: ${JSON.stringify(route.path)},`;
|
|
@@ -5814,216 +5736,227 @@ function createRouteId2(file, appDirectory) {
|
|
|
5814
5736
|
|
|
5815
5737
|
// vite/rsc/virtual-route-modules.ts
|
|
5816
5738
|
var import_es_module_lexer2 = require("es-module-lexer");
|
|
5817
|
-
var
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5739
|
+
var SERVER_COMPONENT_EXPORTS = [
|
|
5740
|
+
"ServerComponent",
|
|
5741
|
+
"ServerLayout",
|
|
5742
|
+
"ServerHydrateFallback",
|
|
5743
|
+
"ServerErrorBoundary"
|
|
5744
|
+
];
|
|
5745
|
+
var SERVER_COMPONENT_EXPORTS_SET = new Set(SERVER_COMPONENT_EXPORTS);
|
|
5746
|
+
function isServerComponentExport(name) {
|
|
5747
|
+
return SERVER_COMPONENT_EXPORTS_SET.has(name);
|
|
5748
|
+
}
|
|
5749
|
+
var SERVER_ROUTE_EXPORTS = [
|
|
5750
|
+
...SERVER_COMPONENT_EXPORTS,
|
|
5751
|
+
"loader",
|
|
5752
|
+
"action",
|
|
5753
|
+
"middleware",
|
|
5754
|
+
"headers"
|
|
5755
|
+
];
|
|
5756
|
+
var SERVER_ROUTE_EXPORTS_SET = new Set(SERVER_ROUTE_EXPORTS);
|
|
5757
|
+
function isServerRouteExport(name) {
|
|
5758
|
+
return SERVER_ROUTE_EXPORTS_SET.has(name);
|
|
5759
|
+
}
|
|
5760
|
+
var CLIENT_NON_COMPONENT_EXPORTS2 = [
|
|
5761
|
+
"clientAction",
|
|
5762
|
+
"clientLoader",
|
|
5763
|
+
"clientMiddleware",
|
|
5764
|
+
"handle",
|
|
5765
|
+
"meta",
|
|
5766
|
+
"links",
|
|
5767
|
+
"shouldRevalidate"
|
|
5768
|
+
];
|
|
5769
|
+
var CLIENT_ROUTE_EXPORTS2 = [
|
|
5770
|
+
...CLIENT_NON_COMPONENT_EXPORTS2,
|
|
5771
|
+
"default",
|
|
5772
|
+
"ErrorBoundary",
|
|
5773
|
+
"HydrateFallback",
|
|
5774
|
+
"Layout"
|
|
5775
|
+
];
|
|
5776
|
+
var CLIENT_ROUTE_EXPORTS_SET = new Set(CLIENT_ROUTE_EXPORTS2);
|
|
5777
|
+
function isClientRouteExport(name) {
|
|
5778
|
+
return CLIENT_ROUTE_EXPORTS_SET.has(name);
|
|
5779
|
+
}
|
|
5780
|
+
var mutuallyExclusiveRouteExports = /* @__PURE__ */ new Map([
|
|
5781
|
+
["ErrorBoundary", "ServerErrorBoundary"],
|
|
5782
|
+
["HydrateFallback", "ServerHydrateFallback"],
|
|
5783
|
+
["Layout", "ServerLayout"],
|
|
5784
|
+
["default", "ServerComponent"]
|
|
5785
|
+
]);
|
|
5786
|
+
var ROUTE_EXPORTS = [
|
|
5787
|
+
...SERVER_ROUTE_EXPORTS,
|
|
5788
|
+
...CLIENT_ROUTE_EXPORTS2
|
|
5789
|
+
];
|
|
5790
|
+
var ROUTE_EXPORTS_SET = new Set(ROUTE_EXPORTS);
|
|
5791
|
+
function isRouteExport(name) {
|
|
5792
|
+
return ROUTE_EXPORTS_SET.has(name);
|
|
5793
|
+
}
|
|
5794
|
+
function isCustomRouteExport(name) {
|
|
5795
|
+
return !isRouteExport(name);
|
|
5796
|
+
}
|
|
5797
|
+
function hasReactServerCondition(viteEnvironment) {
|
|
5798
|
+
return viteEnvironment.config.resolve.conditions.includes("react-server");
|
|
5799
|
+
}
|
|
5800
|
+
function transformVirtualRouteModules({
|
|
5801
|
+
id,
|
|
5802
|
+
code,
|
|
5803
|
+
viteCommand,
|
|
5804
|
+
routeIdByFile,
|
|
5805
|
+
rootRouteFile,
|
|
5806
|
+
viteEnvironment
|
|
5826
5807
|
}) {
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5808
|
+
if (isVirtualRouteModuleId(id) || routeIdByFile.has(id)) {
|
|
5809
|
+
return createVirtualRouteModuleCode({
|
|
5810
|
+
id,
|
|
5811
|
+
code,
|
|
5812
|
+
rootRouteFile,
|
|
5813
|
+
viteCommand,
|
|
5814
|
+
viteEnvironment
|
|
5815
|
+
});
|
|
5816
|
+
}
|
|
5817
|
+
if (isVirtualServerRouteModuleId(id)) {
|
|
5818
|
+
return createVirtualServerRouteModuleCode({
|
|
5819
|
+
id,
|
|
5820
|
+
code,
|
|
5821
|
+
viteEnvironment
|
|
5822
|
+
});
|
|
5823
|
+
}
|
|
5824
|
+
if (isVirtualClientRouteModuleId(id)) {
|
|
5825
|
+
return createVirtualClientRouteModuleCode({
|
|
5826
|
+
id,
|
|
5827
|
+
code,
|
|
5828
|
+
rootRouteFile,
|
|
5829
|
+
viteCommand
|
|
5830
|
+
});
|
|
5831
|
+
}
|
|
5832
|
+
}
|
|
5833
|
+
async function createVirtualRouteModuleCode({
|
|
5834
|
+
id,
|
|
5835
|
+
code: routeSource,
|
|
5836
|
+
rootRouteFile,
|
|
5837
|
+
viteCommand,
|
|
5838
|
+
viteEnvironment
|
|
5839
|
+
}) {
|
|
5840
|
+
const isReactServer = hasReactServerCondition(viteEnvironment);
|
|
5841
|
+
const { staticExports, hasClientExports } = parseRouteExports(routeSource);
|
|
5842
|
+
for (const exportName of staticExports) {
|
|
5843
|
+
if (mutuallyExclusiveRouteExports.has(exportName)) {
|
|
5844
|
+
const conflictingExport = mutuallyExclusiveRouteExports.get(exportName);
|
|
5845
|
+
if (staticExports.includes(conflictingExport)) {
|
|
5846
|
+
throw new Error(
|
|
5847
|
+
`Route module cannot export both "${exportName}" and "${conflictingExport}". Please choose one or the other.`
|
|
5848
|
+
);
|
|
5858
5849
|
}
|
|
5859
5850
|
}
|
|
5860
|
-
if (needsReactImport) {
|
|
5861
|
-
result = `import * as React from "react";
|
|
5862
|
-
${result}`;
|
|
5863
|
-
}
|
|
5864
|
-
return {
|
|
5865
|
-
code: '"use client";\n' + result
|
|
5866
|
-
};
|
|
5867
5851
|
}
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
let needsReactImport = false;
|
|
5874
|
-
for (let exportName of staticExports) {
|
|
5875
|
-
if (isClientRouteExport(exportName)) {
|
|
5876
|
-
result += `export { ${exportName} } from "${createId(
|
|
5877
|
-
id,
|
|
5878
|
-
"client-route-module",
|
|
5879
|
-
routeChunks.hasRouteChunkByExportName[exportName] ? exportName : "shared"
|
|
5880
|
-
)}";
|
|
5852
|
+
const clientModuleId = getVirtualClientModuleId(id);
|
|
5853
|
+
const serverModuleId = getVirtualServerModuleId(id);
|
|
5854
|
+
let code = "";
|
|
5855
|
+
if (isReactServer && staticExports.some(isServerComponentExport)) {
|
|
5856
|
+
code += `import React from "react";
|
|
5881
5857
|
`;
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5858
|
+
}
|
|
5859
|
+
for (const staticExport of staticExports) {
|
|
5860
|
+
if (isReactServer && isServerComponentExport(staticExport)) {
|
|
5861
|
+
code += `import { ${staticExport} as ${staticExport}WithoutCss } from "${serverModuleId}";
|
|
5885
5862
|
`;
|
|
5886
|
-
|
|
5863
|
+
code += `export ${staticExport === "ServerComponent" ? "default " : " "}function ${staticExport.replace(/^Server/, "")}(props) {
|
|
5887
5864
|
`;
|
|
5888
|
-
|
|
5865
|
+
code += ` return React.createElement(React.Fragment, null,
|
|
5889
5866
|
`;
|
|
5890
|
-
|
|
5867
|
+
code += ` import.meta.viteRsc.loadCss(),
|
|
5891
5868
|
`;
|
|
5892
|
-
|
|
5869
|
+
code += ` React.createElement(${staticExport}WithoutCss, props),
|
|
5893
5870
|
`;
|
|
5894
|
-
|
|
5871
|
+
code += ` );
|
|
5895
5872
|
`;
|
|
5896
|
-
|
|
5873
|
+
code += `}
|
|
5897
5874
|
`;
|
|
5898
|
-
|
|
5875
|
+
} else if (isReactServer && isServerRouteExport(staticExport)) {
|
|
5876
|
+
code += `export { ${staticExport} } from "${serverModuleId}";
|
|
5899
5877
|
`;
|
|
5900
|
-
|
|
5901
|
-
|
|
5878
|
+
} else if (isClientRouteExport(staticExport)) {
|
|
5879
|
+
code += `export { ${staticExport} } from "${clientModuleId}";
|
|
5902
5880
|
`;
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
if (needsReactImport) {
|
|
5906
|
-
result = `import * as React from "react";
|
|
5907
|
-
import { EnsureClientRouteModuleForHMR___ } from "${createId(id, "client-route-module", "shared")}";
|
|
5908
|
-
|
|
5909
|
-
${result}`;
|
|
5910
|
-
}
|
|
5911
|
-
if (isRootRouteModule2 && !staticExports.includes("ErrorBoundary") && !staticExports.includes("ServerErrorBoundary")) {
|
|
5912
|
-
result += `export { ErrorBoundary } from "${createId(id, "client-route-module", "shared")}";
|
|
5881
|
+
} else if (isCustomRouteExport(staticExport)) {
|
|
5882
|
+
code += `export { ${staticExport} } from "${isReactServer ? serverModuleId : clientModuleId}";
|
|
5913
5883
|
`;
|
|
5914
5884
|
}
|
|
5915
|
-
return {
|
|
5916
|
-
code: result
|
|
5917
|
-
};
|
|
5918
5885
|
}
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
sourceType: "module"
|
|
5922
|
-
});
|
|
5923
|
-
removeExports(ast, CLIENT_ROUTE_EXPORTS2);
|
|
5924
|
-
return generate(ast);
|
|
5925
|
-
}
|
|
5926
|
-
async function createClientRouteModuleChunk(id, code, chunk, isRootRouteModule2) {
|
|
5927
|
-
let routeChunks = detectRouteChunks2(cache, id, code);
|
|
5928
|
-
const ast = import_parser.parse(code, {
|
|
5929
|
-
sourceType: "module"
|
|
5930
|
-
});
|
|
5931
|
-
const { staticExports } = await parseRouteExports(code);
|
|
5932
|
-
if (chunk === "shared") {
|
|
5933
|
-
removeExports(ast, [
|
|
5934
|
-
...SERVER_ROUTE_EXPORTS,
|
|
5935
|
-
...routeChunks.chunkedExports
|
|
5936
|
-
]);
|
|
5937
|
-
} else {
|
|
5938
|
-
const toRemove = /* @__PURE__ */ new Set([...SERVER_ROUTE_EXPORTS, ...staticExports]);
|
|
5939
|
-
toRemove.delete(chunk);
|
|
5940
|
-
removeExports(ast, Array.from(toRemove));
|
|
5941
|
-
}
|
|
5942
|
-
const generated = generate(ast);
|
|
5943
|
-
let result = '"use client";\n' + generated.code;
|
|
5944
|
-
if (chunk === "shared") {
|
|
5945
|
-
if (isRootRouteModule2 && !staticExports.includes("ErrorBoundary") && !staticExports.includes("ServerErrorBoundary")) {
|
|
5946
|
-
const hasRootLayout = staticExports.includes("Layout") || staticExports.includes("ServerLayout");
|
|
5947
|
-
result += `
|
|
5948
|
-
import { createElement as __rr_createElement } from "react";
|
|
5886
|
+
if (isRootRouteFile({ id, rootRouteFile }) && !staticExports.includes("ErrorBoundary") && !staticExports.includes("ServerErrorBoundary")) {
|
|
5887
|
+
code += `export { ErrorBoundary } from "${clientModuleId}";
|
|
5949
5888
|
`;
|
|
5950
|
-
|
|
5889
|
+
}
|
|
5890
|
+
if (viteCommand === "serve" && !hasClientExports) {
|
|
5891
|
+
code += `export { __ensureClientRouteModuleForHMR } from "${clientModuleId}";
|
|
5951
5892
|
`;
|
|
5952
|
-
|
|
5893
|
+
}
|
|
5894
|
+
return code;
|
|
5895
|
+
}
|
|
5896
|
+
function createVirtualServerRouteModuleCode({
|
|
5897
|
+
id,
|
|
5898
|
+
code: routeSource,
|
|
5899
|
+
viteEnvironment
|
|
5900
|
+
}) {
|
|
5901
|
+
if (!hasReactServerCondition(viteEnvironment)) {
|
|
5902
|
+
throw new Error(
|
|
5903
|
+
[
|
|
5904
|
+
"Virtual server route module was loaded outside of the RSC environment.",
|
|
5905
|
+
`Environment Name: ${viteEnvironment.name}`,
|
|
5906
|
+
`Module ID: ${id}`
|
|
5907
|
+
].join("\n")
|
|
5908
|
+
);
|
|
5909
|
+
}
|
|
5910
|
+
const { staticExports } = parseRouteExports(routeSource);
|
|
5911
|
+
const clientModuleId = getVirtualClientModuleId(id);
|
|
5912
|
+
const serverRouteModuleAst = import_parser.parse(routeSource, {
|
|
5913
|
+
sourceType: "module"
|
|
5914
|
+
});
|
|
5915
|
+
removeExports(serverRouteModuleAst, CLIENT_ROUTE_EXPORTS2);
|
|
5916
|
+
const generatorResult = generate(serverRouteModuleAst);
|
|
5917
|
+
for (const staticExport of staticExports) {
|
|
5918
|
+
if (isClientRouteExport(staticExport)) {
|
|
5919
|
+
generatorResult.code += "\n";
|
|
5920
|
+
generatorResult.code += `export { ${staticExport} } from "${clientModuleId}";
|
|
5953
5921
|
`;
|
|
5954
|
-
|
|
5922
|
+
}
|
|
5923
|
+
}
|
|
5924
|
+
return generatorResult;
|
|
5925
|
+
}
|
|
5926
|
+
function createVirtualClientRouteModuleCode({
|
|
5927
|
+
id,
|
|
5928
|
+
code: routeSource,
|
|
5929
|
+
rootRouteFile,
|
|
5930
|
+
viteCommand
|
|
5931
|
+
}) {
|
|
5932
|
+
const { staticExports, hasClientExports } = parseRouteExports(routeSource);
|
|
5933
|
+
const clientRouteModuleAst = import_parser.parse(routeSource, {
|
|
5934
|
+
sourceType: "module"
|
|
5935
|
+
});
|
|
5936
|
+
removeExports(clientRouteModuleAst, SERVER_ROUTE_EXPORTS);
|
|
5937
|
+
const generatorResult = generate(clientRouteModuleAst);
|
|
5938
|
+
generatorResult.code = '"use client";' + generatorResult.code;
|
|
5939
|
+
if (isRootRouteFile({ id, rootRouteFile }) && !staticExports.includes("ErrorBoundary") && !staticExports.includes("ServerErrorBoundary")) {
|
|
5940
|
+
const hasRootLayout = staticExports.includes("Layout");
|
|
5941
|
+
generatorResult.code += `
|
|
5942
|
+
import { createElement as __rr_createElement } from "react";
|
|
5955
5943
|
`;
|
|
5956
|
-
|
|
5944
|
+
generatorResult.code += `import { UNSAFE_RSCDefaultRootErrorBoundary } from "react-router";
|
|
5957
5945
|
`;
|
|
5958
|
-
|
|
5959
|
-
result += ENSURE_CLIENT_ROUTE_MODULE_CHUNK_FOR_HMR;
|
|
5960
|
-
}
|
|
5961
|
-
result += `
|
|
5962
|
-
if (import.meta.hot) {
|
|
5946
|
+
generatorResult.code += `export function ErrorBoundary() {
|
|
5963
5947
|
`;
|
|
5964
|
-
|
|
5965
|
-
if (!mod.default) {
|
|
5966
|
-
__reactRouterDataRouter.revalidate();
|
|
5967
|
-
}
|
|
5968
|
-
});
|
|
5948
|
+
generatorResult.code += ` return __rr_createElement(UNSAFE_RSCDefaultRootErrorBoundary, { hasRootLayout: ${hasRootLayout} });
|
|
5969
5949
|
`;
|
|
5970
|
-
|
|
5950
|
+
generatorResult.code += `}
|
|
5971
5951
|
`;
|
|
5972
|
-
return {
|
|
5973
|
-
code: result
|
|
5974
|
-
};
|
|
5975
5952
|
}
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
const [filename2, ...rest] = id.split("?");
|
|
5982
|
-
if (!isRouteModule(filename2)) {
|
|
5983
|
-
return;
|
|
5984
|
-
}
|
|
5985
|
-
let isClientEnvironment = clientEnvironments.has(this.environment.name);
|
|
5986
|
-
let isServerEnvironment = serverEnvironments.has(this.environment.name);
|
|
5987
|
-
if (!isClientEnvironment && !isServerEnvironment) {
|
|
5988
|
-
return;
|
|
5989
|
-
}
|
|
5990
|
-
let code = await transformToJs(_code, filename2);
|
|
5991
|
-
let searchParams = rest.length > 0 ? new URLSearchParams(rest.join("?")) : null;
|
|
5992
|
-
let clientRouteModuleType = searchParams?.get("client-route-module");
|
|
5993
|
-
let isServerRouteModule = searchParams?.has("server-route-module");
|
|
5994
|
-
if (clientRouteModuleType) {
|
|
5995
|
-
return await createClientRouteModuleChunk(
|
|
5996
|
-
id,
|
|
5997
|
-
code,
|
|
5998
|
-
clientRouteModuleType,
|
|
5999
|
-
isRootRouteModule(filename2)
|
|
6000
|
-
);
|
|
6001
|
-
}
|
|
6002
|
-
if (isServerRouteModule) {
|
|
6003
|
-
return createServerRouteModule(code);
|
|
6004
|
-
}
|
|
6005
|
-
if (isClientEnvironment) {
|
|
6006
|
-
return await createClientRouteEntry(id, code);
|
|
6007
|
-
}
|
|
6008
|
-
return await createServerRouteEntry(
|
|
6009
|
-
id,
|
|
6010
|
-
code,
|
|
6011
|
-
isRootRouteModule(filename2)
|
|
6012
|
-
);
|
|
6013
|
-
}
|
|
6014
|
-
}
|
|
6015
|
-
};
|
|
6016
|
-
}
|
|
6017
|
-
function createId(id, type, value) {
|
|
6018
|
-
let [base, ...rest] = id.split("?");
|
|
6019
|
-
const searchParams = new URLSearchParams(rest.join("?"));
|
|
6020
|
-
searchParams.delete("client-route-module");
|
|
6021
|
-
searchParams.delete("server-route-module");
|
|
6022
|
-
searchParams.set(type, value || "");
|
|
6023
|
-
return `${base}?${searchParams.toString()}`;
|
|
5953
|
+
if (viteCommand === "serve" && !hasClientExports) {
|
|
5954
|
+
generatorResult.code += `
|
|
5955
|
+
export const __ensureClientRouteModuleForHMR = true;`;
|
|
5956
|
+
}
|
|
5957
|
+
return generatorResult;
|
|
6024
5958
|
}
|
|
6025
|
-
|
|
6026
|
-
await import_es_module_lexer2.init;
|
|
5959
|
+
function parseRouteExports(code) {
|
|
6027
5960
|
const [, exportSpecifiers] = (0, import_es_module_lexer2.parse)(code);
|
|
6028
5961
|
const staticExports = exportSpecifiers.map(({ n: name }) => name);
|
|
6029
5962
|
return {
|
|
@@ -6031,95 +5964,27 @@ async function parseRouteExports(code) {
|
|
|
6031
5964
|
hasClientExports: staticExports.some(isClientRouteExport)
|
|
6032
5965
|
};
|
|
6033
5966
|
}
|
|
6034
|
-
|
|
6035
|
-
"
|
|
6036
|
-
"clientLoader",
|
|
6037
|
-
"clientMiddleware",
|
|
6038
|
-
"handle",
|
|
6039
|
-
"meta",
|
|
6040
|
-
"links",
|
|
6041
|
-
"shouldRevalidate"
|
|
6042
|
-
];
|
|
6043
|
-
var CLIENT_ROUTE_EXPORTS2 = [
|
|
6044
|
-
...CLIENT_NON_COMPONENT_EXPORTS2,
|
|
6045
|
-
"default",
|
|
6046
|
-
"ErrorBoundary",
|
|
6047
|
-
"HydrateFallback",
|
|
6048
|
-
"Layout"
|
|
6049
|
-
];
|
|
6050
|
-
var CLIENT_ROUTE_EXPORTS_SET = new Set(CLIENT_ROUTE_EXPORTS2);
|
|
6051
|
-
function isClientRouteExport(name) {
|
|
6052
|
-
return CLIENT_ROUTE_EXPORTS_SET.has(name);
|
|
5967
|
+
function getVirtualClientModuleId(id) {
|
|
5968
|
+
return `${id.split("?")[0]}?client-route-module`;
|
|
6053
5969
|
}
|
|
6054
|
-
|
|
6055
|
-
"
|
|
6056
|
-
"ServerLayout",
|
|
6057
|
-
"ServerHydrateFallback",
|
|
6058
|
-
"ServerErrorBoundary"
|
|
6059
|
-
];
|
|
6060
|
-
var SERVER_COMPONENT_EXPORTS_SET = new Set(SERVER_COMPONENT_EXPORTS);
|
|
6061
|
-
function isServerComponentExport(name) {
|
|
6062
|
-
return SERVER_COMPONENT_EXPORTS_SET.has(name);
|
|
5970
|
+
function getVirtualServerModuleId(id) {
|
|
5971
|
+
return `${id.split("?")[0]}?server-route-module`;
|
|
6063
5972
|
}
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
"loader",
|
|
6067
|
-
"action",
|
|
6068
|
-
"middleware",
|
|
6069
|
-
"headers"
|
|
6070
|
-
];
|
|
6071
|
-
var SERVER_ROUTE_EXPORTS_SET = new Set(SERVER_ROUTE_EXPORTS);
|
|
6072
|
-
function isServerRouteExport(name) {
|
|
6073
|
-
return SERVER_ROUTE_EXPORTS_SET.has(name);
|
|
5973
|
+
function isVirtualRouteModuleId(id) {
|
|
5974
|
+
return /(\?|&)route-module(&|$)/.test(id);
|
|
6074
5975
|
}
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
"clientLoader",
|
|
6078
|
-
"clientMiddleware",
|
|
6079
|
-
"HydrateFallback"
|
|
6080
|
-
]);
|
|
6081
|
-
var MUTUALLY_EXCLUSIVE_ROUTE_EXPORTS = /* @__PURE__ */ new Map([
|
|
6082
|
-
["ErrorBoundary", "ServerErrorBoundary"],
|
|
6083
|
-
["HydrateFallback", "ServerHydrateFallback"],
|
|
6084
|
-
["Layout", "ServerLayout"],
|
|
6085
|
-
["default", "ServerComponent"]
|
|
6086
|
-
]);
|
|
6087
|
-
function validateRouteModuleExports(toValidate) {
|
|
6088
|
-
let errors = [];
|
|
6089
|
-
for (let [clientExport, serverExport] of MUTUALLY_EXCLUSIVE_ROUTE_EXPORTS) {
|
|
6090
|
-
if (toValidate.includes(clientExport) && toValidate.includes(serverExport)) {
|
|
6091
|
-
errors.push([clientExport, serverExport]);
|
|
6092
|
-
}
|
|
6093
|
-
}
|
|
6094
|
-
if (errors.length > 0) {
|
|
6095
|
-
throw new Error(
|
|
6096
|
-
`Invalid route module exports. The following pairs of exports are mutually exclusive and cannot be exported from the same module:
|
|
6097
|
-
` + errors.map(
|
|
6098
|
-
([clientExport, serverExport]) => `- ${clientExport} and ${serverExport}`
|
|
6099
|
-
).join("\n")
|
|
6100
|
-
);
|
|
6101
|
-
}
|
|
5976
|
+
function isVirtualClientRouteModuleId(id) {
|
|
5977
|
+
return /(\?|&)client-route-module(&|$)/.test(id);
|
|
6102
5978
|
}
|
|
6103
|
-
function
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
HydrateFallback: false
|
|
6113
|
-
}
|
|
6114
|
-
};
|
|
6115
|
-
}
|
|
6116
|
-
if (!Array.from(CLIENT_MODULE_CHUNKS).some(
|
|
6117
|
-
(exportName) => code.includes(exportName)
|
|
6118
|
-
)) {
|
|
6119
|
-
return noRouteChunks();
|
|
6120
|
-
}
|
|
6121
|
-
let [filename2] = id.split("?");
|
|
6122
|
-
return detectRouteChunks(code, cache, filename2);
|
|
5979
|
+
function isVirtualServerRouteModuleId(id) {
|
|
5980
|
+
return /(\?|&)server-route-module(&|$)/.test(id);
|
|
5981
|
+
}
|
|
5982
|
+
function isRootRouteFile({
|
|
5983
|
+
id,
|
|
5984
|
+
rootRouteFile
|
|
5985
|
+
}) {
|
|
5986
|
+
const filePath = id.split("?")[0];
|
|
5987
|
+
return filePath === rootRouteFile;
|
|
6123
5988
|
}
|
|
6124
5989
|
|
|
6125
5990
|
// vite/rsc/plugin.ts
|
|
@@ -6145,25 +6010,6 @@ function reactRouterRSCVitePlugin() {
|
|
|
6145
6010
|
newConfig.routes.root.file
|
|
6146
6011
|
);
|
|
6147
6012
|
}
|
|
6148
|
-
function isRouteModule(id) {
|
|
6149
|
-
if (routeIdByFile?.has(id)) {
|
|
6150
|
-
return true;
|
|
6151
|
-
}
|
|
6152
|
-
return false;
|
|
6153
|
-
}
|
|
6154
|
-
function isRootRouteModule(id) {
|
|
6155
|
-
return import_pathe6.default.normalize(id) === import_pathe6.default.normalize(rootRouteFile);
|
|
6156
|
-
}
|
|
6157
|
-
async function transformToJs(code, filename2) {
|
|
6158
|
-
await preloadVite();
|
|
6159
|
-
let vite2 = getVite();
|
|
6160
|
-
return (await vite2.transformWithEsbuild(code, filename2, {
|
|
6161
|
-
target: "esnext",
|
|
6162
|
-
format: "esm",
|
|
6163
|
-
jsx: "automatic",
|
|
6164
|
-
jsxDev: viteCommand !== "build"
|
|
6165
|
-
})).code;
|
|
6166
|
-
}
|
|
6167
6013
|
return [
|
|
6168
6014
|
{
|
|
6169
6015
|
name: "react-router/rsc",
|
|
@@ -6353,6 +6199,27 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
6353
6199
|
]
|
|
6354
6200
|
}
|
|
6355
6201
|
}
|
|
6202
|
+
},
|
|
6203
|
+
build: {
|
|
6204
|
+
rollupOptions: {
|
|
6205
|
+
// Copied from https://github.com/vitejs/vite-plugin-react/blob/c602225271d4acf462ba00f8d6d8a2e42492c5cd/packages/common/warning.ts
|
|
6206
|
+
onwarn(warning, defaultHandler) {
|
|
6207
|
+
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && (warning.message.includes("use client") || warning.message.includes("use server"))) {
|
|
6208
|
+
return;
|
|
6209
|
+
}
|
|
6210
|
+
if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
|
|
6211
|
+
return;
|
|
6212
|
+
}
|
|
6213
|
+
if (viteUserConfig.build?.rollupOptions?.onwarn) {
|
|
6214
|
+
viteUserConfig.build.rollupOptions.onwarn(
|
|
6215
|
+
warning,
|
|
6216
|
+
defaultHandler
|
|
6217
|
+
);
|
|
6218
|
+
} else {
|
|
6219
|
+
defaultHandler(warning);
|
|
6220
|
+
}
|
|
6221
|
+
}
|
|
6222
|
+
}
|
|
6356
6223
|
}
|
|
6357
6224
|
};
|
|
6358
6225
|
},
|
|
@@ -6495,15 +6362,20 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
6495
6362
|
}
|
|
6496
6363
|
}
|
|
6497
6364
|
},
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6365
|
+
{
|
|
6366
|
+
name: "react-router/rsc/virtual-route-modules",
|
|
6367
|
+
transform(code, id) {
|
|
6368
|
+
if (!routeIdByFile) return;
|
|
6369
|
+
return transformVirtualRouteModules({
|
|
6370
|
+
code,
|
|
6371
|
+
id,
|
|
6372
|
+
viteCommand,
|
|
6373
|
+
routeIdByFile,
|
|
6374
|
+
rootRouteFile,
|
|
6375
|
+
viteEnvironment: this.environment
|
|
6376
|
+
});
|
|
6377
|
+
}
|
|
6378
|
+
},
|
|
6507
6379
|
{
|
|
6508
6380
|
name: "react-router/rsc/virtual-basename",
|
|
6509
6381
|
resolveId(id) {
|
|
@@ -6545,129 +6417,121 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
6545
6417
|
async load(id) {
|
|
6546
6418
|
if (id !== virtual2.injectHmrRuntime.resolvedId) return;
|
|
6547
6419
|
return viteCommand === "serve" ? [
|
|
6548
|
-
`
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
}`
|
|
6420
|
+
`import RefreshRuntime from "${virtual2.hmrRuntime.id}"`,
|
|
6421
|
+
"RefreshRuntime.injectIntoGlobalHook(window)",
|
|
6422
|
+
"window.$RefreshReg$ = () => {}",
|
|
6423
|
+
"window.$RefreshSig$ = () => (type) => type",
|
|
6424
|
+
"window.__vite_plugin_react_preamble_installed__ = true"
|
|
6554
6425
|
].join("\n") : "";
|
|
6555
6426
|
}
|
|
6556
6427
|
},
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
// },
|
|
6665
|
-
// });
|
|
6666
|
-
// }
|
|
6667
|
-
// }
|
|
6668
|
-
// return modules;
|
|
6669
|
-
// },
|
|
6670
|
-
// },
|
|
6428
|
+
{
|
|
6429
|
+
name: "react-router/rsc/hmr/runtime",
|
|
6430
|
+
enforce: "pre",
|
|
6431
|
+
resolveId(id) {
|
|
6432
|
+
if (id === virtual2.hmrRuntime.id) return virtual2.hmrRuntime.resolvedId;
|
|
6433
|
+
},
|
|
6434
|
+
async load(id) {
|
|
6435
|
+
if (id !== virtual2.hmrRuntime.resolvedId) return;
|
|
6436
|
+
const reactRefreshDir = import_pathe6.default.dirname(
|
|
6437
|
+
require.resolve("react-refresh/package.json")
|
|
6438
|
+
);
|
|
6439
|
+
const reactRefreshRuntimePath = (0, import_pathe6.join)(
|
|
6440
|
+
reactRefreshDir,
|
|
6441
|
+
"cjs/react-refresh-runtime.development.js"
|
|
6442
|
+
);
|
|
6443
|
+
return [
|
|
6444
|
+
"const exports = {}",
|
|
6445
|
+
await (0, import_promises4.readFile)(reactRefreshRuntimePath, "utf8"),
|
|
6446
|
+
await (0, import_promises4.readFile)(
|
|
6447
|
+
require.resolve("./static/rsc-refresh-utils.mjs"),
|
|
6448
|
+
"utf8"
|
|
6449
|
+
),
|
|
6450
|
+
"export default exports"
|
|
6451
|
+
].join("\n");
|
|
6452
|
+
}
|
|
6453
|
+
},
|
|
6454
|
+
{
|
|
6455
|
+
name: "react-router/rsc/hmr/react-refresh",
|
|
6456
|
+
async transform(code, id, options) {
|
|
6457
|
+
if (viteCommand !== "serve") return;
|
|
6458
|
+
if (id.includes("/node_modules/")) return;
|
|
6459
|
+
const filepath = id.split("?")[0];
|
|
6460
|
+
const extensionsRE = /\.(jsx?|tsx?|mdx?)$/;
|
|
6461
|
+
if (!extensionsRE.test(filepath)) return;
|
|
6462
|
+
const devRuntime = "react/jsx-dev-runtime";
|
|
6463
|
+
const ssr = options?.ssr === true;
|
|
6464
|
+
const isJSX = filepath.endsWith("x");
|
|
6465
|
+
const useFastRefresh = !ssr && (isJSX || code.includes(devRuntime));
|
|
6466
|
+
if (!useFastRefresh) return;
|
|
6467
|
+
if (isVirtualClientRouteModuleId(id)) {
|
|
6468
|
+
const routeId = routeIdByFile?.get(filepath);
|
|
6469
|
+
return { code: addRefreshWrapper2({ routeId, code, id }) };
|
|
6470
|
+
}
|
|
6471
|
+
const result = await babel2.transformAsync(code, {
|
|
6472
|
+
babelrc: false,
|
|
6473
|
+
configFile: false,
|
|
6474
|
+
filename: id,
|
|
6475
|
+
sourceFileName: filepath,
|
|
6476
|
+
parserOpts: {
|
|
6477
|
+
sourceType: "module",
|
|
6478
|
+
allowAwaitOutsideFunction: true
|
|
6479
|
+
},
|
|
6480
|
+
plugins: [[require("react-refresh/babel"), { skipEnvCheck: true }]],
|
|
6481
|
+
sourceMaps: true
|
|
6482
|
+
});
|
|
6483
|
+
if (result === null) return;
|
|
6484
|
+
code = result.code;
|
|
6485
|
+
const refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
6486
|
+
if (refreshContentRE.test(code)) {
|
|
6487
|
+
code = addRefreshWrapper2({ code, id });
|
|
6488
|
+
}
|
|
6489
|
+
return { code, map: result.map };
|
|
6490
|
+
}
|
|
6491
|
+
},
|
|
6492
|
+
{
|
|
6493
|
+
name: "react-router/rsc/hmr/updates",
|
|
6494
|
+
async hotUpdate({ server, file, modules }) {
|
|
6495
|
+
if (this.environment.name !== "rsc") return;
|
|
6496
|
+
const clientModules = server.environments.client.moduleGraph.getModulesByFile(file);
|
|
6497
|
+
const vite2 = await import("vite");
|
|
6498
|
+
const isServerOnlyChange = !clientModules || clientModules.size === 0 || // Handle CSS injected from server-first routes (with ?direct query
|
|
6499
|
+
// string) since the client graph has a reference to the CSS
|
|
6500
|
+
vite2.isCSSRequest(file) && Array.from(clientModules).some(
|
|
6501
|
+
(mod) => mod.id?.includes("?direct")
|
|
6502
|
+
);
|
|
6503
|
+
for (const mod of getModulesWithImporters(modules)) {
|
|
6504
|
+
if (!mod.file) continue;
|
|
6505
|
+
const normalizedPath = import_pathe6.default.normalize(mod.file);
|
|
6506
|
+
const routeId = routeIdByFile?.get(normalizedPath);
|
|
6507
|
+
if (routeId !== void 0) {
|
|
6508
|
+
const routeSource = await (0, import_promises4.readFile)(normalizedPath, "utf8");
|
|
6509
|
+
const virtualRouteModuleCode = (await server.environments.rsc.pluginContainer.transform(
|
|
6510
|
+
routeSource,
|
|
6511
|
+
`${normalizedPath}?route-module`
|
|
6512
|
+
)).code;
|
|
6513
|
+
const { staticExports } = parseRouteExports(virtualRouteModuleCode);
|
|
6514
|
+
const hasAction = staticExports.includes("action");
|
|
6515
|
+
const hasComponent = staticExports.includes("default");
|
|
6516
|
+
const hasErrorBoundary = staticExports.includes("ErrorBoundary");
|
|
6517
|
+
const hasLoader = staticExports.includes("loader");
|
|
6518
|
+
server.hot.send({
|
|
6519
|
+
type: "custom",
|
|
6520
|
+
event: "react-router:hmr",
|
|
6521
|
+
data: {
|
|
6522
|
+
routeId,
|
|
6523
|
+
isServerOnlyChange,
|
|
6524
|
+
hasAction,
|
|
6525
|
+
hasComponent,
|
|
6526
|
+
hasErrorBoundary,
|
|
6527
|
+
hasLoader
|
|
6528
|
+
}
|
|
6529
|
+
});
|
|
6530
|
+
}
|
|
6531
|
+
}
|
|
6532
|
+
return modules;
|
|
6533
|
+
}
|
|
6534
|
+
},
|
|
6671
6535
|
{
|
|
6672
6536
|
name: "react-router/rsc/virtual-react-router-serve-config",
|
|
6673
6537
|
resolveId(id) {
|
|
@@ -6791,7 +6655,7 @@ var virtual2 = {
|
|
|
6791
6655
|
routeConfig: create("unstable_rsc/routes"),
|
|
6792
6656
|
routeDiscovery: create("unstable_rsc/route-discovery"),
|
|
6793
6657
|
injectHmrRuntime: create("unstable_rsc/inject-hmr-runtime"),
|
|
6794
|
-
|
|
6658
|
+
hmrRuntime: create("unstable_rsc/runtime"),
|
|
6795
6659
|
basename: create("unstable_rsc/basename"),
|
|
6796
6660
|
reactRouterServeConfig: create("unstable_rsc/react-router-serve-config")
|
|
6797
6661
|
};
|
|
@@ -6808,6 +6672,65 @@ function invalidateVirtualModules2(viteDevServer) {
|
|
|
6808
6672
|
function getRootDirectory(viteUserConfig) {
|
|
6809
6673
|
return viteUserConfig.root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();
|
|
6810
6674
|
}
|
|
6675
|
+
function getModulesWithImporters(modules) {
|
|
6676
|
+
const visited = /* @__PURE__ */ new Set();
|
|
6677
|
+
const result = /* @__PURE__ */ new Set();
|
|
6678
|
+
function walk(module2) {
|
|
6679
|
+
if (visited.has(module2)) return;
|
|
6680
|
+
visited.add(module2);
|
|
6681
|
+
result.add(module2);
|
|
6682
|
+
for (const importer of module2.importers) {
|
|
6683
|
+
walk(importer);
|
|
6684
|
+
}
|
|
6685
|
+
}
|
|
6686
|
+
for (const module2 of modules) {
|
|
6687
|
+
walk(module2);
|
|
6688
|
+
}
|
|
6689
|
+
return result;
|
|
6690
|
+
}
|
|
6691
|
+
function addRefreshWrapper2({
|
|
6692
|
+
routeId,
|
|
6693
|
+
code,
|
|
6694
|
+
id
|
|
6695
|
+
}) {
|
|
6696
|
+
const acceptExports = routeId !== void 0 ? CLIENT_NON_COMPONENT_EXPORTS2 : [];
|
|
6697
|
+
return REACT_REFRESH_HEADER2.replaceAll("__SOURCE__", JSON.stringify(id)) + code + REACT_REFRESH_FOOTER2.replaceAll("__SOURCE__", JSON.stringify(id)).replaceAll("__ACCEPT_EXPORTS__", JSON.stringify(acceptExports)).replaceAll("__ROUTE_ID__", JSON.stringify(routeId));
|
|
6698
|
+
}
|
|
6699
|
+
var REACT_REFRESH_HEADER2 = `
|
|
6700
|
+
import RefreshRuntime from "${virtual2.hmrRuntime.id}";
|
|
6701
|
+
|
|
6702
|
+
const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
|
|
6703
|
+
let prevRefreshReg;
|
|
6704
|
+
let prevRefreshSig;
|
|
6705
|
+
|
|
6706
|
+
if (import.meta.hot && !inWebWorker) {
|
|
6707
|
+
if (!window.__vite_plugin_react_preamble_installed__) {
|
|
6708
|
+
throw new Error(
|
|
6709
|
+
"React Router Vite plugin can't detect preamble. Something is wrong."
|
|
6710
|
+
);
|
|
6711
|
+
}
|
|
6712
|
+
|
|
6713
|
+
prevRefreshReg = window.$RefreshReg$;
|
|
6714
|
+
prevRefreshSig = window.$RefreshSig$;
|
|
6715
|
+
window.$RefreshReg$ = (type, id) => {
|
|
6716
|
+
RefreshRuntime.register(type, __SOURCE__ + " " + id)
|
|
6717
|
+
};
|
|
6718
|
+
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
6719
|
+
}`.replaceAll("\n", "");
|
|
6720
|
+
var REACT_REFRESH_FOOTER2 = `
|
|
6721
|
+
if (import.meta.hot && !inWebWorker) {
|
|
6722
|
+
window.$RefreshReg$ = prevRefreshReg;
|
|
6723
|
+
window.$RefreshSig$ = prevRefreshSig;
|
|
6724
|
+
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
|
6725
|
+
RefreshRuntime.registerExportsForReactRefresh(__SOURCE__, currentExports);
|
|
6726
|
+
import.meta.hot.accept((nextExports) => {
|
|
6727
|
+
if (!nextExports) return;
|
|
6728
|
+
__ROUTE_ID__ && window.__reactRouterRouteModuleUpdates.set(__ROUTE_ID__, nextExports);
|
|
6729
|
+
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(currentExports, nextExports, __ACCEPT_EXPORTS__);
|
|
6730
|
+
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
|
6731
|
+
});
|
|
6732
|
+
});
|
|
6733
|
+
}`;
|
|
6811
6734
|
var getClientBuildDirectory2 = (reactRouterConfig) => import_pathe6.default.join(reactRouterConfig.buildDirectory, "client");
|
|
6812
6735
|
function getPrerenderConcurrencyConfig2(reactRouterConfig) {
|
|
6813
6736
|
let concurrency = 1;
|
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-689d76079",
|
|
4
4
|
"description": "Dev tools and CLI for React Router",
|
|
5
5
|
"homepage": "https://reactrouter.com",
|
|
6
6
|
"bugs": {
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"tinyglobby": "^0.2.14",
|
|
93
93
|
"valibot": "^1.2.0",
|
|
94
94
|
"vite-node": "^3.2.2",
|
|
95
|
-
"@react-router/node": "0.0.0-experimental-
|
|
95
|
+
"@react-router/node": "0.0.0-experimental-689d76079"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@types/babel__core": "^7.20.5",
|
|
@@ -116,17 +116,17 @@
|
|
|
116
116
|
"vite": "^6.3.0",
|
|
117
117
|
"wireit": "0.14.9",
|
|
118
118
|
"wrangler": "^4.23.0",
|
|
119
|
-
"
|
|
120
|
-
"react-router": "
|
|
119
|
+
"react-router": "^0.0.0-experimental-689d76079",
|
|
120
|
+
"@react-router/serve": "0.0.0-experimental-689d76079"
|
|
121
121
|
},
|
|
122
122
|
"peerDependencies": {
|
|
123
123
|
"@vitejs/plugin-rsc": "~0.5.21",
|
|
124
124
|
"react-server-dom-webpack": "^19.2.3",
|
|
125
|
-
"typescript": "^5.1.0",
|
|
125
|
+
"typescript": "^5.1.0 || ^6.0.0",
|
|
126
126
|
"vite": "^5.1.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
127
127
|
"wrangler": "^3.28.2 || ^4.0.0",
|
|
128
|
-
"@react-router/serve": "^0.0.0-experimental-
|
|
129
|
-
"react-router": "^0.0.0-experimental-
|
|
128
|
+
"@react-router/serve": "^0.0.0-experimental-689d76079",
|
|
129
|
+
"react-router": "^0.0.0-experimental-689d76079"
|
|
130
130
|
},
|
|
131
131
|
"peerDependenciesMeta": {
|
|
132
132
|
"@vitejs/plugin-rsc": {
|