@react-router/dev 7.1.1-pre.0 → 7.1.2-pre.0
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 +18 -5
- package/dist/cli/index.js +93 -86
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +48 -7
- package/dist/vite.js +165 -154
- package/module-sync-enabled/false.cjs +1 -0
- package/module-sync-enabled/index.d.mts +2 -0
- package/module-sync-enabled/index.mjs +4 -0
- package/module-sync-enabled/true.mjs +2 -0
- package/package.json +14 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
# `@react-router/dev`
|
|
2
2
|
|
|
3
|
-
## 7.1.
|
|
3
|
+
## 7.1.2-pre.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- Fix
|
|
7
|
+
- Fix default external conditions in Vite v6. This fixes resolution issues with certain npm packages. ([#12644](https://github.com/remix-run/react-router/pull/12644))
|
|
8
|
+
- Fix mismatch in prerendering html/data files when path is missing a leading slash ([#12684](https://github.com/remix-run/react-router/pull/12684))
|
|
9
|
+
- Use `module-sync` server condition when enabled in the runtime. This fixes React context mismatches (e.g. `useHref() may be used only in the context of a <Router> component.`) during development on Node 22.10.0+ when using libraries that have a peer dependency on React Router. ([#12729](https://github.com/remix-run/react-router/pull/12729))
|
|
10
|
+
- Fix react-refresh source maps ([#12686](https://github.com/remix-run/react-router/pull/12686))
|
|
8
11
|
- Updated dependencies:
|
|
9
|
-
- `react-router@7.1.
|
|
10
|
-
- `@react-router/node@7.1.
|
|
11
|
-
- `@react-router/serve@7.1.
|
|
12
|
+
- `react-router@7.1.2-pre.0`
|
|
13
|
+
- `@react-router/node@7.1.2-pre.0`
|
|
14
|
+
- `@react-router/serve@7.1.2-pre.0`
|
|
15
|
+
|
|
16
|
+
## 7.1.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Fix for a crash when optional args are passed to the CLI ([`5b1ca202f`](https://github.com/remix-run/react-router/commit/5b1ca202f77ef342db0109c6b791d33188077cd0))
|
|
21
|
+
- Updated dependencies:
|
|
22
|
+
- `react-router@7.1.1`
|
|
23
|
+
- `@react-router/node@7.1.1`
|
|
24
|
+
- `@react-router/serve@7.1.1`
|
|
12
25
|
|
|
13
26
|
## 7.1.0
|
|
14
27
|
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @react-router/dev v7.1.
|
|
3
|
+
* @react-router/dev v7.1.2-pre.0
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -55,26 +55,55 @@ var init_invariant = __esm({
|
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
// config/is-react-router-repo.ts
|
|
59
|
+
function isReactRouterRepo() {
|
|
60
|
+
let serverRuntimePath = import_pathe.default.dirname(
|
|
61
|
+
require.resolve("@react-router/node/package.json")
|
|
62
|
+
);
|
|
63
|
+
let serverRuntimeParentDir = import_pathe.default.basename(
|
|
64
|
+
import_pathe.default.resolve(serverRuntimePath, "..")
|
|
65
|
+
);
|
|
66
|
+
return serverRuntimeParentDir === "packages";
|
|
61
67
|
}
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
var import_pathe;
|
|
69
|
+
var init_is_react_router_repo = __esm({
|
|
70
|
+
"config/is-react-router-repo.ts"() {
|
|
71
|
+
"use strict";
|
|
72
|
+
import_pathe = __toESM(require("pathe"));
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// vite/vite.ts
|
|
77
|
+
async function preloadVite() {
|
|
78
|
+
vite = await import(viteImportSpecifier);
|
|
79
|
+
}
|
|
80
|
+
function getVite() {
|
|
81
|
+
invariant(vite, "getVite() called before preloadVite()");
|
|
64
82
|
return vite;
|
|
65
83
|
}
|
|
66
|
-
var vite;
|
|
67
|
-
var
|
|
68
|
-
"vite/
|
|
84
|
+
var import_pathe2, vite, viteImportSpecifier;
|
|
85
|
+
var init_vite = __esm({
|
|
86
|
+
"vite/vite.ts"() {
|
|
69
87
|
"use strict";
|
|
88
|
+
import_pathe2 = __toESM(require("pathe"));
|
|
70
89
|
init_invariant();
|
|
90
|
+
init_is_react_router_repo();
|
|
91
|
+
viteImportSpecifier = isReactRouterRepo() ? (
|
|
92
|
+
// Support testing against different versions of Vite by ensuring that Vite
|
|
93
|
+
// is resolved from the current working directory when running within this
|
|
94
|
+
// repo. If we don't do this, Vite will always be imported relative to this
|
|
95
|
+
// file, which means that it will always resolve to Vite 6.
|
|
96
|
+
`file:///${import_pathe2.default.normalize(
|
|
97
|
+
require.resolve("vite/package.json", { paths: [process.cwd()] })
|
|
98
|
+
).replace("package.json", "dist/node/index.js")}`
|
|
99
|
+
) : "vite";
|
|
71
100
|
}
|
|
72
101
|
});
|
|
73
102
|
|
|
74
103
|
// vite/vite-node.ts
|
|
75
104
|
async function createContext(viteConfig = {}) {
|
|
76
|
-
await
|
|
77
|
-
const vite2 =
|
|
105
|
+
await preloadVite();
|
|
106
|
+
const vite2 = getVite();
|
|
78
107
|
const devServer = await vite2.createServer(
|
|
79
108
|
vite2.mergeConfig(
|
|
80
109
|
{
|
|
@@ -116,7 +145,7 @@ var init_vite_node = __esm({
|
|
|
116
145
|
import_server = require("vite-node/server");
|
|
117
146
|
import_client = require("vite-node/client");
|
|
118
147
|
import_source_map = require("vite-node/source-map");
|
|
119
|
-
|
|
148
|
+
init_vite();
|
|
120
149
|
}
|
|
121
150
|
});
|
|
122
151
|
|
|
@@ -149,7 +178,7 @@ function validateRouteConfig({
|
|
|
149
178
|
`Route config in "${routeConfigFile}" is invalid.`,
|
|
150
179
|
root ? `${root}` : [],
|
|
151
180
|
nested ? Object.entries(nested).map(
|
|
152
|
-
([
|
|
181
|
+
([path10, message]) => `Path: routes.${path10}
|
|
153
182
|
${message}`
|
|
154
183
|
) : []
|
|
155
184
|
].flat().join("\n\n")
|
|
@@ -307,13 +336,13 @@ async function resolveConfig({
|
|
|
307
336
|
"The `prerender` config must be a boolean, an array of string paths, or a function returning a boolean or array of string paths"
|
|
308
337
|
);
|
|
309
338
|
}
|
|
310
|
-
let appDirectory =
|
|
311
|
-
let buildDirectory =
|
|
339
|
+
let appDirectory = import_pathe3.default.resolve(root, userAppDirectory || "app");
|
|
340
|
+
let buildDirectory = import_pathe3.default.resolve(root, userBuildDirectory);
|
|
312
341
|
let rootRouteFile = findEntry(appDirectory, "root");
|
|
313
342
|
if (!rootRouteFile) {
|
|
314
|
-
let rootRouteDisplayPath =
|
|
343
|
+
let rootRouteDisplayPath = import_pathe3.default.relative(
|
|
315
344
|
root,
|
|
316
|
-
|
|
345
|
+
import_pathe3.default.join(appDirectory, "root.tsx")
|
|
317
346
|
);
|
|
318
347
|
return err(
|
|
319
348
|
`Could not find a root route module in the app directory as "${rootRouteDisplayPath}"`
|
|
@@ -325,15 +354,15 @@ async function resolveConfig({
|
|
|
325
354
|
let routeConfigFile = findEntry(appDirectory, "routes");
|
|
326
355
|
try {
|
|
327
356
|
if (!routeConfigFile) {
|
|
328
|
-
let routeConfigDisplayPath =
|
|
357
|
+
let routeConfigDisplayPath = import_pathe3.default.relative(
|
|
329
358
|
root,
|
|
330
|
-
|
|
359
|
+
import_pathe3.default.join(appDirectory, "routes.ts")
|
|
331
360
|
);
|
|
332
361
|
return err(`Route config file not found at "${routeConfigDisplayPath}".`);
|
|
333
362
|
}
|
|
334
363
|
setAppDirectory(appDirectory);
|
|
335
364
|
let routeConfigExport = (await viteNodeContext.runner.executeFile(
|
|
336
|
-
|
|
365
|
+
import_pathe3.default.join(appDirectory, routeConfigFile)
|
|
337
366
|
)).default;
|
|
338
367
|
let routeConfig = await routeConfigExport;
|
|
339
368
|
let result = validateRouteConfig({
|
|
@@ -353,7 +382,7 @@ async function resolveConfig({
|
|
|
353
382
|
import_picocolors.default.red(`Route config in "${routeConfigFile}" is invalid.`),
|
|
354
383
|
"",
|
|
355
384
|
error.loc?.file && error.loc?.column && error.frame ? [
|
|
356
|
-
|
|
385
|
+
import_pathe3.default.relative(appDirectory, error.loc.file) + ":" + error.loc.line + ":" + error.loc.column,
|
|
357
386
|
error.frame.trim?.()
|
|
358
387
|
] : error.stack
|
|
359
388
|
].flat().join("\n")
|
|
@@ -425,8 +454,8 @@ async function createConfigLoader({
|
|
|
425
454
|
);
|
|
426
455
|
fsWatcher.on("all", async (...args) => {
|
|
427
456
|
let [event, rawFilepath] = args;
|
|
428
|
-
let filepath =
|
|
429
|
-
let appFileAddedOrRemoved = appDirectory && (event === "add" || event === "unlink") && filepath.startsWith(
|
|
457
|
+
let filepath = import_pathe3.default.normalize(rawFilepath);
|
|
458
|
+
let appFileAddedOrRemoved = appDirectory && (event === "add" || event === "unlink") && filepath.startsWith(import_pathe3.default.normalize(appDirectory));
|
|
430
459
|
let configCodeUpdated = Boolean(
|
|
431
460
|
viteNodeContext.devServer?.moduleGraph.getModuleById(filepath)
|
|
432
461
|
);
|
|
@@ -467,25 +496,16 @@ async function createConfigLoader({
|
|
|
467
496
|
}
|
|
468
497
|
};
|
|
469
498
|
}
|
|
470
|
-
function isInReactRouterMonorepo() {
|
|
471
|
-
let serverRuntimePath = import_pathe.default.dirname(
|
|
472
|
-
require.resolve("@react-router/node/package.json")
|
|
473
|
-
);
|
|
474
|
-
let serverRuntimeParentDir = import_pathe.default.basename(
|
|
475
|
-
import_pathe.default.resolve(serverRuntimePath, "..")
|
|
476
|
-
);
|
|
477
|
-
return serverRuntimeParentDir === "packages";
|
|
478
|
-
}
|
|
479
499
|
function findEntry(dir, basename2, options) {
|
|
480
500
|
for (let ext of entryExts) {
|
|
481
|
-
let file =
|
|
501
|
+
let file = import_pathe3.default.resolve(dir, basename2 + ext);
|
|
482
502
|
if (import_node_fs.default.existsSync(file)) {
|
|
483
|
-
return options?.absolute ?? false ? file :
|
|
503
|
+
return options?.absolute ?? false ? file : import_pathe3.default.relative(dir, file);
|
|
484
504
|
}
|
|
485
505
|
}
|
|
486
506
|
return void 0;
|
|
487
507
|
}
|
|
488
|
-
var import_node_fs, import_node_child_process, import_package_json,
|
|
508
|
+
var import_node_fs, import_node_child_process, import_package_json, import_pathe3, import_chokidar, import_picocolors, import_pick2, import_omit, import_cloneDeep, import_isEqual, excludedConfigPresetKeys, branchRouteProperties, configRouteToBranchRoute, mergeReactRouterConfig, deepFreeze, ssrExternals, entryExts;
|
|
489
509
|
var init_config = __esm({
|
|
490
510
|
"config/config.ts"() {
|
|
491
511
|
"use strict";
|
|
@@ -493,7 +513,7 @@ var init_config = __esm({
|
|
|
493
513
|
import_node_child_process = require("child_process");
|
|
494
514
|
import_package_json = __toESM(require("@npmcli/package-json"));
|
|
495
515
|
init_vite_node();
|
|
496
|
-
|
|
516
|
+
import_pathe3 = __toESM(require("pathe"));
|
|
497
517
|
import_chokidar = __toESM(require("chokidar"));
|
|
498
518
|
import_picocolors = __toESM(require("picocolors"));
|
|
499
519
|
import_pick2 = __toESM(require("lodash/pick"));
|
|
@@ -502,6 +522,7 @@ var init_config = __esm({
|
|
|
502
522
|
import_isEqual = __toESM(require("lodash/isEqual"));
|
|
503
523
|
init_routes();
|
|
504
524
|
init_detectPackageManager();
|
|
525
|
+
init_is_react_router_repo();
|
|
505
526
|
excludedConfigPresetKeys = ["presets"];
|
|
506
527
|
branchRouteProperties = [
|
|
507
528
|
"id",
|
|
@@ -548,7 +569,7 @@ var init_config = __esm({
|
|
|
548
569
|
});
|
|
549
570
|
return o;
|
|
550
571
|
};
|
|
551
|
-
ssrExternals =
|
|
572
|
+
ssrExternals = isReactRouterRepo() ? [
|
|
552
573
|
// This is only needed within this repo because these packages
|
|
553
574
|
// are linked to a directory outside of node_modules so Vite
|
|
554
575
|
// treats them as internal code by default.
|
|
@@ -695,7 +716,7 @@ var init_generate = __esm({
|
|
|
695
716
|
Path3 = __toESM(require("pathe"));
|
|
696
717
|
Pathe2 = __toESM(require("pathe/utils"));
|
|
697
718
|
init_paths();
|
|
698
|
-
noExtension = (
|
|
719
|
+
noExtension = (path10) => Path3.join(Path3.dirname(path10), Pathe2.filename(path10));
|
|
699
720
|
}
|
|
700
721
|
});
|
|
701
722
|
|
|
@@ -791,24 +812,24 @@ var init_node_adapter = __esm({
|
|
|
791
812
|
});
|
|
792
813
|
|
|
793
814
|
// vite/resolve-file-url.ts
|
|
794
|
-
var
|
|
815
|
+
var path4;
|
|
795
816
|
var init_resolve_file_url = __esm({
|
|
796
817
|
"vite/resolve-file-url.ts"() {
|
|
797
818
|
"use strict";
|
|
798
|
-
|
|
799
|
-
|
|
819
|
+
path4 = __toESM(require("path"));
|
|
820
|
+
init_vite();
|
|
800
821
|
}
|
|
801
822
|
});
|
|
802
823
|
|
|
803
824
|
// vite/styles.ts
|
|
804
|
-
var
|
|
825
|
+
var path5, import_react_router, cssFileRegExp, cssModulesRegExp;
|
|
805
826
|
var init_styles = __esm({
|
|
806
827
|
"vite/styles.ts"() {
|
|
807
828
|
"use strict";
|
|
808
|
-
|
|
829
|
+
path5 = __toESM(require("path"));
|
|
809
830
|
import_react_router = require("react-router");
|
|
810
831
|
init_resolve_file_url();
|
|
811
|
-
|
|
832
|
+
init_vite();
|
|
812
833
|
cssFileRegExp = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
|
813
834
|
cssModulesRegExp = new RegExp(`\\.module${cssFileRegExp.source}`);
|
|
814
835
|
}
|
|
@@ -864,7 +885,7 @@ async function resolveViteConfig({
|
|
|
864
885
|
mode,
|
|
865
886
|
root
|
|
866
887
|
}) {
|
|
867
|
-
let vite2 =
|
|
888
|
+
let vite2 = getVite();
|
|
868
889
|
let viteConfig = await vite2.resolveConfig(
|
|
869
890
|
{ mode, configFile, root },
|
|
870
891
|
"build",
|
|
@@ -914,17 +935,17 @@ async function loadPluginContext({
|
|
|
914
935
|
function findConfig(dir, basename2, extensions) {
|
|
915
936
|
for (let ext of extensions) {
|
|
916
937
|
let name = basename2 + ext;
|
|
917
|
-
let file =
|
|
938
|
+
let file = path6.join(dir, name);
|
|
918
939
|
if (fse.existsSync(file)) return file;
|
|
919
940
|
}
|
|
920
941
|
return void 0;
|
|
921
942
|
}
|
|
922
|
-
var import_node_crypto,
|
|
943
|
+
var import_node_crypto, path6, url, fse, babel, import_react_router2, import_es_module_lexer, import_jsesc, import_picocolors3, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
|
|
923
944
|
var init_plugin = __esm({
|
|
924
945
|
"vite/plugin.ts"() {
|
|
925
946
|
"use strict";
|
|
926
947
|
import_node_crypto = require("crypto");
|
|
927
|
-
|
|
948
|
+
path6 = __toESM(require("path"));
|
|
928
949
|
url = __toESM(require("url"));
|
|
929
950
|
fse = __toESM(require("fs-extra"));
|
|
930
951
|
babel = __toESM(require("@babel/core"));
|
|
@@ -941,7 +962,7 @@ var init_plugin = __esm({
|
|
|
941
962
|
init_resolve_file_url();
|
|
942
963
|
init_combine_urls();
|
|
943
964
|
init_remove_exports();
|
|
944
|
-
|
|
965
|
+
init_vite();
|
|
945
966
|
init_config();
|
|
946
967
|
init_with_props();
|
|
947
968
|
virtualHmrRuntime = create("hmr-runtime");
|
|
@@ -951,18 +972,18 @@ var init_plugin = __esm({
|
|
|
951
972
|
serverManifest: create("server-manifest"),
|
|
952
973
|
browserManifest: create("browser-manifest")
|
|
953
974
|
};
|
|
954
|
-
getServerBuildDirectory = (ctx) =>
|
|
975
|
+
getServerBuildDirectory = (ctx) => path6.join(
|
|
955
976
|
ctx.reactRouterConfig.buildDirectory,
|
|
956
977
|
"server",
|
|
957
978
|
...ctx.serverBundleBuildConfig ? [ctx.serverBundleBuildConfig.serverBundleId] : []
|
|
958
979
|
);
|
|
959
|
-
defaultEntriesDir =
|
|
960
|
-
|
|
980
|
+
defaultEntriesDir = path6.resolve(
|
|
981
|
+
path6.dirname(require.resolve("@react-router/dev/package.json")),
|
|
961
982
|
"dist",
|
|
962
983
|
"config",
|
|
963
984
|
"defaults"
|
|
964
985
|
);
|
|
965
|
-
defaultEntries = fse.readdirSync(defaultEntriesDir).map((filename3) =>
|
|
986
|
+
defaultEntries = fse.readdirSync(defaultEntriesDir).map((filename3) => path6.join(defaultEntriesDir, filename3));
|
|
966
987
|
invariant(defaultEntries.length > 0, "No default entries found");
|
|
967
988
|
REACT_REFRESH_HEADER = `
|
|
968
989
|
import RefreshRuntime from "${virtualHmrRuntime.id}";
|
|
@@ -984,21 +1005,7 @@ if (import.meta.hot && !inWebWorker) {
|
|
|
984
1005
|
RefreshRuntime.register(type, __SOURCE__ + " " + id)
|
|
985
1006
|
};
|
|
986
1007
|
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
987
|
-
}`.
|
|
988
|
-
REACT_REFRESH_FOOTER = `
|
|
989
|
-
if (import.meta.hot && !inWebWorker) {
|
|
990
|
-
window.$RefreshReg$ = prevRefreshReg;
|
|
991
|
-
window.$RefreshSig$ = prevRefreshSig;
|
|
992
|
-
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
|
993
|
-
RefreshRuntime.registerExportsForReactRefresh(__SOURCE__, currentExports);
|
|
994
|
-
import.meta.hot.accept((nextExports) => {
|
|
995
|
-
if (!nextExports) return;
|
|
996
|
-
__ROUTE_ID__ && window.__reactRouterRouteModuleUpdates.set(__ROUTE_ID__, nextExports);
|
|
997
|
-
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(currentExports, nextExports, __ACCEPT_EXPORTS__);
|
|
998
|
-
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
|
999
|
-
});
|
|
1000
|
-
});
|
|
1001
|
-
}`.trim();
|
|
1008
|
+
}`.replaceAll("\n", "");
|
|
1002
1009
|
}
|
|
1003
1010
|
});
|
|
1004
1011
|
|
|
@@ -1195,7 +1202,7 @@ async function build(root, {
|
|
|
1195
1202
|
sourcemapClient,
|
|
1196
1203
|
sourcemapServer
|
|
1197
1204
|
}) {
|
|
1198
|
-
await
|
|
1205
|
+
await preloadVite();
|
|
1199
1206
|
let viteConfig = await resolveViteConfig({ configFile, mode, root });
|
|
1200
1207
|
const ctx = await extractPluginContext(viteConfig);
|
|
1201
1208
|
if (!ctx) {
|
|
@@ -1205,7 +1212,7 @@ async function build(root, {
|
|
|
1205
1212
|
process.exit(1);
|
|
1206
1213
|
}
|
|
1207
1214
|
let { reactRouterConfig } = ctx;
|
|
1208
|
-
let vite2 =
|
|
1215
|
+
let vite2 = getVite();
|
|
1209
1216
|
async function viteBuild({
|
|
1210
1217
|
ssr,
|
|
1211
1218
|
serverBundleBuildConfig
|
|
@@ -1262,7 +1269,7 @@ var init_build = __esm({
|
|
|
1262
1269
|
init_plugin();
|
|
1263
1270
|
init_config();
|
|
1264
1271
|
init_invariant();
|
|
1265
|
-
|
|
1272
|
+
init_vite();
|
|
1266
1273
|
}
|
|
1267
1274
|
});
|
|
1268
1275
|
|
|
@@ -1283,8 +1290,8 @@ async function dev(root, {
|
|
|
1283
1290
|
port,
|
|
1284
1291
|
strictPort
|
|
1285
1292
|
}) {
|
|
1286
|
-
await
|
|
1287
|
-
let vite2 =
|
|
1293
|
+
await preloadVite();
|
|
1294
|
+
let vite2 = getVite();
|
|
1288
1295
|
let server = await vite2.createServer({
|
|
1289
1296
|
root,
|
|
1290
1297
|
mode,
|
|
@@ -1324,7 +1331,7 @@ var init_dev = __esm({
|
|
|
1324
1331
|
"vite/dev.ts"() {
|
|
1325
1332
|
"use strict";
|
|
1326
1333
|
import_picocolors6 = __toESM(require("picocolors"));
|
|
1327
|
-
|
|
1334
|
+
init_vite();
|
|
1328
1335
|
init_profiler();
|
|
1329
1336
|
}
|
|
1330
1337
|
});
|
|
@@ -1335,7 +1342,7 @@ var import_semver = __toESM(require("semver"));
|
|
|
1335
1342
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
1336
1343
|
|
|
1337
1344
|
// cli/commands.ts
|
|
1338
|
-
var
|
|
1345
|
+
var path9 = __toESM(require("path"));
|
|
1339
1346
|
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
1340
1347
|
var import_package_json2 = __toESM(require("@npmcli/package-json"));
|
|
1341
1348
|
var import_exit_hook = __toESM(require("exit-hook"));
|
|
@@ -1421,7 +1428,7 @@ function transpile(tsx, options = {}) {
|
|
|
1421
1428
|
// cli/commands.ts
|
|
1422
1429
|
init_profiler();
|
|
1423
1430
|
init_typegen();
|
|
1424
|
-
|
|
1431
|
+
init_vite();
|
|
1425
1432
|
async function routes(reactRouterRoot, flags = {}) {
|
|
1426
1433
|
let ctx = await loadPluginContext({
|
|
1427
1434
|
root: reactRouterRoot,
|
|
@@ -1493,14 +1500,14 @@ async function generateEntry(entry, reactRouterRoot, flags = {}) {
|
|
|
1493
1500
|
console.error(import_picocolors7.default.red(`No default server entry detected.`));
|
|
1494
1501
|
return;
|
|
1495
1502
|
}
|
|
1496
|
-
let defaultsDirectory =
|
|
1497
|
-
|
|
1503
|
+
let defaultsDirectory = path9.resolve(
|
|
1504
|
+
path9.dirname(require.resolve("@react-router/dev/package.json")),
|
|
1498
1505
|
"dist",
|
|
1499
1506
|
"config",
|
|
1500
1507
|
"defaults"
|
|
1501
1508
|
);
|
|
1502
|
-
let defaultEntryClient =
|
|
1503
|
-
let defaultEntryServer =
|
|
1509
|
+
let defaultEntryClient = path9.resolve(defaultsDirectory, "entry.client.tsx");
|
|
1510
|
+
let defaultEntryServer = path9.resolve(
|
|
1504
1511
|
defaultsDirectory,
|
|
1505
1512
|
`entry.server.node.tsx`
|
|
1506
1513
|
);
|
|
@@ -1509,7 +1516,7 @@ async function generateEntry(entry, reactRouterRoot, flags = {}) {
|
|
|
1509
1516
|
let useTypeScript = flags.typescript ?? true;
|
|
1510
1517
|
let outputExtension = useTypeScript ? "tsx" : "jsx";
|
|
1511
1518
|
let outputEntry = `${entry}.${outputExtension}`;
|
|
1512
|
-
let outputFile2 =
|
|
1519
|
+
let outputFile2 = path9.resolve(appDirectory, outputEntry);
|
|
1513
1520
|
if (!useTypeScript) {
|
|
1514
1521
|
let javascript = transpile(contents, {
|
|
1515
1522
|
cwd: rootDirectory,
|
|
@@ -1521,7 +1528,7 @@ async function generateEntry(entry, reactRouterRoot, flags = {}) {
|
|
|
1521
1528
|
}
|
|
1522
1529
|
console.log(
|
|
1523
1530
|
import_picocolors7.default.blue(
|
|
1524
|
-
`Entry file ${entry} created at ${
|
|
1531
|
+
`Entry file ${entry} created at ${path9.relative(
|
|
1525
1532
|
rootDirectory,
|
|
1526
1533
|
outputFile2
|
|
1527
1534
|
)}.`
|
|
@@ -1530,10 +1537,10 @@ async function generateEntry(entry, reactRouterRoot, flags = {}) {
|
|
|
1530
1537
|
}
|
|
1531
1538
|
async function checkForEntry(rootDirectory, appDirectory, entries2) {
|
|
1532
1539
|
for (let entry of entries2) {
|
|
1533
|
-
let entryPath =
|
|
1540
|
+
let entryPath = path9.resolve(appDirectory, entry);
|
|
1534
1541
|
let exists = await import_fs_extra2.default.pathExists(entryPath);
|
|
1535
1542
|
if (exists) {
|
|
1536
|
-
let relative8 =
|
|
1543
|
+
let relative8 = path9.relative(rootDirectory, entryPath);
|
|
1537
1544
|
console.error(import_picocolors7.default.red(`Entry file ${relative8} already exists.`));
|
|
1538
1545
|
return process.exit(1);
|
|
1539
1546
|
}
|
|
@@ -1552,8 +1559,8 @@ async function createClientEntry(rootDirectory, appDirectory, inputFile) {
|
|
|
1552
1559
|
async function typegen(root, flags) {
|
|
1553
1560
|
root ??= process.cwd();
|
|
1554
1561
|
if (flags.watch) {
|
|
1555
|
-
await
|
|
1556
|
-
const vite2 =
|
|
1562
|
+
await preloadVite();
|
|
1563
|
+
const vite2 = getVite();
|
|
1557
1564
|
const logger = vite2.createLogger("info", { prefix: "[react-router]" });
|
|
1558
1565
|
await watch(root, { logger });
|
|
1559
1566
|
await new Promise(() => {
|
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 v7.1.
|
|
2
|
+
* @react-router/dev v7.1.2-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -122,6 +122,40 @@ async function toNodeRequest(res, nodeRes) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
// vite/vite.ts
|
|
126
|
+
var import_pathe2 = __toESM(require("pathe"));
|
|
127
|
+
|
|
128
|
+
// config/is-react-router-repo.ts
|
|
129
|
+
var import_pathe = __toESM(require("pathe"));
|
|
130
|
+
function isReactRouterRepo() {
|
|
131
|
+
let serverRuntimePath = import_pathe.default.dirname(
|
|
132
|
+
require.resolve("@react-router/node/package.json")
|
|
133
|
+
);
|
|
134
|
+
let serverRuntimeParentDir = import_pathe.default.basename(
|
|
135
|
+
import_pathe.default.resolve(serverRuntimePath, "..")
|
|
136
|
+
);
|
|
137
|
+
return serverRuntimeParentDir === "packages";
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// vite/vite.ts
|
|
141
|
+
var vite;
|
|
142
|
+
var viteImportSpecifier = isReactRouterRepo() ? (
|
|
143
|
+
// Support testing against different versions of Vite by ensuring that Vite
|
|
144
|
+
// is resolved from the current working directory when running within this
|
|
145
|
+
// repo. If we don't do this, Vite will always be imported relative to this
|
|
146
|
+
// file, which means that it will always resolve to Vite 6.
|
|
147
|
+
`file:///${import_pathe2.default.normalize(
|
|
148
|
+
require.resolve("vite/package.json", { paths: [process.cwd()] })
|
|
149
|
+
).replace("package.json", "dist/node/index.js")}`
|
|
150
|
+
) : "vite";
|
|
151
|
+
async function preloadVite() {
|
|
152
|
+
vite = await import(viteImportSpecifier);
|
|
153
|
+
}
|
|
154
|
+
function getVite() {
|
|
155
|
+
invariant(vite, "getVite() called before preloadVite()");
|
|
156
|
+
return vite;
|
|
157
|
+
}
|
|
158
|
+
|
|
125
159
|
// vite/cloudflare-dev-proxy.ts
|
|
126
160
|
var serverBuildId = "virtual:react-router/server-build";
|
|
127
161
|
function importWrangler() {
|
|
@@ -136,13 +170,20 @@ var cloudflareDevProxyVitePlugin = (options = {}) => {
|
|
|
136
170
|
let { getLoadContext, ...restOptions } = options;
|
|
137
171
|
return {
|
|
138
172
|
name: PLUGIN_NAME,
|
|
139
|
-
config: () =>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
173
|
+
config: async () => {
|
|
174
|
+
await preloadVite();
|
|
175
|
+
const vite2 = getVite();
|
|
176
|
+
const serverConditions = [
|
|
177
|
+
...vite2.defaultServerConditions ?? []
|
|
178
|
+
];
|
|
179
|
+
return {
|
|
180
|
+
ssr: {
|
|
181
|
+
resolve: {
|
|
182
|
+
externalConditions: ["workerd", "worker", ...serverConditions]
|
|
183
|
+
}
|
|
143
184
|
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
185
|
+
};
|
|
186
|
+
},
|
|
146
187
|
configResolved: (viteConfig) => {
|
|
147
188
|
let pluginIndex = (name) => viteConfig.plugins.findIndex((plugin) => plugin.name === name);
|
|
148
189
|
let reactRouterPluginIndex = pluginIndex("react-router");
|