diff --git a/.changeset/nine-eyes-beam.md b/.changeset/nine-eyes-beam.md new file mode 100644 index 0000000000..d402445cd4 --- /dev/null +++ b/.changeset/nine-eyes-beam.md @@ -0,0 +1,5 @@ +--- +"@react-router/dev": patch +--- + +Improve chunk error logging when a chunk cannot be found during the build diff --git a/contributors.yml b/contributors.yml index 18c55bf2e3..c90598e12d 100644 --- a/contributors.yml +++ b/contributors.yml @@ -359,6 +359,7 @@ - ThornWu - tiborbarsi - timdorr +- timfisher - TkDodo - tkindy - tlinhart diff --git a/packages/react-router-dev/vite/plugin.ts b/packages/react-router-dev/vite/plugin.ts index 3905414211..d83af46e5a 100644 --- a/packages/react-router-dev/vite/plugin.ts +++ b/packages/react-router-dev/vite/plugin.ts @@ -331,12 +331,12 @@ const getReactRouterManifestBuildAssets = ( prependedAssetFilePaths: string[] = [] ): ReactRouterManifest["entry"] & { css: string[] } => { let entryChunk = resolveChunk(ctx, viteManifest, entryFilePath); - invariant(entryChunk, "Chunk not found"); + invariant(entryChunk, `Chunk not found: ${entryFilePath}`); // This is here to support prepending client entry assets to the root route let prependedAssetChunks = prependedAssetFilePaths.map((filePath) => { let chunk = resolveChunk(ctx, viteManifest, filePath); - invariant(chunk, "Chunk not found"); + invariant(chunk, `Chunk not found: ${filePath}`); return chunk; });