Skip to content

feat: support custom source map implementations - #18

Closed
intellild wants to merge 1 commit into
codex/rstack-rename-sourcemap-featurefrom
codex/rstack-custom-sourcemap-trait
Closed

intellild wants to merge 1 commit into
codex/rstack-rename-sourcemap-featurefrom
codex/rstack-custom-sourcemap-trait

Conversation

@intellild

@intellild intellild commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Superseded by #22, which passes the source map through PrinterOptions.

Summary

  • Add a SourceMap trait and a standalone custom_sourcemap feature.
  • Keep parcel_sourcemap behind the existing sourcemap feature and provide its trait adapter.
  • Make printer and bundler source-map handling generic over the selected implementation.
  • Use the source-index fix from fix: preserve output source indices when bundling CSS #23 with custom map writers, including writers that deduplicate paths or allocate non-contiguous IDs.
  • Add benchmarks and focused bundler regression tests.

Example

Consumers can provide their own source-map writer:

let mut map = MySourceMap::default();
let result = stylesheet.to_css(PrinterOptions::default(), Some(&mut map))?;

For example, a bundler can canonicalize two imported paths to one output source index while mappings still point to the correct source content.

Validation

  • cargo check --locked --workspace --all-features
  • cargo test --locked -p rspack-lightningcss --all-features (189 passed)
  • cargo test --locked -p rspack-lightningcss --no-default-features --features bundler --test test_bundler_source_map (3 passed with the custom implementation)
  • cargo check --locked -p rspack-lightningcss --no-default-features --features visitor --example custom_at_rule --test test_custom_parser

by OpenAI Codex

Copilot AI balanced review requested due to automatic review settings November 4, 2026 06:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T06:55:31.838580Z 6c2c168 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c2c168591

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/printer.rs
Comment on lines +133 to +134
let _ = (source_root, data_url);
None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve input-map support through mutable-reference adapters

When a caller passes a mutable-reference wrapper as the writer (for example, Some(&mut map_ref) where map_ref: &mut ParcelSourceMap), this implementation silently disables inline source-map remapping even though the underlying implementation supports it. Both StyleSheet::to_css_impl and Bundler::load_file use S::from_data_url, so choosing S = &mut T loses the original source locations. If bundling used the concrete writer and printing subsequently uses the reference adapter, the bundled CSS source was never registered and the fallback mappings can even reference nonexistent output sources. Preserve access to an owned input-map reader rather than making the reference adapter unconditionally report that input maps are unreadable.

Useful? React with 👍 / 👎.

@codspeed

codspeed Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 12 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing codex/rstack-custom-sourcemap-trait (d710de8) with codex/rstack-rename-sourcemap-feature (43b17bc)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@intellild
intellild added this pull request to stack #19 November 4, 2026 06:57
@intellild
intellild force-pushed the codex/rstack-custom-sourcemap-trait branch from 6c2c168 to 73c0f35 Compare November 4, 2026 07:06
@intellild
intellild force-pushed the codex/rstack-to-css-printer-trait branch from c6503a0 to 88b1907 Compare November 4, 2026 07:06
@intellild
intellild force-pushed the codex/rstack-custom-sourcemap-trait branch from 73c0f35 to 2b38861 Compare November 4, 2026 07:45
@intellild
intellild force-pushed the codex/rstack-to-css-printer-trait branch from 88b1907 to 2ed94ad Compare November 4, 2026 07:45
@intellild
intellild force-pushed the codex/rstack-custom-sourcemap-trait branch from 2b38861 to e334341 Compare November 4, 2026 09:00
@intellild
intellild removed this pull request from stack #19 November 4, 2026 09:03
@intellild
intellild changed the base branch from codex/rstack-to-css-printer-trait to codex/rstack-rename-sourcemap-feature November 4, 2026 09:04
@intellild
intellild added this pull request to stack #21 November 4, 2026 09:04
@intellild
intellild removed this pull request from stack #21 November 4, 2026 09:34
@intellild
intellild force-pushed the codex/rstack-rename-sourcemap-feature branch from 44992a0 to 43b17bc Compare November 4, 2026 09:35
@intellild
intellild force-pushed the codex/rstack-custom-sourcemap-trait branch from e334341 to d710de8 Compare November 4, 2026 09:35
@intellild intellild closed this Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants