@react-router/dev 0.0.0-experimental-bafa092e7 → 0.0.0-experimental-47ed76689
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 +62 -0
- package/dist/cli/index.js +61 -53
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +9 -9
- package/dist/vite.js +88 -78
- package/package.json +8 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
# `@react-router/dev`
|
|
2
2
|
|
|
3
|
+
## 7.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 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))
|
|
8
|
+
|
|
9
|
+
- 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))
|
|
10
|
+
|
|
11
|
+
- Update `vite-node` ([#13673](https://github.com/remix-run/react-router/pull/13673))
|
|
12
|
+
|
|
13
|
+
- Fix typegen for non-{.js,.jsx,.ts,.tsx} routes like .mdx ([#12453](https://github.com/remix-run/react-router/pull/12453))
|
|
14
|
+
|
|
15
|
+
- Fix href types for optional dynamic params ([#13725](https://github.com/remix-run/react-router/pull/13725))
|
|
16
|
+
|
|
17
|
+
7.6.1 introduced fixes for `href` when using optional static segments,
|
|
18
|
+
but those fixes caused regressions with how optional dynamic params worked in 7.6.0:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
// 7.6.0
|
|
22
|
+
href("/users/:id?"); // ✅
|
|
23
|
+
href("/users/:id?", { id: 1 }); // ✅
|
|
24
|
+
|
|
25
|
+
// 7.6.1
|
|
26
|
+
href("/users/:id?"); // ❌
|
|
27
|
+
href("/users/:id?", { id: 1 }); // ❌
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Now, optional static segments are expanded into different paths for `href`, but optional dynamic params are not.
|
|
31
|
+
This way `href` can unambiguously refer to an exact URL path, all while keeping the number of path options to a minimum.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// 7.6.2
|
|
35
|
+
|
|
36
|
+
// path: /users/:id?/edit?
|
|
37
|
+
href("
|
|
38
|
+
// ^ suggestions when cursor is here:
|
|
39
|
+
//
|
|
40
|
+
// /users/:id?
|
|
41
|
+
// /users/:id?/edit
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Additionally, you can pass `params` from component props without needing to narrow them manually:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
declare const params: { id?: number };
|
|
48
|
+
|
|
49
|
+
// 7.6.0
|
|
50
|
+
href("/users/:id?", params);
|
|
51
|
+
|
|
52
|
+
// 7.6.1
|
|
53
|
+
href("/users/:id?", params); // ❌
|
|
54
|
+
"id" in params ? href("/users/:id", params) : href("/users"); // works... but is annoying
|
|
55
|
+
|
|
56
|
+
// 7.6.2
|
|
57
|
+
href("/users/:id?", params); // restores behavior of 7.6.0
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- Updated dependencies:
|
|
61
|
+
- `react-router@7.6.2`
|
|
62
|
+
- `@react-router/node@7.6.2`
|
|
63
|
+
- `@react-router/serve@7.6.2`
|
|
64
|
+
|
|
3
65
|
## 7.6.1
|
|
4
66
|
|
|
5
67
|
### 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-47ed76689
|
|
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
|
}
|
|
@@ -928,7 +929,7 @@ function generateRoutes(ctx) {
|
|
|
928
929
|
lineages.set(route.id, lineage2);
|
|
929
930
|
const fullpath2 = fullpath(lineage2);
|
|
930
931
|
if (!fullpath2) continue;
|
|
931
|
-
const pages =
|
|
932
|
+
const pages = expand(fullpath2);
|
|
932
933
|
pages.forEach((page) => allPages.add(page));
|
|
933
934
|
lineage2.forEach(({ id }) => {
|
|
934
935
|
let routePages = routeToPages.get(id);
|
|
@@ -1136,9 +1137,13 @@ function getRouteAnnotations({
|
|
|
1136
1137
|
}
|
|
1137
1138
|
function relativeImportSource(from, to) {
|
|
1138
1139
|
let path8 = Path3.relative(Path3.dirname(from), to);
|
|
1140
|
+
let extension = Path3.extname(path8);
|
|
1139
1141
|
path8 = Path3.join(Path3.dirname(path8), Pathe.filename(path8));
|
|
1140
1142
|
if (!path8.startsWith("../")) path8 = "./" + path8;
|
|
1141
|
-
|
|
1143
|
+
if (!extension || /\.(js|ts)x?$/.test(extension)) {
|
|
1144
|
+
extension = ".js";
|
|
1145
|
+
}
|
|
1146
|
+
return path8 + extension;
|
|
1142
1147
|
}
|
|
1143
1148
|
function rootDirsPath(ctx, typesPath) {
|
|
1144
1149
|
const rel = Path3.relative(typesDirectory(ctx), typesPath);
|
|
@@ -1157,28 +1162,27 @@ function paramsType(path8) {
|
|
|
1157
1162
|
})
|
|
1158
1163
|
);
|
|
1159
1164
|
}
|
|
1160
|
-
function
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
...
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
);
|
|
1176
|
-
|
|
1177
|
-
result.
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
);
|
|
1165
|
+
function expand(fullpath2) {
|
|
1166
|
+
function recurse(segments2, index) {
|
|
1167
|
+
if (index === segments2.length) return [""];
|
|
1168
|
+
const segment = segments2[index];
|
|
1169
|
+
const isOptional = segment.endsWith("?");
|
|
1170
|
+
const isDynamic = segment.startsWith(":");
|
|
1171
|
+
const required = segment.replace(/\?$/, "");
|
|
1172
|
+
const keep = !isOptional || isDynamic;
|
|
1173
|
+
const kept = isDynamic ? segment : required;
|
|
1174
|
+
const withoutSegment = recurse(segments2, index + 1);
|
|
1175
|
+
const withSegment = withoutSegment.map((rest) => [kept, rest].join("/"));
|
|
1176
|
+
if (keep) return withSegment;
|
|
1177
|
+
return [...withoutSegment, ...withSegment];
|
|
1178
|
+
}
|
|
1179
|
+
const segments = fullpath2.split("/");
|
|
1180
|
+
const expanded = /* @__PURE__ */ new Set();
|
|
1181
|
+
for (let result of recurse(segments, 0)) {
|
|
1182
|
+
if (result !== "/") result = result.replace(/\/$/, "");
|
|
1183
|
+
expanded.add(result);
|
|
1184
|
+
}
|
|
1185
|
+
return expanded;
|
|
1182
1186
|
}
|
|
1183
1187
|
var import_dedent, Path3, Pathe, t2;
|
|
1184
1188
|
var init_generate = __esm({
|
|
@@ -1445,7 +1449,7 @@ async function cleanBuildDirectory(viteConfig, ctx) {
|
|
|
1445
1449
|
return !relativePath.startsWith("..") && !path6.isAbsolute(relativePath);
|
|
1446
1450
|
};
|
|
1447
1451
|
if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
|
|
1448
|
-
await
|
|
1452
|
+
await (0, import_promises2.rm)(buildDirectory, { force: true, recursive: true });
|
|
1449
1453
|
}
|
|
1450
1454
|
}
|
|
1451
1455
|
async function cleanViteManifests(environmentsOptions, ctx) {
|
|
@@ -1458,15 +1462,15 @@ async function cleanViteManifests(environmentsOptions, ctx) {
|
|
|
1458
1462
|
);
|
|
1459
1463
|
await Promise.all(
|
|
1460
1464
|
viteManifestPaths.map(async (viteManifestPath) => {
|
|
1461
|
-
let manifestExists =
|
|
1465
|
+
let manifestExists = (0, import_node_fs3.existsSync)(viteManifestPath);
|
|
1462
1466
|
if (!manifestExists) return;
|
|
1463
1467
|
if (!ctx.viteManifestEnabled) {
|
|
1464
|
-
await
|
|
1468
|
+
await (0, import_promises2.rm)(viteManifestPath, { force: true, recursive: true });
|
|
1465
1469
|
}
|
|
1466
1470
|
let viteDir = path6.dirname(viteManifestPath);
|
|
1467
|
-
let viteDirFiles = await
|
|
1471
|
+
let viteDirFiles = await (0, import_promises2.readdir)(viteDir, { recursive: true });
|
|
1468
1472
|
if (viteDirFiles.length === 0) {
|
|
1469
|
-
await
|
|
1473
|
+
await (0, import_promises2.rm)(viteDir, { force: true, recursive: true });
|
|
1470
1474
|
}
|
|
1471
1475
|
})
|
|
1472
1476
|
);
|
|
@@ -1532,13 +1536,13 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
1532
1536
|
},
|
|
1533
1537
|
build: {
|
|
1534
1538
|
// We move SSR-only assets to client assets. Note that the
|
|
1535
|
-
// SSR build can also emit code-split JS files (e.g
|
|
1539
|
+
// SSR build can also emit code-split JS files (e.g., by
|
|
1536
1540
|
// dynamic import) under the same assets directory
|
|
1537
1541
|
// regardless of "ssrEmitAssets" option, so we also need to
|
|
1538
|
-
// keep these JS files
|
|
1542
|
+
// keep these JS files to be kept as-is.
|
|
1539
1543
|
ssrEmitAssets: true,
|
|
1540
1544
|
copyPublicDir: false,
|
|
1541
|
-
//
|
|
1545
|
+
// The client only uses assets in the public directory
|
|
1542
1546
|
rollupOptions: {
|
|
1543
1547
|
input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual.serverBuild.id,
|
|
1544
1548
|
output: {
|
|
@@ -1562,7 +1566,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
1562
1566
|
route.file
|
|
1563
1567
|
);
|
|
1564
1568
|
let isRootRoute = route.file === ctx.reactRouterConfig.routes.root.file;
|
|
1565
|
-
let code =
|
|
1569
|
+
let code = (0, import_node_fs3.readFileSync)(routeFilePath, "utf-8");
|
|
1566
1570
|
return [
|
|
1567
1571
|
`${routeFilePath}${BUILD_CLIENT_ROUTE_QUERY_STRING}`,
|
|
1568
1572
|
...ctx.reactRouterConfig.future.unstable_splitRouteModules && !isRootRoute ? routeChunkExportNames.map(
|
|
@@ -1631,18 +1635,19 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
|
|
|
1631
1635
|
function isNonNullable(x) {
|
|
1632
1636
|
return x != null;
|
|
1633
1637
|
}
|
|
1634
|
-
var import_node_crypto,
|
|
1638
|
+
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
1639
|
var init_plugin = __esm({
|
|
1636
1640
|
"vite/plugin.ts"() {
|
|
1637
1641
|
"use strict";
|
|
1638
1642
|
import_node_crypto = require("crypto");
|
|
1639
|
-
|
|
1643
|
+
import_node_fs3 = require("fs");
|
|
1644
|
+
import_promises2 = require("fs/promises");
|
|
1640
1645
|
path6 = __toESM(require("path"));
|
|
1641
1646
|
url = __toESM(require("url"));
|
|
1642
|
-
fse = __toESM(require("fs-extra"));
|
|
1643
1647
|
babel2 = __toESM(require("@babel/core"));
|
|
1644
1648
|
import_react_router2 = require("react-router");
|
|
1645
1649
|
import_es_module_lexer = require("es-module-lexer");
|
|
1650
|
+
import_tinyglobby = require("tinyglobby");
|
|
1646
1651
|
import_pick3 = __toESM(require("lodash/pick"));
|
|
1647
1652
|
import_jsesc = __toESM(require("jsesc"));
|
|
1648
1653
|
import_picocolors4 = __toESM(require("picocolors"));
|
|
@@ -1698,7 +1703,9 @@ var init_plugin = __esm({
|
|
|
1698
1703
|
"config",
|
|
1699
1704
|
"defaults"
|
|
1700
1705
|
);
|
|
1701
|
-
defaultEntries =
|
|
1706
|
+
defaultEntries = (0, import_node_fs3.readdirSync)(defaultEntriesDir).map(
|
|
1707
|
+
(filename2) => path6.join(defaultEntriesDir, filename2)
|
|
1708
|
+
);
|
|
1702
1709
|
invariant(defaultEntries.length > 0, "No default entries found");
|
|
1703
1710
|
REACT_REFRESH_HEADER = `
|
|
1704
1711
|
import RefreshRuntime from "${virtualHmrRuntime.id}";
|
|
@@ -1978,8 +1985,9 @@ var import_semver = __toESM(require("semver"));
|
|
|
1978
1985
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
1979
1986
|
|
|
1980
1987
|
// cli/commands.ts
|
|
1988
|
+
var import_node_fs4 = require("fs");
|
|
1989
|
+
var import_promises3 = require("fs/promises");
|
|
1981
1990
|
var path7 = __toESM(require("path"));
|
|
1982
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
1983
1991
|
var import_package_json2 = __toESM(require("@npmcli/package-json"));
|
|
1984
1992
|
var import_exit_hook = __toESM(require("exit-hook"));
|
|
1985
1993
|
var import_picocolors7 = __toESM(require("picocolors"));
|
|
@@ -2153,21 +2161,21 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2153
2161
|
let useTypeScript = flags.typescript ?? true;
|
|
2154
2162
|
let outputExtension = useTypeScript ? "tsx" : "jsx";
|
|
2155
2163
|
let outputEntry = `${entry}.${outputExtension}`;
|
|
2156
|
-
let
|
|
2164
|
+
let outputFile = path7.resolve(appDirectory, outputEntry);
|
|
2157
2165
|
if (!useTypeScript) {
|
|
2158
2166
|
let javascript = transpile(contents, {
|
|
2159
2167
|
cwd: rootDirectory,
|
|
2160
2168
|
filename: isServerEntry ? defaultEntryServer : defaultEntryClient
|
|
2161
2169
|
});
|
|
2162
|
-
await
|
|
2170
|
+
await (0, import_promises3.writeFile)(outputFile, javascript, "utf-8");
|
|
2163
2171
|
} else {
|
|
2164
|
-
await
|
|
2172
|
+
await (0, import_promises3.writeFile)(outputFile, contents, "utf-8");
|
|
2165
2173
|
}
|
|
2166
2174
|
console.log(
|
|
2167
2175
|
import_picocolors7.default.blue(
|
|
2168
2176
|
`Entry file ${entry} created at ${path7.relative(
|
|
2169
2177
|
rootDirectory,
|
|
2170
|
-
|
|
2178
|
+
outputFile
|
|
2171
2179
|
)}.`
|
|
2172
2180
|
)
|
|
2173
2181
|
);
|
|
@@ -2181,7 +2189,7 @@ function resolveRootDirectory(root, flags) {
|
|
|
2181
2189
|
async function checkForEntry(rootDirectory, appDirectory, entries2) {
|
|
2182
2190
|
for (let entry of entries2) {
|
|
2183
2191
|
let entryPath = path7.resolve(appDirectory, entry);
|
|
2184
|
-
let exists =
|
|
2192
|
+
let exists = (0, import_node_fs4.existsSync)(entryPath);
|
|
2185
2193
|
if (exists) {
|
|
2186
2194
|
let relative7 = path7.relative(rootDirectory, entryPath);
|
|
2187
2195
|
console.error(import_picocolors7.default.red(`Entry file ${relative7} already exists.`));
|
|
@@ -2191,12 +2199,12 @@ async function checkForEntry(rootDirectory, appDirectory, entries2) {
|
|
|
2191
2199
|
}
|
|
2192
2200
|
async function createServerEntry(rootDirectory, appDirectory, inputFile) {
|
|
2193
2201
|
await checkForEntry(rootDirectory, appDirectory, serverEntries);
|
|
2194
|
-
let contents = await
|
|
2202
|
+
let contents = await (0, import_promises3.readFile)(inputFile, "utf-8");
|
|
2195
2203
|
return contents;
|
|
2196
2204
|
}
|
|
2197
2205
|
async function createClientEntry(rootDirectory, appDirectory, inputFile) {
|
|
2198
2206
|
await checkForEntry(rootDirectory, appDirectory, clientEntries);
|
|
2199
|
-
let contents = await
|
|
2207
|
+
let contents = await (0, import_promises3.readFile)(inputFile, "utf-8");
|
|
2200
2208
|
return contents;
|
|
2201
2209
|
}
|
|
2202
2210
|
async function typegen(root, flags) {
|
package/dist/config.js
CHANGED
package/dist/routes.js
CHANGED
package/dist/vite/cloudflare.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-47ed76689
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -174,11 +174,6 @@ var import_node_fs = __toESM(require("fs"));
|
|
|
174
174
|
var import_node_child_process = require("child_process");
|
|
175
175
|
var import_package_json = __toESM(require("@npmcli/package-json"));
|
|
176
176
|
|
|
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
177
|
// vite/ssr-externals.ts
|
|
183
178
|
var ssrExternals = isReactRouterRepo() ? [
|
|
184
179
|
// This is only needed within this repo because these packages
|
|
@@ -202,6 +197,11 @@ async function createContext({
|
|
|
202
197
|
}) {
|
|
203
198
|
await preloadVite();
|
|
204
199
|
const vite2 = getVite();
|
|
200
|
+
const [{ ViteNodeServer }, { ViteNodeRunner }, { installSourcemapsSupport }] = await Promise.all([
|
|
201
|
+
import("vite-node/server"),
|
|
202
|
+
import("vite-node/client"),
|
|
203
|
+
import("vite-node/source-map")
|
|
204
|
+
]);
|
|
205
205
|
const devServer = await vite2.createServer({
|
|
206
206
|
root,
|
|
207
207
|
mode,
|
|
@@ -231,11 +231,11 @@ async function createContext({
|
|
|
231
231
|
plugins: []
|
|
232
232
|
});
|
|
233
233
|
await devServer.pluginContainer.buildStart({});
|
|
234
|
-
const server = new
|
|
235
|
-
|
|
234
|
+
const server = new ViteNodeServer(devServer);
|
|
235
|
+
installSourcemapsSupport({
|
|
236
236
|
getSourceMap: (source) => server.getSourceMap(source)
|
|
237
237
|
});
|
|
238
|
-
const runner = new
|
|
238
|
+
const runner = new ViteNodeRunner({
|
|
239
239
|
root: devServer.config.root,
|
|
240
240
|
base: devServer.config.base,
|
|
241
241
|
fetchModule(id) {
|
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-47ed76689
|
|
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) {
|
|
@@ -915,7 +916,7 @@ function generateRoutes(ctx) {
|
|
|
915
916
|
lineages.set(route.id, lineage2);
|
|
916
917
|
const fullpath2 = fullpath(lineage2);
|
|
917
918
|
if (!fullpath2) continue;
|
|
918
|
-
const pages =
|
|
919
|
+
const pages = expand(fullpath2);
|
|
919
920
|
pages.forEach((page) => allPages.add(page));
|
|
920
921
|
lineage2.forEach(({ id }) => {
|
|
921
922
|
let routePages = routeToPages.get(id);
|
|
@@ -1123,9 +1124,13 @@ function getRouteAnnotations({
|
|
|
1123
1124
|
}
|
|
1124
1125
|
function relativeImportSource(from, to) {
|
|
1125
1126
|
let path6 = Path3.relative(Path3.dirname(from), to);
|
|
1127
|
+
let extension = Path3.extname(path6);
|
|
1126
1128
|
path6 = Path3.join(Path3.dirname(path6), Pathe.filename(path6));
|
|
1127
1129
|
if (!path6.startsWith("../")) path6 = "./" + path6;
|
|
1128
|
-
|
|
1130
|
+
if (!extension || /\.(js|ts)x?$/.test(extension)) {
|
|
1131
|
+
extension = ".js";
|
|
1132
|
+
}
|
|
1133
|
+
return path6 + extension;
|
|
1129
1134
|
}
|
|
1130
1135
|
function rootDirsPath(ctx, typesPath) {
|
|
1131
1136
|
const rel = Path3.relative(typesDirectory(ctx), typesPath);
|
|
@@ -1144,28 +1149,27 @@ function paramsType(path6) {
|
|
|
1144
1149
|
})
|
|
1145
1150
|
);
|
|
1146
1151
|
}
|
|
1147
|
-
function
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1152
|
+
function expand(fullpath2) {
|
|
1153
|
+
function recurse(segments2, index) {
|
|
1154
|
+
if (index === segments2.length) return [""];
|
|
1155
|
+
const segment = segments2[index];
|
|
1156
|
+
const isOptional = segment.endsWith("?");
|
|
1157
|
+
const isDynamic = segment.startsWith(":");
|
|
1158
|
+
const required = segment.replace(/\?$/, "");
|
|
1159
|
+
const keep = !isOptional || isDynamic;
|
|
1160
|
+
const kept = isDynamic ? segment : required;
|
|
1161
|
+
const withoutSegment = recurse(segments2, index + 1);
|
|
1162
|
+
const withSegment = withoutSegment.map((rest) => [kept, rest].join("/"));
|
|
1163
|
+
if (keep) return withSegment;
|
|
1164
|
+
return [...withoutSegment, ...withSegment];
|
|
1155
1165
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
result
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
)
|
|
1162
|
-
);
|
|
1163
|
-
if (isOptional) {
|
|
1164
|
-
result.push(...restExploded);
|
|
1166
|
+
const segments = fullpath2.split("/");
|
|
1167
|
+
const expanded = /* @__PURE__ */ new Set();
|
|
1168
|
+
for (let result of recurse(segments, 0)) {
|
|
1169
|
+
if (result !== "/") result = result.replace(/\/$/, "");
|
|
1170
|
+
expanded.add(result);
|
|
1165
1171
|
}
|
|
1166
|
-
return
|
|
1167
|
-
(exploded) => path6.startsWith("/") && exploded === "" ? "/" : exploded
|
|
1168
|
-
);
|
|
1172
|
+
return expanded;
|
|
1169
1173
|
}
|
|
1170
1174
|
|
|
1171
1175
|
// typegen/index.ts
|
|
@@ -2444,8 +2448,8 @@ function dedupe(array2) {
|
|
|
2444
2448
|
return [...new Set(array2)];
|
|
2445
2449
|
}
|
|
2446
2450
|
var writeFileSafe = async (file, contents) => {
|
|
2447
|
-
await
|
|
2448
|
-
await
|
|
2451
|
+
await (0, import_promises2.mkdir)(path5.dirname(file), { recursive: true });
|
|
2452
|
+
await (0, import_promises2.writeFile)(file, contents);
|
|
2449
2453
|
};
|
|
2450
2454
|
var getExportNames = (code) => {
|
|
2451
2455
|
let [, exportSpecifiers] = (0, import_es_module_lexer.parse)(code);
|
|
@@ -2479,7 +2483,7 @@ var compileRouteFile = async (viteChildCompiler, ctx, routeFile, readRouteFile)
|
|
|
2479
2483
|
};
|
|
2480
2484
|
let [id, code] = await Promise.all([
|
|
2481
2485
|
resolveId(),
|
|
2482
|
-
readRouteFile?.() ??
|
|
2486
|
+
readRouteFile?.() ?? (0, import_promises2.readFile)(routePath, "utf-8"),
|
|
2483
2487
|
// pluginContainer.transform(...) fails if we don't do this first:
|
|
2484
2488
|
moduleGraph.ensureEntryFromUrl(url2, ssr)
|
|
2485
2489
|
]);
|
|
@@ -2541,7 +2545,9 @@ var defaultEntriesDir = path5.resolve(
|
|
|
2541
2545
|
"config",
|
|
2542
2546
|
"defaults"
|
|
2543
2547
|
);
|
|
2544
|
-
var defaultEntries =
|
|
2548
|
+
var defaultEntries = (0, import_node_fs2.readdirSync)(defaultEntriesDir).map(
|
|
2549
|
+
(filename2) => path5.join(defaultEntriesDir, filename2)
|
|
2550
|
+
);
|
|
2545
2551
|
invariant(defaultEntries.length > 0, "No default entries found");
|
|
2546
2552
|
var reactRouterDevLoadContext = () => void 0;
|
|
2547
2553
|
var reactRouterVitePlugin = () => {
|
|
@@ -2678,7 +2684,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2678
2684
|
` : ""}`;
|
|
2679
2685
|
};
|
|
2680
2686
|
let loadViteManifest = async (directory) => {
|
|
2681
|
-
let manifestContents = await
|
|
2687
|
+
let manifestContents = await (0, import_promises2.readFile)(
|
|
2682
2688
|
path5.resolve(directory, ".vite", "manifest.json"),
|
|
2683
2689
|
"utf-8"
|
|
2684
2690
|
);
|
|
@@ -2700,7 +2706,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2700
2706
|
};
|
|
2701
2707
|
let generateSriManifest = async (ctx2) => {
|
|
2702
2708
|
let clientBuildDirectory = getClientBuildDirectory(ctx2.reactRouterConfig);
|
|
2703
|
-
let entries =
|
|
2709
|
+
let entries = (0, import_node_fs2.readdirSync)(clientBuildDirectory, {
|
|
2704
2710
|
withFileTypes: true,
|
|
2705
2711
|
recursive: true
|
|
2706
2712
|
});
|
|
@@ -2710,7 +2716,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2710
2716
|
const entryNormalizedPath = "parentPath" in entry && typeof entry.parentPath === "string" ? entry.parentPath : entry.path;
|
|
2711
2717
|
let contents;
|
|
2712
2718
|
try {
|
|
2713
|
-
contents = await
|
|
2719
|
+
contents = await (0, import_promises2.readFile)(
|
|
2714
2720
|
path5.join(entryNormalizedPath, entry.name),
|
|
2715
2721
|
"utf-8"
|
|
2716
2722
|
);
|
|
@@ -2966,6 +2972,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2966
2972
|
config: async (_viteUserConfig, _viteConfigEnv) => {
|
|
2967
2973
|
await preloadVite();
|
|
2968
2974
|
let vite2 = getVite();
|
|
2975
|
+
let viteMajorVersion = parseInt(vite2.version.split(".")[0], 10);
|
|
2969
2976
|
viteUserConfig = _viteUserConfig;
|
|
2970
2977
|
viteConfigEnv = _viteConfigEnv;
|
|
2971
2978
|
viteCommand = viteConfigEnv.command;
|
|
@@ -2995,7 +3002,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2995
3002
|
vite2.loadEnv(
|
|
2996
3003
|
viteConfigEnv.mode,
|
|
2997
3004
|
viteUserConfig.envDir ?? ctx.rootDirectory,
|
|
2998
|
-
// We override default prefix of "VITE_" with a blank string since
|
|
3005
|
+
// We override the default prefix of "VITE_" with a blank string since
|
|
2999
3006
|
// we're targeting the server, so we want to load all environment
|
|
3000
3007
|
// variables, not just those explicitly marked for the client
|
|
3001
3008
|
""
|
|
@@ -3024,7 +3031,13 @@ var reactRouterVitePlugin = () => {
|
|
|
3024
3031
|
...Object.values(ctx.reactRouterConfig.routes).map(
|
|
3025
3032
|
(route) => resolveRelativeRouteFilePath(route, ctx.reactRouterConfig)
|
|
3026
3033
|
)
|
|
3027
|
-
]
|
|
3034
|
+
].map(
|
|
3035
|
+
(entry) => (
|
|
3036
|
+
// In Vite 7, the `optimizeDeps.entries` option only accepts glob patterns.
|
|
3037
|
+
// In prior versions, absolute file paths were treated differently.
|
|
3038
|
+
viteMajorVersion >= 7 ? (0, import_tinyglobby.escapePath)(entry) : entry
|
|
3039
|
+
)
|
|
3040
|
+
) : [],
|
|
3028
3041
|
include: [
|
|
3029
3042
|
// Pre-bundle React dependencies to avoid React duplicates,
|
|
3030
3043
|
// even if React dependencies are not direct dependencies.
|
|
@@ -3059,7 +3072,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3059
3072
|
conditions: viteCommand === "build" ? viteClientConditions : ["development", ...viteClientConditions]
|
|
3060
3073
|
},
|
|
3061
3074
|
base: viteUserConfig.base,
|
|
3062
|
-
// When consumer provides an
|
|
3075
|
+
// When consumer provides an allowlist for files that can be read by
|
|
3063
3076
|
// the server, ensure that the default entry files are included.
|
|
3064
3077
|
// If we don't do this and a default entry file is used, the server
|
|
3065
3078
|
// will throw an error that the file is not allowed to be read.
|
|
@@ -3271,7 +3284,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3271
3284
|
if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi) {
|
|
3272
3285
|
viteDevServer.middlewares.use(async (req, res, next) => {
|
|
3273
3286
|
let [reqPathname, reqSearch] = (req.url ?? "").split("?");
|
|
3274
|
-
if (reqPathname
|
|
3287
|
+
if (reqPathname.endsWith("/@react-router/critical.css")) {
|
|
3275
3288
|
let pathname = new URLSearchParams(reqSearch).get("pathname");
|
|
3276
3289
|
if (!pathname) {
|
|
3277
3290
|
return next("No pathname provided");
|
|
@@ -3351,15 +3364,15 @@ var reactRouterVitePlugin = () => {
|
|
|
3351
3364
|
let src = path5.join(serverBuildDirectory, ssrAssetPath);
|
|
3352
3365
|
let dest = path5.join(clientBuildDirectory, ssrAssetPath);
|
|
3353
3366
|
if (!userSsrEmitAssets) {
|
|
3354
|
-
if (!
|
|
3355
|
-
await
|
|
3367
|
+
if (!(0, import_node_fs2.existsSync)(dest)) {
|
|
3368
|
+
await (0, import_promises2.rename)(src, dest);
|
|
3356
3369
|
movedAssetPaths.push(dest);
|
|
3357
3370
|
} else {
|
|
3358
|
-
await
|
|
3371
|
+
await (0, import_promises2.rm)(src, { force: true, recursive: true });
|
|
3359
3372
|
removedAssetPaths.push(dest);
|
|
3360
3373
|
}
|
|
3361
|
-
} else if (!
|
|
3362
|
-
await
|
|
3374
|
+
} else if (!(0, import_node_fs2.existsSync)(dest)) {
|
|
3375
|
+
await (0, import_promises2.cp)(src, dest, { recursive: true });
|
|
3363
3376
|
copiedAssetPaths.push(dest);
|
|
3364
3377
|
}
|
|
3365
3378
|
}
|
|
@@ -3370,7 +3383,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3370
3383
|
await Promise.all(
|
|
3371
3384
|
ssrCssPaths.map(async (cssPath) => {
|
|
3372
3385
|
let src = path5.join(serverBuildDirectory, cssPath);
|
|
3373
|
-
await
|
|
3386
|
+
await (0, import_promises2.rm)(src, { force: true, recursive: true });
|
|
3374
3387
|
removedAssetPaths.push(src);
|
|
3375
3388
|
})
|
|
3376
3389
|
);
|
|
@@ -3381,9 +3394,9 @@ var reactRouterVitePlugin = () => {
|
|
|
3381
3394
|
await Promise.all(
|
|
3382
3395
|
Array.from(cleanedAssetDirs).map(async (dir) => {
|
|
3383
3396
|
try {
|
|
3384
|
-
const files = await
|
|
3397
|
+
const files = await (0, import_promises2.readdir)(dir, { recursive: true });
|
|
3385
3398
|
if (files.length === 0) {
|
|
3386
|
-
await
|
|
3399
|
+
await (0, import_promises2.rm)(dir, { force: true, recursive: true });
|
|
3387
3400
|
}
|
|
3388
3401
|
} catch {
|
|
3389
3402
|
}
|
|
@@ -3447,7 +3460,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3447
3460
|
"due to ssr:false"
|
|
3448
3461
|
].join(" ")
|
|
3449
3462
|
);
|
|
3450
|
-
|
|
3463
|
+
(0, import_node_fs2.rmSync)(serverBuildDirectory, { force: true, recursive: true });
|
|
3451
3464
|
}
|
|
3452
3465
|
}
|
|
3453
3466
|
},
|
|
@@ -3465,7 +3478,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3465
3478
|
// primarily ensures code is never duplicated across a route module and
|
|
3466
3479
|
// its chunks. If we didn't have this plugin, any app that explicitly
|
|
3467
3480
|
// imports a route module would result in duplicate code since the app
|
|
3468
|
-
// would contain code for both the unprocessed route module
|
|
3481
|
+
// would contain code for both the unprocessed route module and its
|
|
3469
3482
|
// individual chunks. This is because, since they have different module
|
|
3470
3483
|
// IDs, they are treated as completely separate modules even though they
|
|
3471
3484
|
// all reference the same underlying file. This plugin addresses this by
|
|
@@ -3771,11 +3784,8 @@ var reactRouterVitePlugin = () => {
|
|
|
3771
3784
|
);
|
|
3772
3785
|
return [
|
|
3773
3786
|
"const exports = {}",
|
|
3774
|
-
await
|
|
3775
|
-
await
|
|
3776
|
-
require.resolve("./static/refresh-utils.cjs"),
|
|
3777
|
-
"utf8"
|
|
3778
|
-
),
|
|
3787
|
+
await (0, import_promises2.readFile)(reactRefreshRuntimePath, "utf8"),
|
|
3788
|
+
await (0, import_promises2.readFile)(require.resolve("./static/refresh-utils.cjs"), "utf8"),
|
|
3779
3789
|
"export default exports"
|
|
3780
3790
|
].join("\n");
|
|
3781
3791
|
}
|
|
@@ -3858,10 +3868,10 @@ var reactRouterVitePlugin = () => {
|
|
|
3858
3868
|
{
|
|
3859
3869
|
name: "react-router-server-change-trigger-client-hmr",
|
|
3860
3870
|
// 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
|
|
3871
|
+
// Previously, the server and client modules were shared in a single module
|
|
3862
3872
|
// 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
|
|
3873
|
+
// client HMR updates. In Vite v6+, these module graphs are separate from
|
|
3874
|
+
// each other, so we need to manually trigger client HMR updates if server
|
|
3865
3875
|
// code has changed.
|
|
3866
3876
|
hotUpdate({ server, modules }) {
|
|
3867
3877
|
if (this.environment.name !== "ssr" && modules.length <= 0) {
|
|
@@ -4055,7 +4065,7 @@ async function handleSpaMode(viteConfig, reactRouterConfig, serverBuildDirectory
|
|
|
4055
4065
|
"SPA Mode: Did you forget to include `<Scripts/>` in your root route? Your pre-rendered HTML cannot hydrate without `<Scripts />`."
|
|
4056
4066
|
);
|
|
4057
4067
|
}
|
|
4058
|
-
await
|
|
4068
|
+
await (0, import_promises2.writeFile)(path5.join(clientBuildDirectory, filename2), html);
|
|
4059
4069
|
let prettyDir = path5.relative(process.cwd(), clientBuildDirectory);
|
|
4060
4070
|
let prettyPath = path5.join(prettyDir, filename2);
|
|
4061
4071
|
if (build.prerender.length > 0) {
|
|
@@ -4186,8 +4196,8 @@ ${normalizedPath}`
|
|
|
4186
4196
|
}
|
|
4187
4197
|
let outdir = path5.relative(process.cwd(), clientBuildDirectory);
|
|
4188
4198
|
let outfile = path5.join(outdir, ...normalizedPath.split("/"));
|
|
4189
|
-
await
|
|
4190
|
-
await
|
|
4199
|
+
await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
|
|
4200
|
+
await (0, import_promises2.writeFile)(outfile, data);
|
|
4191
4201
|
viteConfig.logger.info(
|
|
4192
4202
|
`Prerender (data): ${prerenderPath} -> ${import_picocolors3.default.bold(outfile)}`
|
|
4193
4203
|
);
|
|
@@ -4225,8 +4235,8 @@ ${html}`
|
|
|
4225
4235
|
}
|
|
4226
4236
|
let outdir = path5.relative(process.cwd(), clientBuildDirectory);
|
|
4227
4237
|
let outfile = path5.join(outdir, ...normalizedPath.split("/"), "index.html");
|
|
4228
|
-
await
|
|
4229
|
-
await
|
|
4238
|
+
await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
|
|
4239
|
+
await (0, import_promises2.writeFile)(outfile, html);
|
|
4230
4240
|
viteConfig.logger.info(
|
|
4231
4241
|
`Prerender (html): ${prerenderPath} -> ${import_picocolors3.default.bold(outfile)}`
|
|
4232
4242
|
);
|
|
@@ -4244,8 +4254,8 @@ ${content.toString("utf8")}`
|
|
|
4244
4254
|
}
|
|
4245
4255
|
let outdir = path5.relative(process.cwd(), clientBuildDirectory);
|
|
4246
4256
|
let outfile = path5.join(outdir, ...normalizedPath.split("/"));
|
|
4247
|
-
await
|
|
4248
|
-
await
|
|
4257
|
+
await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
|
|
4258
|
+
await (0, import_promises2.writeFile)(outfile, content);
|
|
4249
4259
|
viteConfig.logger.info(
|
|
4250
4260
|
`Prerender (resource): ${prerenderPath} -> ${import_picocolors3.default.bold(outfile)}`
|
|
4251
4261
|
);
|
|
@@ -4498,7 +4508,7 @@ async function cleanBuildDirectory(viteConfig, ctx) {
|
|
|
4498
4508
|
return !relativePath.startsWith("..") && !path5.isAbsolute(relativePath);
|
|
4499
4509
|
};
|
|
4500
4510
|
if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
|
|
4501
|
-
await
|
|
4511
|
+
await (0, import_promises2.rm)(buildDirectory, { force: true, recursive: true });
|
|
4502
4512
|
}
|
|
4503
4513
|
}
|
|
4504
4514
|
async function cleanViteManifests(environmentsOptions, ctx) {
|
|
@@ -4511,15 +4521,15 @@ async function cleanViteManifests(environmentsOptions, ctx) {
|
|
|
4511
4521
|
);
|
|
4512
4522
|
await Promise.all(
|
|
4513
4523
|
viteManifestPaths.map(async (viteManifestPath) => {
|
|
4514
|
-
let manifestExists =
|
|
4524
|
+
let manifestExists = (0, import_node_fs2.existsSync)(viteManifestPath);
|
|
4515
4525
|
if (!manifestExists) return;
|
|
4516
4526
|
if (!ctx.viteManifestEnabled) {
|
|
4517
|
-
await
|
|
4527
|
+
await (0, import_promises2.rm)(viteManifestPath, { force: true, recursive: true });
|
|
4518
4528
|
}
|
|
4519
4529
|
let viteDir = path5.dirname(viteManifestPath);
|
|
4520
|
-
let viteDirFiles = await
|
|
4530
|
+
let viteDirFiles = await (0, import_promises2.readdir)(viteDir, { recursive: true });
|
|
4521
4531
|
if (viteDirFiles.length === 0) {
|
|
4522
|
-
await
|
|
4532
|
+
await (0, import_promises2.rm)(viteDir, { force: true, recursive: true });
|
|
4523
4533
|
}
|
|
4524
4534
|
})
|
|
4525
4535
|
);
|
|
@@ -4655,13 +4665,13 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
4655
4665
|
},
|
|
4656
4666
|
build: {
|
|
4657
4667
|
// We move SSR-only assets to client assets. Note that the
|
|
4658
|
-
// SSR build can also emit code-split JS files (e.g
|
|
4668
|
+
// SSR build can also emit code-split JS files (e.g., by
|
|
4659
4669
|
// dynamic import) under the same assets directory
|
|
4660
4670
|
// regardless of "ssrEmitAssets" option, so we also need to
|
|
4661
|
-
// keep these JS files
|
|
4671
|
+
// keep these JS files to be kept as-is.
|
|
4662
4672
|
ssrEmitAssets: true,
|
|
4663
4673
|
copyPublicDir: false,
|
|
4664
|
-
//
|
|
4674
|
+
// The client only uses assets in the public directory
|
|
4665
4675
|
rollupOptions: {
|
|
4666
4676
|
input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual.serverBuild.id,
|
|
4667
4677
|
output: {
|
|
@@ -4685,7 +4695,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
4685
4695
|
route.file
|
|
4686
4696
|
);
|
|
4687
4697
|
let isRootRoute = route.file === ctx.reactRouterConfig.routes.root.file;
|
|
4688
|
-
let code =
|
|
4698
|
+
let code = (0, import_node_fs2.readFileSync)(routeFilePath, "utf-8");
|
|
4689
4699
|
return [
|
|
4690
4700
|
`${routeFilePath}${BUILD_CLIENT_ROUTE_QUERY_STRING}`,
|
|
4691
4701
|
...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-47ed76689",
|
|
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-47ed76689"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@types/babel__core": "^7.20.5",
|
|
@@ -94,7 +94,6 @@
|
|
|
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",
|
|
@@ -110,15 +109,15 @@
|
|
|
110
109
|
"vite": "^6.1.0",
|
|
111
110
|
"wireit": "0.14.9",
|
|
112
111
|
"wrangler": "^4.2.0",
|
|
113
|
-
"react-router": "^0.0.0-experimental-
|
|
114
|
-
"@react-router/serve": "0.0.0-experimental-
|
|
112
|
+
"react-router": "^0.0.0-experimental-47ed76689",
|
|
113
|
+
"@react-router/serve": "0.0.0-experimental-47ed76689"
|
|
115
114
|
},
|
|
116
115
|
"peerDependencies": {
|
|
117
116
|
"typescript": "^5.1.0",
|
|
118
|
-
"vite": "^5.1.0 || ^6.0.0",
|
|
117
|
+
"vite": "^5.1.0 || ^6.0.0 || ^7.0.0",
|
|
119
118
|
"wrangler": "^3.28.2 || ^4.0.0",
|
|
120
|
-
"@react-router/serve": "^0.0.0-experimental-
|
|
121
|
-
"react-router": "^0.0.0-experimental-
|
|
119
|
+
"@react-router/serve": "^0.0.0-experimental-47ed76689",
|
|
120
|
+
"react-router": "^0.0.0-experimental-47ed76689"
|
|
122
121
|
},
|
|
123
122
|
"peerDependenciesMeta": {
|
|
124
123
|
"@react-router/serve": {
|