Skip to content

[Feature]: fill missing sourcesContent from the module resource when emitting source maps #16348

Closed

Description

@Sheraff

Written with the help of an AI coding agent (Claude); reproduced locally on @rspack/core 2.3.0 and webpack 5.112.2.

What problem does this feature solve?

A loader that turns one file into several modules (vue-loader blocks; in our case TanStack Router splitting a route file into a route module and lazy chunks) has two options for its maps' sourcesContent:

Today the only way to get both is to fill sourcesContent in the emitted .map assets during processAssets. That parses and re-serializes the maps on the JS thread on every rebuild.

What does the proposed API of configuration look like?

An opt-in that fills missing sourcesContent entries from the module's resource file when the devtool plugin emits a map, after module hashes are computed. For example:

new rspack.SourceMapDevToolPlugin({
  filename: '[file].map',
  fillSourcesContent: true,
})

Name, shape, and whether it belongs on devtool are up to you. webpack has no equivalent that I know of.

Activity

  1. self-assigned this
    on Oct 30, 2026
  2. SyMind commented on Nov 17, 2026

    @SyMind
    Member

    After investigating this, I don’t currently see a small, robust solution on Rspack’s side.

    Browsers associate source maps with specific scripts through the SourceMap response header or a sourceMappingURL comment. Updating the .map file alone does not automatically refresh the map attached to an already-loaded script. With Rspack’s current HMR pipeline, source-map changes therefore need to participate in invalidation, even when the generated JavaScript is unchanged.

    Filling sourcesContent only when emitting the final map does not address this synchronization problem.

    For TanStack, the more practical trade-offs may be:

    • Omit sourcesContent from these split modules’ loader maps. To preserve original-source debugging, the sources URLs would need to be fetchable.
    • Stop generating source maps for these split modules, accepting the reduced debugging support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions