@react-router/dev 0.0.0-experimental-b588f7e → 0.0.0-experimental-a25096010
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 +74 -0
- package/dist/cli/index.js +69 -55
- package/dist/config.js +1 -1
- package/dist/routes.js +7 -2
- package/dist/vite/cloudflare.d.ts +1 -1
- package/dist/vite/cloudflare.js +18 -11
- package/dist/vite.js +109 -92
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
1
|
# `@react-router/dev`
|
|
2
2
|
|
|
3
|
+
## 7.6.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add Vite 7 support ([#13748](https://github.com/remix-run/react-router/pull/13748))
|
|
8
|
+
- Skip `package.json` resolution checks when a custom `entry.server.(j|t)sx` file is provided. ([#13744](https://github.com/remix-run/react-router/pull/13744))
|
|
9
|
+
- Add validation for a route's id not being 'root' ([#13792](https://github.com/remix-run/react-router/pull/13792))
|
|
10
|
+
- Updated dependencies:
|
|
11
|
+
- `@react-router/node@7.6.3`
|
|
12
|
+
- `react-router@7.6.3`
|
|
13
|
+
- `@react-router/serve@7.6.3`
|
|
14
|
+
|
|
15
|
+
## 7.6.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Avoid additional `with-props` chunk in Framework Mode by moving route module component prop logic from the Vite plugin to `react-router` ([#13650](https://github.com/remix-run/react-router/pull/13650))
|
|
20
|
+
|
|
21
|
+
- When `future.unstable_viteEnvironmentApi` is enabled and an absolute Vite `base` has been configured, ensure critical CSS is handled correctly during development ([#13598](https://github.com/remix-run/react-router/pull/13598))
|
|
22
|
+
|
|
23
|
+
- Update `vite-node` ([#13673](https://github.com/remix-run/react-router/pull/13673))
|
|
24
|
+
|
|
25
|
+
- Fix typegen for non-{.js,.jsx,.ts,.tsx} routes like .mdx ([#12453](https://github.com/remix-run/react-router/pull/12453))
|
|
26
|
+
|
|
27
|
+
- Fix href types for optional dynamic params ([#13725](https://github.com/remix-run/react-router/pull/13725))
|
|
28
|
+
|
|
29
|
+
7.6.1 introduced fixes for `href` when using optional static segments,
|
|
30
|
+
but those fixes caused regressions with how optional dynamic params worked in 7.6.0:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
// 7.6.0
|
|
34
|
+
href("/users/:id?"); // ✅
|
|
35
|
+
href("/users/:id?", { id: 1 }); // ✅
|
|
36
|
+
|
|
37
|
+
// 7.6.1
|
|
38
|
+
href("/users/:id?"); // ❌
|
|
39
|
+
href("/users/:id?", { id: 1 }); // ❌
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Now, optional static segments are expanded into different paths for `href`, but optional dynamic params are not.
|
|
43
|
+
This way `href` can unambiguously refer to an exact URL path, all while keeping the number of path options to a minimum.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
// 7.6.2
|
|
47
|
+
|
|
48
|
+
// path: /users/:id?/edit?
|
|
49
|
+
href("
|
|
50
|
+
// ^ suggestions when cursor is here:
|
|
51
|
+
//
|
|
52
|
+
// /users/:id?
|
|
53
|
+
// /users/:id?/edit
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Additionally, you can pass `params` from component props without needing to narrow them manually:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
declare const params: { id?: number };
|
|
60
|
+
|
|
61
|
+
// 7.6.0
|
|
62
|
+
href("/users/:id?", params);
|
|
63
|
+
|
|
64
|
+
// 7.6.1
|
|
65
|
+
href("/users/:id?", params); // ❌
|
|
66
|
+
"id" in params ? href("/users/:id", params) : href("/users"); // works... but is annoying
|
|
67
|
+
|
|
68
|
+
// 7.6.2
|
|
69
|
+
href("/users/:id?", params); // restores behavior of 7.6.0
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- Updated dependencies:
|
|
73
|
+
- `react-router@7.6.2`
|
|
74
|
+
- `@react-router/node@7.6.2`
|
|
75
|
+
- `@react-router/serve@7.6.2`
|
|
76
|
+
|
|
3
77
|
## 7.6.1
|
|
4
78
|
|
|
5
79
|
### 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-a25096010
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -130,6 +130,11 @@ async function createContext({
|
|
|
130
130
|
}) {
|
|
131
131
|
await preloadVite();
|
|
132
132
|
const vite2 = getVite();
|
|
133
|
+
const [{ ViteNodeServer }, { ViteNodeRunner }, { installSourcemapsSupport }] = await Promise.all([
|
|
134
|
+
import("vite-node/server"),
|
|
135
|
+
import("vite-node/client"),
|
|
136
|
+
import("vite-node/source-map")
|
|
137
|
+
]);
|
|
133
138
|
const devServer = await vite2.createServer({
|
|
134
139
|
root,
|
|
135
140
|
mode,
|
|
@@ -159,11 +164,11 @@ async function createContext({
|
|
|
159
164
|
plugins: []
|
|
160
165
|
});
|
|
161
166
|
await devServer.pluginContainer.buildStart({});
|
|
162
|
-
const server = new
|
|
163
|
-
|
|
167
|
+
const server = new ViteNodeServer(devServer);
|
|
168
|
+
installSourcemapsSupport({
|
|
164
169
|
getSourceMap: (source) => server.getSourceMap(source)
|
|
165
170
|
});
|
|
166
|
-
const runner = new
|
|
171
|
+
const runner = new ViteNodeRunner({
|
|
167
172
|
root: devServer.config.root,
|
|
168
173
|
base: devServer.config.base,
|
|
169
174
|
fetchModule(id) {
|
|
@@ -175,13 +180,9 @@ async function createContext({
|
|
|
175
180
|
});
|
|
176
181
|
return { devServer, server, runner };
|
|
177
182
|
}
|
|
178
|
-
var import_server, import_client, import_source_map;
|
|
179
183
|
var init_vite_node = __esm({
|
|
180
184
|
"vite/vite-node.ts"() {
|
|
181
185
|
"use strict";
|
|
182
|
-
import_server = require("vite-node/server");
|
|
183
|
-
import_client = require("vite-node/client");
|
|
184
|
-
import_source_map = require("vite-node/source-map");
|
|
185
186
|
init_vite();
|
|
186
187
|
init_ssr_externals();
|
|
187
188
|
}
|
|
@@ -272,7 +273,12 @@ var init_routes = __esm({
|
|
|
272
273
|
return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
|
|
273
274
|
}, "Invalid type: Expected object but received a promise. Did you forget to await?"),
|
|
274
275
|
v.object({
|
|
275
|
-
id: v.optional(
|
|
276
|
+
id: v.optional(
|
|
277
|
+
v.pipe(
|
|
278
|
+
v.string(),
|
|
279
|
+
v.notValue("root", "A route cannot use the reserved id 'root'.")
|
|
280
|
+
)
|
|
281
|
+
),
|
|
276
282
|
path: v.optional(v.string()),
|
|
277
283
|
index: v.optional(v.boolean()),
|
|
278
284
|
caseSensitive: v.optional(v.boolean()),
|
|
@@ -928,7 +934,7 @@ function generateRoutes(ctx) {
|
|
|
928
934
|
lineages.set(route.id, lineage2);
|
|
929
935
|
const fullpath2 = fullpath(lineage2);
|
|
930
936
|
if (!fullpath2) continue;
|
|
931
|
-
const pages =
|
|
937
|
+
const pages = expand(fullpath2);
|
|
932
938
|
pages.forEach((page) => allPages.add(page));
|
|
933
939
|
lineage2.forEach(({ id }) => {
|
|
934
940
|
let routePages = routeToPages.get(id);
|
|
@@ -1136,9 +1142,13 @@ function getRouteAnnotations({
|
|
|
1136
1142
|
}
|
|
1137
1143
|
function relativeImportSource(from, to) {
|
|
1138
1144
|
let path8 = Path3.relative(Path3.dirname(from), to);
|
|
1145
|
+
let extension = Path3.extname(path8);
|
|
1139
1146
|
path8 = Path3.join(Path3.dirname(path8), Pathe.filename(path8));
|
|
1140
1147
|
if (!path8.startsWith("../")) path8 = "./" + path8;
|
|
1141
|
-
|
|
1148
|
+
if (!extension || /\.(js|ts)x?$/.test(extension)) {
|
|
1149
|
+
extension = ".js";
|
|
1150
|
+
}
|
|
1151
|
+
return path8 + extension;
|
|
1142
1152
|
}
|
|
1143
1153
|
function rootDirsPath(ctx, typesPath) {
|
|
1144
1154
|
const rel = Path3.relative(typesDirectory(ctx), typesPath);
|
|
@@ -1157,28 +1167,27 @@ function paramsType(path8) {
|
|
|
1157
1167
|
})
|
|
1158
1168
|
);
|
|
1159
1169
|
}
|
|
1160
|
-
function
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
...
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
);
|
|
1176
|
-
|
|
1177
|
-
result.
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
);
|
|
1170
|
+
function expand(fullpath2) {
|
|
1171
|
+
function recurse(segments2, index) {
|
|
1172
|
+
if (index === segments2.length) return [""];
|
|
1173
|
+
const segment = segments2[index];
|
|
1174
|
+
const isOptional = segment.endsWith("?");
|
|
1175
|
+
const isDynamic = segment.startsWith(":");
|
|
1176
|
+
const required = segment.replace(/\?$/, "");
|
|
1177
|
+
const keep = !isOptional || isDynamic;
|
|
1178
|
+
const kept = isDynamic ? segment : required;
|
|
1179
|
+
const withoutSegment = recurse(segments2, index + 1);
|
|
1180
|
+
const withSegment = withoutSegment.map((rest) => [kept, rest].join("/"));
|
|
1181
|
+
if (keep) return withSegment;
|
|
1182
|
+
return [...withoutSegment, ...withSegment];
|
|
1183
|
+
}
|
|
1184
|
+
const segments = fullpath2.split("/");
|
|
1185
|
+
const expanded = /* @__PURE__ */ new Set();
|
|
1186
|
+
for (let result of recurse(segments, 0)) {
|
|
1187
|
+
if (result !== "/") result = result.replace(/\/$/, "");
|
|
1188
|
+
expanded.add(result);
|
|
1189
|
+
}
|
|
1190
|
+
return expanded;
|
|
1182
1191
|
}
|
|
1183
1192
|
var import_dedent, Path3, Pathe, t2;
|
|
1184
1193
|
var init_generate = __esm({
|
|
@@ -1268,11 +1277,12 @@ var init_typegen = __esm({
|
|
|
1268
1277
|
});
|
|
1269
1278
|
|
|
1270
1279
|
// vite/node-adapter.ts
|
|
1271
|
-
var import_node_events, import_node_stream, import_set_cookie_parser, import_node;
|
|
1280
|
+
var import_node_events, import_node_tls, import_node_stream, import_set_cookie_parser, import_node;
|
|
1272
1281
|
var init_node_adapter = __esm({
|
|
1273
1282
|
"vite/node-adapter.ts"() {
|
|
1274
1283
|
"use strict";
|
|
1275
1284
|
import_node_events = require("events");
|
|
1285
|
+
import_node_tls = require("tls");
|
|
1276
1286
|
import_node_stream = require("stream");
|
|
1277
1287
|
import_set_cookie_parser = require("set-cookie-parser");
|
|
1278
1288
|
import_node = require("@react-router/node");
|
|
@@ -1445,7 +1455,7 @@ async function cleanBuildDirectory(viteConfig, ctx) {
|
|
|
1445
1455
|
return !relativePath.startsWith("..") && !path6.isAbsolute(relativePath);
|
|
1446
1456
|
};
|
|
1447
1457
|
if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
|
|
1448
|
-
await
|
|
1458
|
+
await (0, import_promises2.rm)(buildDirectory, { force: true, recursive: true });
|
|
1449
1459
|
}
|
|
1450
1460
|
}
|
|
1451
1461
|
async function cleanViteManifests(environmentsOptions, ctx) {
|
|
@@ -1458,15 +1468,15 @@ async function cleanViteManifests(environmentsOptions, ctx) {
|
|
|
1458
1468
|
);
|
|
1459
1469
|
await Promise.all(
|
|
1460
1470
|
viteManifestPaths.map(async (viteManifestPath) => {
|
|
1461
|
-
let manifestExists =
|
|
1471
|
+
let manifestExists = (0, import_node_fs3.existsSync)(viteManifestPath);
|
|
1462
1472
|
if (!manifestExists) return;
|
|
1463
1473
|
if (!ctx.viteManifestEnabled) {
|
|
1464
|
-
await
|
|
1474
|
+
await (0, import_promises2.rm)(viteManifestPath, { force: true, recursive: true });
|
|
1465
1475
|
}
|
|
1466
1476
|
let viteDir = path6.dirname(viteManifestPath);
|
|
1467
|
-
let viteDirFiles = await
|
|
1477
|
+
let viteDirFiles = await (0, import_promises2.readdir)(viteDir, { recursive: true });
|
|
1468
1478
|
if (viteDirFiles.length === 0) {
|
|
1469
|
-
await
|
|
1479
|
+
await (0, import_promises2.rm)(viteDir, { force: true, recursive: true });
|
|
1470
1480
|
}
|
|
1471
1481
|
})
|
|
1472
1482
|
);
|
|
@@ -1532,13 +1542,13 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
1532
1542
|
},
|
|
1533
1543
|
build: {
|
|
1534
1544
|
// We move SSR-only assets to client assets. Note that the
|
|
1535
|
-
// SSR build can also emit code-split JS files (e.g
|
|
1545
|
+
// SSR build can also emit code-split JS files (e.g., by
|
|
1536
1546
|
// dynamic import) under the same assets directory
|
|
1537
1547
|
// regardless of "ssrEmitAssets" option, so we also need to
|
|
1538
|
-
// keep these JS files
|
|
1548
|
+
// keep these JS files to be kept as-is.
|
|
1539
1549
|
ssrEmitAssets: true,
|
|
1540
1550
|
copyPublicDir: false,
|
|
1541
|
-
//
|
|
1551
|
+
// The client only uses assets in the public directory
|
|
1542
1552
|
rollupOptions: {
|
|
1543
1553
|
input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual.serverBuild.id,
|
|
1544
1554
|
output: {
|
|
@@ -1562,7 +1572,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
1562
1572
|
route.file
|
|
1563
1573
|
);
|
|
1564
1574
|
let isRootRoute = route.file === ctx.reactRouterConfig.routes.root.file;
|
|
1565
|
-
let code =
|
|
1575
|
+
let code = (0, import_node_fs3.readFileSync)(routeFilePath, "utf-8");
|
|
1566
1576
|
return [
|
|
1567
1577
|
`${routeFilePath}${BUILD_CLIENT_ROUTE_QUERY_STRING}`,
|
|
1568
1578
|
...ctx.reactRouterConfig.future.unstable_splitRouteModules && !isRootRoute ? routeChunkExportNames.map(
|
|
@@ -1631,18 +1641,19 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
|
|
|
1631
1641
|
function isNonNullable(x) {
|
|
1632
1642
|
return x != null;
|
|
1633
1643
|
}
|
|
1634
|
-
var import_node_crypto,
|
|
1644
|
+
var import_node_crypto, import_node_fs3, import_promises2, path6, url, babel2, import_react_router2, import_es_module_lexer, import_tinyglobby, import_pick3, import_jsesc, import_picocolors4, import_kebabCase, CLIENT_NON_COMPONENT_EXPORTS, CLIENT_ROUTE_EXPORTS, BUILD_CLIENT_ROUTE_QUERY_STRING, SSR_BUNDLE_PREFIX, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
|
|
1635
1645
|
var init_plugin = __esm({
|
|
1636
1646
|
"vite/plugin.ts"() {
|
|
1637
1647
|
"use strict";
|
|
1638
1648
|
import_node_crypto = require("crypto");
|
|
1639
|
-
|
|
1649
|
+
import_node_fs3 = require("fs");
|
|
1650
|
+
import_promises2 = require("fs/promises");
|
|
1640
1651
|
path6 = __toESM(require("path"));
|
|
1641
1652
|
url = __toESM(require("url"));
|
|
1642
|
-
fse = __toESM(require("fs-extra"));
|
|
1643
1653
|
babel2 = __toESM(require("@babel/core"));
|
|
1644
1654
|
import_react_router2 = require("react-router");
|
|
1645
1655
|
import_es_module_lexer = require("es-module-lexer");
|
|
1656
|
+
import_tinyglobby = require("tinyglobby");
|
|
1646
1657
|
import_pick3 = __toESM(require("lodash/pick"));
|
|
1647
1658
|
import_jsesc = __toESM(require("jsesc"));
|
|
1648
1659
|
import_picocolors4 = __toESM(require("picocolors"));
|
|
@@ -1698,7 +1709,9 @@ var init_plugin = __esm({
|
|
|
1698
1709
|
"config",
|
|
1699
1710
|
"defaults"
|
|
1700
1711
|
);
|
|
1701
|
-
defaultEntries =
|
|
1712
|
+
defaultEntries = (0, import_node_fs3.readdirSync)(defaultEntriesDir).map(
|
|
1713
|
+
(filename2) => path6.join(defaultEntriesDir, filename2)
|
|
1714
|
+
);
|
|
1702
1715
|
invariant(defaultEntries.length > 0, "No default entries found");
|
|
1703
1716
|
REACT_REFRESH_HEADER = `
|
|
1704
1717
|
import RefreshRuntime from "${virtualHmrRuntime.id}";
|
|
@@ -1978,8 +1991,9 @@ var import_semver = __toESM(require("semver"));
|
|
|
1978
1991
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
1979
1992
|
|
|
1980
1993
|
// cli/commands.ts
|
|
1994
|
+
var import_node_fs4 = require("fs");
|
|
1995
|
+
var import_promises3 = require("fs/promises");
|
|
1981
1996
|
var path7 = __toESM(require("path"));
|
|
1982
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
1983
1997
|
var import_package_json2 = __toESM(require("@npmcli/package-json"));
|
|
1984
1998
|
var import_exit_hook = __toESM(require("exit-hook"));
|
|
1985
1999
|
var import_picocolors7 = __toESM(require("picocolors"));
|
|
@@ -2153,21 +2167,21 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2153
2167
|
let useTypeScript = flags.typescript ?? true;
|
|
2154
2168
|
let outputExtension = useTypeScript ? "tsx" : "jsx";
|
|
2155
2169
|
let outputEntry = `${entry}.${outputExtension}`;
|
|
2156
|
-
let
|
|
2170
|
+
let outputFile = path7.resolve(appDirectory, outputEntry);
|
|
2157
2171
|
if (!useTypeScript) {
|
|
2158
2172
|
let javascript = transpile(contents, {
|
|
2159
2173
|
cwd: rootDirectory,
|
|
2160
2174
|
filename: isServerEntry ? defaultEntryServer : defaultEntryClient
|
|
2161
2175
|
});
|
|
2162
|
-
await
|
|
2176
|
+
await (0, import_promises3.writeFile)(outputFile, javascript, "utf-8");
|
|
2163
2177
|
} else {
|
|
2164
|
-
await
|
|
2178
|
+
await (0, import_promises3.writeFile)(outputFile, contents, "utf-8");
|
|
2165
2179
|
}
|
|
2166
2180
|
console.log(
|
|
2167
2181
|
import_picocolors7.default.blue(
|
|
2168
2182
|
`Entry file ${entry} created at ${path7.relative(
|
|
2169
2183
|
rootDirectory,
|
|
2170
|
-
|
|
2184
|
+
outputFile
|
|
2171
2185
|
)}.`
|
|
2172
2186
|
)
|
|
2173
2187
|
);
|
|
@@ -2181,7 +2195,7 @@ function resolveRootDirectory(root, flags) {
|
|
|
2181
2195
|
async function checkForEntry(rootDirectory, appDirectory, entries2) {
|
|
2182
2196
|
for (let entry of entries2) {
|
|
2183
2197
|
let entryPath = path7.resolve(appDirectory, entry);
|
|
2184
|
-
let exists =
|
|
2198
|
+
let exists = (0, import_node_fs4.existsSync)(entryPath);
|
|
2185
2199
|
if (exists) {
|
|
2186
2200
|
let relative7 = path7.relative(rootDirectory, entryPath);
|
|
2187
2201
|
console.error(import_picocolors7.default.red(`Entry file ${relative7} already exists.`));
|
|
@@ -2191,12 +2205,12 @@ async function checkForEntry(rootDirectory, appDirectory, entries2) {
|
|
|
2191
2205
|
}
|
|
2192
2206
|
async function createServerEntry(rootDirectory, appDirectory, inputFile) {
|
|
2193
2207
|
await checkForEntry(rootDirectory, appDirectory, serverEntries);
|
|
2194
|
-
let contents = await
|
|
2208
|
+
let contents = await (0, import_promises3.readFile)(inputFile, "utf-8");
|
|
2195
2209
|
return contents;
|
|
2196
2210
|
}
|
|
2197
2211
|
async function createClientEntry(rootDirectory, appDirectory, inputFile) {
|
|
2198
2212
|
await checkForEntry(rootDirectory, appDirectory, clientEntries);
|
|
2199
|
-
let contents = await
|
|
2213
|
+
let contents = await (0, import_promises3.readFile)(inputFile, "utf-8");
|
|
2200
2214
|
return contents;
|
|
2201
2215
|
}
|
|
2202
2216
|
async function typegen(root, flags) {
|
package/dist/config.js
CHANGED
package/dist/routes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-a25096010
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -74,7 +74,12 @@ var routeConfigEntrySchema = v.pipe(
|
|
|
74
74
|
return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
|
|
75
75
|
}, "Invalid type: Expected object but received a promise. Did you forget to await?"),
|
|
76
76
|
v.object({
|
|
77
|
-
id: v.optional(
|
|
77
|
+
id: v.optional(
|
|
78
|
+
v.pipe(
|
|
79
|
+
v.string(),
|
|
80
|
+
v.notValue("root", "A route cannot use the reserved id 'root'.")
|
|
81
|
+
)
|
|
82
|
+
),
|
|
78
83
|
path: v.optional(v.string()),
|
|
79
84
|
index: v.optional(v.boolean()),
|
|
80
85
|
caseSensitive: v.optional(v.boolean()),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UNSAFE_MiddlewareEnabled, unstable_InitialContext, AppLoadContext } from 'react-router';
|
|
2
2
|
import { Plugin } from 'vite';
|
|
3
|
-
import {
|
|
3
|
+
import { PlatformProxy, GetPlatformProxyOptions } from 'wrangler';
|
|
4
4
|
|
|
5
5
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
6
|
type CfProperties = Record<string, unknown>;
|
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-a25096010
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -49,6 +49,7 @@ var import_react_router = require("react-router");
|
|
|
49
49
|
|
|
50
50
|
// vite/node-adapter.ts
|
|
51
51
|
var import_node_events = require("events");
|
|
52
|
+
var import_node_tls = require("tls");
|
|
52
53
|
var import_node_stream = require("stream");
|
|
53
54
|
var import_set_cookie_parser = require("set-cookie-parser");
|
|
54
55
|
var import_node = require("@react-router/node");
|
|
@@ -91,7 +92,8 @@ function fromNodeHeaders(nodeReq) {
|
|
|
91
92
|
return headers;
|
|
92
93
|
}
|
|
93
94
|
function fromNodeRequest(nodeReq, nodeRes) {
|
|
94
|
-
let
|
|
95
|
+
let protocol = nodeReq.socket instanceof import_node_tls.TLSSocket && nodeReq.socket.encrypted ? "https" : "http";
|
|
96
|
+
let origin = nodeReq.headers.origin && "null" !== nodeReq.headers.origin ? nodeReq.headers.origin : `${protocol}://${nodeReq.headers.host}`;
|
|
95
97
|
invariant(
|
|
96
98
|
nodeReq.originalUrl,
|
|
97
99
|
"Expected `nodeReq.originalUrl` to be defined"
|
|
@@ -174,11 +176,6 @@ var import_node_fs = __toESM(require("fs"));
|
|
|
174
176
|
var import_node_child_process = require("child_process");
|
|
175
177
|
var import_package_json = __toESM(require("@npmcli/package-json"));
|
|
176
178
|
|
|
177
|
-
// vite/vite-node.ts
|
|
178
|
-
var import_server = require("vite-node/server");
|
|
179
|
-
var import_client = require("vite-node/client");
|
|
180
|
-
var import_source_map = require("vite-node/source-map");
|
|
181
|
-
|
|
182
179
|
// vite/ssr-externals.ts
|
|
183
180
|
var ssrExternals = isReactRouterRepo() ? [
|
|
184
181
|
// This is only needed within this repo because these packages
|
|
@@ -202,6 +199,11 @@ async function createContext({
|
|
|
202
199
|
}) {
|
|
203
200
|
await preloadVite();
|
|
204
201
|
const vite2 = getVite();
|
|
202
|
+
const [{ ViteNodeServer }, { ViteNodeRunner }, { installSourcemapsSupport }] = await Promise.all([
|
|
203
|
+
import("vite-node/server"),
|
|
204
|
+
import("vite-node/client"),
|
|
205
|
+
import("vite-node/source-map")
|
|
206
|
+
]);
|
|
205
207
|
const devServer = await vite2.createServer({
|
|
206
208
|
root,
|
|
207
209
|
mode,
|
|
@@ -231,11 +233,11 @@ async function createContext({
|
|
|
231
233
|
plugins: []
|
|
232
234
|
});
|
|
233
235
|
await devServer.pluginContainer.buildStart({});
|
|
234
|
-
const server = new
|
|
235
|
-
|
|
236
|
+
const server = new ViteNodeServer(devServer);
|
|
237
|
+
installSourcemapsSupport({
|
|
236
238
|
getSourceMap: (source) => server.getSourceMap(source)
|
|
237
239
|
});
|
|
238
|
-
const runner = new
|
|
240
|
+
const runner = new ViteNodeRunner({
|
|
239
241
|
root: devServer.config.root,
|
|
240
242
|
base: devServer.config.base,
|
|
241
243
|
fetchModule(id) {
|
|
@@ -269,7 +271,12 @@ var routeConfigEntrySchema = v.pipe(
|
|
|
269
271
|
return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
|
|
270
272
|
}, "Invalid type: Expected object but received a promise. Did you forget to await?"),
|
|
271
273
|
v.object({
|
|
272
|
-
id: v.optional(
|
|
274
|
+
id: v.optional(
|
|
275
|
+
v.pipe(
|
|
276
|
+
v.string(),
|
|
277
|
+
v.notValue("root", "A route cannot use the reserved id 'root'.")
|
|
278
|
+
)
|
|
279
|
+
),
|
|
273
280
|
path: v.optional(v.string()),
|
|
274
281
|
index: v.optional(v.boolean()),
|
|
275
282
|
caseSensitive: v.optional(v.boolean()),
|
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-a25096010
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -46,13 +46,14 @@ module.exports = __toCommonJS(vite_exports);
|
|
|
46
46
|
|
|
47
47
|
// vite/plugin.ts
|
|
48
48
|
var import_node_crypto = require("crypto");
|
|
49
|
-
var
|
|
49
|
+
var import_node_fs2 = require("fs");
|
|
50
|
+
var import_promises2 = require("fs/promises");
|
|
50
51
|
var path5 = __toESM(require("path"));
|
|
51
52
|
var url = __toESM(require("url"));
|
|
52
|
-
var fse = __toESM(require("fs-extra"));
|
|
53
53
|
var babel = __toESM(require("@babel/core"));
|
|
54
54
|
var import_react_router2 = require("react-router");
|
|
55
55
|
var import_es_module_lexer = require("es-module-lexer");
|
|
56
|
+
var import_tinyglobby = require("tinyglobby");
|
|
56
57
|
var import_pick3 = __toESM(require("lodash/pick"));
|
|
57
58
|
var import_jsesc = __toESM(require("jsesc"));
|
|
58
59
|
var import_picocolors3 = __toESM(require("picocolors"));
|
|
@@ -68,11 +69,6 @@ var import_node_fs = __toESM(require("fs"));
|
|
|
68
69
|
var import_node_child_process = require("child_process");
|
|
69
70
|
var import_package_json = __toESM(require("@npmcli/package-json"));
|
|
70
71
|
|
|
71
|
-
// vite/vite-node.ts
|
|
72
|
-
var import_server = require("vite-node/server");
|
|
73
|
-
var import_client = require("vite-node/client");
|
|
74
|
-
var import_source_map = require("vite-node/source-map");
|
|
75
|
-
|
|
76
72
|
// vite/vite.ts
|
|
77
73
|
var import_pathe2 = __toESM(require("pathe"));
|
|
78
74
|
|
|
@@ -140,6 +136,11 @@ async function createContext({
|
|
|
140
136
|
}) {
|
|
141
137
|
await preloadVite();
|
|
142
138
|
const vite2 = getVite();
|
|
139
|
+
const [{ ViteNodeServer }, { ViteNodeRunner }, { installSourcemapsSupport }] = await Promise.all([
|
|
140
|
+
import("vite-node/server"),
|
|
141
|
+
import("vite-node/client"),
|
|
142
|
+
import("vite-node/source-map")
|
|
143
|
+
]);
|
|
143
144
|
const devServer = await vite2.createServer({
|
|
144
145
|
root,
|
|
145
146
|
mode,
|
|
@@ -169,11 +170,11 @@ async function createContext({
|
|
|
169
170
|
plugins: []
|
|
170
171
|
});
|
|
171
172
|
await devServer.pluginContainer.buildStart({});
|
|
172
|
-
const server = new
|
|
173
|
-
|
|
173
|
+
const server = new ViteNodeServer(devServer);
|
|
174
|
+
installSourcemapsSupport({
|
|
174
175
|
getSourceMap: (source) => server.getSourceMap(source)
|
|
175
176
|
});
|
|
176
|
-
const runner = new
|
|
177
|
+
const runner = new ViteNodeRunner({
|
|
177
178
|
root: devServer.config.root,
|
|
178
179
|
base: devServer.config.base,
|
|
179
180
|
fetchModule(id) {
|
|
@@ -207,7 +208,12 @@ var routeConfigEntrySchema = v.pipe(
|
|
|
207
208
|
return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
|
|
208
209
|
}, "Invalid type: Expected object but received a promise. Did you forget to await?"),
|
|
209
210
|
v.object({
|
|
210
|
-
id: v.optional(
|
|
211
|
+
id: v.optional(
|
|
212
|
+
v.pipe(
|
|
213
|
+
v.string(),
|
|
214
|
+
v.notValue("root", "A route cannot use the reserved id 'root'.")
|
|
215
|
+
)
|
|
216
|
+
),
|
|
211
217
|
path: v.optional(v.string()),
|
|
212
218
|
index: v.optional(v.boolean()),
|
|
213
219
|
caseSensitive: v.optional(v.boolean()),
|
|
@@ -684,22 +690,22 @@ async function resolveEntryFiles({
|
|
|
684
690
|
let userEntryServerFile = findEntry(appDirectory, "entry.server");
|
|
685
691
|
let entryServerFile;
|
|
686
692
|
let entryClientFile = userEntryClientFile || "entry.client.tsx";
|
|
687
|
-
let packageJsonPath = findEntry(rootDirectory, "package", {
|
|
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);
|
|
699
|
-
let deps = pkgJson.content.dependencies ?? {};
|
|
700
693
|
if (userEntryServerFile) {
|
|
701
694
|
entryServerFile = userEntryServerFile;
|
|
702
695
|
} else {
|
|
696
|
+
let packageJsonPath = findEntry(rootDirectory, "package", {
|
|
697
|
+
extensions: [".json"],
|
|
698
|
+
absolute: true,
|
|
699
|
+
walkParents: true
|
|
700
|
+
});
|
|
701
|
+
if (!packageJsonPath) {
|
|
702
|
+
throw new Error(
|
|
703
|
+
`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.`
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
let packageJsonDirectory = import_pathe3.default.dirname(packageJsonPath);
|
|
707
|
+
let pkgJson = await import_package_json.default.load(packageJsonDirectory);
|
|
708
|
+
let deps = pkgJson.content.dependencies ?? {};
|
|
703
709
|
if (!deps["@react-router/node"]) {
|
|
704
710
|
throw new Error(
|
|
705
711
|
`Could not determine server runtime. Please install @react-router/node, or provide a custom entry.server.tsx/jsx file in your app directory.`
|
|
@@ -915,7 +921,7 @@ function generateRoutes(ctx) {
|
|
|
915
921
|
lineages.set(route.id, lineage2);
|
|
916
922
|
const fullpath2 = fullpath(lineage2);
|
|
917
923
|
if (!fullpath2) continue;
|
|
918
|
-
const pages =
|
|
924
|
+
const pages = expand(fullpath2);
|
|
919
925
|
pages.forEach((page) => allPages.add(page));
|
|
920
926
|
lineage2.forEach(({ id }) => {
|
|
921
927
|
let routePages = routeToPages.get(id);
|
|
@@ -1123,9 +1129,13 @@ function getRouteAnnotations({
|
|
|
1123
1129
|
}
|
|
1124
1130
|
function relativeImportSource(from, to) {
|
|
1125
1131
|
let path6 = Path3.relative(Path3.dirname(from), to);
|
|
1132
|
+
let extension = Path3.extname(path6);
|
|
1126
1133
|
path6 = Path3.join(Path3.dirname(path6), Pathe.filename(path6));
|
|
1127
1134
|
if (!path6.startsWith("../")) path6 = "./" + path6;
|
|
1128
|
-
|
|
1135
|
+
if (!extension || /\.(js|ts)x?$/.test(extension)) {
|
|
1136
|
+
extension = ".js";
|
|
1137
|
+
}
|
|
1138
|
+
return path6 + extension;
|
|
1129
1139
|
}
|
|
1130
1140
|
function rootDirsPath(ctx, typesPath) {
|
|
1131
1141
|
const rel = Path3.relative(typesDirectory(ctx), typesPath);
|
|
@@ -1144,28 +1154,27 @@ function paramsType(path6) {
|
|
|
1144
1154
|
})
|
|
1145
1155
|
);
|
|
1146
1156
|
}
|
|
1147
|
-
function
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1157
|
+
function expand(fullpath2) {
|
|
1158
|
+
function recurse(segments2, index) {
|
|
1159
|
+
if (index === segments2.length) return [""];
|
|
1160
|
+
const segment = segments2[index];
|
|
1161
|
+
const isOptional = segment.endsWith("?");
|
|
1162
|
+
const isDynamic = segment.startsWith(":");
|
|
1163
|
+
const required = segment.replace(/\?$/, "");
|
|
1164
|
+
const keep = !isOptional || isDynamic;
|
|
1165
|
+
const kept = isDynamic ? segment : required;
|
|
1166
|
+
const withoutSegment = recurse(segments2, index + 1);
|
|
1167
|
+
const withSegment = withoutSegment.map((rest) => [kept, rest].join("/"));
|
|
1168
|
+
if (keep) return withSegment;
|
|
1169
|
+
return [...withoutSegment, ...withSegment];
|
|
1155
1170
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
result
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
)
|
|
1162
|
-
);
|
|
1163
|
-
if (isOptional) {
|
|
1164
|
-
result.push(...restExploded);
|
|
1171
|
+
const segments = fullpath2.split("/");
|
|
1172
|
+
const expanded = /* @__PURE__ */ new Set();
|
|
1173
|
+
for (let result of recurse(segments, 0)) {
|
|
1174
|
+
if (result !== "/") result = result.replace(/\/$/, "");
|
|
1175
|
+
expanded.add(result);
|
|
1165
1176
|
}
|
|
1166
|
-
return
|
|
1167
|
-
(exploded) => path6.startsWith("/") && exploded === "" ? "/" : exploded
|
|
1168
|
-
);
|
|
1177
|
+
return expanded;
|
|
1169
1178
|
}
|
|
1170
1179
|
|
|
1171
1180
|
// typegen/index.ts
|
|
@@ -1223,6 +1232,7 @@ async function watch(rootDirectory, { mode, logger }) {
|
|
|
1223
1232
|
|
|
1224
1233
|
// vite/node-adapter.ts
|
|
1225
1234
|
var import_node_events = require("events");
|
|
1235
|
+
var import_node_tls = require("tls");
|
|
1226
1236
|
var import_node_stream = require("stream");
|
|
1227
1237
|
var import_set_cookie_parser = require("set-cookie-parser");
|
|
1228
1238
|
var import_node = require("@react-router/node");
|
|
@@ -1253,7 +1263,8 @@ function fromNodeHeaders(nodeReq) {
|
|
|
1253
1263
|
return headers;
|
|
1254
1264
|
}
|
|
1255
1265
|
function fromNodeRequest(nodeReq, nodeRes) {
|
|
1256
|
-
let
|
|
1266
|
+
let protocol = nodeReq.socket instanceof import_node_tls.TLSSocket && nodeReq.socket.encrypted ? "https" : "http";
|
|
1267
|
+
let origin = nodeReq.headers.origin && "null" !== nodeReq.headers.origin ? nodeReq.headers.origin : `${protocol}://${nodeReq.headers.host}`;
|
|
1257
1268
|
invariant(
|
|
1258
1269
|
nodeReq.originalUrl,
|
|
1259
1270
|
"Expected `nodeReq.originalUrl` to be defined"
|
|
@@ -2444,8 +2455,8 @@ function dedupe(array2) {
|
|
|
2444
2455
|
return [...new Set(array2)];
|
|
2445
2456
|
}
|
|
2446
2457
|
var writeFileSafe = async (file, contents) => {
|
|
2447
|
-
await
|
|
2448
|
-
await
|
|
2458
|
+
await (0, import_promises2.mkdir)(path5.dirname(file), { recursive: true });
|
|
2459
|
+
await (0, import_promises2.writeFile)(file, contents);
|
|
2449
2460
|
};
|
|
2450
2461
|
var getExportNames = (code) => {
|
|
2451
2462
|
let [, exportSpecifiers] = (0, import_es_module_lexer.parse)(code);
|
|
@@ -2479,7 +2490,7 @@ var compileRouteFile = async (viteChildCompiler, ctx, routeFile, readRouteFile)
|
|
|
2479
2490
|
};
|
|
2480
2491
|
let [id, code] = await Promise.all([
|
|
2481
2492
|
resolveId(),
|
|
2482
|
-
readRouteFile?.() ??
|
|
2493
|
+
readRouteFile?.() ?? (0, import_promises2.readFile)(routePath, "utf-8"),
|
|
2483
2494
|
// pluginContainer.transform(...) fails if we don't do this first:
|
|
2484
2495
|
moduleGraph.ensureEntryFromUrl(url2, ssr)
|
|
2485
2496
|
]);
|
|
@@ -2541,7 +2552,9 @@ var defaultEntriesDir = path5.resolve(
|
|
|
2541
2552
|
"config",
|
|
2542
2553
|
"defaults"
|
|
2543
2554
|
);
|
|
2544
|
-
var defaultEntries =
|
|
2555
|
+
var defaultEntries = (0, import_node_fs2.readdirSync)(defaultEntriesDir).map(
|
|
2556
|
+
(filename2) => path5.join(defaultEntriesDir, filename2)
|
|
2557
|
+
);
|
|
2545
2558
|
invariant(defaultEntries.length > 0, "No default entries found");
|
|
2546
2559
|
var reactRouterDevLoadContext = () => void 0;
|
|
2547
2560
|
var reactRouterVitePlugin = () => {
|
|
@@ -2678,7 +2691,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2678
2691
|
` : ""}`;
|
|
2679
2692
|
};
|
|
2680
2693
|
let loadViteManifest = async (directory) => {
|
|
2681
|
-
let manifestContents = await
|
|
2694
|
+
let manifestContents = await (0, import_promises2.readFile)(
|
|
2682
2695
|
path5.resolve(directory, ".vite", "manifest.json"),
|
|
2683
2696
|
"utf-8"
|
|
2684
2697
|
);
|
|
@@ -2700,7 +2713,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2700
2713
|
};
|
|
2701
2714
|
let generateSriManifest = async (ctx2) => {
|
|
2702
2715
|
let clientBuildDirectory = getClientBuildDirectory(ctx2.reactRouterConfig);
|
|
2703
|
-
let entries =
|
|
2716
|
+
let entries = (0, import_node_fs2.readdirSync)(clientBuildDirectory, {
|
|
2704
2717
|
withFileTypes: true,
|
|
2705
2718
|
recursive: true
|
|
2706
2719
|
});
|
|
@@ -2710,7 +2723,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2710
2723
|
const entryNormalizedPath = "parentPath" in entry && typeof entry.parentPath === "string" ? entry.parentPath : entry.path;
|
|
2711
2724
|
let contents;
|
|
2712
2725
|
try {
|
|
2713
|
-
contents = await
|
|
2726
|
+
contents = await (0, import_promises2.readFile)(
|
|
2714
2727
|
path5.join(entryNormalizedPath, entry.name),
|
|
2715
2728
|
"utf-8"
|
|
2716
2729
|
);
|
|
@@ -2966,6 +2979,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2966
2979
|
config: async (_viteUserConfig, _viteConfigEnv) => {
|
|
2967
2980
|
await preloadVite();
|
|
2968
2981
|
let vite2 = getVite();
|
|
2982
|
+
let viteMajorVersion = parseInt(vite2.version.split(".")[0], 10);
|
|
2969
2983
|
viteUserConfig = _viteUserConfig;
|
|
2970
2984
|
viteConfigEnv = _viteConfigEnv;
|
|
2971
2985
|
viteCommand = viteConfigEnv.command;
|
|
@@ -2995,7 +3009,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2995
3009
|
vite2.loadEnv(
|
|
2996
3010
|
viteConfigEnv.mode,
|
|
2997
3011
|
viteUserConfig.envDir ?? ctx.rootDirectory,
|
|
2998
|
-
// We override default prefix of "VITE_" with a blank string since
|
|
3012
|
+
// We override the default prefix of "VITE_" with a blank string since
|
|
2999
3013
|
// we're targeting the server, so we want to load all environment
|
|
3000
3014
|
// variables, not just those explicitly marked for the client
|
|
3001
3015
|
""
|
|
@@ -3024,7 +3038,13 @@ var reactRouterVitePlugin = () => {
|
|
|
3024
3038
|
...Object.values(ctx.reactRouterConfig.routes).map(
|
|
3025
3039
|
(route) => resolveRelativeRouteFilePath(route, ctx.reactRouterConfig)
|
|
3026
3040
|
)
|
|
3027
|
-
]
|
|
3041
|
+
].map(
|
|
3042
|
+
(entry) => (
|
|
3043
|
+
// In Vite 7, the `optimizeDeps.entries` option only accepts glob patterns.
|
|
3044
|
+
// In prior versions, absolute file paths were treated differently.
|
|
3045
|
+
viteMajorVersion >= 7 ? (0, import_tinyglobby.escapePath)(entry) : entry
|
|
3046
|
+
)
|
|
3047
|
+
) : [],
|
|
3028
3048
|
include: [
|
|
3029
3049
|
// Pre-bundle React dependencies to avoid React duplicates,
|
|
3030
3050
|
// even if React dependencies are not direct dependencies.
|
|
@@ -3059,7 +3079,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3059
3079
|
conditions: viteCommand === "build" ? viteClientConditions : ["development", ...viteClientConditions]
|
|
3060
3080
|
},
|
|
3061
3081
|
base: viteUserConfig.base,
|
|
3062
|
-
// When consumer provides an
|
|
3082
|
+
// When consumer provides an allowlist for files that can be read by
|
|
3063
3083
|
// the server, ensure that the default entry files are included.
|
|
3064
3084
|
// If we don't do this and a default entry file is used, the server
|
|
3065
3085
|
// will throw an error that the file is not allowed to be read.
|
|
@@ -3351,15 +3371,15 @@ var reactRouterVitePlugin = () => {
|
|
|
3351
3371
|
let src = path5.join(serverBuildDirectory, ssrAssetPath);
|
|
3352
3372
|
let dest = path5.join(clientBuildDirectory, ssrAssetPath);
|
|
3353
3373
|
if (!userSsrEmitAssets) {
|
|
3354
|
-
if (!
|
|
3355
|
-
await
|
|
3374
|
+
if (!(0, import_node_fs2.existsSync)(dest)) {
|
|
3375
|
+
await (0, import_promises2.rename)(src, dest);
|
|
3356
3376
|
movedAssetPaths.push(dest);
|
|
3357
3377
|
} else {
|
|
3358
|
-
await
|
|
3378
|
+
await (0, import_promises2.rm)(src, { force: true, recursive: true });
|
|
3359
3379
|
removedAssetPaths.push(dest);
|
|
3360
3380
|
}
|
|
3361
|
-
} else if (!
|
|
3362
|
-
await
|
|
3381
|
+
} else if (!(0, import_node_fs2.existsSync)(dest)) {
|
|
3382
|
+
await (0, import_promises2.cp)(src, dest, { recursive: true });
|
|
3363
3383
|
copiedAssetPaths.push(dest);
|
|
3364
3384
|
}
|
|
3365
3385
|
}
|
|
@@ -3370,7 +3390,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3370
3390
|
await Promise.all(
|
|
3371
3391
|
ssrCssPaths.map(async (cssPath) => {
|
|
3372
3392
|
let src = path5.join(serverBuildDirectory, cssPath);
|
|
3373
|
-
await
|
|
3393
|
+
await (0, import_promises2.rm)(src, { force: true, recursive: true });
|
|
3374
3394
|
removedAssetPaths.push(src);
|
|
3375
3395
|
})
|
|
3376
3396
|
);
|
|
@@ -3381,9 +3401,9 @@ var reactRouterVitePlugin = () => {
|
|
|
3381
3401
|
await Promise.all(
|
|
3382
3402
|
Array.from(cleanedAssetDirs).map(async (dir) => {
|
|
3383
3403
|
try {
|
|
3384
|
-
const files = await
|
|
3404
|
+
const files = await (0, import_promises2.readdir)(dir, { recursive: true });
|
|
3385
3405
|
if (files.length === 0) {
|
|
3386
|
-
await
|
|
3406
|
+
await (0, import_promises2.rm)(dir, { force: true, recursive: true });
|
|
3387
3407
|
}
|
|
3388
3408
|
} catch {
|
|
3389
3409
|
}
|
|
@@ -3447,7 +3467,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3447
3467
|
"due to ssr:false"
|
|
3448
3468
|
].join(" ")
|
|
3449
3469
|
);
|
|
3450
|
-
|
|
3470
|
+
(0, import_node_fs2.rmSync)(serverBuildDirectory, { force: true, recursive: true });
|
|
3451
3471
|
}
|
|
3452
3472
|
}
|
|
3453
3473
|
},
|
|
@@ -3465,7 +3485,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3465
3485
|
// primarily ensures code is never duplicated across a route module and
|
|
3466
3486
|
// its chunks. If we didn't have this plugin, any app that explicitly
|
|
3467
3487
|
// imports a route module would result in duplicate code since the app
|
|
3468
|
-
// would contain code for both the unprocessed route module
|
|
3488
|
+
// would contain code for both the unprocessed route module and its
|
|
3469
3489
|
// individual chunks. This is because, since they have different module
|
|
3470
3490
|
// IDs, they are treated as completely separate modules even though they
|
|
3471
3491
|
// all reference the same underlying file. This plugin addresses this by
|
|
@@ -3771,11 +3791,8 @@ var reactRouterVitePlugin = () => {
|
|
|
3771
3791
|
);
|
|
3772
3792
|
return [
|
|
3773
3793
|
"const exports = {}",
|
|
3774
|
-
await
|
|
3775
|
-
await
|
|
3776
|
-
require.resolve("./static/refresh-utils.cjs"),
|
|
3777
|
-
"utf8"
|
|
3778
|
-
),
|
|
3794
|
+
await (0, import_promises2.readFile)(reactRefreshRuntimePath, "utf8"),
|
|
3795
|
+
await (0, import_promises2.readFile)(require.resolve("./static/refresh-utils.cjs"), "utf8"),
|
|
3779
3796
|
"export default exports"
|
|
3780
3797
|
].join("\n");
|
|
3781
3798
|
}
|
|
@@ -3858,10 +3875,10 @@ var reactRouterVitePlugin = () => {
|
|
|
3858
3875
|
{
|
|
3859
3876
|
name: "react-router-server-change-trigger-client-hmr",
|
|
3860
3877
|
// This hook is only available in Vite v6+ so this is a no-op in v5.
|
|
3861
|
-
// Previously the server and client modules were shared in a single module
|
|
3878
|
+
// Previously, the server and client modules were shared in a single module
|
|
3862
3879
|
// graph. This meant that changes to server code automatically resulted in
|
|
3863
|
-
// client HMR updates. In Vite v6
|
|
3864
|
-
// each other so we need to manually trigger client HMR updates if server
|
|
3880
|
+
// client HMR updates. In Vite v6+, these module graphs are separate from
|
|
3881
|
+
// each other, so we need to manually trigger client HMR updates if server
|
|
3865
3882
|
// code has changed.
|
|
3866
3883
|
hotUpdate({ server, modules }) {
|
|
3867
3884
|
if (this.environment.name !== "ssr" && modules.length <= 0) {
|
|
@@ -4055,7 +4072,7 @@ async function handleSpaMode(viteConfig, reactRouterConfig, serverBuildDirectory
|
|
|
4055
4072
|
"SPA Mode: Did you forget to include `<Scripts/>` in your root route? Your pre-rendered HTML cannot hydrate without `<Scripts />`."
|
|
4056
4073
|
);
|
|
4057
4074
|
}
|
|
4058
|
-
await
|
|
4075
|
+
await (0, import_promises2.writeFile)(path5.join(clientBuildDirectory, filename2), html);
|
|
4059
4076
|
let prettyDir = path5.relative(process.cwd(), clientBuildDirectory);
|
|
4060
4077
|
let prettyPath = path5.join(prettyDir, filename2);
|
|
4061
4078
|
if (build.prerender.length > 0) {
|
|
@@ -4186,8 +4203,8 @@ ${normalizedPath}`
|
|
|
4186
4203
|
}
|
|
4187
4204
|
let outdir = path5.relative(process.cwd(), clientBuildDirectory);
|
|
4188
4205
|
let outfile = path5.join(outdir, ...normalizedPath.split("/"));
|
|
4189
|
-
await
|
|
4190
|
-
await
|
|
4206
|
+
await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
|
|
4207
|
+
await (0, import_promises2.writeFile)(outfile, data);
|
|
4191
4208
|
viteConfig.logger.info(
|
|
4192
4209
|
`Prerender (data): ${prerenderPath} -> ${import_picocolors3.default.bold(outfile)}`
|
|
4193
4210
|
);
|
|
@@ -4225,8 +4242,8 @@ ${html}`
|
|
|
4225
4242
|
}
|
|
4226
4243
|
let outdir = path5.relative(process.cwd(), clientBuildDirectory);
|
|
4227
4244
|
let outfile = path5.join(outdir, ...normalizedPath.split("/"), "index.html");
|
|
4228
|
-
await
|
|
4229
|
-
await
|
|
4245
|
+
await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
|
|
4246
|
+
await (0, import_promises2.writeFile)(outfile, html);
|
|
4230
4247
|
viteConfig.logger.info(
|
|
4231
4248
|
`Prerender (html): ${prerenderPath} -> ${import_picocolors3.default.bold(outfile)}`
|
|
4232
4249
|
);
|
|
@@ -4244,8 +4261,8 @@ ${content.toString("utf8")}`
|
|
|
4244
4261
|
}
|
|
4245
4262
|
let outdir = path5.relative(process.cwd(), clientBuildDirectory);
|
|
4246
4263
|
let outfile = path5.join(outdir, ...normalizedPath.split("/"));
|
|
4247
|
-
await
|
|
4248
|
-
await
|
|
4264
|
+
await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
|
|
4265
|
+
await (0, import_promises2.writeFile)(outfile, content);
|
|
4249
4266
|
viteConfig.logger.info(
|
|
4250
4267
|
`Prerender (resource): ${prerenderPath} -> ${import_picocolors3.default.bold(outfile)}`
|
|
4251
4268
|
);
|
|
@@ -4498,7 +4515,7 @@ async function cleanBuildDirectory(viteConfig, ctx) {
|
|
|
4498
4515
|
return !relativePath.startsWith("..") && !path5.isAbsolute(relativePath);
|
|
4499
4516
|
};
|
|
4500
4517
|
if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
|
|
4501
|
-
await
|
|
4518
|
+
await (0, import_promises2.rm)(buildDirectory, { force: true, recursive: true });
|
|
4502
4519
|
}
|
|
4503
4520
|
}
|
|
4504
4521
|
async function cleanViteManifests(environmentsOptions, ctx) {
|
|
@@ -4511,15 +4528,15 @@ async function cleanViteManifests(environmentsOptions, ctx) {
|
|
|
4511
4528
|
);
|
|
4512
4529
|
await Promise.all(
|
|
4513
4530
|
viteManifestPaths.map(async (viteManifestPath) => {
|
|
4514
|
-
let manifestExists =
|
|
4531
|
+
let manifestExists = (0, import_node_fs2.existsSync)(viteManifestPath);
|
|
4515
4532
|
if (!manifestExists) return;
|
|
4516
4533
|
if (!ctx.viteManifestEnabled) {
|
|
4517
|
-
await
|
|
4534
|
+
await (0, import_promises2.rm)(viteManifestPath, { force: true, recursive: true });
|
|
4518
4535
|
}
|
|
4519
4536
|
let viteDir = path5.dirname(viteManifestPath);
|
|
4520
|
-
let viteDirFiles = await
|
|
4537
|
+
let viteDirFiles = await (0, import_promises2.readdir)(viteDir, { recursive: true });
|
|
4521
4538
|
if (viteDirFiles.length === 0) {
|
|
4522
|
-
await
|
|
4539
|
+
await (0, import_promises2.rm)(viteDir, { force: true, recursive: true });
|
|
4523
4540
|
}
|
|
4524
4541
|
})
|
|
4525
4542
|
);
|
|
@@ -4655,13 +4672,13 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
4655
4672
|
},
|
|
4656
4673
|
build: {
|
|
4657
4674
|
// We move SSR-only assets to client assets. Note that the
|
|
4658
|
-
// SSR build can also emit code-split JS files (e.g
|
|
4675
|
+
// SSR build can also emit code-split JS files (e.g., by
|
|
4659
4676
|
// dynamic import) under the same assets directory
|
|
4660
4677
|
// regardless of "ssrEmitAssets" option, so we also need to
|
|
4661
|
-
// keep these JS files
|
|
4678
|
+
// keep these JS files to be kept as-is.
|
|
4662
4679
|
ssrEmitAssets: true,
|
|
4663
4680
|
copyPublicDir: false,
|
|
4664
|
-
//
|
|
4681
|
+
// The client only uses assets in the public directory
|
|
4665
4682
|
rollupOptions: {
|
|
4666
4683
|
input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual.serverBuild.id,
|
|
4667
4684
|
output: {
|
|
@@ -4685,7 +4702,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
4685
4702
|
route.file
|
|
4686
4703
|
);
|
|
4687
4704
|
let isRootRoute = route.file === ctx.reactRouterConfig.routes.root.file;
|
|
4688
|
-
let code =
|
|
4705
|
+
let code = (0, import_node_fs2.readFileSync)(routeFilePath, "utf-8");
|
|
4689
4706
|
return [
|
|
4690
4707
|
`${routeFilePath}${BUILD_CLIENT_ROUTE_QUERY_STRING}`,
|
|
4691
4708
|
...ctx.reactRouterConfig.future.unstable_splitRouteModules && !isRootRoute ? routeChunkExportNames.map(
|
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-a25096010",
|
|
4
4
|
"description": "Dev tools and CLI for React Router",
|
|
5
5
|
"homepage": "https://reactrouter.com",
|
|
6
6
|
"bugs": {
|
|
@@ -75,7 +75,6 @@
|
|
|
75
75
|
"dedent": "^1.5.3",
|
|
76
76
|
"es-module-lexer": "^1.3.1",
|
|
77
77
|
"exit-hook": "2.2.1",
|
|
78
|
-
"fs-extra": "^10.0.0",
|
|
79
78
|
"jsesc": "3.0.2",
|
|
80
79
|
"lodash": "^4.17.21",
|
|
81
80
|
"pathe": "^1.1.2",
|
|
@@ -84,9 +83,10 @@
|
|
|
84
83
|
"react-refresh": "^0.14.0",
|
|
85
84
|
"semver": "^7.3.7",
|
|
86
85
|
"set-cookie-parser": "^2.6.0",
|
|
86
|
+
"tinyglobby": "^0.2.14",
|
|
87
87
|
"valibot": "^0.41.0",
|
|
88
88
|
"vite-node": "^3.1.4",
|
|
89
|
-
"@react-router/node": "0.0.0-experimental-
|
|
89
|
+
"@react-router/node": "0.0.0-experimental-a25096010"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@types/babel__core": "^7.20.5",
|
|
@@ -94,13 +94,13 @@
|
|
|
94
94
|
"@types/babel__traverse": "^7.20.5",
|
|
95
95
|
"@types/dedent": "^0.7.0",
|
|
96
96
|
"@types/express": "^4.17.9",
|
|
97
|
-
"@types/fs-extra": "^8.1.2",
|
|
98
97
|
"@types/jsesc": "^3.0.1",
|
|
99
98
|
"@types/lodash": "^4.14.182",
|
|
100
99
|
"@types/node": "^20.0.0",
|
|
101
100
|
"@types/npmcli__package-json": "^4.0.0",
|
|
102
101
|
"@types/prettier": "^2.7.3",
|
|
103
102
|
"@types/set-cookie-parser": "^2.4.1",
|
|
103
|
+
"@types/semver": "^7.7.0",
|
|
104
104
|
"esbuild-register": "^3.6.0",
|
|
105
105
|
"execa": "5.1.1",
|
|
106
106
|
"express": "^4.19.2",
|
|
@@ -110,15 +110,15 @@
|
|
|
110
110
|
"vite": "^6.1.0",
|
|
111
111
|
"wireit": "0.14.9",
|
|
112
112
|
"wrangler": "^4.2.0",
|
|
113
|
-
"react-router": "
|
|
114
|
-
"
|
|
113
|
+
"@react-router/serve": "0.0.0-experimental-a25096010",
|
|
114
|
+
"react-router": "^0.0.0-experimental-a25096010"
|
|
115
115
|
},
|
|
116
116
|
"peerDependencies": {
|
|
117
117
|
"typescript": "^5.1.0",
|
|
118
|
-
"vite": "^5.1.0 || ^6.0.0",
|
|
118
|
+
"vite": "^5.1.0 || ^6.0.0 || ^7.0.0",
|
|
119
119
|
"wrangler": "^3.28.2 || ^4.0.0",
|
|
120
|
-
"@react-router/serve": "^0.0.0-experimental-
|
|
121
|
-
"react-router": "^0.0.0-experimental-
|
|
120
|
+
"@react-router/serve": "^0.0.0-experimental-a25096010",
|
|
121
|
+
"react-router": "^0.0.0-experimental-a25096010"
|
|
122
122
|
},
|
|
123
123
|
"peerDependenciesMeta": {
|
|
124
124
|
"@react-router/serve": {
|