Skip to content

Support source maps - #27

Merged
marcoroth merged 1 commit into
mainfrom
source-maps
Nov 8, 2026
Merged

marcoroth merged 1 commit into
mainfrom
source-maps

Conversation

@marcoroth

@marcoroth marcoroth commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

This pull request adds source_map, input_source_map and project_root to LightningCSS.transform and the first and last of them to LightningCSS.bundle, with the generated map on Result#map.

An asset pipeline that compiles Sass and then transforms the CSS with Lightning CSS had to drop its source map at this step, or keep one that pointed at CSS that no longer matched the output.

result = LightningCSS.transform(css, filename: "main.css", source_map: true, input_source_map: sass_map, minify: true)

result.map
#=> "{\"version\":3,\"sourceRoot\":null,\"mappings\":\"ACCA,oBACA\",\"sources\":[\"main.css\",\"app.scss\"],...}"

The map is built the same way as in the Node binding, and the output for the examples in the issue matches it exactly. parcel_sourcemap is now a direct dependency, at the version Lightning CSS already resolves to.

bundle adds every file it read to sources with its contents. Lightning CSS loads those files in parallel, so the order of sources can differ between runs, while the mappings stay correct for that order.

An input_source_map that can't be read raises a LightningCSS::OptionError, where the Node binding ignores it. So does one passed without source_map: true, since it would otherwise do nothing. bundle refuses input_source_map, because a bundle reads many files, and transform_style_attribute refuses all three.

Resolves #26

@marcoroth
marcoroth merged commit 8ce6e6a into main Nov 8, 2026
11 checks passed
@marcoroth
marcoroth deleted the source-maps branch November 8, 2026 06:50
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.

Support source maps (source_map, input_source_map, project_root)

1 participant