Skip to content

fix(dev): declare an empty source map for route chunk placeholders when an export can't be split - #15520

Open
huuyafwww wants to merge 2 commits into
remix-run:mainfrom
huuyafwww:fix/route-chunk-placeholder-sourcemap
Open

huuyafwww wants to merge 2 commits into
remix-run:mainfrom
huuyafwww:fix/route-chunk-placeholder-sourcemap

Conversation

@huuyafwww

Copy link
Copy Markdown

Hi. While looking at the source map handling that #15440 added to the route module transforms, I noticed one path still returns a plain string: the placeholder that react-router:split-route-modules emits for a ?route-chunk= entry whose export turned out not to be splittable (or when splitting is disabled). With build.sourcemap enabled on Vite 7, Rollup reports this for every such route:

[plugin react-router:split-route-modules] Sourcemap is likely to be incorrect: a plugin (react-router:split-route-modules) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help

This returns the placeholder with map: { mappings: "" }, the same shape #15440 used for the generated route barrel, so Rollup knows there is nothing to map back to. rolldown doesn't warn either way, so nothing changes on Vite 8.

The existing "emits source maps for split route chunks" test asserted that stderr doesn't contain SOURCEMAP_BROKEN, but Vite prints the message without the code, so that check couldn't fail; it now looks for the message text. The new test builds a route whose clientLoader shares a top-level variable with the default export, so it can't be split, with sourcemap: true, and checks that the placeholder chunk is emitted without the warning. It fails on main with the Vite 7 template and passes here on both templates. Typecheck, lint, format, changes:validate and the split-route-modules integration suite are green on Chromium.

…en an export can't be split

The placeholder `react-router:split-route-modules` returns for a
`?route-chunk=` entry whose export turned out not to be splittable was
still a plain string, so with `build.sourcemap` enabled Rollup warned
that the plugin dropped the source map. It now returns the same
`map: { mappings: "" }` shape that remix-run#15440 uses for the route barrel.

The existing source map test looked for the `SOURCEMAP_BROKEN` code,
which Vite never prints, so it checks the message text now, and a new
test covers the placeholder path on both Vite templates.
@brophdawg11 brophdawg11 added pkg:@react-router/dev feat:vite aw:review Admin command: review an issue or pull request labels Sep 17, 2026
@brophdawg11

Copy link
Copy Markdown
Contributor

@remix-run-bot

@remix-run-bot remix-run-bot removed the aw:review Admin command: review an issue or pull request label Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants