4 releases (2 breaking)
0.3.0 | Dec 7, 2021 |
---|---|
0.2.1 | Nov 29, 2021 |
0.2.0 | Nov 27, 2021 |
0.1.0 | Nov 7, 2021 |
#9 in #abi-stable
48 downloads per month
Used in swc_ecma_plugin_ast
370KB
8K
SLoC
rplugin
General utilities for building plugin system for processing AST. Refer to rustdoc for more details.
lib.rs
:
AST processing plugin system.
Designed as a general crate, to support using it from other libraries too. This depends on the [abi_stable] crate.
Why new crate?
I (kdy1) wants to pass the AST data to plugin without having to change the type of AST nodes.
e.g. Using RBox instead of Box is not an acceptable option, as many users already use swc as a crate.
Instead, we just use proc-macro to convert ast into something that can be passed directly to the plugin, using StableAbi. In plugin, we convert it back to normal AST before processing, so the plugin authors can use exactly same code as core transforms. Of course, this is slow, but it's only slow if it's compared to the changing type. It's much faster than serializing/deserializing.
In short, we do
Normal AST -> Plugin AST -> Normal AST -> plugin -> Normal AST -> Plugin AST -> Normal AST
Note for potential users
Currently this crate depends on swc_common
, but if there's a request, I
can change it to not depend on swc_common
.
Dependencies
~9–15MB
~194K SLoC