-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optimizer plugin for new CSS compiler #7340
Conversation
|
let map; | ||
if (result.map != null) { | ||
map = new SourceMap(options.projectRoot); | ||
map.addVLQMap(JSON.parse(result.map)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we'd return a parcel source map directly from @parcel/css. I think we can only return a buffer though, not an actual node source map object (they could be using different versions). But still should be faster than returning and re-parsing VLQ/JSON.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the buffer have a stable format/"ABI"?
Benchmark ResultsKitchen Sink ✅
Timings
Cold Bundles
Cached Bundles
React HackerNews ✅
Timings
Cold Bundles
Cached Bundles
AtlasKit Editor ✅
Timings
Cold BundlesNo bundle changes detected. Cached Bundles
Three.js ✅
Timings
Cold Bundles
Cached Bundles
|
This adds a
@parcel/optimizer-css
plugin, which uses @parcel/css, our new CSS minifier written in Rust. It's significantly faster than cssnano (see readme linked above for benchmarks). For now, it's experimental, so not included in the default config.I'm actually not sure if we want this to eventually be a transformer rather than an optimizer. Eventually it will also perform the work of the current CSS transformer, e.g. extracting dependencies, and there aren't many CSS minification opportunities that will be effective cross file, so probably ok to perform minification in the transformer as well. For now, I put it in an optimizer because minification is the first target.