Skip to content

[Bug]: missing sourcesContent entries are emitted as "" instead of null #16347

Closed

Description

@Sheraff

Investigated and written with the help of an AI coding agent (Claude); reproduced locally.

System Info

System: Linux 6.12 x64 (Debian 13)
Binaries: Node 26.12.1, npm 12.2.0
npmPackages: @rspack/core 2.3.0 (also 2.2.9); webpack 5.112.2 for comparison

Details

A loader returns a map without sourcesContent:

// loader.js
module.exports = function (code) {
  this.callback(null, code, {
    version: 3,
    sources: [this.resourcePath],
    names: [],
    mappings: 'AAAA',
  })
}

When another source in the same chunk map has text, Rspack writes "" for the missing entry, and webpack writes null:

rspack: sourcesContent for b.js = ""
webpack: sourcesContent for b.js = null

Chrome DevTools uses any non-null entry as the file's text (CompilerScriptMapping.ts), so it shows b.js as an empty file. With null, it fetches the source URL instead. So on Rspack, a loader can't leave the text out and let DevTools load the file from the server.

The "" seems to come from rspack_sources (helpers.rs, source.rs).

Expected: null for a missing entry, as in webpack.

Related: #16348 (filling the text when the map is emitted).

Reproduce link

https://github.com/Sheraff/rspack-sources-content-null

Reproduce Steps

  1. npm install
  2. npm run repro

Activity

  1. self-assigned this
    on Oct 30, 2026
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