rsbuild-plugin-react-router 0.7.3 → 0.8.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/dist/index.js CHANGED
@@ -1,26 +1,69 @@
1
1
  let globalStore, previousPrepareStackTrace, o, origin, bigint1e6, characters, charactersLength, O, quoteValue, options, f, fiber, scoped;
2
- import { existsSync, mkdirSync, readFileSync, realpathSync, statSync, watch, writeFileSync } from "node:fs";
3
- import fs_extra from "fs-extra";
4
2
  import { rspack } from "@rsbuild/core";
5
- import { dirname, isAbsolute, join as external_pathe_join, relative, resolve as external_pathe_resolve } from "pathe";
3
+ import { dirname, isAbsolute, join, relative, resolve as external_pathe_resolve } from "pathe";
4
+ import { createHash, randomUUID } from "node:crypto";
5
+ import { existsSync, readFileSync, realpathSync, statSync, watch } from "node:fs";
6
+ import fs_extra from "fs-extra";
6
7
  import { availableParallelism, cpus } from "node:os";
8
+ import { SourceMap, createRequire } from "node:module";
7
9
  import { matchRoutes } from "react-router";
8
10
  import { access, mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
9
- import { createHash } from "node:crypto";
10
- import { fileURLToPath, fileURLToPath as __rspack_fileURLToPath } from "node:url";
11
+ import { fileURLToPath, pathToFileURL, fileURLToPath as __rspack_fileURLToPath } from "node:url";
11
12
  import { Worker } from "node:worker_threads";
12
13
  import jsesc from "jsesc";
13
- import { SourceMap, createRequire } from "node:module";
14
14
  import { dirname as external_node_path_dirname, isAbsolute as external_node_path_isAbsolute, join as external_node_path_join, relative as external_node_path_relative, resolve as external_node_path_resolve, sep as external_node_path_sep, dirname as __rspack_dirname } from "node:path";
15
15
  import { createJiti } from "jiti";
16
16
  import { createRequestListener as node_fetch_server_createRequestListener } from "@remix-run/node-fetch-server";
17
- import { SERVER_ONLY_ROUTE_EXPORTS, SERVER_EXPORTS, CLIENT_NON_COMPONENT_EXPORTS, CLIENT_EXPORTS, JS_EXTENSIONS, BUILD_CLIENT_ROUTE_QUERY_STRING, SPA_FALLBACK_HTML_FILE, PLUGIN_NAME, DEFAULT_JS_DIST_PATH } from "./468.js";
17
+ import { SERVER_ONLY_ROUTE_EXPORTS, BROWSER_MANIFEST_ENTRY_NAME, SPA_FALLBACK_HTML_FILE, JS_EXTENSIONS, SERVER_EXPORTS, BUILD_CLIENT_ROUTE_QUERY_STRING, CLIENT_EXPORTS, CLIENT_NON_COMPONENT_EXPORTS, PLUGIN_NAME, DEFAULT_JS_DIST_PATH } from "./468.js";
18
18
  import { analyzeRouteModuleCode, combineURLs, generate as yuku_generate, executeRouteTransformTask, generateWithProps, resolveAppPackagePath, validateRouteChunks, roundMs, resolveEffectiveAssetPrefix, removeUnusedImports, getProgram, detectRouteChunks, getPatternIdentifierNames, getExportedName, createRouteId, removeExports, HMR_PATCHABLE_ROUTE_FLAGS, getExportNames, escapeHtml, getRouteModuleAnalysis, parseVersionMajorMinor, getRouteChunkNameFromModuleId, createEmptyRouteChunkByExportName, findEntryFile, yuku_parse, routeChunkExportNames, buildManifestChunkValidity, createReactRouterPerformanceProfiler, getRouteChunkEntryName, getRouteChunkModuleId, normalizeAssetPrefix, detectRouteChunksIfEnabled, validateSpaModeRouteExports, createBundlerRouteExportResolver, getPackageVersion, getRouteEntryBaseName, collectReferencedNames } from "./511.js";
19
19
  import { resolveServerBuildModule, headerEntries } from "./819.js";
20
20
  var effect, description, __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
21
- let getAvailableCpuCount = ()=>'function' == typeof availableParallelism ? availableParallelism() : cpus().length, getDefaultConcurrency = (cpuCount = getAvailableCpuCount())=>Math.max(0, Math.floor(cpuCount) - 2), getCappedPluginConcurrency = (cap = 16)=>Math.max(1, Math.min(cap, getDefaultConcurrency() || 1)), createReactRouterHydrationModuleTest = (entryClientPath)=>{
21
+ let createReactRouterManifestSnapshot = ({ manifest, sri, moduleExportsByRouteId, serverBuildPlan, routesByServerBundleId })=>{
22
+ let { server, moduleExportsByRouteId: detachedModuleExports } = structuredClone({
23
+ server: {
24
+ ...manifest,
25
+ sri
26
+ },
27
+ moduleExportsByRouteId
28
+ }), browser = {
29
+ ...server,
30
+ sri: void 0
31
+ }, bundles = serverBuildPlan.serverBundleEntries.flatMap(({ bundleId, entryName })=>{
32
+ let bundleRoutes = routesByServerBundleId[bundleId];
33
+ return bundleRoutes ? [
34
+ {
35
+ bundleId,
36
+ entryName,
37
+ manifest: {
38
+ ...server,
39
+ routes: Object.fromEntries(Object.entries(server.routes).filter(([routeId])=>Object.hasOwn(bundleRoutes, routeId)))
40
+ }
41
+ }
42
+ ] : [];
43
+ });
44
+ return {
45
+ browser,
46
+ moduleExportsByRouteId: detachedModuleExports,
47
+ server,
48
+ serverByBundleId: Object.fromEntries(bundles.map(({ bundleId, manifest })=>[
49
+ bundleId,
50
+ manifest
51
+ ])),
52
+ serverByEntryName: Object.fromEntries([
53
+ [
54
+ serverBuildPlan.defaultEntryName,
55
+ server
56
+ ],
57
+ ...bundles.map(({ entryName, manifest })=>[
58
+ entryName,
59
+ manifest
60
+ ])
61
+ ])
62
+ };
63
+ }, getAvailableCpuCount = ()=>'function' == typeof availableParallelism ? availableParallelism() : cpus().length, getDefaultConcurrency = (cpuCount = getAvailableCpuCount())=>Math.max(0, Math.floor(cpuCount) - 2), getCappedPluginConcurrency = (cap = 16)=>Math.max(1, Math.min(cap, getDefaultConcurrency() || 1)), DEV_HDR_UPDATE_EVENT = 'react-router:hdr-update', DEV_HMR_RUNTIME_MODULE_ID = 'virtual/react-router/hmr-runtime', DEV_MANIFEST_UPDATE_EVENT = 'react-router:manifest-update', dev_hmr_isObject = (value)=>null !== value && 'object' == typeof value, isSwcLoader = (loader)=>'string' == typeof loader && loader.includes('builtin:swc-loader'), readSwcLoaderRefresh = (value)=>Array.isArray(value) ? value.some(readSwcLoaderRefresh) : !!dev_hmr_isObject(value) && (isSwcLoader(value.loader) ? value.options?.jsc?.transform?.react?.refresh === !0 : Object.values(value).some(readSwcLoaderRefresh)), readRuleSwcRefresh = (rule)=>!!dev_hmr_isObject(rule) && (isSwcLoader(rule.loader) ? readSwcLoaderRefresh(rule) : readSwcLoaderRefresh(rule.use) || readRuleSetSwcRefresh(rule.oneOf) || readRuleSetSwcRefresh(rule.rules)), readRuleSetSwcRefresh = (rules)=>Array.isArray(rules) && rules.some(readRuleSwcRefresh), isRspackSwcReactRefreshEnabled = (rspackConfig)=>readRuleSetSwcRefresh(rspackConfig.module?.rules), createReactRouterHydrationModuleTest = (entryClientPath)=>{
22
64
  let eagerPatterns = [
23
- 'virtual/react-router/browser-manifest',
65
+ BROWSER_MANIFEST_ENTRY_NAME,
66
+ DEV_HMR_RUNTIME_MODULE_ID,
24
67
  ...entryClientPath ? [
25
68
  entryClientPath.replace(/\\/g, '/'),
26
69
  BUILD_CLIENT_ROUTE_QUERY_STRING,
@@ -824,7 +867,7 @@ let isEqual = (u)=>Predicate_hasProperty(u, Equal_symbol), Inspectable_NodeInspe
824
867
  return out;
825
868
  }
826
869
  return [];
827
- }), Array_dedupe = (self)=>dedupeWith(self, equals), join = Function_dual(2, (self, sep)=>Array_fromIterable(self).join(sep)), Chunk_TypeId = Symbol.for("effect/Chunk"), emptyArray = [], Chunk_equivalence = Equivalence_make((self, that)=>self.length === that.length && toReadonlyArray(self).every((value, i)=>equals(value, Chunk_unsafeGet(that, i)))), ChunkProto = {
870
+ }), Array_dedupe = (self)=>dedupeWith(self, equals), Array_join = Function_dual(2, (self, sep)=>Array_fromIterable(self).join(sep)), Chunk_TypeId = Symbol.for("effect/Chunk"), emptyArray = [], Chunk_equivalence = Equivalence_make((self, that)=>self.length === that.length && toReadonlyArray(self).every((value, i)=>equals(value, Chunk_unsafeGet(that, i)))), ChunkProto = {
828
871
  [Chunk_TypeId]: {
829
872
  _A: (_)=>_
830
873
  },
@@ -3140,7 +3183,7 @@ let OP_INVALID_DATA = "InvalidData", OP_MISSING_DATA = "MissingData", OP_SOURCE_
3140
3183
  return error._op = OP_INVALID_DATA, error.path = path, error.message = message, Object.defineProperty(error, "toString", {
3141
3184
  enumerable: !1,
3142
3185
  value () {
3143
- let path = Function_pipe(this.path, join(options.pathDelim));
3186
+ let path = Function_pipe(this.path, Array_join(options.pathDelim));
3144
3187
  return `(Invalid data at ${path}: "${this.message}")`;
3145
3188
  }
3146
3189
  }), error;
@@ -3151,7 +3194,7 @@ let OP_INVALID_DATA = "InvalidData", OP_MISSING_DATA = "MissingData", OP_SOURCE_
3151
3194
  return error._op = OP_MISSING_DATA, error.path = path, error.message = message, Object.defineProperty(error, "toString", {
3152
3195
  enumerable: !1,
3153
3196
  value () {
3154
- let path = Function_pipe(this.path, join(options.pathDelim));
3197
+ let path = Function_pipe(this.path, Array_join(options.pathDelim));
3155
3198
  return `(Missing data at ${path}: "${this.message}")`;
3156
3199
  }
3157
3200
  }), error;
@@ -3162,7 +3205,7 @@ let OP_INVALID_DATA = "InvalidData", OP_MISSING_DATA = "MissingData", OP_SOURCE_
3162
3205
  return error._op = OP_SOURCE_UNAVAILABLE, error.path = path, error.message = message, error.cause = cause, Object.defineProperty(error, "toString", {
3163
3206
  enumerable: !1,
3164
3207
  value () {
3165
- let path = Function_pipe(this.path, join(options.pathDelim));
3208
+ let path = Function_pipe(this.path, Array_join(options.pathDelim));
3166
3209
  return `(Source unavailable at ${path}: "${this.message}")`;
3167
3210
  }
3168
3211
  }), error;
@@ -3173,7 +3216,7 @@ let OP_INVALID_DATA = "InvalidData", OP_MISSING_DATA = "MissingData", OP_SOURCE_
3173
3216
  return error._op = OP_UNSUPPORTED, error.path = path, error.message = message, Object.defineProperty(error, "toString", {
3174
3217
  enumerable: !1,
3175
3218
  value () {
3176
- let path = Function_pipe(this.path, join(options.pathDelim));
3219
+ let path = Function_pipe(this.path, Array_join(options.pathDelim));
3177
3220
  return `(Unsupported operation at ${path}: "${this.message}")`;
3178
3221
  }
3179
3222
  }), error;
@@ -3346,7 +3389,7 @@ let OP_INVALID_DATA = "InvalidData", OP_MISSING_DATA = "MissingData", OP_SOURCE_
3346
3389
  if (isRight(left) && isLeft(right)) return core_fail(right.left);
3347
3390
  if (isRight(left) && isRight(right)) {
3348
3391
  var left1, right1;
3349
- let leftPad, rightPad, path = Function_pipe(prefix, join(".")), fail = fromFlatLoopFail(prefix, path), [lefts, rights] = (left1 = Function_pipe(left.right, Array_map(either_right)), right1 = Function_pipe(right.right, Array_map(either_right)), leftPad = Array_unfold(left1.length, (index)=>index >= right1.length ? Option_none() : option_some([
3392
+ let leftPad, rightPad, path = Function_pipe(prefix, Array_join(".")), fail = fromFlatLoopFail(prefix, path), [lefts, rights] = (left1 = Function_pipe(left.right, Array_map(either_right)), right1 = Function_pipe(right.right, Array_map(either_right)), leftPad = Array_unfold(left1.length, (index)=>index >= right1.length ? Option_none() : option_some([
3350
3393
  fail(index),
3351
3394
  index + 1
3352
3395
  ])), rightPad = Array_unfold(right1.length, (index)=>index >= left1.length ? Option_none() : option_some([
@@ -3521,7 +3564,7 @@ let nativeTracer = {
3521
3564
  [FlatConfigProviderTypeId]: FlatConfigProviderTypeId,
3522
3565
  patch: (options = {
3523
3566
  load: (path, primitive, split = !0)=>{
3524
- let pathString = Function_pipe(path, join(pathDelim)), current = getEnv();
3567
+ let pathString = Function_pipe(path, Array_join(pathDelim)), current = getEnv();
3525
3568
  return Function_pipe(pathString in current ? option_some(current[pathString]) : Option_none(), mapError(()=>MissingData(path, `Expected ${pathString} to exist in the process context`)), core_flatMap((value)=>{
3526
3569
  var text, path1, primitive1, delimiter;
3527
3570
  let text1, delim;
@@ -7175,7 +7218,54 @@ class CacheImpl {
7175
7218
  handle
7176
7219
  })), timeToLive = ()=>Duration_seconds(60), new CacheImpl(65536, _empty, fiberId_none, lookup, (exit)=>decode(timeToLive()))));
7177
7220
  }, ()=>fiberRefUnsafeMake(!1);
7178
- let FiberSet_TypeId = Symbol.for("effect/FiberSet"), FiberSet_Proto = {
7221
+ let getManifestAssetType = (name, assetTypesByName)=>{
7222
+ if (/\.hot-update\.[cm]?js(?:[?#]|$)/.test(name)) return;
7223
+ let assetType = assetTypesByName?.[name];
7224
+ if (void 0 !== assetType) return 'extract-css' === assetType ? 'css' : assetType;
7225
+ let path = name.replace(/[?#].*$/, '');
7226
+ return /\.[cm]?js$/.test(path) ? "javascript" : path.endsWith('.css') ? 'css' : void 0;
7227
+ }, orderChunkFiles = (chunkName, files, assetTypesByName)=>{
7228
+ let ownFileIndex = files.findIndex((file)=>"javascript" === getManifestAssetType(file, assetTypesByName) && file.replace(/[?#].*$/, '').replace(/\.[^.]+$/, '').endsWith(chunkName));
7229
+ return ownFileIndex <= 0 ? files : [
7230
+ files[ownFileIndex],
7231
+ ...files.slice(0, ownFileIndex),
7232
+ ...files.slice(ownFileIndex + 1)
7233
+ ];
7234
+ }, collectManifestFilesByName = (items, names, getFiles)=>{
7235
+ let filesByName = {};
7236
+ if (!names) {
7237
+ for (let [name, item] of items)null != item && (filesByName[name] = getFiles(item));
7238
+ return filesByName;
7239
+ }
7240
+ let missingNames = new Set(names);
7241
+ if ('function' == typeof items.get) for (let name of names){
7242
+ let item = items.get(name);
7243
+ item && null != item && (filesByName[name] = getFiles(item), missingNames.delete(name));
7244
+ }
7245
+ if (0 === missingNames.size) return filesByName;
7246
+ for (let [name, item] of items)if (missingNames.has(name) && null != item && (filesByName[name] = getFiles(item), missingNames.delete(name), 0 === missingNames.size)) break;
7247
+ return filesByName;
7248
+ }, createReactRouterManifestStats = (compilation, chunkNames)=>{
7249
+ if (!compilation) return;
7250
+ let assetsByChunkName = collectManifestFilesByName(compilation.namedChunks, chunkNames, (chunk)=>Array.from(chunk.files ?? [])), entrypointFilesByName = compilation.entrypoints ? collectManifestFilesByName(compilation.entrypoints, chunkNames, (entrypoint)=>Array.from(entrypoint.getFiles?.() ?? [])) : {}, assetTypesByName = {};
7251
+ if (compilation.getAsset) for (let file of new Set([
7252
+ ...Object.values(assetsByChunkName).flat(),
7253
+ ...Object.values(entrypointFilesByName).flat()
7254
+ ])){
7255
+ let info = compilation.getAsset(file)?.info, assetType = info?.assetType ?? ('boolean' == typeof info?.javascriptModule ? "javascript" : void 0);
7256
+ void 0 !== assetType && (assetTypesByName[file] = assetType);
7257
+ }
7258
+ for (let [chunkName, files] of Object.entries(assetsByChunkName))assetsByChunkName[chunkName] = orderChunkFiles(chunkName, files, assetTypesByName);
7259
+ return {
7260
+ assetsByChunkName,
7261
+ ...Object.keys(entrypointFilesByName).length > 0 ? {
7262
+ entrypointFilesByName
7263
+ } : {},
7264
+ ...Object.keys(assetTypesByName).length > 0 ? {
7265
+ assetTypesByName
7266
+ } : {}
7267
+ };
7268
+ }, FiberSet_TypeId = Symbol.for("effect/FiberSet"), FiberSet_Proto = {
7179
7269
  [FiberSet_TypeId]: FiberSet_TypeId,
7180
7270
  [Symbol.iterator] () {
7181
7271
  return "Closed" === this.state._tag ? constEmpty : this.state.backing[Symbol.iterator]();
@@ -7306,32 +7396,9 @@ let createReactRouterManifestOptions = ({ routeChunks, routeModuleAnalysis })=>{
7306
7396
  routeModuleAnalysis
7307
7397
  } : {}
7308
7398
  };
7309
- }, isManifestJsAsset = (asset)=>/(?<!\.hot-update)\.[cm]?js(?:\?.*)?$/.test(asset), isManifestCssAsset = (asset)=>/\.css(?:\?.*)?$/.test(asset), hasSome = (iterable)=>{
7399
+ }, isManifestJsAsset = (asset)=>/(?<!\.hot-update)\.[cm]?js(?:\?.*)?$/.test(asset), hasSome = (iterable)=>{
7310
7400
  for (let _ of iterable)return !0;
7311
7401
  return !1;
7312
- }, collectManifestFilesByName = (items, names, getFiles)=>{
7313
- let filesByName = {};
7314
- if (!names) {
7315
- for (let [name, item] of items)null != item && (filesByName[name] = getFiles(name, item));
7316
- return filesByName;
7317
- }
7318
- let missingNames = new Set(names);
7319
- if ('function' == typeof items.get) for (let name of names){
7320
- let item = items.get(name);
7321
- null != item && (filesByName[name] = getFiles(name, item), missingNames.delete(name));
7322
- }
7323
- if (0 === missingNames.size) return filesByName;
7324
- for (let [name, item] of items)if (missingNames.has(name) && null != item && (filesByName[name] = getFiles(name, item), missingNames.delete(name), 0 === missingNames.size)) break;
7325
- return filesByName;
7326
- }, createReactRouterManifestStats = (compilation, chunkNames)=>{
7327
- if (!compilation) return;
7328
- let assetsByChunkName = collectManifestFilesByName(compilation.namedChunks, chunkNames, (_chunkName, chunk)=>Array.from(chunk.files ?? [])), entrypointFilesByName = compilation.entrypoints ? collectManifestFilesByName(compilation.entrypoints, chunkNames, (_name, entrypoint)=>Array.from(entrypoint.getFiles?.() ?? [])) : {};
7329
- return Object.keys(entrypointFilesByName).length > 0 ? {
7330
- assetsByChunkName,
7331
- entrypointFilesByName
7332
- } : {
7333
- assetsByChunkName
7334
- };
7335
7402
  }, CSS_IMPORT_RE = /\.(?:css|less|sass|scss)(?:\?[^'"`]+)?['"`]/, getReactRouterManifestPath = ({ version, isBuild, entryModulePath })=>{
7336
7403
  if (!isBuild) return 'static/js/virtual/react-router/browser-manifest.js';
7337
7404
  let dir = ((entryModulePath)=>{
@@ -7343,11 +7410,11 @@ let createReactRouterManifestOptions = ({ routeChunks, routeModuleAnalysis })=>{
7343
7410
  };
7344
7411
  async function generateReactRouterManifestForDev(routes, _options, clientStats, context, assetPrefix = '/', manifestOptions) {
7345
7412
  return runPluginEffect(core_gen(function*() {
7346
- let chunkAssetsByName, result = {}, splitRouteModules = manifestOptions?.splitRouteModules ?? !1, enforceSplitRouteModules = 'enforce' === splitRouteModules, isBuild = manifestOptions?.isBuild ?? !1, routeChunkConfig = splitRouteModules && manifestOptions?.rootRouteFile ? {
7413
+ let chunkAssetsByName, getAssetType, result = {}, splitRouteModules = manifestOptions?.splitRouteModules ?? !1, enforceSplitRouteModules = 'enforce' === splitRouteModules, isBuild = manifestOptions?.isBuild ?? !1, routeChunkConfig = splitRouteModules && manifestOptions?.rootRouteFile ? {
7347
7414
  splitRouteModules,
7348
7415
  appDirectory: context,
7349
7416
  rootRouteFile: manifestOptions.rootRouteFile
7350
- } : null, getAssetsForChunk = (chunkAssetsByName = new Map(), (chunkName)=>{
7417
+ } : null, getAssetsForChunk = (chunkAssetsByName = new Map(), getAssetType = (name)=>getManifestAssetType(name, clientStats?.assetTypesByName), (chunkName)=>{
7351
7418
  let cached = chunkAssetsByName.get(chunkName);
7352
7419
  if (cached) return cached;
7353
7420
  let assets = clientStats?.assetsByChunkName?.[chunkName];
@@ -7360,13 +7427,19 @@ async function generateReactRouterManifestForDev(routes, _options, clientStats,
7360
7427
  };
7361
7428
  return chunkAssetsByName.set(chunkName, result), result;
7362
7429
  }
7363
- let cssAssets = new Set(), jsAssets = new Set();
7364
- for (let asset of assets)isManifestCssAsset(asset) ? cssAssets.add(asset) : isManifestJsAsset(asset) && jsAssets.add(asset);
7365
- for (let asset of clientStats?.entrypointFilesByName?.[chunkName] ?? [])isManifestCssAsset(asset) ? cssAssets.add(asset) : isBuild && isManifestJsAsset(asset) && jsAssets.add(asset);
7366
- if (0 === jsAssets.size) throw Error(`[react-router] Chunk "${chunkName}" emitted no JavaScript asset the browser manifest can reference (files: ${assets.join(', ') || 'none'}). Check the web \`output.filename.js\` scheme.`);
7430
+ let cssAssets = new Set(), jsAssets = [];
7431
+ for (let asset of assets){
7432
+ let assetType = getAssetType(asset);
7433
+ 'css' === assetType ? cssAssets.add(asset) : "javascript" === assetType && jsAssets.push(asset);
7434
+ }
7435
+ if (0 === jsAssets.length) throw Error(`[react-router] Chunk "${chunkName}" emitted no JavaScript asset the browser manifest can reference (files: ${assets.join(', ') || 'none'}). Check the web \`output.filename.js\` scheme.`);
7436
+ for (let asset of clientStats?.entrypointFilesByName?.[chunkName] ?? []){
7437
+ let assetType = getAssetType(asset);
7438
+ 'css' === assetType ? cssAssets.add(asset) : isBuild && "javascript" === assetType && jsAssets.push(asset);
7439
+ }
7367
7440
  let result = {
7368
7441
  js: [
7369
- ...jsAssets
7442
+ ...new Set(jsAssets)
7370
7443
  ],
7371
7444
  css: [
7372
7445
  ...cssAssets
@@ -7465,12 +7538,12 @@ async function generateReactRouterManifestForDev(routes, _options, clientStats,
7465
7538
  }, version = createHash('sha256').update(JSON.stringify(fingerprintedValues)).digest('hex').slice(0, 8), manifestPath = getReactRouterManifestPath({
7466
7539
  version,
7467
7540
  isBuild,
7468
- entryModulePath: entryJsAssets[0]
7469
- });
7541
+ entryModulePath: (entryJsAssets[0] ?? '').replace(/[?#].*$/, '')
7542
+ }), browserManifestPath = clientStats?.assetsByChunkName?.[BROWSER_MANIFEST_ENTRY_NAME]?.find((name)=>"javascript" === getManifestAssetType(name, clientStats.assetTypesByName)) ?? manifestPath;
7470
7543
  return {
7471
7544
  manifest: {
7472
7545
  version,
7473
- url: combineURLs(assetPrefix, isBuild ? manifestPath : `${manifestPath}?v=${version}`),
7546
+ url: combineURLs(assetPrefix, isBuild ? manifestPath : `${browserManifestPath}${browserManifestPath.includes('?') ? '&' : '?'}v=${version}`),
7474
7547
  hmr: void 0,
7475
7548
  entry: fingerprintedValues.entry,
7476
7549
  sri: void 0,
@@ -7962,8 +8035,8 @@ let defaultWorkerPath = fileURLToPath(new URL('./server-build-worker.js', import
7962
8035
  unstable_subResourceIntegrity: subResourceIntegrity
7963
8036
  }
7964
8037
  };
7965
- }, BROWSER_MANIFEST_ASSET = 'static/js/virtual/react-router/browser-manifest.js', ABSOLUTE_URL_RE = /^[a-zA-Z][a-zA-Z\d+\-.]*:/, addIntegrity = (sri, assetPrefix, assetName, integrity)=>{
7966
- 'string' == typeof assetName && isManifestJsAsset(assetName) && 'string' == typeof integrity && (sri[ABSOLUTE_URL_RE.test(assetName) || assetName.startsWith('//') || assetName.startsWith('/') ? assetName : combineURLs(assetPrefix, assetName)] = integrity);
8038
+ }, ABSOLUTE_URL_RE = /^[a-zA-Z][a-zA-Z\d+\-.]*:/, addIntegrity = (sri, assetPrefix, assetName, integrity)=>{
8039
+ 'string' == typeof integrity && (sri[ABSOLUTE_URL_RE.test(assetName) || assetName.startsWith('//') || assetName.startsWith('/') ? assetName : combineURLs(assetPrefix, assetName)] = integrity);
7967
8040
  }, computeSubresourceIntegrity = (source)=>{
7968
8041
  if (source) return `sha384-${createHash('sha384').update(source.source()).digest('base64')}`;
7969
8042
  };
@@ -7988,7 +8061,7 @@ let isRelocatableServerAsset = (info)=>!!info?.sourceFilename && !info?.javascri
7988
8061
  return collected.sort((a, b)=>a.name < b.name ? -1 : +(a.name > b.name)), collected;
7989
8062
  })(compilation), written = [], skipped = [];
7990
8063
  for (let asset of assets){
7991
- let destination = external_pathe_join(outputClientPath, asset.name), sourceBuffer = asset.source.buffer(), sourceDigest = digestBuffer(sourceBuffer);
8064
+ let destination = join(outputClientPath, asset.name), sourceBuffer = asset.source.buffer(), sourceDigest = digestBuffer(sourceBuffer);
7992
8065
  if (relocatedDestinations?.get(destination) === sourceDigest || existsSyncFn(destination) && digestBuffer(await readFileFn(destination)) === sourceDigest) skipped.push(asset.name);
7993
8066
  else {
7994
8067
  await mkdirFn(dirname(destination));
@@ -8066,7 +8139,7 @@ let VIRTUAL_MODULE_PREFIX = 'virtual/react-router/', getVirtualModuleFilePath =
8066
8139
  let relativeId = moduleId.slice(VIRTUAL_MODULE_PREFIX.length), segments = relativeId.split('/');
8067
8140
  if (!relativeId || segments.some((segment)=>!segment || '.' === segment || '..' === segment)) throw Error(`Invalid virtual module id: ${moduleId}`);
8068
8141
  return `node_modules/${moduleId}.js`;
8069
- }, DEV_MANIFEST_UPDATE_EVENT = 'react-router:manifest-update', dev_hmr_isObject = (value)=>null !== value && 'object' == typeof value, isSwcLoader = (loader)=>'string' == typeof loader && loader.includes('builtin:swc-loader'), readSwcLoaderRefresh = (value)=>Array.isArray(value) ? value.some(readSwcLoaderRefresh) : !!dev_hmr_isObject(value) && (isSwcLoader(value.loader) ? value.options?.jsc?.transform?.react?.refresh === !0 : Object.values(value).some(readSwcLoaderRefresh)), readRuleSwcRefresh = (rule)=>!!dev_hmr_isObject(rule) && (isSwcLoader(rule.loader) ? readSwcLoaderRefresh(rule) : readSwcLoaderRefresh(rule.use) || readRuleSetSwcRefresh(rule.oneOf) || readRuleSetSwcRefresh(rule.rules)), readRuleSetSwcRefresh = (rules)=>Array.isArray(rules) && rules.some(readRuleSwcRefresh), isRspackSwcReactRefreshEnabled = (rspackConfig)=>readRuleSetSwcRefresh(rspackConfig.module?.rules), REACT_ROUTER_EXTERNALS = [
8142
+ }, REACT_ROUTER_EXTERNALS = [
8070
8143
  'react-router',
8071
8144
  'react-router-dom',
8072
8145
  '@react-router/architect',
@@ -9080,7 +9153,7 @@ export function EnsureClientRouteModuleForHMR___() { return ___EnsureClientRoute
9080
9153
  });
9081
9154
  return {
9082
9155
  buildManifest,
9083
- devRuntime: (({ api, isBuild, buildPlan, clientPatchesRouteMetadata, onNodeRebuildCommitted })=>{
9156
+ devRuntime: (({ api, isBuild, buildPlan, clientPatchesRouteMetadata })=>{
9084
9157
  let scheduledCssAssetOwnershipReload, state, nextSessionId, closeObservationByServer, isCurrentBinding, applyCloseOutcome, observeClose, identityByCompilation, webIdentityByNodeCompilation, attemptIdentityByCompilation;
9085
9158
  if (isBuild) return {
9086
9159
  captureWeb () {},
@@ -9097,8 +9170,8 @@ export function EnsureClientRouteModuleForHMR___() { return ___EnsureClientRoute
9097
9170
  scheduledCssAssetOwnershipReload = setTimeout(()=>{
9098
9171
  scheduledCssAssetOwnershipReload = void 0, lastCssAssetOwnershipReloadAt > scheduledAt || sendCssAssetOwnershipReload();
9099
9172
  }, 1000);
9100
- }, closeBinding = (binding, error)=>{
9101
- scheduledCssAssetOwnershipReload && (clearTimeout(scheduledCssAssetOwnershipReload), scheduledCssAssetOwnershipReload = void 0), reloadAfterCssAssetOwnershipRemoval = !1;
9173
+ }, hdrChannels = new WeakMap(), isHmrEnabled = ()=>'function' == typeof clientPatchesRouteMetadata ? clientPatchesRouteMetadata() : !0 === clientPatchesRouteMetadata, closeBinding = (binding, error)=>{
9174
+ hdrChannels.get(binding)?.close(), hdrChannels.delete(binding), scheduledCssAssetOwnershipReload && (clearTimeout(scheduledCssAssetOwnershipReload), scheduledCssAssetOwnershipReload = void 0), reloadAfterCssAssetOwnershipRemoval = !1;
9102
9175
  let pair = binding.compilers;
9103
9176
  pair && (pair.pendingAttempt = void 0, pair.currentAttemptIdentity = void 0, pair.latestCompletedWebIdentity = void 0, pair.latestCompletedWebStats = void 0, pair.latestCompletedNodeStats = void 0, pair.latestWebStart = void 0, pair.latestNodeStart = void 0), binding.compilers = void 0, binding.runtime.close(error);
9104
9177
  var server = binding.server, runtime = binding.runtime;
@@ -9206,7 +9279,7 @@ export function EnsureClientRouteModuleForHMR___() { return ___EnsureClientRoute
9206
9279
  if ('retry-node' === result) return void pair.node.watching?.invalidate();
9207
9280
  let nodeCompilation = getEnvironmentStats(stats, 'node')?.compilation;
9208
9281
  'committed' === result && nodeCompilation && identity.node === binding.runtime.getCommittedNodeIdentity() && hdrIntentsByPair.get(pair)?.signalCommitted(nodeCompilation, ()=>{
9209
- onNodeRebuildCommitted?.();
9282
+ hdrChannels.get(binding)?.publish();
9210
9283
  });
9211
9284
  } catch (cause) {
9212
9285
  sessions.getActiveBinding()?.id === binding.id && binding.runtime.failAttempt(normalizeEffectError(cause));
@@ -9435,7 +9508,7 @@ export function EnsureClientRouteModuleForHMR___() { return ___EnsureClientRoute
9435
9508
  sessions.getActiveBinding()?.runtime === runtime && (reloadAfterCssAssetOwnershipRemoval = 'removed' === change, sendCssAssetOwnershipReload());
9436
9509
  },
9437
9510
  onRouteManifestChanged (manifest) {
9438
- sessions.getActiveBinding()?.runtime !== runtime || (('function' == typeof clientPatchesRouteMetadata ? clientPatchesRouteMetadata() : clientPatchesRouteMetadata) ? server.sockWrite('custom', {
9511
+ sessions.getActiveBinding()?.runtime === runtime && (isHmrEnabled() ? server.sockWrite('custom', {
9439
9512
  event: DEV_MANIFEST_UPDATE_EVENT,
9440
9513
  data: manifest.routes
9441
9514
  }) : server.sockWrite('full-reload', {
@@ -9444,7 +9517,28 @@ export function EnsureClientRouteModuleForHMR___() { return ___EnsureClientRoute
9444
9517
  },
9445
9518
  onWarning: (message)=>api.logger.warn(message)
9446
9519
  }), binding = sessions.createBinding(server, runtime);
9447
- Object.defineProperty(server, DEV_RUNTIME_KEY, {
9520
+ hdrChannels.set(binding, (({ hot, isEnabled })=>{
9521
+ let sessionId = randomUUID(), revision = 0, closed = !1, payload = ()=>({
9522
+ event: DEV_HDR_UPDATE_EVENT,
9523
+ data: {
9524
+ sessionId,
9525
+ revision
9526
+ }
9527
+ }), unsubscribe = hot.onConnect((client)=>{
9528
+ !closed && isEnabled() && revision > 0 && client.send('custom', payload());
9529
+ });
9530
+ return {
9531
+ publish () {
9532
+ !closed && isEnabled() && (revision += 1, hot.send('custom', payload()));
9533
+ },
9534
+ close () {
9535
+ closed || (closed = !0, unsubscribe());
9536
+ }
9537
+ };
9538
+ })({
9539
+ hot: server.environments.web.hot,
9540
+ isEnabled: ()=>sessions.getActiveBinding() === binding && isHmrEnabled()
9541
+ })), Object.defineProperty(server, DEV_RUNTIME_KEY, {
9448
9542
  configurable: !0,
9449
9543
  enumerable: !1,
9450
9544
  value: runtime
@@ -9516,7 +9610,7 @@ export function EnsureClientRouteModuleForHMR___() { return ___EnsureClientRoute
9516
9610
  }), node.hooks.thisCompilation.tap(`${PLUGIN_NAME}:dev-node-web-compilation`, (compilation)=>{
9517
9611
  if (sessions.getActiveBinding()?.id !== sessionId) return;
9518
9612
  let changes = snapshotDevChangedFiles(pair.node);
9519
- hdrIntents.capture(compilation, changes.known && Array.from(changes.files).some((file)=>!file.includes('.react-router/hdr-revision.mjs') && !/\.css(?:\.[cm]?[jt]s)?$/.test(file))), pair.latestNodeStart = {
9613
+ hdrIntents.capture(compilation, changes.known && Array.from(changes.files).some((file)=>!/\.css(?:\.[cm]?[jt]s)?$/.test(file))), pair.latestNodeStart = {
9520
9614
  status: 'started',
9521
9615
  identity: getCompilationIdentity(compilation)
9522
9616
  }, pair.currentAttemptIdentity && compilationIdentities.setAttemptIdentityForCompilation(compilation, pair.currentAttemptIdentity), pair.latestCompletedWebIdentity && compilationIdentities.setWebIdentityForNodeCompilation(compilation, pair.latestCompletedWebIdentity);
@@ -9570,8 +9664,7 @@ export function EnsureClientRouteModuleForHMR___() { return ___EnsureClientRoute
9570
9664
  api,
9571
9665
  isBuild,
9572
9666
  buildPlan: serverBuildPlan,
9573
- clientPatchesRouteMetadata: devHmr?.isEnabled,
9574
- onNodeRebuildCommitted: devHmr?.onNodeRebuildCommitted
9667
+ clientPatchesRouteMetadata: devHmr?.isEnabled
9575
9668
  }),
9576
9669
  prerenderPaths,
9577
9670
  routesByServerBundleId,
@@ -9858,7 +9951,7 @@ export {
9858
9951
  nodeDependencies: {}
9859
9952
  };
9860
9953
  }, createClassicModePlan = async ({ api, allowedActionOriginsForBuild, appDirectory, assetsBuildDirectory, basename, customServer, defaultEntryName, devHmr, entryServerPath, finalEntryClientPath, future, hasServerApp, isBuild, isSpaMode, prerenderConfig, reactRouterConfig, routeChunkCache, routeConfig, routeDiscovery, routes, rootRouteFile, serverAppPath, shouldDependOnWebCompiler, splitRouteModules, ssr })=>{
9861
- var rootDirectory;
9954
+ var rootPath, rootDirectory;
9862
9955
  let reactRouterPath, reactRouterDomPath, { manifestChunkNames, webRouteEntries } = (({ appDirectory, isBuild, routes, splitRouteModules })=>{
9863
9956
  let manifestChunkNames = new Set([
9864
9957
  'entry.client'
@@ -9907,7 +10000,7 @@ export {
9907
10000
  rootDirectory: process.cwd(),
9908
10001
  ssr,
9909
10002
  devHmr
9910
- }), reactRouterAliases = (reactRouterPath = resolveAppPackagePath('react-router'), reactRouterDomPath = resolveAppPackagePath('react-router/dom'), {
10003
+ }), reactRouterAliases = (reactRouterPath = resolveAppPackagePath('react-router', rootPath = api.context.rootPath), reactRouterDomPath = resolveAppPackagePath('react-router/dom', rootPath), {
9911
10004
  ...reactRouterPath ? {
9912
10005
  'react-router$': reactRouterPath
9913
10006
  } : {},
@@ -9988,7 +10081,7 @@ export {
9988
10081
  ...bundleManifestModules,
9989
10082
  'virtual/react-router/with-props': generateWithProps(),
9990
10083
  ...void 0 !== devHmrRuntimeModule ? {
9991
- 'virtual/react-router/hmr-runtime': devHmrRuntimeModule
10084
+ [DEV_HMR_RUNTIME_MODULE_ID]: devHmrRuntimeModule
9992
10085
  } : {}
9993
10086
  };
9994
10087
  })({
@@ -10012,14 +10105,21 @@ export {
10012
10105
  }),
10013
10106
  server: customServer ? void 0 : {
10014
10107
  setup: [
10015
- (({ loadBuild })=>function(context) {
10108
+ (({ loadBuild, rootPath })=>function(context) {
10016
10109
  if ('dev' === context.action) return ()=>{
10017
10110
  var dependencies;
10018
10111
  let listenerPromise, getListener;
10019
10112
  installDevServerSourceMapSupport(), context.server.middlewares.use((dependencies = {
10020
- loadBuild
10113
+ loadBuild,
10114
+ rootPath
10021
10115
  }, (getListener = ()=>listenerPromise ??= (async ()=>{
10022
- let createRequestHandler = dependencies.createRequestHandler ?? (await import("react-router")).createRequestHandler, createRequestListener = dependencies.createRequestListener ?? (await import("@remix-run/node-fetch-server")).createRequestListener, requestHandler = createRequestHandler(dependencies.loadBuild, 'development');
10116
+ let createRequestHandler = dependencies.createRequestHandler;
10117
+ if (!createRequestHandler) {
10118
+ let reactRouterPath = resolveAppPackagePath('react-router', dependencies.rootPath);
10119
+ if (!reactRouterPath) throw Error('Cannot resolve react-router from the application.');
10120
+ createRequestHandler = (await import(pathToFileURL(reactRouterPath).href)).createRequestHandler;
10121
+ }
10122
+ let createRequestListener = dependencies.createRequestListener ?? (await import("@remix-run/node-fetch-server")).createRequestListener, requestHandler = createRequestHandler(dependencies.loadBuild, 'development');
10023
10123
  return createRequestListener((request)=>requestHandler(request));
10024
10124
  })())().catch(()=>{
10025
10125
  listenerPromise = void 0;
@@ -10033,7 +10133,8 @@ export {
10033
10133
  }));
10034
10134
  };
10035
10135
  })({
10036
- loadBuild: artifacts.devRuntime.createBuildLoader()
10136
+ loadBuild: artifacts.devRuntime.createBuildLoader(),
10137
+ rootPath: api.context.rootPath
10037
10138
  })
10038
10139
  ]
10039
10140
  },
@@ -10113,7 +10214,7 @@ export {
10113
10214
  name: PLUGIN_NAME,
10114
10215
  async setup (api) {
10115
10216
  var memoMap;
10116
- let sendRscDevUpdate, scheduledRscDevUpdate, clientStats, fiberRunFork, disposePromise, buildFiber, scope, runtimeEffect, self, runtime, reactRouterUserConfig, effectRuntime = (memoMap = memoMap ?? unsafeMakeMemoMap(), scope = unsafeRunSyncEffect(fiberRuntime_scopeMake()), runtimeEffect = core_suspend(()=>{
10217
+ let sendRscDevUpdate, scheduledRscDevUpdate, persistedSnapshotError, clientStats, fiberRunFork, disposePromise, buildFiber, scope, runtimeEffect, self, runtime, reactRouterUserConfig, effectRuntime = (memoMap = memoMap ?? unsafeMakeMemoMap(), scope = unsafeRunSyncEffect(fiberRuntime_scopeMake()), runtimeEffect = core_suspend(()=>{
10117
10218
  if (!buildFiber) {
10118
10219
  let scheduler = new SyncScheduler();
10119
10220
  buildFiber = unsafeForkEffect(core_tap(scopeExtend(toRuntimeWithMemoMap(PluginRuntimeLive, memoMap), scope), (rt)=>{
@@ -10210,7 +10311,7 @@ export {
10210
10311
  (isSourceMapEnabled(sourceMapSetting) || !0 === devtoolSetting || ('string' == typeof devtoolSetting ? devtoolSetting.includes('source-map') : null !== devtoolSetting && 'object' == typeof devtoolSetting)) && warn("\n WARNING: Source maps are enabled in production\n This makes your server code publicly visible in the browser.\n This is highly discouraged! If you insist, ensure that you are using\n environment variables for secrets and not hard-coding them in your source code.\n");
10211
10312
  }(api.getNormalizedConfig(), (msg)=>api.logger.warn(msg), 'web');
10212
10313
  }), api.onBeforeCreateCompiler(()=>{
10213
- let root = api.getNormalizedConfig(), web = root.environments.web;
10314
+ let root = api.getNormalizedConfig(), web = root.environments.web ?? api.getRsbuildConfig().environments?.web;
10214
10315
  assetPrefix = resolveEffectiveAssetPrefix({
10215
10316
  dev: web?.dev,
10216
10317
  output: web?.output,
@@ -10300,7 +10401,7 @@ export {
10300
10401
  hasConfiguredServerModuleFormat: void 0 !== userAndPresetConfigs.serverModuleFormat
10301
10402
  };
10302
10403
  }))), { appDirectory, basename, buildDirectory, future, allowedActionOrigins, routeDiscovery: userRouteDiscovery, ssr, prerender: prerenderConfig, serverBuildFile, serverBundles, serverModuleFormat, splitRouteModules, subResourceIntegrity, buildEnd } = resolvedConfig;
10303
- await registerReactRouterTypegen(api, {
10404
+ !1 !== pluginOptions.typegen && await registerReactRouterTypegen(api, {
10304
10405
  runtime: effectRuntime,
10305
10406
  appDirectory
10306
10407
  });
@@ -10556,42 +10657,59 @@ export {
10556
10657
  routeConfigWatchPaths,
10557
10658
  routeRestartMarkerPath,
10558
10659
  onRouteTopologyChange: pluginOptions.onRouteTopologyChange
10559
- }), latestBrowserManifest = null, latestBrowserManifestModuleExports = {}, latestServerManifest = null, latestServerManifestsByBundleId = {}, serverManifestStampPath = external_pathe_resolve(api.context.cachePath, 'react-router', 'server-manifest.json'), routeByFilePath = new Map(Object.values(routes).map((route)=>[
10660
+ }), serverManifestStampPath = external_pathe_resolve(api.context.cachePath, 'react-router', createHash('sha256').update(JSON.stringify([
10661
+ appDirectory,
10662
+ outputClientPath
10663
+ ])).digest('hex'), 'server-manifest.json'), writeServerManifestStamp = (snapshot)=>{
10664
+ let previous, stamp = JSON.stringify({
10665
+ schema: 1,
10666
+ isBuild,
10667
+ appDirectory,
10668
+ outputClientPath,
10669
+ routes,
10670
+ assetPrefix,
10671
+ snapshot
10672
+ });
10673
+ try {
10674
+ previous = readFileSync(serverManifestStampPath, 'utf8');
10675
+ } catch (error) {
10676
+ if ('ENOENT' !== error.code) throw error;
10677
+ }
10678
+ stamp !== previous && fs_extra.outputFileSync(serverManifestStampPath, stamp);
10679
+ }, routeByFilePath = new Map(Object.values(routes).map((route)=>[
10560
10680
  external_pathe_resolve(appDirectory, route.file),
10561
10681
  route
10562
10682
  ])), devHmrRefreshRuntimePath = isBuild || isRscMode ? void 0 : ((rootPath)=>{
10563
- let resolveFrom = (base, request)=>createRequire(base).resolve(request), rootPackageJson = external_pathe_join(rootPath, 'package.json');
10683
+ let resolveFrom = (base, request)=>createRequire(base).resolve(request), rootPackageJson = join(rootPath, 'package.json');
10564
10684
  try {
10565
10685
  let pluginReactEntry = resolveFrom(rootPackageJson, '@rsbuild/plugin-react'), refreshPluginEntry = resolveFrom(pluginReactEntry, '@rspack/plugin-react-refresh');
10566
10686
  return resolveFrom(refreshPluginEntry, 'react-refresh/runtime');
10567
10687
  } catch {
10568
10688
  return;
10569
10689
  }
10570
- })(api.context.rootPath), devHdrSignal = devHmrRefreshRuntimePath ? (({ filePath, onError })=>{
10571
- let revision = 0, dirEnsured = !1, write = ()=>{
10572
- try {
10573
- let revision1;
10574
- dirEnsured || (mkdirSync(dirname(filePath), {
10575
- recursive: !0
10576
- }), dirEnsured = !0), writeFileSync(filePath, (revision1 = revision, `export default ${revision1};\n`));
10577
- } catch (error) {
10578
- onError?.(error instanceof Error ? error : Error(String(error)));
10579
- }
10580
- };
10581
- return {
10582
- filePath,
10583
- ensure: write,
10584
- bump () {
10585
- revision += 1, write();
10586
- }
10587
- };
10588
- })({
10589
- filePath: external_pathe_join(api.context.rootPath, '.react-router', 'hdr-revision.mjs'),
10590
- onError: (error)=>api.logger.debug(`[${PLUGIN_NAME}] Failed to signal hot data revalidation: ${error.message}`)
10591
- }) : void 0, devHmrEnabled = !1;
10592
- devHmrRefreshRuntimePath && devHdrSignal && api.modifyEnvironmentConfig(async (environmentConfig, { name, mergeEnvironmentConfig })=>'web' !== name ? environmentConfig : mergeEnvironmentConfig(environmentConfig, {
10690
+ })(api.context.rootPath), devHmrEnabled = !1;
10691
+ devHmrRefreshRuntimePath && api.modifyEnvironmentConfig(async (environmentConfig, { name, mergeEnvironmentConfig })=>'web' !== name ? environmentConfig : mergeEnvironmentConfig(environmentConfig, {
10593
10692
  tools: {
10594
- rspack: (rspackConfig)=>((devHmrEnabled = isRspackSwcReactRefreshEnabled(rspackConfig)) && devHdrSignal.ensure(), rspackConfig)
10693
+ rspack: (rspackConfig)=>{
10694
+ if (devHmrEnabled = isRspackSwcReactRefreshEnabled(rspackConfig)) {
10695
+ let entries = rspackConfig.entry;
10696
+ if (entries && 'object' == typeof entries && !Array.isArray(entries)) for (let [name, entry] of Object.entries(entries)){
10697
+ let description = 'string' == typeof entry || Array.isArray(entry) ? {
10698
+ import: entry
10699
+ } : entry;
10700
+ entries[name] = {
10701
+ ...description,
10702
+ import: [
10703
+ DEV_HMR_RUNTIME_MODULE_ID,
10704
+ ...[
10705
+ description.import ?? []
10706
+ ].flat()
10707
+ ]
10708
+ };
10709
+ }
10710
+ }
10711
+ return rspackConfig;
10712
+ }
10595
10713
  }
10596
10714
  }));
10597
10715
  let commonModeOptions = {
@@ -10632,18 +10750,10 @@ export {
10632
10750
  routeChunkCache,
10633
10751
  serverAppPath,
10634
10752
  shouldDependOnWebCompiler,
10635
- devHmr: devHmrRefreshRuntimePath && devHdrSignal ? {
10753
+ devHmr: devHmrRefreshRuntimePath ? {
10636
10754
  isEnabled: ()=>devHmrEnabled,
10637
- runtimeModule: (({ reactRefreshRuntimePath, hdrRevisionFilePath })=>`
10755
+ runtimeModule: (({ reactRefreshRuntimePath })=>`
10638
10756
  import * as __refreshRuntimeModule from ${JSON.stringify(reactRefreshRuntimePath)};
10639
- // Read revision so the import survives sideEffects: false tree-shaking.
10640
- import __hdrRevision from ${JSON.stringify(hdrRevisionFilePath)};
10641
-
10642
- let latestHdrRevision = __hdrRevision;
10643
-
10644
- export function getReactRouterHdrRevision() {
10645
- return latestHdrRevision;
10646
- }
10647
10757
 
10648
10758
  const RefreshRuntime =
10649
10759
  __refreshRuntimeModule && __refreshRuntimeModule.performReactRefresh
@@ -10653,7 +10763,24 @@ const RefreshRuntime =
10653
10763
  const pendingRouteUpdates = new Map();
10654
10764
  let flushTimeout;
10655
10765
  let pendingRevalidation = false;
10656
- let pendingComponentRouteRevalidation = false;
10766
+ let flushing = false;
10767
+ let hdrSession;
10768
+ let latestHdrRevision = 0;
10769
+ const retiredHdrSessions = new Set();
10770
+
10771
+ function receiveHdrRevision(message) {
10772
+ if (!message || typeof message.sessionId !== 'string' ||
10773
+ !Number.isSafeInteger(message.revision) || message.revision < 1 ||
10774
+ retiredHdrSessions.has(message.sessionId)) return;
10775
+ if (hdrSession !== message.sessionId) {
10776
+ if (hdrSession) retiredHdrSessions.add(hdrSession);
10777
+ hdrSession = message.sessionId;
10778
+ latestHdrRevision = 0;
10779
+ }
10780
+ if (message.revision <= latestHdrRevision) return;
10781
+ latestHdrRevision = message.revision;
10782
+ scheduleReactRouterRevalidation();
10783
+ }
10657
10784
 
10658
10785
  function getCurrentRouterPath(router) {
10659
10786
  const basename = router.basename || '/';
@@ -10694,7 +10821,7 @@ export function scheduleReactRouterRouteUpdate(
10694
10821
  scheduleFlush();
10695
10822
  }
10696
10823
 
10697
- export function scheduleReactRouterRevalidation() {
10824
+ function scheduleReactRouterRevalidation() {
10698
10825
  pendingRevalidation = true;
10699
10826
  scheduleFlush();
10700
10827
  }
@@ -10893,45 +11020,50 @@ function applyManifestUpdate(nextRoutes) {
10893
11020
  }
10894
11021
 
10895
11022
  async function flush() {
11023
+ if (flushing) return;
11024
+ if (import.meta.webpackHot && import.meta.webpackHot.status() !== 'idle') {
11025
+ scheduleFlush();
11026
+ return;
11027
+ }
10896
11028
  const router = window.__reactRouterDataRouter;
10897
11029
  const routeModules = window.__reactRouterRouteModules;
10898
11030
  const manifest = window.__reactRouterManifest;
10899
11031
  const context = window.__reactRouterContext;
10900
11032
  if (!router || !routeModules || !manifest || !context) {
11033
+ scheduleFlush();
10901
11034
  return;
10902
11035
  }
10903
-
10904
- let shouldRevalidate = pendingRevalidation;
10905
- pendingRevalidation = false;
10906
- const { nextManifest, hmrRoutes, shouldRefreshRouteState } =
10907
- applyPendingRouteUpdates(router, routeModules, manifest, context);
10908
- // Loader updates must be visible during revalidation. Component-only routes
10909
- // stay staged until revalidation completes, matching React Router's HMR flow.
10910
- if (nextManifest && shouldRefreshRouteState) {
10911
- pendingComponentRouteRevalidation = false;
10912
- if (hmrRoutes) {
10913
- patchCurrentRouteMatches(router, hmrRoutes);
10914
- }
10915
- Object.assign(manifest, nextManifest);
10916
- await refreshRouteState(router);
10917
- shouldRevalidate = false;
10918
- } else if (nextManifest) {
10919
- if (hmrRoutes) {
10920
- patchCurrentRouteMatches(router, hmrRoutes);
10921
- }
10922
- Object.assign(manifest, nextManifest);
10923
- // The node compiler also emits an HDR revision for this route edit. If it
10924
- // did not arrive in this flush, consume that redundant revalidation later.
10925
- pendingComponentRouteRevalidation = !shouldRevalidate;
10926
- shouldRevalidate = false;
10927
- } else if (shouldRevalidate) {
10928
- if (pendingComponentRouteRevalidation) {
10929
- pendingComponentRouteRevalidation = false;
10930
- } else {
11036
+ flushing = true;
11037
+ try {
11038
+ let shouldRevalidate = pendingRevalidation;
11039
+ pendingRevalidation = false;
11040
+ const { nextManifest, hmrRoutes, shouldRefreshRouteState } =
11041
+ applyPendingRouteUpdates(router, routeModules, manifest, context);
11042
+ // Loader updates must be visible during revalidation. Component-only routes
11043
+ // stay staged until revalidation completes, matching React Router's HMR flow.
11044
+ if (nextManifest && shouldRefreshRouteState) {
11045
+ if (hmrRoutes) {
11046
+ patchCurrentRouteMatches(router, hmrRoutes);
11047
+ }
11048
+ Object.assign(manifest, nextManifest);
11049
+ await refreshRouteState(router);
11050
+ shouldRevalidate = false;
11051
+ } else if (nextManifest) {
11052
+ if (hmrRoutes) {
11053
+ patchCurrentRouteMatches(router, hmrRoutes);
11054
+ }
11055
+ Object.assign(manifest, nextManifest);
11056
+ }
11057
+ // A replay may represent several server edits, not just the component
11058
+ // update in this batch. Only an actual data revalidation can consume it.
11059
+ if (shouldRevalidate) {
10931
11060
  await revalidateRouter(router);
10932
11061
  }
11062
+ performReactRefresh();
11063
+ } finally {
11064
+ flushing = false;
11065
+ if (pendingRevalidation || pendingRouteUpdates.size > 0) scheduleFlush();
10933
11066
  }
10934
- performReactRefresh();
10935
11067
  }
10936
11068
 
10937
11069
  if (typeof window !== 'undefined' && import.meta.webpackHot) {
@@ -10939,21 +11071,14 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
10939
11071
  ${JSON.stringify(DEV_MANIFEST_UPDATE_EVENT)},
10940
11072
  applyManifestUpdate
10941
11073
  );
10942
- import.meta.webpackHot.accept(
10943
- ${JSON.stringify(hdrRevisionFilePath)},
10944
- () => {
10945
- latestHdrRevision = __hdrRevision;
10946
- scheduleReactRouterRevalidation();
10947
- }
11074
+ import.meta.webpackHot.on(
11075
+ ${JSON.stringify(DEV_HDR_UPDATE_EVENT)},
11076
+ receiveHdrRevision
10948
11077
  );
10949
11078
  }
10950
11079
  `)({
10951
- reactRefreshRuntimePath: devHmrRefreshRuntimePath,
10952
- hdrRevisionFilePath: devHdrSignal.filePath
10953
- }),
10954
- onNodeRebuildCommitted: ()=>{
10955
- devHmrEnabled && devHdrSignal.bump();
10956
- }
11080
+ reactRefreshRuntimePath: devHmrRefreshRuntimePath
11081
+ })
10957
11082
  } : void 0
10958
11083
  })), { manifestChunkNames } = modePlan, hasPendingRscNodeUpdate = !1, pendingRscNodeFiles = new Set();
10959
11084
  isRscMode && !isBuild && (api.onBeforeStartDevServer(({ server })=>{
@@ -10996,8 +11121,81 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
10996
11121
  getRouteTopology: routeTopology.getRouteTopology,
10997
11122
  initialRouteTopology: routeTopology.initialRouteTopology,
10998
11123
  onRouteTopologyChange: pluginOptions.onRouteTopologyChange
11124
+ }), manifestState = (({ api, isBuild, onPublish })=>{
11125
+ let latest = null, pending = new WeakMap();
11126
+ return isBuild && api.onBeforeEnvironmentCompile(({ environment })=>{
11127
+ 'web' === environment.name && (latest = null);
11128
+ }), api.onAfterEnvironmentCompile(({ environment, stats })=>{
11129
+ if ('web' !== environment.name) return;
11130
+ let snapshot = stats && !stats.hasErrors() ? pending.get(stats.compilation) : void 0;
11131
+ if (stats && pending.delete(stats.compilation), snapshot && stats) {
11132
+ var compilation;
11133
+ compilation = stats.compilation, latest = snapshot, onPublish(compilation, snapshot);
11134
+ } else isBuild && (latest = null);
11135
+ }), {
11136
+ stage (compilation, snapshot) {
11137
+ pending.set(compilation, snapshot);
11138
+ },
11139
+ read: ()=>latest
11140
+ };
11141
+ })({
11142
+ api,
11143
+ isBuild,
11144
+ onPublish: (compilation, snapshot)=>{
11145
+ writeServerManifestStamp(snapshot), devBackgroundResources.setManifest(snapshot.browser), isBuild || 'classic' !== modePlan.kind || modePlan.artifacts.devRuntime.captureWeb(compilation, snapshot.serverByEntryName);
11146
+ }
11147
+ }), persistedSnapshot = null;
11148
+ api.onBeforeCreateCompiler(()=>{
11149
+ if (!isBuild || 'classic' !== modePlan.kind || api.getNormalizedConfig().environments.web) return;
11150
+ let rebuildMessage = `[${PLUGIN_NAME}] Run a full build before building only the node environment; no compatible finalized browser manifest is available.`;
11151
+ try {
11152
+ let stamp = JSON.parse(readFileSync(serverManifestStampPath, 'utf8'));
11153
+ if (1 !== stamp.schema || !0 !== stamp.isBuild || stamp.appDirectory !== appDirectory || stamp.outputClientPath !== outputClientPath || stamp.assetPrefix !== assetPrefix || JSON.stringify(stamp.routes) !== JSON.stringify(routes) || 'string' != typeof stamp.snapshot?.server?.version || !stamp.snapshot?.serverByBundleId || !stamp.snapshot?.browser) throw Error(rebuildMessage);
11154
+ persistedSnapshot = createReactRouterManifestSnapshot({
11155
+ manifest: stamp.snapshot.browser,
11156
+ sri: stamp.snapshot.server.sri,
11157
+ moduleExportsByRouteId: stamp.snapshot.moduleExportsByRouteId,
11158
+ serverBuildPlan: {
11159
+ defaultEntryName: devServerBuildEntryName,
11160
+ serverBundleEntries: modePlan.artifacts.serverBundleEntries
11161
+ },
11162
+ routesByServerBundleId: modePlan.artifacts.routesByServerBundleId
11163
+ }), writeServerManifestStamp(persistedSnapshot);
11164
+ } catch (cause) {
11165
+ persistedSnapshotError = Error(rebuildMessage, {
11166
+ cause
11167
+ });
11168
+ }
10999
11169
  });
11000
- if (api.onAfterEnvironmentCompile(({ stats, environment })=>{
11170
+ let readManifestSnapshot = ()=>{
11171
+ if (persistedSnapshotError) throw persistedSnapshotError;
11172
+ return manifestState.read() ?? persistedSnapshot;
11173
+ };
11174
+ if (isBuild && 'classic' === modePlan.kind && (({ api, routeByFilePath, getSnapshot })=>{
11175
+ api.modifyRspackConfig((config, { environment })=>{
11176
+ 'node' === environment.name && (config.plugins ??= [], config.plugins.push({
11177
+ apply (compiler) {
11178
+ let name = 'ReactRouterNodeOnlyManifestValidation';
11179
+ compiler.hooks.thisCompilation.tap(name, (compilation)=>{
11180
+ compilation.hooks.afterOptimizeModules.tap(name, (modules)=>{
11181
+ let snapshot = getSnapshot();
11182
+ if (snapshot) for (let module of modules){
11183
+ if (!(module instanceof rspack.NormalModule)) continue;
11184
+ let route = routeByFilePath.get(external_pathe_resolve(module.resource.split('?')[0]));
11185
+ if (!route) continue;
11186
+ let exports = compilation.moduleGraph.getProvidedExports(module), saved = snapshot.browser.routes[route.id];
11187
+ if (!Array.isArray(exports) || !saved || exports.includes('loader') !== saved.hasLoader || exports.includes('action') !== saved.hasAction) throw Error(`Run a full build before building only the node environment: loader/action exports changed for route "${route.id}".`);
11188
+ }
11189
+ });
11190
+ });
11191
+ }
11192
+ }));
11193
+ });
11194
+ })({
11195
+ api,
11196
+ routeByFilePath,
11197
+ getSnapshot: ()=>persistedSnapshot
11198
+ }), api.onAfterEnvironmentCompile(({ stats, environment })=>{
11001
11199
  if ('web' === environment.name && (clientStats = createReactRouterManifestStats(stats?.compilation, manifestChunkNames), isRscMode && stats)) {
11002
11200
  let unsupported = ((compilation)=>{
11003
11201
  let unsupported = new Set();
@@ -11027,7 +11225,7 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
11027
11225
  logPerformance && performanceProfiler.flush(environment.name, {
11028
11226
  compilerLifecycleMs: roundMs(performance.now() - setupStartMs)
11029
11227
  });
11030
- }), 'classic' === modePlan.kind ? api.onAfterBuild(({ environments })=>effectRuntime.runPromise(tryPluginPromise(()=>runReactRouterPrerenderBuild({
11228
+ }), 'classic' === modePlan.kind ? api.onAfterBuild(({ environments, stats })=>stats?.hasErrors() ? void 0 : effectRuntime.runPromise(tryPluginPromise(()=>runReactRouterPrerenderBuild({
11031
11229
  api,
11032
11230
  hasWebEnvironment: !!environments.web,
11033
11231
  buildDirectory,
@@ -11039,8 +11237,8 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
11039
11237
  basename,
11040
11238
  future,
11041
11239
  routes,
11042
- latestBrowserManifest,
11043
- latestBrowserManifestModuleExports,
11240
+ latestBrowserManifest: readManifestSnapshot()?.browser ?? null,
11241
+ latestBrowserManifestModuleExports: readManifestSnapshot()?.moduleExportsByRouteId ?? {},
11044
11242
  clientStats,
11045
11243
  pluginOptions,
11046
11244
  appDirectory,
@@ -11050,7 +11248,7 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
11050
11248
  buildManifest: modePlan.artifacts.buildManifest,
11051
11249
  buildEndReactRouterConfig: resolvedConfigWithRoutes,
11052
11250
  buildEnd
11053
- })))) : api.onAfterBuild(({ environments })=>effectRuntime.runPromise(tryPluginPromise(()=>runReactRouterRscPrerenderBuild({
11251
+ })))) : api.onAfterBuild(({ environments, stats })=>stats?.hasErrors() ? void 0 : effectRuntime.runPromise(tryPluginPromise(()=>runReactRouterRscPrerenderBuild({
11054
11252
  api,
11055
11253
  hasWebEnvironment: !!environments.web,
11056
11254
  buildDirectory,
@@ -11417,7 +11615,7 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
11417
11615
  outputClientPath,
11418
11616
  performanceProfiler
11419
11617
  })) : (!function(api, routes, pluginOptions, appDirectory, assetPrefix = '/', routeChunkOptions, options) {
11420
- let getAssetPrefix = 'function' == typeof assetPrefix ? assetPrefix : ()=>assetPrefix, manifestChunkNames = options?.manifestChunkNames ?? ((routes, appDirectory, splitRouteModules = !1)=>{
11618
+ let getAssetPrefix = 'function' == typeof assetPrefix ? assetPrefix : ()=>assetPrefix, manifestChunkNames = new Set(options?.manifestChunkNames ?? ((routes, appDirectory, splitRouteModules = !1)=>{
11421
11619
  let chunkNames = new Set([
11422
11620
  'entry.client'
11423
11621
  ]);
@@ -11426,7 +11624,10 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
11426
11624
  if (chunkNames.add(routeEntryName), splitRouteModules && 'root' !== route.id) for (let exportName of routeChunkExportNames)chunkNames.add(getRouteChunkEntryName(routeEntryName, exportName));
11427
11625
  }
11428
11626
  return chunkNames;
11429
- })(routes, appDirectory, routeChunkOptions?.splitRouteModules), isBuild = !!routeChunkOptions?.isBuild, finalizeSri = !!(isBuild && (options?.subResourceIntegrity ?? options?.future?.unstable_subResourceIntegrity)), buildAndEmitManifest = async ({ assets, sources, compilation }, { withSri })=>{
11627
+ })(routes, appDirectory, routeChunkOptions?.splitRouteModules));
11628
+ manifestChunkNames.add(BROWSER_MANIFEST_ENTRY_NAME);
11629
+ let isBuild = !!routeChunkOptions?.isBuild, finalizeSri = !!(isBuild && (options?.subResourceIntegrity ?? options?.future?.unstable_subResourceIntegrity)), buildAndEmitManifest = async ({ assets, sources, compilation }, { withSri })=>{
11630
+ if (compilation.errors?.length) return;
11430
11631
  let currentAssetPrefix = getAssetPrefix(), stats = createReactRouterManifestStats(compilation, manifestChunkNames), { manifest, moduleExportsByRouteId } = await generateReactRouterManifestForDev(routes, pluginOptions, stats, appDirectory, currentAssetPrefix, createReactRouterManifestOptions({
11431
11632
  routeChunks: routeChunkOptions,
11432
11633
  routeModuleAnalysis: options?.routeModuleAnalysis
@@ -11434,18 +11635,22 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
11434
11635
  ...manifest
11435
11636
  };
11436
11637
  delete browserManifest.sri;
11437
- let browserManifestAsset = assets[BROWSER_MANIFEST_ASSET];
11438
- if (browserManifestAsset) {
11638
+ let browserManifestPaths = stats?.assetsByChunkName?.[BROWSER_MANIFEST_ENTRY_NAME]?.filter((name)=>"javascript" === getManifestAssetType(name, stats.assetTypesByName)) ?? [
11639
+ 'static/js/virtual/react-router/browser-manifest.js'
11640
+ ];
11641
+ for (let browserManifestPath of isBuild ? [] : browserManifestPaths){
11642
+ let browserManifestAsset = assets[browserManifestPath];
11643
+ if (!browserManifestAsset) continue;
11439
11644
  let originalSource = browserManifestAsset.source().toString(), serializedManifest = jsesc(browserManifest, {
11440
11645
  es6: !0
11441
11646
  }), newSource = originalSource.replace(/["'`]PLACEHOLDER["'`]/, ()=>serializedManifest);
11442
- compilation.updateAsset(BROWSER_MANIFEST_ASSET, new sources.RawSource(newSource));
11647
+ compilation.updateAsset(browserManifestPath, new sources.RawSource(newSource));
11443
11648
  }
11444
11649
  if (isBuild) {
11445
- let entryAssets = stats?.assetsByChunkName?.['entry.client'], entryJsAssets = entryAssets?.filter(isManifestJsAsset) || [], manifestPath = getReactRouterManifestPath({
11650
+ let entryAssets = stats?.assetsByChunkName?.['entry.client'], entryJsAssets = entryAssets?.filter((name)=>"javascript" === getManifestAssetType(name, stats?.assetTypesByName)) || [], manifestPath = getReactRouterManifestPath({
11446
11651
  version: manifest.version,
11447
11652
  isBuild: !0,
11448
- entryModulePath: entryJsAssets[0]
11653
+ entryModulePath: (entryJsAssets[0] ?? '').replace(/[?#].*$/, '')
11449
11654
  }), manifestSource = `window.__reactRouterManifest=${jsesc(browserManifest, {
11450
11655
  es6: !0
11451
11656
  })};`, source = new sources.RawSource(manifestSource);
@@ -11453,8 +11658,13 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
11453
11658
  }
11454
11659
  let sri = withSri ? ((stats, compilation, assetPrefix = '/')=>{
11455
11660
  let sri = {};
11456
- for (let asset of stats?.assets ?? [])addIntegrity(sri, assetPrefix, asset.name, asset.integrity);
11457
- if ('function' == typeof compilation?.getAssets) for (let asset of compilation.getAssets())isManifestJsAsset(asset.name) && addIntegrity(sri, assetPrefix, asset.name, computeSubresourceIntegrity(asset.source) ?? asset.info?.integrity);
11661
+ for (let asset of stats?.assets ?? [])'string' == typeof asset.name && isManifestJsAsset(asset.name) && addIntegrity(sri, assetPrefix, asset.name, asset.integrity);
11662
+ if ('function' == typeof compilation?.getAssets) for (let asset of compilation.getAssets()){
11663
+ let assetType = asset.info?.assetType ?? ('boolean' == typeof asset.info?.javascriptModule ? "javascript" : void 0);
11664
+ "javascript" === getManifestAssetType(asset.name, void 0 === assetType ? void 0 : {
11665
+ [asset.name]: assetType
11666
+ }) && addIntegrity(sri, assetPrefix, asset.name, computeSubresourceIntegrity(asset.source) ?? asset.info?.integrity);
11667
+ }
11458
11668
  return Object.keys(sri).length > 0 ? sri : void 0;
11459
11669
  })(compilation.getStats().toJson({
11460
11670
  all: !1,
@@ -11478,36 +11688,16 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
11478
11688
  future,
11479
11689
  manifestChunkNames,
11480
11690
  routeModuleAnalysis,
11481
- onManifest: (manifest, sri, moduleExportsByRouteId, context)=>{
11482
- var compilation;
11483
- return compilation = context.compilation, void performanceProfiler.recordSync('web', 'manifest:stage', 'virtual/react-router/browser-manifest', ()=>{
11484
- latestBrowserManifest = manifest, devBackgroundResources.setManifest(manifest), latestBrowserManifestModuleExports = moduleExportsByRouteId;
11485
- let baseServerManifest = {
11486
- ...manifest,
11487
- sri: sri
11488
- };
11489
- latestServerManifest = baseServerManifest;
11490
- let manifestsByEntryName = {
11491
- [devServerBuildEntryName]: baseServerManifest
11492
- };
11493
- if ('classic' === modePlan.kind) {
11494
- let stamp;
11495
- for (let { bundleId, entryName } of modePlan.artifacts.serverBundleEntries){
11496
- let bundleRoutes = modePlan.artifacts.routesByServerBundleId[bundleId];
11497
- if (!bundleRoutes) continue;
11498
- let routeIds = new Set(Object.keys(bundleRoutes)), filteredRoutes = Object.fromEntries(Object.entries(manifest.routes).filter(([routeId])=>routeIds.has(routeId))), bundleManifest = {
11499
- ...baseServerManifest,
11500
- routes: filteredRoutes
11501
- };
11502
- latestServerManifestsByBundleId[bundleId] = bundleManifest, manifestsByEntryName[entryName] = bundleManifest;
11503
- }
11504
- (stamp = JSON.stringify({
11505
- manifest: latestServerManifest,
11506
- bundles: latestServerManifestsByBundleId
11507
- })) !== (existsSync(serverManifestStampPath) ? readFileSync(serverManifestStampPath, 'utf8') : void 0) && fs_extra.outputFileSync(serverManifestStampPath, stamp), isBuild || modePlan.artifacts.devRuntime.captureWeb(compilation, manifestsByEntryName);
11508
- }
11509
- });
11510
- }
11691
+ onManifest: (manifest, sri, moduleExportsByRouteId, context)=>performanceProfiler.recordSync('web', 'manifest:stage', 'virtual/react-router/browser-manifest', ()=>manifestState.stage(context.compilation, createReactRouterManifestSnapshot({
11692
+ manifest,
11693
+ sri,
11694
+ moduleExportsByRouteId,
11695
+ serverBuildPlan: {
11696
+ defaultEntryName: devServerBuildEntryName,
11697
+ serverBundleEntries: modePlan.artifacts.serverBundleEntries
11698
+ },
11699
+ routesByServerBundleId: modePlan.artifacts.routesByServerBundleId
11700
+ })))
11511
11701
  }), (({ api, resolvedServerOutput, performanceProfiler, getLatestServerManifest, serverManifestStampPath, getLatestServerManifestByBundleId, routes, pluginOptions, getClientStats, appDirectory, getAssetPrefix, routeChunkOptions, routeModuleAnalysis, routeTransformRunner, routeByFilePath, routeChunkConfig, isBuild, splitRouteModules, useRouteModuleTransformApi, ssr, isSpaMode, rootRoutePath, outputClientPath, isDevHmrEnabled = ()=>!1, onRouteModuleAnalysis })=>{
11512
11702
  let transformRouteModule = async (args)=>performanceProfiler.record(args.environment?.name, 'route:module', args.resource, async ()=>routeTransformRunner({
11513
11703
  kind: 'routeModule',
@@ -11543,7 +11733,9 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
11543
11733
  if (existsSync(serverManifestStampPath) ? args.addDependency(serverManifestStampPath) : args.addMissingDependency(serverManifestStampPath), args.resource.includes('virtual/react-router/server-build')) return {
11544
11734
  code: args.code
11545
11735
  };
11546
- let bundleMatch = args.resource.match(/virtual\/react-router\/server-manifest(?:-([^?]+))?/), bundleId = bundleMatch?.[1]?.replace(/\.js$/, ''), latestServerManifest = getLatestServerManifest(), manifest = (latestServerManifest ? (bundleId && getLatestServerManifestByBundleId(bundleId)) ?? latestServerManifest : null) ?? await getReactRouterManifestForDev(routes, pluginOptions, getClientStats(), appDirectory, getAssetPrefix(), createReactRouterManifestOptions({
11736
+ let bundleMatch = args.resource.match(/virtual\/react-router\/server-manifest(?:-([^?]+))?/), bundleId = bundleMatch?.[1]?.replace(/\.js$/, ''), latestServerManifest = getLatestServerManifest();
11737
+ if (isBuild && !latestServerManifest) throw Error(`[${PLUGIN_NAME}] Production server manifest requested before the browser manifest was finalized.`);
11738
+ let manifest = (latestServerManifest ? (bundleId && getLatestServerManifestByBundleId(bundleId)) ?? latestServerManifest : null) ?? await getReactRouterManifestForDev(routes, pluginOptions, getClientStats(), appDirectory, getAssetPrefix(), createReactRouterManifestOptions({
11547
11739
  routeChunks: routeChunkOptions,
11548
11740
  routeModuleAnalysis
11549
11741
  }));
@@ -11646,9 +11838,9 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
11646
11838
  api,
11647
11839
  resolvedServerOutput,
11648
11840
  performanceProfiler,
11649
- getLatestServerManifest: ()=>latestServerManifest,
11841
+ getLatestServerManifest: ()=>readManifestSnapshot()?.server ?? null,
11650
11842
  serverManifestStampPath,
11651
- getLatestServerManifestByBundleId: (bundleId)=>latestServerManifestsByBundleId[bundleId],
11843
+ getLatestServerManifestByBundleId: (bundleId)=>readManifestSnapshot()?.serverByBundleId[bundleId],
11652
11844
  routes,
11653
11845
  pluginOptions,
11654
11846
  getClientStats: ()=>clientStats,