How to build plugins to support CSS-in-JS with evaluation phase #6594
-
Some Zero Runtime CSS-in-JS solutions (for example: Linaria and unreleased Stylex from Meta) now highly rely on JS runtime evaluation phase using Babel. They need to evaluate JS expressions and then replace Is there anything we can do to migrate this kind of tools to SWC? Using SWC with these tools hurts build time performance a lot due to running the Babel part inevitably. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I do not believe there is a way to dynamically evaluate values in the current plugin implementation. After all, SWC runs in a rust's host runtime context and plugin also runs in its wasm runner, not in the JS context. |
Beta Was this translation helpful? Give feedback.
-
If you want to evaluate expressions in compile time, see https://rustdoc.swc.rs/swc_ecma_minifier/eval/struct.Evaluator.html |
Beta Was this translation helpful? Give feedback.
I do not believe there is a way to dynamically evaluate values in the current plugin implementation. After all, SWC runs in a rust's host runtime context and plugin also runs in its wasm runner, not in the JS context.