@react-router/dev 0.0.0-experimental-d312c78a4 → 0.0.0-experimental-df6bc686c
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/dist/cli/index.js +87 -119
- package/dist/config/defaults/entry.server.node.tsx +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +1 -1
- package/dist/vite.js +22 -15
- 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/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-df6bc686c
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -391,7 +391,7 @@ async function resolveConfig({
|
|
|
391
391
|
}
|
|
392
392
|
let future = {
|
|
393
393
|
unstable_optimizeDeps: reactRouterUserConfig.future?.unstable_optimizeDeps ?? false,
|
|
394
|
-
|
|
394
|
+
unstable_splitRouteModules: userFuture?.unstable_splitRouteModules ?? false
|
|
395
395
|
};
|
|
396
396
|
let reactRouterConfig = deepFreeze({
|
|
397
397
|
appDirectory,
|
|
@@ -498,6 +498,15 @@ async function createConfigLoader({
|
|
|
498
498
|
}
|
|
499
499
|
};
|
|
500
500
|
}
|
|
501
|
+
async function loadConfig({ rootDirectory }) {
|
|
502
|
+
let configLoader = await createConfigLoader({
|
|
503
|
+
rootDirectory,
|
|
504
|
+
watch: false
|
|
505
|
+
});
|
|
506
|
+
let config = await configLoader.getConfig();
|
|
507
|
+
await configLoader.close();
|
|
508
|
+
return config;
|
|
509
|
+
}
|
|
501
510
|
function findEntry(dir, basename2, options) {
|
|
502
511
|
for (let ext of entryExts) {
|
|
503
512
|
let file = import_pathe3.default.resolve(dir, basename2 + ext);
|
|
@@ -588,6 +597,45 @@ var init_config = __esm({
|
|
|
588
597
|
}
|
|
589
598
|
});
|
|
590
599
|
|
|
600
|
+
// vite/profiler.ts
|
|
601
|
+
var import_node_fs2, import_node_path, import_picocolors2, getSession, start, profileCount, stop;
|
|
602
|
+
var init_profiler = __esm({
|
|
603
|
+
"vite/profiler.ts"() {
|
|
604
|
+
"use strict";
|
|
605
|
+
import_node_fs2 = __toESM(require("fs"));
|
|
606
|
+
import_node_path = __toESM(require("path"));
|
|
607
|
+
import_picocolors2 = __toESM(require("picocolors"));
|
|
608
|
+
getSession = () => global.__reactRouter_profile_session;
|
|
609
|
+
start = async (callback) => {
|
|
610
|
+
let inspector = await import("inspector").then((r) => r.default);
|
|
611
|
+
let session = global.__reactRouter_profile_session = new inspector.Session();
|
|
612
|
+
session.connect();
|
|
613
|
+
session.post("Profiler.enable", () => {
|
|
614
|
+
session.post("Profiler.start", callback);
|
|
615
|
+
});
|
|
616
|
+
};
|
|
617
|
+
profileCount = 0;
|
|
618
|
+
stop = (log) => {
|
|
619
|
+
let session = getSession();
|
|
620
|
+
if (!session) return;
|
|
621
|
+
return new Promise((res, rej) => {
|
|
622
|
+
session.post("Profiler.stop", (err2, { profile }) => {
|
|
623
|
+
if (err2) return rej(err2);
|
|
624
|
+
let outPath = import_node_path.default.resolve(`./react-router-${profileCount++}.cpuprofile`);
|
|
625
|
+
import_node_fs2.default.writeFileSync(outPath, JSON.stringify(profile));
|
|
626
|
+
log(
|
|
627
|
+
import_picocolors2.default.yellow(
|
|
628
|
+
`CPU profile written to ${import_picocolors2.default.white(import_picocolors2.default.dim(outPath))}`
|
|
629
|
+
)
|
|
630
|
+
);
|
|
631
|
+
global.__reactRouter_profile_session = void 0;
|
|
632
|
+
res();
|
|
633
|
+
});
|
|
634
|
+
});
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
|
|
591
639
|
// typegen/paths.ts
|
|
592
640
|
function getTypesDir(ctx) {
|
|
593
641
|
return Path2.join(ctx.rootDirectory, ".react-router/types");
|
|
@@ -730,16 +778,16 @@ async function run(rootDirectory) {
|
|
|
730
778
|
async function watch(rootDirectory, { logger } = {}) {
|
|
731
779
|
const ctx = await createContext2({ rootDirectory, watch: true });
|
|
732
780
|
await writeAll(ctx);
|
|
733
|
-
logger?.info(
|
|
781
|
+
logger?.info(import_picocolors3.default.green("generated types"), { timestamp: true, clear: true });
|
|
734
782
|
ctx.configLoader.onChange(async ({ result, routeConfigChanged }) => {
|
|
735
783
|
if (!result.ok) {
|
|
736
|
-
logger?.error(
|
|
784
|
+
logger?.error(import_picocolors3.default.red(result.error), { timestamp: true, clear: true });
|
|
737
785
|
return;
|
|
738
786
|
}
|
|
739
787
|
ctx.config = result.value;
|
|
740
788
|
if (routeConfigChanged) {
|
|
741
789
|
await writeAll(ctx);
|
|
742
|
-
logger?.info(
|
|
790
|
+
logger?.info(import_picocolors3.default.green("regenerated types"), {
|
|
743
791
|
timestamp: true,
|
|
744
792
|
clear: true
|
|
745
793
|
});
|
|
@@ -767,21 +815,21 @@ async function createContext2({
|
|
|
767
815
|
}
|
|
768
816
|
async function writeAll(ctx) {
|
|
769
817
|
const typegenDir = getTypesDir(ctx);
|
|
770
|
-
|
|
818
|
+
import_node_fs3.default.rmSync(typegenDir, { recursive: true, force: true });
|
|
771
819
|
Object.values(ctx.config.routes).forEach((route) => {
|
|
772
820
|
const typesPath = getTypesPath(ctx, route);
|
|
773
821
|
const content = generate(ctx, route);
|
|
774
|
-
|
|
775
|
-
|
|
822
|
+
import_node_fs3.default.mkdirSync(Path4.dirname(typesPath), { recursive: true });
|
|
823
|
+
import_node_fs3.default.writeFileSync(typesPath, content);
|
|
776
824
|
});
|
|
777
825
|
}
|
|
778
|
-
var
|
|
826
|
+
var import_node_fs3, Path4, import_picocolors3;
|
|
779
827
|
var init_typegen = __esm({
|
|
780
828
|
"typegen/index.ts"() {
|
|
781
829
|
"use strict";
|
|
782
|
-
|
|
830
|
+
import_node_fs3 = __toESM(require("fs"));
|
|
783
831
|
Path4 = __toESM(require("pathe"));
|
|
784
|
-
|
|
832
|
+
import_picocolors3 = __toESM(require("picocolors"));
|
|
785
833
|
init_config();
|
|
786
834
|
init_generate();
|
|
787
835
|
init_paths();
|
|
@@ -814,21 +862,21 @@ var init_node_adapter = __esm({
|
|
|
814
862
|
});
|
|
815
863
|
|
|
816
864
|
// vite/resolve-file-url.ts
|
|
817
|
-
var
|
|
865
|
+
var path5;
|
|
818
866
|
var init_resolve_file_url = __esm({
|
|
819
867
|
"vite/resolve-file-url.ts"() {
|
|
820
868
|
"use strict";
|
|
821
|
-
|
|
869
|
+
path5 = __toESM(require("path"));
|
|
822
870
|
init_vite();
|
|
823
871
|
}
|
|
824
872
|
});
|
|
825
873
|
|
|
826
874
|
// vite/styles.ts
|
|
827
|
-
var
|
|
875
|
+
var path6, import_react_router, cssFileRegExp, cssModulesRegExp;
|
|
828
876
|
var init_styles = __esm({
|
|
829
877
|
"vite/styles.ts"() {
|
|
830
878
|
"use strict";
|
|
831
|
-
|
|
879
|
+
path6 = __toESM(require("path"));
|
|
832
880
|
import_react_router = require("react-router");
|
|
833
881
|
init_resolve_file_url();
|
|
834
882
|
init_vite();
|
|
@@ -936,56 +984,19 @@ async function resolveViteConfig({
|
|
|
936
984
|
async function extractPluginContext(viteConfig) {
|
|
937
985
|
return viteConfig["__reactRouterPluginContext"];
|
|
938
986
|
}
|
|
939
|
-
|
|
940
|
-
configFile,
|
|
941
|
-
root
|
|
942
|
-
}) {
|
|
943
|
-
if (!root) {
|
|
944
|
-
root = process.env.REACT_ROUTER_ROOT || process.cwd();
|
|
945
|
-
}
|
|
946
|
-
configFile = configFile ?? findConfig(root, "vite.config", [
|
|
947
|
-
".ts",
|
|
948
|
-
".cts",
|
|
949
|
-
".mts",
|
|
950
|
-
".js",
|
|
951
|
-
".cjs",
|
|
952
|
-
".mjs"
|
|
953
|
-
]);
|
|
954
|
-
if (!configFile) {
|
|
955
|
-
console.error(import_picocolors3.default.red("Vite config file not found"));
|
|
956
|
-
process.exit(1);
|
|
957
|
-
}
|
|
958
|
-
let viteConfig = await resolveViteConfig({ configFile, root });
|
|
959
|
-
let ctx = await extractPluginContext(viteConfig);
|
|
960
|
-
if (!ctx) {
|
|
961
|
-
console.error(
|
|
962
|
-
import_picocolors3.default.red("React Router Vite plugin not found in Vite config")
|
|
963
|
-
);
|
|
964
|
-
process.exit(1);
|
|
965
|
-
}
|
|
966
|
-
return ctx;
|
|
967
|
-
}
|
|
968
|
-
function findConfig(dir, basename2, extensions) {
|
|
969
|
-
for (let ext of extensions) {
|
|
970
|
-
let name = basename2 + ext;
|
|
971
|
-
let file = path6.join(dir, name);
|
|
972
|
-
if (fse.existsSync(file)) return file;
|
|
973
|
-
}
|
|
974
|
-
return void 0;
|
|
975
|
-
}
|
|
976
|
-
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;
|
|
987
|
+
var import_node_crypto, path7, url, fse, babel2, import_react_router2, import_es_module_lexer, import_jsesc, import_picocolors4, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
|
|
977
988
|
var init_plugin = __esm({
|
|
978
989
|
"vite/plugin.ts"() {
|
|
979
990
|
"use strict";
|
|
980
991
|
import_node_crypto = require("crypto");
|
|
981
|
-
|
|
992
|
+
path7 = __toESM(require("path"));
|
|
982
993
|
url = __toESM(require("url"));
|
|
983
994
|
fse = __toESM(require("fs-extra"));
|
|
984
|
-
|
|
995
|
+
babel2 = __toESM(require("@babel/core"));
|
|
985
996
|
import_react_router2 = require("react-router");
|
|
986
997
|
import_es_module_lexer = require("es-module-lexer");
|
|
987
998
|
import_jsesc = __toESM(require("jsesc"));
|
|
988
|
-
|
|
999
|
+
import_picocolors4 = __toESM(require("picocolors"));
|
|
989
1000
|
init_typegen();
|
|
990
1001
|
init_invariant();
|
|
991
1002
|
init_babel();
|
|
@@ -1006,18 +1017,18 @@ var init_plugin = __esm({
|
|
|
1006
1017
|
serverManifest: create("server-manifest"),
|
|
1007
1018
|
browserManifest: create("browser-manifest")
|
|
1008
1019
|
};
|
|
1009
|
-
getServerBuildDirectory = (ctx) =>
|
|
1020
|
+
getServerBuildDirectory = (ctx) => path7.join(
|
|
1010
1021
|
ctx.reactRouterConfig.buildDirectory,
|
|
1011
1022
|
"server",
|
|
1012
1023
|
...ctx.serverBundleBuildConfig ? [ctx.serverBundleBuildConfig.serverBundleId] : []
|
|
1013
1024
|
);
|
|
1014
|
-
defaultEntriesDir =
|
|
1015
|
-
|
|
1025
|
+
defaultEntriesDir = path7.resolve(
|
|
1026
|
+
path7.dirname(require.resolve("@react-router/dev/package.json")),
|
|
1016
1027
|
"dist",
|
|
1017
1028
|
"config",
|
|
1018
1029
|
"defaults"
|
|
1019
1030
|
);
|
|
1020
|
-
defaultEntries = fse.readdirSync(defaultEntriesDir).map((filename3) =>
|
|
1031
|
+
defaultEntries = fse.readdirSync(defaultEntriesDir).map((filename3) => path7.join(defaultEntriesDir, filename3));
|
|
1021
1032
|
invariant(defaultEntries.length > 0, "No default entries found");
|
|
1022
1033
|
REACT_REFRESH_HEADER = `
|
|
1023
1034
|
import RefreshRuntime from "${virtualHmrRuntime.id}";
|
|
@@ -1043,45 +1054,6 @@ if (import.meta.hot && !inWebWorker) {
|
|
|
1043
1054
|
}
|
|
1044
1055
|
});
|
|
1045
1056
|
|
|
1046
|
-
// vite/profiler.ts
|
|
1047
|
-
var import_node_fs3, import_node_path, import_picocolors4, getSession, start, profileCount, stop;
|
|
1048
|
-
var init_profiler = __esm({
|
|
1049
|
-
"vite/profiler.ts"() {
|
|
1050
|
-
"use strict";
|
|
1051
|
-
import_node_fs3 = __toESM(require("fs"));
|
|
1052
|
-
import_node_path = __toESM(require("path"));
|
|
1053
|
-
import_picocolors4 = __toESM(require("picocolors"));
|
|
1054
|
-
getSession = () => global.__reactRouter_profile_session;
|
|
1055
|
-
start = async (callback) => {
|
|
1056
|
-
let inspector = await import("inspector").then((r) => r.default);
|
|
1057
|
-
let session = global.__reactRouter_profile_session = new inspector.Session();
|
|
1058
|
-
session.connect();
|
|
1059
|
-
session.post("Profiler.enable", () => {
|
|
1060
|
-
session.post("Profiler.start", callback);
|
|
1061
|
-
});
|
|
1062
|
-
};
|
|
1063
|
-
profileCount = 0;
|
|
1064
|
-
stop = (log) => {
|
|
1065
|
-
let session = getSession();
|
|
1066
|
-
if (!session) return;
|
|
1067
|
-
return new Promise((res, rej) => {
|
|
1068
|
-
session.post("Profiler.stop", (err2, { profile }) => {
|
|
1069
|
-
if (err2) return rej(err2);
|
|
1070
|
-
let outPath = import_node_path.default.resolve(`./react-router-${profileCount++}.cpuprofile`);
|
|
1071
|
-
import_node_fs3.default.writeFileSync(outPath, JSON.stringify(profile));
|
|
1072
|
-
log(
|
|
1073
|
-
import_picocolors4.default.yellow(
|
|
1074
|
-
`CPU profile written to ${import_picocolors4.default.white(import_picocolors4.default.dim(outPath))}`
|
|
1075
|
-
)
|
|
1076
|
-
);
|
|
1077
|
-
global.__reactRouter_profile_session = void 0;
|
|
1078
|
-
res();
|
|
1079
|
-
});
|
|
1080
|
-
});
|
|
1081
|
-
};
|
|
1082
|
-
}
|
|
1083
|
-
});
|
|
1084
|
-
|
|
1085
1057
|
// vite/build.ts
|
|
1086
1058
|
var build_exports = {};
|
|
1087
1059
|
__export(build_exports, {
|
|
@@ -1381,6 +1353,8 @@ var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
|
1381
1353
|
var import_package_json2 = __toESM(require("@npmcli/package-json"));
|
|
1382
1354
|
var import_exit_hook = __toESM(require("exit-hook"));
|
|
1383
1355
|
var import_picocolors7 = __toESM(require("picocolors"));
|
|
1356
|
+
var import_react_router3 = require("react-router");
|
|
1357
|
+
init_config();
|
|
1384
1358
|
|
|
1385
1359
|
// config/format.ts
|
|
1386
1360
|
function formatRoutes(routeManifest, format) {
|
|
@@ -1438,16 +1412,13 @@ function formatRoutesAsJsx(routeManifest) {
|
|
|
1438
1412
|
return output;
|
|
1439
1413
|
}
|
|
1440
1414
|
|
|
1441
|
-
// cli/commands.ts
|
|
1442
|
-
init_plugin();
|
|
1443
|
-
|
|
1444
1415
|
// cli/useJavascript.ts
|
|
1445
|
-
var
|
|
1416
|
+
var babel = __toESM(require("@babel/core"));
|
|
1446
1417
|
var import_plugin_syntax_jsx = __toESM(require("@babel/plugin-syntax-jsx"));
|
|
1447
1418
|
var import_preset_typescript = __toESM(require("@babel/preset-typescript"));
|
|
1448
1419
|
var import_prettier = __toESM(require("prettier"));
|
|
1449
1420
|
function transpile(tsx, options = {}) {
|
|
1450
|
-
let mjs =
|
|
1421
|
+
let mjs = babel.transformSync(tsx, {
|
|
1451
1422
|
compact: false,
|
|
1452
1423
|
cwd: options.cwd,
|
|
1453
1424
|
filename: options.filename,
|
|
@@ -1464,18 +1435,14 @@ init_profiler();
|
|
|
1464
1435
|
init_typegen();
|
|
1465
1436
|
init_vite();
|
|
1466
1437
|
async function routes(reactRouterRoot, flags = {}) {
|
|
1467
|
-
let
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
if (!ctx) {
|
|
1472
|
-
console.error(
|
|
1473
|
-
import_picocolors7.default.red("React Router Vite plugin not found in Vite config")
|
|
1474
|
-
);
|
|
1438
|
+
let rootDirectory = reactRouterRoot ?? process.cwd();
|
|
1439
|
+
let configResult = await loadConfig({ rootDirectory });
|
|
1440
|
+
if (!configResult.ok) {
|
|
1441
|
+
console.error(import_picocolors7.default.red(configResult.error));
|
|
1475
1442
|
process.exit(1);
|
|
1476
1443
|
}
|
|
1477
1444
|
let format = flags.json ? "json" : "jsx";
|
|
1478
|
-
console.log(formatRoutes(
|
|
1445
|
+
console.log(formatRoutes(configResult.value.routes, format));
|
|
1479
1446
|
}
|
|
1480
1447
|
async function build2(root, options = {}) {
|
|
1481
1448
|
if (!root) {
|
|
@@ -1509,17 +1476,18 @@ var conjunctionListFormat = new Intl.ListFormat("en", {
|
|
|
1509
1476
|
type: "conjunction"
|
|
1510
1477
|
});
|
|
1511
1478
|
async function generateEntry(entry, reactRouterRoot, flags = {}) {
|
|
1512
|
-
let ctx = await loadPluginContext({
|
|
1513
|
-
root: reactRouterRoot,
|
|
1514
|
-
configFile: flags.config
|
|
1515
|
-
});
|
|
1516
|
-
let rootDirectory = ctx.rootDirectory;
|
|
1517
|
-
let appDirectory = ctx.reactRouterConfig.appDirectory;
|
|
1518
1479
|
if (!entry) {
|
|
1519
1480
|
await generateEntry("entry.client", reactRouterRoot, flags);
|
|
1520
1481
|
await generateEntry("entry.server", reactRouterRoot, flags);
|
|
1521
1482
|
return;
|
|
1522
1483
|
}
|
|
1484
|
+
let rootDirectory = reactRouterRoot ?? process.cwd();
|
|
1485
|
+
let configResult = await loadConfig({ rootDirectory });
|
|
1486
|
+
if (!configResult.ok) {
|
|
1487
|
+
console.error(import_picocolors7.default.red(configResult.error));
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1490
|
+
let appDirectory = configResult.value.appDirectory;
|
|
1523
1491
|
if (!entries.includes(entry)) {
|
|
1524
1492
|
let entriesArray = Array.from(entries);
|
|
1525
1493
|
let list = conjunctionListFormat.format(entriesArray);
|
|
@@ -61,7 +61,7 @@ export default function handleRequest(
|
|
|
61
61
|
}
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
-
// Abort the rendering stream after the `streamTimeout` so it has
|
|
64
|
+
// Abort the rendering stream after the `streamTimeout` so it has time to
|
|
65
65
|
// flush down the rejected boundaries
|
|
66
66
|
setTimeout(abort, streamTimeout + 1000);
|
|
67
67
|
});
|
package/dist/config.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ interface FutureConfig {
|
|
|
41
41
|
/**
|
|
42
42
|
* Automatically split route modules into multiple chunks when possible.
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
unstable_splitRouteModules?: boolean | "enforce";
|
|
45
45
|
}
|
|
46
46
|
type BuildManifest = DefaultBuildManifest | ServerBundlesBuildManifest;
|
|
47
47
|
type BuildEndHook = (args: {
|
package/dist/config.js
CHANGED
package/dist/routes.js
CHANGED
package/dist/vite/cloudflare.js
CHANGED
package/dist/vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-df6bc686c
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -445,7 +445,7 @@ async function resolveConfig({
|
|
|
445
445
|
}
|
|
446
446
|
let future = {
|
|
447
447
|
unstable_optimizeDeps: reactRouterUserConfig.future?.unstable_optimizeDeps ?? false,
|
|
448
|
-
|
|
448
|
+
unstable_splitRouteModules: userFuture?.unstable_splitRouteModules ?? false
|
|
449
449
|
};
|
|
450
450
|
let reactRouterConfig = deepFreeze({
|
|
451
451
|
appDirectory,
|
|
@@ -2228,7 +2228,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2228
2228
|
viteChildCompiler,
|
|
2229
2229
|
ctx
|
|
2230
2230
|
);
|
|
2231
|
-
let
|
|
2231
|
+
let enforceSplitRouteModules = ctx.reactRouterConfig.future.unstable_splitRouteModules === "enforce";
|
|
2232
2232
|
for (let [key, route] of Object.entries(ctx.reactRouterConfig.routes)) {
|
|
2233
2233
|
let routeFile = path6.join(ctx.reactRouterConfig.appDirectory, route.file);
|
|
2234
2234
|
let sourceExports = routeManifestExports[key];
|
|
@@ -2242,7 +2242,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2242
2242
|
routeFile,
|
|
2243
2243
|
{ routeFile, viteChildCompiler }
|
|
2244
2244
|
);
|
|
2245
|
-
if (
|
|
2245
|
+
if (enforceSplitRouteModules) {
|
|
2246
2246
|
validateRouteChunks({
|
|
2247
2247
|
ctx,
|
|
2248
2248
|
id: route.file,
|
|
@@ -2328,7 +2328,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2328
2328
|
viteChildCompiler,
|
|
2329
2329
|
ctx
|
|
2330
2330
|
);
|
|
2331
|
-
let
|
|
2331
|
+
let enforceSplitRouteModules = ctx.reactRouterConfig.future.unstable_splitRouteModules === "enforce";
|
|
2332
2332
|
for (let [key, route] of Object.entries(ctx.reactRouterConfig.routes)) {
|
|
2333
2333
|
let routeFile = route.file;
|
|
2334
2334
|
let sourceExports = routeManifestExports[key];
|
|
@@ -2342,7 +2342,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2342
2342
|
resolveRelativeRouteFilePath(route, ctx.reactRouterConfig)
|
|
2343
2343
|
)}`
|
|
2344
2344
|
);
|
|
2345
|
-
if (
|
|
2345
|
+
if (enforceSplitRouteModules) {
|
|
2346
2346
|
let { hasRouteChunkByExportName } = await detectRouteChunksIfEnabled(
|
|
2347
2347
|
cache,
|
|
2348
2348
|
ctx,
|
|
@@ -2406,8 +2406,13 @@ var reactRouterVitePlugin = () => {
|
|
|
2406
2406
|
let viteClientConditions = [
|
|
2407
2407
|
...vite2.defaultClientConditions ?? []
|
|
2408
2408
|
];
|
|
2409
|
+
let packageRoot = path6.dirname(
|
|
2410
|
+
require.resolve("@react-router/dev/package.json")
|
|
2411
|
+
);
|
|
2412
|
+
let { moduleSyncEnabled } = await import(`file:///${path6.join(packageRoot, "module-sync-enabled/index.mjs")}`);
|
|
2409
2413
|
let viteServerConditions = [
|
|
2410
|
-
...vite2.defaultServerConditions ?? []
|
|
2414
|
+
...vite2.defaultServerConditions ?? [],
|
|
2415
|
+
...moduleSyncEnabled ? ["module-sync"] : []
|
|
2411
2416
|
];
|
|
2412
2417
|
logger = vite2.createLogger(viteUserConfig.logLevel, {
|
|
2413
2418
|
prefix: "[react-router]"
|
|
@@ -2535,7 +2540,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2535
2540
|
);
|
|
2536
2541
|
return [
|
|
2537
2542
|
`${routeFilePath}${BUILD_CLIENT_ROUTE_QUERY_STRING}`,
|
|
2538
|
-
|
|
2543
|
+
...ctx.reactRouterConfig.future.unstable_splitRouteModules && !isRootRoute ? routeChunkExportNames.map(
|
|
2539
2544
|
(exportName) => code.includes(exportName) ? getRouteChunkModuleId(
|
|
2540
2545
|
routeFilePath,
|
|
2541
2546
|
exportName
|
|
@@ -2902,8 +2907,8 @@ var reactRouterVitePlugin = () => {
|
|
|
2902
2907
|
if (chunk === null) {
|
|
2903
2908
|
return preventEmptyChunkSnippet({ reason: "Route chunks disabled" });
|
|
2904
2909
|
}
|
|
2905
|
-
let
|
|
2906
|
-
if (
|
|
2910
|
+
let enforceSplitRouteModules = ctx.reactRouterConfig.future.unstable_splitRouteModules === "enforce";
|
|
2911
|
+
if (enforceSplitRouteModules && chunkName === "main" && chunk) {
|
|
2907
2912
|
let exportNames = getExportNames(chunk.code);
|
|
2908
2913
|
validateRouteChunks({
|
|
2909
2914
|
ctx,
|
|
@@ -3025,6 +3030,9 @@ var reactRouterVitePlugin = () => {
|
|
|
3025
3030
|
{
|
|
3026
3031
|
name: "react-router:route-exports",
|
|
3027
3032
|
async transform(code, id, options) {
|
|
3033
|
+
if (isRouteChunkModuleId(id)) {
|
|
3034
|
+
id = id.split("?")[0];
|
|
3035
|
+
}
|
|
3028
3036
|
let route = getRoute(ctx.reactRouterConfig, id);
|
|
3029
3037
|
if (!route) return;
|
|
3030
3038
|
if (!options?.ssr && !ctx.reactRouterConfig.ssr) {
|
|
@@ -3596,7 +3604,7 @@ async function detectRouteChunksIfEnabled(cache, ctx, id, input) {
|
|
|
3596
3604
|
}
|
|
3597
3605
|
};
|
|
3598
3606
|
}
|
|
3599
|
-
if (!ctx.reactRouterConfig.future.
|
|
3607
|
+
if (!ctx.reactRouterConfig.future.unstable_splitRouteModules) {
|
|
3600
3608
|
return noRouteChunks();
|
|
3601
3609
|
}
|
|
3602
3610
|
if (normalizeRelativeFilePath(id, ctx.reactRouterConfig) === ctx.reactRouterConfig.routes.root.file) {
|
|
@@ -3610,7 +3618,7 @@ async function detectRouteChunksIfEnabled(cache, ctx, id, input) {
|
|
|
3610
3618
|
return detectRouteChunks(code, cache, cacheKey);
|
|
3611
3619
|
}
|
|
3612
3620
|
async function getRouteChunkIfEnabled(cache, ctx, id, chunkName, input) {
|
|
3613
|
-
if (!ctx.reactRouterConfig.future.
|
|
3621
|
+
if (!ctx.reactRouterConfig.future.unstable_splitRouteModules) {
|
|
3614
3622
|
return null;
|
|
3615
3623
|
}
|
|
3616
3624
|
let code = await resolveRouteFileCode(ctx, input);
|
|
@@ -3629,13 +3637,12 @@ function validateRouteChunks({
|
|
|
3629
3637
|
let plural = invalidChunks.length > 1;
|
|
3630
3638
|
throw new Error(
|
|
3631
3639
|
[
|
|
3632
|
-
`
|
|
3640
|
+
`Error splitting route module: ${normalizeRelativeFilePath(
|
|
3633
3641
|
id,
|
|
3634
3642
|
ctx.reactRouterConfig
|
|
3635
3643
|
)}`,
|
|
3636
3644
|
invalidChunks.map((name) => `- ${name}`).join("\n"),
|
|
3637
|
-
`${plural ?
|
|
3638
|
-
`If you need to share code between ${plural ? `these` : `this`} and other exports, you should extract the shared code into a separate module.`
|
|
3645
|
+
`${plural ? "These exports" : "This export"} could not be split into ${plural ? "their own chunks" : "its own chunk"} because ${plural ? "they share" : "it shares"} code with other exports. You should extract any shared code into its own module and then import it within the route module.`
|
|
3639
3646
|
].join("\n\n")
|
|
3640
3647
|
);
|
|
3641
3648
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports.default = false;
|
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-df6bc686c",
|
|
4
4
|
"description": "Dev tools and CLI for React Router",
|
|
5
5
|
"homepage": "https://reactrouter.com",
|
|
6
6
|
"bugs": {
|
|
@@ -31,6 +31,12 @@
|
|
|
31
31
|
},
|
|
32
32
|
"./package.json": "./package.json"
|
|
33
33
|
},
|
|
34
|
+
"imports": {
|
|
35
|
+
"#module-sync-enabled": {
|
|
36
|
+
"module-sync": "./module-sync-enabled/true.mjs",
|
|
37
|
+
"default": "./module-sync-enabled/false.cjs"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
34
40
|
"bin": {
|
|
35
41
|
"react-router": "bin.js"
|
|
36
42
|
},
|
|
@@ -40,6 +46,7 @@
|
|
|
40
46
|
"files": [
|
|
41
47
|
"cli/**",
|
|
42
48
|
"config/**",
|
|
49
|
+
"module-sync-enabled/**",
|
|
43
50
|
"typegen/**",
|
|
44
51
|
"vite/**",
|
|
45
52
|
"*.ts",
|
|
@@ -81,7 +88,7 @@
|
|
|
81
88
|
"set-cookie-parser": "^2.6.0",
|
|
82
89
|
"valibot": "^0.41.0",
|
|
83
90
|
"vite-node": "3.0.0-beta.2",
|
|
84
|
-
"@react-router/node": "0.0.0-experimental-
|
|
91
|
+
"@react-router/node": "0.0.0-experimental-df6bc686c"
|
|
85
92
|
},
|
|
86
93
|
"devDependencies": {
|
|
87
94
|
"@types/babel__core": "^7.20.5",
|
|
@@ -110,15 +117,15 @@
|
|
|
110
117
|
"vite": "^6.0.0",
|
|
111
118
|
"wireit": "0.14.9",
|
|
112
119
|
"wrangler": "^3.28.2",
|
|
113
|
-
"@react-router/serve": "0.0.0-experimental-
|
|
114
|
-
"react-router": "^0.0.0-experimental-
|
|
120
|
+
"@react-router/serve": "0.0.0-experimental-df6bc686c",
|
|
121
|
+
"react-router": "^0.0.0-experimental-df6bc686c"
|
|
115
122
|
},
|
|
116
123
|
"peerDependencies": {
|
|
117
124
|
"typescript": "^5.1.0",
|
|
118
125
|
"vite": "^5.1.0 || ^6.0.0",
|
|
119
126
|
"wrangler": "^3.28.2",
|
|
120
|
-
"@react-router/serve": "^0.0.0-experimental-
|
|
121
|
-
"react-router": "^0.0.0-experimental-
|
|
127
|
+
"@react-router/serve": "^0.0.0-experimental-df6bc686c",
|
|
128
|
+
"react-router": "^0.0.0-experimental-df6bc686c"
|
|
122
129
|
},
|
|
123
130
|
"peerDependenciesMeta": {
|
|
124
131
|
"@react-router/serve": {
|
|
@@ -136,6 +143,7 @@
|
|
|
136
143
|
},
|
|
137
144
|
"files": [
|
|
138
145
|
"dist/",
|
|
146
|
+
"module-sync-enabled/",
|
|
139
147
|
"bin.js",
|
|
140
148
|
"CHANGELOG.md",
|
|
141
149
|
"LICENSE.md",
|