Skip to content

fix(source-maps): avoid loader request in lightningcss source maps#13830

Open
zalishchuk wants to merge 1 commit intoweb-infra-dev:mainfrom
zalishchuk:fix-lightningcss-loader-sourcemap-source
Open

fix(source-maps): avoid loader request in lightningcss source maps#13830
zalishchuk wants to merge 1 commit intoweb-infra-dev:mainfrom
zalishchuk:fix-lightningcss-loader-sourcemap-source

Conversation

@zalishchuk
Copy link
Copy Markdown

Summary

Fix builtin:lightningcss-loader sourcemap source names so loader-chain requests are not exposed as user-visible sources.

PR #13436 fixed previous-loader sourcemap composition by wrapping Lightning CSS output in SourceMapSource, but the loader used loader_context.context.module.request() as the generated source name. In a loader chain, that request includes entries such as css-loader!...!builtin:lightningcss-loader!...!sass-loader!...!file.scss, which can make Chrome DevTools link injected CSS rules to index.js / loader internals instead of the original CSS or SCSS file.

This change keeps the existing inner_source_map: loader_context.take_source_map() composition behavior, but uses the actual resource filename as the intermediate source name. It also extends the existing Sass previous-source-map regression test to assert that final CSS sourcemap sources do not include loader internals.

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings April 25, 2026 17:02
@zalishchuk zalishchuk requested a review from JSerFeng as a code owner April 25, 2026 17:02
@github-actions github-actions Bot added the release: bug fix release: bug related release(mr only) label Apr 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes builtin:lightningcss-loader sourcemap source naming so that loader-chain requests (e.g. ...!builtin:lightningcss-loader!...!sass-loader!...) are not exposed as user-visible sources, improving DevTools source attribution when composing sourcemaps from previous loaders.

Changes:

  • Switch Lightning CSS sourcemap “source name” from the full module request (including loader chain) to the actual resource filename/path.
  • Extend the existing Sass previous-source-map config case to assert that final CSS sourcemap sources do not contain builtin:lightningcss-loader or sass-loader.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/rspack_loader_lightningcss/src/lib.rs Uses the resource filename/path (not loader-chain module request) for Lightning CSS sourcemap source naming and composition.
tests/rspack-test/configCases/builtin-lightningcss-loader/sass-previous-source-map/rspack.config.js Adds regression assertions ensuring final sourcemap sources don’t include loader internals.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zalishchuk zalishchuk force-pushed the fix-lightningcss-loader-sourcemap-source branch from 459de32 to daaa0f9 Compare April 25, 2026 17:20
@chenjiahan chenjiahan requested a review from SyMind April 26, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: injectStyles + lightningcss-loader makes DevTools link CSS rules to index.js

2 participants