Repository navigation
feat: support custom source map implementations - #1
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This reverts commit ca480a6.
intellild
force-pushed
the
codex/rebase-pr-1289
branch
from
October 21, 2026 08:39
e7e0071 to
1aeaa9d
Compare
Merging this PR will not alter performance
Performance Changes
Comparing Footnotes
|
intellild
added a commit
that referenced
this pull request
Oct 22, 2026
Keep the shared custom-property extraction imports alongside the PrinterTrait refactor from PR #1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Support custom source map implementations so consumers such as Rspack can write mappings directly into their own representation instead of generating a Parcel source map and converting it afterward.
This brings parcel-bundler/lightningcss#1289, rebased onto current
master(5aec9d4), into this repository.ToCssover the sealedPrinterTraitand introduce theSourceMapwriter abstraction.custom_sourcemap; the defaultsourcemapfeature continues to provide the Parcel implementation, whilebundlercan use custom maps without requiring it.NonNegativevalues and ordered CSS Modules exports/references.rspack_lightningcsspackage name,0.1.0version, and release configuration; adapt examples, benchmarks, the lockfile, and new source map tests to the renamed crate.Examples
A bundler with its own map type can enable
custom_sourcemap(orbundler) with default features disabled, implementrspack_lightningcss::printer::SourceMap, and pass its writer directly:Avoiding the intermediate Parcel map removes the map conversion step and allows consumers to omit the built-in map dependency. With source map support enabled, callers that do not need a map pass
None::<&mut ()>.A custom writer may return source indices such as 100 and 110, or reuse an existing index for two equivalent paths. The bundler keeps internal stylesheet indices separate and translates them to these writer indices when emitting mappings.
The printer trait also needs to preserve generated line positions: its default
std::fmt::Write::write_charimplementation wrote blank lines without incrementing the map's generated line. Delegating to the printer's existing character writer restores the original positions; the CLI source map regression test now passes. The custom at-rule example also converts formatting errors toPrinterError.Validation
cargo fmt --all -- --checkandgit diff --check: passed.cargo test --all-features: 172 tests passed, including CLI source maps, custom bundler source indices, and doctests.cargo check --lib --no-default-features: passed with no extra features and separately withcustom_sourcemap,bundler, andserde.cargo clippy --all-targets --all-features: completed with warnings.cargo check --workspace --all-targets --features rspack_lightningcss/cli,rspack_lightningcss/jsonschema,rspack_lightningcss/serde,rspack_lightningcss/visitor,rspack_lightningcss/into_owned,rspack_lightningcss/substitute_variables: passed.not_unsafe_ptr_arg_dereferrors from#[js_function(1)]in unchangednode/src/lib.rs(lines 18 and 24). The selectorsbenchfeature also requires nightly and was excluded from the stable workspace checks.5aec9d4: the full Rust suite, four library feature configurations, core clippy, and workspace compilation passed using the locked dependencies.by OpenAI Codex