You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As was correctly noticed in the issue's comment, the approach with extracting metadata via special comment is extremely unstable and inconvenient to use.
As one of the solutions for this problem, @SukkaW suggested using napi-rs to compile StyleX code and to allow access to metadata and to a source map in the babel plugin's style with no need to use the "metacomment" approach. This approach is more stable and convenient to use for writing plugins and tools for working with StyleX, ex. for creating a plugin for Webpack, Rollup, or other tools.
Proposal
The basic implementation of rs compiler is written in Rust and it's based on the napi-rs library. The compiler is a simple javascript function that takes the source code and options as input and returns the transformed code, metadata, and source map as output.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Motivation
As was correctly noticed in the issue's comment, the approach with extracting metadata via special comment is extremely unstable and inconvenient to use.
As one of the solutions for this problem, @SukkaW suggested using
napi-rs
to compile StyleX code and to allow access to metadata and to a source map in the babel plugin's style with no need to use the "metacomment" approach. This approach is more stable and convenient to use for writing plugins and tools for working with StyleX, ex. for creating a plugin forWebpack
,Rollup
, or other tools.Proposal
The basic implementation of
rs
compiler is written in Rust and it's based on thenapi-rs
library. The compiler is a simple javascript function that takes the source code and options as input and returns the transformed code, metadata, and source map as output.The source code of the compiler is located here:
crates/stylex-compiler-rs
.The demo of using
rs
compiler is located here:crates/stylex-compiler-rs/transform.js
.Example
Source code:
Transformation:
Output:
Pull Request: #38
Special thanks to @SukkaW for the recommendation. I would like to get a feedback about this RFC.
Beta Was this translation helpful? Give feedback.
All reactions