Skip to content

Incorrect debug ID is produced when using devtool: "hidden-source-map-debugids" #20133

Description

@in-doge-we-trust

Bug Description

When I either set a devtool config value to hidden-source-map-debugids or use a webpack.SourceMapDevToolPlugin with a configuration matching hidden-source-map-debugids, the debug ID appended to the generated .js file is corrupted – it looks like //# debugId=<hash>false instead of //debugId=<hash>.

Link to Minimal Reproduction and step to reproduce

https://github.com/in-doge-we-trust/webpack-debugids-append-issue-repro

Case #1 (webpack.SourceMapDevToolPlugin is used manually) steps:

  1. Run npm install
  2. Run npm run build

Case #2 (devtool set to hidden-source-map-debugids) steps:

  1. Run npm run clear (optional)
  2. Run npm run build

Expected Behavior

debugId value in the source-map file matches the value in //# debugId=<hash> comment appended to the generated .js.

Actual Behavior

debugId value in the source-map file is correct, while //# debugId=<hash> comment has false appended to the end and looks like this – //# debugId=<hash>false.

Environment

Binaries:
    Node: 22.18.0
    npm: 10.9.3
Packages:
    webpack: 5.102.1 => 5.102.1
    webpack-cli: 6.0.1 => 6.0.1

Is this a regression?

No

Last Working Version

No response

Additional Context

As a temporary workaround, developers can force the append to be a new line character:

// webpack.config.js
const config = {
  // --snip--

  plugins: [
    new webpack.SourceMapDevToolPlugin({
      filename: "[file].map",

      debugIds: true,
      append: '\n', // force append value

      module: true,
      columns: true,
    }),
  ],
};

export default config;

In that case, append doesn't corrupt the injected debugId, so it looks correct.

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions