Use lightningcss to implement CSS packager#8492
Conversation
Benchmark ResultsKitchen Sink ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. React HackerNews 🚨
Timings
Cold BundlesNo bundles found, this is probably a failed build... Cached BundlesNo bundles found, this is probably a failed build... AtlasKit Editor 🚨
Timings
Cold BundlesNo bundles found, this is probably a failed build... Cached BundlesNo bundles found, this is probably a failed build... Three.js ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. |
# Conflicts: # packages/optimizers/css/package.json # packages/packagers/css/package.json # packages/packagers/css/src/CSSPackager.js # packages/transformers/css/package.json # packages/transformers/css/src/CSSTransformer.js # yarn.lock
| contents += `@import "${url}";\n`; | ||
| lineOffset++; | ||
| } | ||
| let res = await bundleAsync({ |
There was a problem hiding this comment.
What can we do for the REPL where bundleAsync doesn't exist?
There was a problem hiding this comment.
It does exist now (as of a few months ago)! Uses emscripten's asyncify transform to turn the rust function into a coroutine.
There was a problem hiding this comment.
We will need to usual alias (and devdep) to the wasm package though like in the CSS packager and optimizer:
parcel/packages/optimizers/css/package.json
Lines 34 to 36 in 6801029
There was a problem hiding this comment.
added the dep. are we just relying on the transformer to initialize the wasm module? looks like CSSOptimizer doesn't do it, so I just followed that.
There was a problem hiding this comment.
Good point, I apparently forgot that in the optimizer. It's not really safe to assume that every worker running the packager also has also at least once invoked the CSS transformer.
* upstream/v2: (22 commits) Add source map support to the inline-require optimizer (#9511) [Web Extension] Add content script world property to manifest schema validation (#9510) feat: add getCurrentPackageManager (#9505) Default Bundler Contributor Notes (#9488) rename parentAsset to root for msb config and remove unstable (#9486) Macro errors -> v2 (#9501) Statically evaluate constants referenced by macros (#9487) Multiple css bundles in Entry bundle groups issue (#9023) Fix macro issues (#9485) Bump follow-redirects from 1.14.7 to 1.15.4 (#9475) Revert more CI changes to centos job (#9472) Use lightningcss to implement CSS packager (#8492) Fixup CI again (#9471) Clippy and use napi's Either3 (#9047) Upgrade to eslint 8 (#8580) Add support for JS macros (#9299) Fixup REPL CI (#9467) Drop per-pipeline transformation cache (#9459) Upgrade some CI actions (#9466) REPL (#9365) ...
Fixes #8162
This re-implements the CSS packager using the
bundleAsyncfunction oflightningcss. This means there is support for bundling@importrules with cascade layers and supports conditions, and improved support for media queries. The logic for bundling these is fairly complicated, and can't really be done fully correctly without an AST.Need to do some testing on real world apps, and some perf testing.