Generate AST transformers from config#5337
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via npm install rollup/rollup#generate-ast-transformerNotice: Ensure you have installed Rust nightly. If you haven't installed it yet, please first see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust, then see https://rust-lang.github.io/rustup/concepts/channels.html to learn how to install Rust nightly. or load it into the REPL: |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #5337 +/- ##
==========================================
- Coverage 98.81% 98.81% -0.01%
==========================================
Files 232 232
Lines 8983 8993 +10
Branches 2342 2345 +3
==========================================
+ Hits 8877 8886 +9
Misses 46 46
- Partials 60 61 +1 ☔ View full report in Codecov by Sentry. |
This allows to inline node if possible and denotes inlined nodes in the type.
Avoid Rust field constants for duplicated nodes to avoid warnings.
b9af278 to
1a8f720
Compare
|
This PR has been released as part of rollup@4.9.6. You can test it via |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
This changes how the converters from SWC AST to binary and from binary to JavaScript AST work. Previously, all of them were hand-crafted, which means it was extremely important that every single node was properly checked, all indices aligned and all fields were converted in the right way and order.
To make this easier, the JavaScript converter is now fully generated from a script that reads a config file and automatically assigns indices and orders fields. It also generates constants for the Rust code so that field order is aligned.
To have the same level of efficiency, field types in Rust can contain an "_INLINED_FIELDNAME" suffix which indicates if there is a field that is not referenced via its position but is rather directly added to a node as the last field. In that case, this field needs to be converted first. If the inlined field changes, the type name changes, which ensures we know that the Rust code needs to be updated.
The bigger picture here, though, is that we eventually want to