@react-router/dev 0.0.0-experimental-a383e1e6e → 0.0.0-experimental-b9cf540fe

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # `@react-router/dev`
2
2
 
3
+ ## 7.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies:
8
+ - `react-router@7.1.5`
9
+ - `@react-router/node@7.1.5`
10
+ - `@react-router/serve@7.1.5`
11
+
3
12
  ## 7.1.4
4
13
 
5
14
  ### Patch Changes
package/bin.js CHANGED
@@ -5,8 +5,8 @@ let arg = require("arg");
5
5
  // default `NODE_ENV` so React loads the proper version in it's CJS entry script.
6
6
  // We have to do this before importing `run.ts` since that is what imports
7
7
  // `react` (indirectly via `react-router`)
8
- let args = arg({}, { argv: process.argv.slice(2), stopAtPositional: true });
9
- if (args._[0] === "dev") {
8
+ let args = arg({}, { argv: process.argv.slice(2), permissive: true });
9
+ if (args._.length === 0 || args._[0] === "dev") {
10
10
  process.env.NODE_ENV = process.env.NODE_ENV ?? "development";
11
11
  } else {
12
12
  process.env.NODE_ENV = process.env.NODE_ENV ?? "production";
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-a383e1e6e
3
+ * @react-router/dev v0.0.0-experimental-b9cf540fe
4
4
  *
5
5
  * Copyright (c) Remix Software Inc.
6
6
  *
@@ -706,8 +706,6 @@ function generate(ctx, route) {
706
706
  export type HeadersArgs = T.HeadersArgs
707
707
  export type HeadersFunction = (args: HeadersArgs) => Headers | HeadersInit
708
708
 
709
- export type unstable_MiddlewareArgs = T.CreateServerMiddlewareArgs<Info>
710
- export type unstable_ClientMiddlewareArgs = T.CreateClientMiddlewareArgs<Info>
711
709
  export type LoaderArgs = T.CreateServerLoaderArgs<Info>
712
710
  export type ClientLoaderArgs = T.CreateClientLoaderArgs<Info>
713
711
  export type ActionArgs = T.CreateServerActionArgs<Info>
@@ -926,7 +924,28 @@ var init_cache = __esm({
926
924
  });
927
925
 
928
926
  // vite/route-chunks.ts
929
- var routeChunkExportNames, routeChunkNames, routeChunkQueryStringPrefix, routeChunkQueryStrings;
927
+ function getRouteChunkModuleId(filePath, chunkName) {
928
+ return `${filePath}${routeChunkQueryStrings[chunkName]}`;
929
+ }
930
+ function isRouteChunkModuleId(id) {
931
+ return Object.values(routeChunkQueryStrings).some(
932
+ (queryString) => id.endsWith(queryString)
933
+ );
934
+ }
935
+ function isRouteChunkName(name) {
936
+ return name === mainChunkName || routeChunkExportNames.includes(name);
937
+ }
938
+ function getRouteChunkNameFromModuleId(id) {
939
+ if (!isRouteChunkModuleId(id)) {
940
+ return null;
941
+ }
942
+ let chunkName = id.split(routeChunkQueryStringPrefix)[1].split("&")[0];
943
+ if (!isRouteChunkName(chunkName)) {
944
+ return null;
945
+ }
946
+ return chunkName;
947
+ }
948
+ var routeChunkExportNames, mainChunkName, routeChunkNames, routeChunkQueryStringPrefix, routeChunkQueryStrings;
930
949
  var init_route_chunks = __esm({
931
950
  "vite/route-chunks.ts"() {
932
951
  "use strict";
@@ -938,6 +957,7 @@ var init_route_chunks = __esm({
938
957
  "clientLoader",
939
958
  "HydrateFallback"
940
959
  ];
960
+ mainChunkName = "main";
941
961
  routeChunkNames = ["main", ...routeChunkExportNames];
942
962
  routeChunkQueryStringPrefix = "?route-chunk=";
943
963
  routeChunkQueryStrings = {
@@ -985,7 +1005,235 @@ async function resolveViteConfig({
985
1005
  async function extractPluginContext(viteConfig) {
986
1006
  return viteConfig["__reactRouterPluginContext"];
987
1007
  }
988
- var import_node_crypto, path7, url, fse, babel2, import_react_router2, import_es_module_lexer, import_jsesc, import_picocolors4, import_kebabCase, CLIENT_ONLY_NON_COMPONENT_EXPORTS, CLIENT_ROUTE_EXPORTS, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
1008
+ function getAddressableRoutes(routes2) {
1009
+ let nonAddressableIds = /* @__PURE__ */ new Set();
1010
+ for (let id in routes2) {
1011
+ let route = routes2[id];
1012
+ if (route.index) {
1013
+ invariant(
1014
+ route.parentId,
1015
+ `Expected index route "${route.id}" to have "parentId" set`
1016
+ );
1017
+ nonAddressableIds.add(route.parentId);
1018
+ }
1019
+ if (typeof route.path !== "string" && !route.index) {
1020
+ nonAddressableIds.add(id);
1021
+ }
1022
+ }
1023
+ return Object.values(routes2).filter(
1024
+ (route) => !nonAddressableIds.has(route.id)
1025
+ );
1026
+ }
1027
+ function getRouteBranch(routes2, routeId) {
1028
+ let branch = [];
1029
+ let currentRouteId = routeId;
1030
+ while (currentRouteId) {
1031
+ let route = routes2[currentRouteId];
1032
+ invariant(route, `Missing route for ${currentRouteId}`);
1033
+ branch.push(route);
1034
+ currentRouteId = route.parentId;
1035
+ }
1036
+ return branch.reverse();
1037
+ }
1038
+ function hasServerBundles(buildManifest) {
1039
+ return Object.keys(buildManifest.serverBundles ?? {}).length > 0;
1040
+ }
1041
+ function getRoutesByServerBundleId(buildManifest) {
1042
+ if (!buildManifest.routeIdToServerBundleId) {
1043
+ return {};
1044
+ }
1045
+ let routesByServerBundleId = {};
1046
+ for (let [routeId, serverBundleId] of Object.entries(
1047
+ buildManifest.routeIdToServerBundleId
1048
+ )) {
1049
+ routesByServerBundleId[serverBundleId] ??= {};
1050
+ let branch = getRouteBranch(buildManifest.routes, routeId);
1051
+ for (let route of branch) {
1052
+ routesByServerBundleId[serverBundleId][route.id] = route;
1053
+ }
1054
+ }
1055
+ return routesByServerBundleId;
1056
+ }
1057
+ async function getBuildManifest(ctx) {
1058
+ let { routes: routes2, serverBundles, appDirectory } = ctx.reactRouterConfig;
1059
+ if (!serverBundles) {
1060
+ return { routes: routes2 };
1061
+ }
1062
+ let { normalizePath } = await import("vite");
1063
+ let serverBuildDirectory = getServerBuildDirectory(ctx);
1064
+ let resolvedAppDirectory = path7.resolve(ctx.rootDirectory, appDirectory);
1065
+ let rootRelativeRoutes = Object.fromEntries(
1066
+ Object.entries(routes2).map(([id, route]) => {
1067
+ let filePath = path7.join(resolvedAppDirectory, route.file);
1068
+ let rootRelativeFilePath = normalizePath(
1069
+ path7.relative(ctx.rootDirectory, filePath)
1070
+ );
1071
+ return [id, { ...route, file: rootRelativeFilePath }];
1072
+ })
1073
+ );
1074
+ let buildManifest = {
1075
+ serverBundles: {},
1076
+ routeIdToServerBundleId: {},
1077
+ routes: rootRelativeRoutes
1078
+ };
1079
+ await Promise.all(
1080
+ getAddressableRoutes(routes2).map(async (route) => {
1081
+ let branch = getRouteBranch(routes2, route.id);
1082
+ let serverBundleId = await serverBundles({
1083
+ branch: branch.map(
1084
+ (route2) => configRouteToBranchRoute({
1085
+ ...route2,
1086
+ // Ensure absolute paths are passed to the serverBundles function
1087
+ file: path7.join(resolvedAppDirectory, route2.file)
1088
+ })
1089
+ )
1090
+ });
1091
+ if (typeof serverBundleId !== "string") {
1092
+ throw new Error(`The "serverBundles" function must return a string`);
1093
+ }
1094
+ if (!/^[a-zA-Z0-9-_]+$/.test(serverBundleId)) {
1095
+ throw new Error(
1096
+ `The "serverBundles" function must only return strings containing alphanumeric characters, hyphens and underscores.`
1097
+ );
1098
+ }
1099
+ buildManifest.routeIdToServerBundleId[route.id] = serverBundleId;
1100
+ buildManifest.serverBundles[serverBundleId] ??= {
1101
+ id: serverBundleId,
1102
+ file: normalizePath(
1103
+ path7.join(
1104
+ path7.relative(
1105
+ ctx.rootDirectory,
1106
+ path7.join(serverBuildDirectory, serverBundleId)
1107
+ ),
1108
+ ctx.reactRouterConfig.serverBuildFile
1109
+ )
1110
+ )
1111
+ };
1112
+ })
1113
+ );
1114
+ return buildManifest;
1115
+ }
1116
+ function mergeBuildOptions(base, overrides) {
1117
+ let vite2 = getVite();
1118
+ return vite2.mergeConfig({ build: base }, { build: overrides }).build;
1119
+ }
1120
+ async function getEnvironmentOptionsResolvers(ctx, buildManifest) {
1121
+ let { serverBuildFile, serverModuleFormat } = ctx.reactRouterConfig;
1122
+ function getBaseBuildOptions({
1123
+ viteUserConfig
1124
+ }) {
1125
+ return {
1126
+ cssMinify: viteUserConfig.build?.cssMinify ?? true,
1127
+ manifest: true,
1128
+ // The manifest is enabled for all builds to detect SSR-only assets
1129
+ rollupOptions: {
1130
+ preserveEntrySignatures: "exports-only",
1131
+ // Silence Rollup "use client" warnings
1132
+ // Adapted from https://github.com/vitejs/vite-plugin-react/pull/144
1133
+ onwarn(warning, defaultHandler) {
1134
+ if (warning.code === "MODULE_LEVEL_DIRECTIVE" && warning.message.includes("use client")) {
1135
+ return;
1136
+ }
1137
+ let userHandler = viteUserConfig.build?.rollupOptions?.onwarn;
1138
+ if (userHandler) {
1139
+ userHandler(warning, defaultHandler);
1140
+ } else {
1141
+ defaultHandler(warning);
1142
+ }
1143
+ }
1144
+ }
1145
+ };
1146
+ }
1147
+ function getBaseServerBuildOptions({
1148
+ viteUserConfig
1149
+ }) {
1150
+ return mergeBuildOptions(getBaseBuildOptions({ viteUserConfig }), {
1151
+ // We move SSR-only assets to client assets. Note that the
1152
+ // SSR build can also emit code-split JS files (e.g. by
1153
+ // dynamic import) under the same assets directory
1154
+ // regardless of "ssrEmitAssets" option, so we also need to
1155
+ // keep these JS files have to be kept as-is.
1156
+ ssrEmitAssets: true,
1157
+ copyPublicDir: false,
1158
+ // Assets in the public directory are only used by the client
1159
+ rollupOptions: {
1160
+ output: {
1161
+ entryFileNames: serverBuildFile,
1162
+ format: serverModuleFormat
1163
+ }
1164
+ }
1165
+ });
1166
+ }
1167
+ let environmentOptionsResolvers = {
1168
+ client: ({ viteUserConfig }) => ({
1169
+ build: mergeBuildOptions(getBaseBuildOptions({ viteUserConfig }), {
1170
+ rollupOptions: {
1171
+ input: [
1172
+ ctx.entryClientFilePath,
1173
+ ...Object.values(ctx.reactRouterConfig.routes).flatMap((route) => {
1174
+ let routeFilePath = path7.resolve(
1175
+ ctx.reactRouterConfig.appDirectory,
1176
+ route.file
1177
+ );
1178
+ let isRootRoute = route.file === ctx.reactRouterConfig.routes.root.file;
1179
+ let code = fse.readFileSync(routeFilePath, "utf-8");
1180
+ return [
1181
+ `${routeFilePath}${BUILD_CLIENT_ROUTE_QUERY_STRING}`,
1182
+ ...ctx.reactRouterConfig.future.unstable_splitRouteModules && !isRootRoute ? routeChunkExportNames.map(
1183
+ (exportName) => code.includes(exportName) ? getRouteChunkModuleId(routeFilePath, exportName) : null
1184
+ ) : []
1185
+ ].filter(isNonNullable);
1186
+ })
1187
+ ],
1188
+ output: {
1189
+ entryFileNames({ moduleIds }) {
1190
+ let routeChunkModuleId = moduleIds.find(isRouteChunkModuleId);
1191
+ let routeChunkName = routeChunkModuleId ? getRouteChunkNameFromModuleId(routeChunkModuleId) : null;
1192
+ let routeChunkSuffix = routeChunkName ? `-${(0, import_kebabCase.default)(routeChunkName)}` : "";
1193
+ return `assets/[name]${routeChunkSuffix}-[hash].js`;
1194
+ }
1195
+ }
1196
+ },
1197
+ outDir: getClientBuildDirectory(ctx.reactRouterConfig)
1198
+ })
1199
+ })
1200
+ };
1201
+ if (hasServerBundles(buildManifest)) {
1202
+ for (let [serverBundleId, routes2] of Object.entries(
1203
+ getRoutesByServerBundleId(buildManifest)
1204
+ )) {
1205
+ environmentOptionsResolvers[`ssr-bundle-${serverBundleId}`] = ({
1206
+ viteUserConfig
1207
+ }) => ({
1208
+ build: mergeBuildOptions(
1209
+ getBaseServerBuildOptions({ viteUserConfig }),
1210
+ {
1211
+ outDir: getServerBuildDirectory(ctx, { serverBundleId }),
1212
+ rollupOptions: {
1213
+ input: `${virtual.serverBuild.id}?route-ids=${Object.keys(
1214
+ routes2
1215
+ ).join(",")}`
1216
+ }
1217
+ }
1218
+ )
1219
+ });
1220
+ }
1221
+ } else {
1222
+ environmentOptionsResolvers.ssr = ({ viteUserConfig }) => ({
1223
+ build: mergeBuildOptions(getBaseServerBuildOptions({ viteUserConfig }), {
1224
+ outDir: getServerBuildDirectory(ctx),
1225
+ rollupOptions: {
1226
+ input: viteUserConfig.build?.rollupOptions?.input ?? virtual.serverBuild.id
1227
+ }
1228
+ })
1229
+ });
1230
+ }
1231
+ return environmentOptionsResolvers;
1232
+ }
1233
+ function isNonNullable(x) {
1234
+ return x != null;
1235
+ }
1236
+ var import_node_crypto, path7, url, fse, babel2, import_react_router2, import_es_module_lexer, import_pick3, import_jsesc, import_picocolors4, import_kebabCase, BUILD_CLIENT_ROUTE_QUERY_STRING, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
989
1237
  var init_plugin = __esm({
990
1238
  "vite/plugin.ts"() {
991
1239
  "use strict";
@@ -996,6 +1244,7 @@ var init_plugin = __esm({
996
1244
  babel2 = __toESM(require("@babel/core"));
997
1245
  import_react_router2 = require("react-router");
998
1246
  import_es_module_lexer = require("es-module-lexer");
1247
+ import_pick3 = __toESM(require("lodash/pick"));
999
1248
  import_jsesc = __toESM(require("jsesc"));
1000
1249
  import_picocolors4 = __toESM(require("picocolors"));
1001
1250
  import_kebabCase = __toESM(require("lodash/kebabCase"));
@@ -1012,22 +1261,7 @@ var init_plugin = __esm({
1012
1261
  init_vite();
1013
1262
  init_config();
1014
1263
  init_with_props();
1015
- CLIENT_ONLY_NON_COMPONENT_EXPORTS = [
1016
- "clientAction",
1017
- "clientLoader",
1018
- "unstable_clientMiddleware",
1019
- "handle",
1020
- "meta",
1021
- "links",
1022
- "shouldRevalidate"
1023
- ];
1024
- CLIENT_ROUTE_EXPORTS = [
1025
- ...CLIENT_ONLY_NON_COMPONENT_EXPORTS,
1026
- "default",
1027
- "ErrorBoundary",
1028
- "HydrateFallback",
1029
- "Layout"
1030
- ];
1264
+ BUILD_CLIENT_ROUTE_QUERY_STRING = "?__react-router-build-client-route";
1031
1265
  virtualHmrRuntime = create("hmr-runtime");
1032
1266
  virtualInjectHmrRuntime = create("inject-hmr-runtime");
1033
1267
  virtual = {
@@ -1035,11 +1269,12 @@ var init_plugin = __esm({
1035
1269
  serverManifest: create("server-manifest"),
1036
1270
  browserManifest: create("browser-manifest")
1037
1271
  };
1038
- getServerBuildDirectory = (ctx) => path7.join(
1272
+ getServerBuildDirectory = (ctx, { serverBundleId } = {}) => path7.join(
1039
1273
  ctx.reactRouterConfig.buildDirectory,
1040
1274
  "server",
1041
- ...ctx.serverBundleBuildConfig ? [ctx.serverBundleBuildConfig.serverBundleId] : []
1275
+ ...serverBundleId ? [serverBundleId] : []
1042
1276
  );
1277
+ getClientBuildDirectory = (reactRouterConfig) => path7.join(reactRouterConfig.buildDirectory, "client");
1043
1278
  defaultEntriesDir = path7.resolve(
1044
1279
  path7.dirname(require.resolve("@react-router/dev/package.json")),
1045
1280
  "dist",
@@ -1077,121 +1312,6 @@ var build_exports = {};
1077
1312
  __export(build_exports, {
1078
1313
  build: () => build
1079
1314
  });
1080
- function getAddressableRoutes(routes2) {
1081
- let nonAddressableIds = /* @__PURE__ */ new Set();
1082
- for (let id in routes2) {
1083
- let route = routes2[id];
1084
- if (route.index) {
1085
- invariant(
1086
- route.parentId,
1087
- `Expected index route "${route.id}" to have "parentId" set`
1088
- );
1089
- nonAddressableIds.add(route.parentId);
1090
- }
1091
- if (typeof route.path !== "string" && !route.index) {
1092
- nonAddressableIds.add(id);
1093
- }
1094
- }
1095
- return Object.values(routes2).filter(
1096
- (route) => !nonAddressableIds.has(route.id)
1097
- );
1098
- }
1099
- function getRouteBranch(routes2, routeId) {
1100
- let branch = [];
1101
- let currentRouteId = routeId;
1102
- while (currentRouteId) {
1103
- let route = routes2[currentRouteId];
1104
- invariant(route, `Missing route for ${currentRouteId}`);
1105
- branch.push(route);
1106
- currentRouteId = route.parentId;
1107
- }
1108
- return branch.reverse();
1109
- }
1110
- async function getServerBuilds(ctx) {
1111
- let { rootDirectory } = ctx;
1112
- const { routes: routes2, serverBuildFile, serverBundles, appDirectory } = ctx.reactRouterConfig;
1113
- let serverBuildDirectory = getServerBuildDirectory(ctx);
1114
- if (!serverBundles) {
1115
- return {
1116
- serverBuilds: [{ ssr: true }],
1117
- buildManifest: { routes: routes2 }
1118
- };
1119
- }
1120
- let { normalizePath } = await import("vite");
1121
- let resolvedAppDirectory = import_node_path2.default.resolve(rootDirectory, appDirectory);
1122
- let rootRelativeRoutes = Object.fromEntries(
1123
- Object.entries(routes2).map(([id, route]) => {
1124
- let filePath = import_node_path2.default.join(resolvedAppDirectory, route.file);
1125
- let rootRelativeFilePath = normalizePath(
1126
- import_node_path2.default.relative(rootDirectory, filePath)
1127
- );
1128
- return [id, { ...route, file: rootRelativeFilePath }];
1129
- })
1130
- );
1131
- let buildManifest = {
1132
- serverBundles: {},
1133
- routeIdToServerBundleId: {},
1134
- routes: rootRelativeRoutes
1135
- };
1136
- let serverBundleBuildConfigById = /* @__PURE__ */ new Map();
1137
- await Promise.all(
1138
- getAddressableRoutes(routes2).map(async (route) => {
1139
- let branch = getRouteBranch(routes2, route.id);
1140
- let serverBundleId = await serverBundles({
1141
- branch: branch.map(
1142
- (route2) => configRouteToBranchRoute({
1143
- ...route2,
1144
- // Ensure absolute paths are passed to the serverBundles function
1145
- file: import_node_path2.default.join(resolvedAppDirectory, route2.file)
1146
- })
1147
- )
1148
- });
1149
- if (typeof serverBundleId !== "string") {
1150
- throw new Error(`The "serverBundles" function must return a string`);
1151
- }
1152
- if (!/^[a-zA-Z0-9-_]+$/.test(serverBundleId)) {
1153
- throw new Error(
1154
- `The "serverBundles" function must only return strings containing alphanumeric characters, hyphens and underscores.`
1155
- );
1156
- }
1157
- buildManifest.routeIdToServerBundleId[route.id] = serverBundleId;
1158
- let relativeServerBundleDirectory = import_node_path2.default.relative(
1159
- rootDirectory,
1160
- import_node_path2.default.join(serverBuildDirectory, serverBundleId)
1161
- );
1162
- let serverBuildConfig = serverBundleBuildConfigById.get(serverBundleId);
1163
- if (!serverBuildConfig) {
1164
- buildManifest.serverBundles[serverBundleId] = {
1165
- id: serverBundleId,
1166
- file: normalizePath(
1167
- import_node_path2.default.join(relativeServerBundleDirectory, serverBuildFile)
1168
- )
1169
- };
1170
- serverBuildConfig = {
1171
- routes: {},
1172
- serverBundleId
1173
- };
1174
- serverBundleBuildConfigById.set(serverBundleId, serverBuildConfig);
1175
- }
1176
- for (let route2 of branch) {
1177
- serverBuildConfig.routes[route2.id] = route2;
1178
- }
1179
- })
1180
- );
1181
- let serverBuilds = Array.from(serverBundleBuildConfigById.values()).map(
1182
- (serverBundleBuildConfig) => {
1183
- let serverBuild = {
1184
- ssr: true,
1185
- serverBundleBuildConfig
1186
- };
1187
- return serverBuild;
1188
- }
1189
- );
1190
- return {
1191
- serverBuilds,
1192
- buildManifest
1193
- };
1194
- }
1195
1315
  async function cleanBuildDirectory(viteConfig, ctx) {
1196
1316
  let buildDirectory = ctx.reactRouterConfig.buildDirectory;
1197
1317
  let isWithinRoot = () => {
@@ -1202,17 +1322,22 @@ async function cleanBuildDirectory(viteConfig, ctx) {
1202
1322
  await import_fs_extra.default.remove(buildDirectory);
1203
1323
  }
1204
1324
  }
1205
- function getViteManifestPaths(ctx, serverBuilds) {
1206
- let buildRelative = (pathname) => import_node_path2.default.resolve(ctx.reactRouterConfig.buildDirectory, pathname);
1207
- let viteManifestPaths = [
1208
- "client/.vite/manifest.json",
1209
- ...serverBuilds.map(({ serverBundleBuildConfig }) => {
1210
- let serverBundleId = serverBundleBuildConfig?.serverBundleId;
1211
- let serverBundlePath = serverBundleId ? serverBundleId + "/" : "";
1212
- return `server/${serverBundlePath}.vite/manifest.json`;
1213
- })
1214
- ].map((srcPath) => buildRelative(srcPath));
1215
- return viteManifestPaths;
1325
+ function getViteManifestPaths(environmentOptionsResolvers) {
1326
+ return Object.entries(environmentOptionsResolvers).map(
1327
+ ([environmentName, resolveOptions]) => {
1328
+ invariant(
1329
+ resolveOptions,
1330
+ `Expected build environment options resolver for ${environmentName}`
1331
+ );
1332
+ let options = resolveOptions({
1333
+ viteCommand: "build",
1334
+ viteUserConfig: {}
1335
+ });
1336
+ let outDir = options.build.outDir;
1337
+ invariant(outDir, `Expected build.outDir for ${environmentName}`);
1338
+ return import_node_path2.default.join(outDir, ".vite/manifest.json");
1339
+ }
1340
+ );
1216
1341
  }
1217
1342
  async function build(root, {
1218
1343
  assetsInlineLimit,
@@ -1237,10 +1362,17 @@ async function build(root, {
1237
1362
  }
1238
1363
  let { reactRouterConfig } = ctx;
1239
1364
  let vite2 = getVite();
1240
- async function viteBuild({
1241
- ssr,
1242
- serverBundleBuildConfig
1243
- }) {
1365
+ async function viteBuild(environmentOptionsResolvers2, environmentName) {
1366
+ let ssr = environmentName !== "client";
1367
+ let resolveOptions = environmentOptionsResolvers2[environmentName];
1368
+ invariant(
1369
+ resolveOptions,
1370
+ `Missing environment options resolver for ${environmentName}`
1371
+ );
1372
+ let environmentBuildContext = {
1373
+ name: environmentName,
1374
+ resolveOptions
1375
+ };
1244
1376
  await vite2.build({
1245
1377
  root,
1246
1378
  mode,
@@ -1255,14 +1387,25 @@ async function build(root, {
1255
1387
  optimizeDeps: { force },
1256
1388
  clearScreen,
1257
1389
  logLevel,
1258
- ...serverBundleBuildConfig ? { __reactRouterServerBundleBuildConfig: serverBundleBuildConfig } : {}
1390
+ ...{ __reactRouterEnvironmentBuildContext: environmentBuildContext }
1259
1391
  });
1260
1392
  }
1261
1393
  await cleanBuildDirectory(viteConfig, ctx);
1262
- await viteBuild({ ssr: false });
1263
- let { serverBuilds, buildManifest } = await getServerBuilds(ctx);
1264
- await Promise.all(serverBuilds.map(viteBuild));
1265
- let viteManifestPaths = getViteManifestPaths(ctx, serverBuilds);
1394
+ let buildManifest = await getBuildManifest(ctx);
1395
+ let environmentOptionsResolvers = await getEnvironmentOptionsResolvers(
1396
+ ctx,
1397
+ buildManifest
1398
+ );
1399
+ await viteBuild(environmentOptionsResolvers, "client");
1400
+ let serverEnvironmentNames = Object.keys(
1401
+ environmentOptionsResolvers
1402
+ ).filter((environmentName) => environmentName !== "client");
1403
+ await Promise.all(
1404
+ serverEnvironmentNames.map(
1405
+ (environmentName) => viteBuild(environmentOptionsResolvers, environmentName)
1406
+ )
1407
+ );
1408
+ let viteManifestPaths = getViteManifestPaths(environmentOptionsResolvers);
1266
1409
  await Promise.all(
1267
1410
  viteManifestPaths.map(async (viteManifestPath) => {
1268
1411
  let manifestExists = await import_fs_extra.default.pathExists(viteManifestPath);
@@ -1291,7 +1434,6 @@ var init_build = __esm({
1291
1434
  import_fs_extra = __toESM(require("fs-extra"));
1292
1435
  import_picocolors5 = __toESM(require("picocolors"));
1293
1436
  init_plugin();
1294
- init_config();
1295
1437
  init_invariant();
1296
1438
  init_vite();
1297
1439
  }
package/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a383e1e6e
2
+ * @react-router/dev v0.0.0-experimental-b9cf540fe
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/routes.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a383e1e6e
2
+ * @react-router/dev v0.0.0-experimental-b9cf540fe
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-a383e1e6e
2
+ * @react-router/dev v0.0.0-experimental-b9cf540fe
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *