Skip to content
Source
Sign inSign up
TanStack/bling

WIP: SWC plugin #2

ClosedThisen(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/2/headopened

Showing 7 changed files with 65 additions and 0 deletions (loading 4).

x
0 of 7 viewed, 7 left
5 additions and 0 deletions.cargo/configAdded
View file
@@ -0,0 +1,5 @@
+# These command aliases are not final, may change
+[alias]
+# Alias to build actual plugin binary for the specified target.
+build-wasi = "build --target wasm32-wasi"
+build-wasm32 = "build --target wasm32-unknown-unknown"
48 additions and 0 deletionspackages/swc-plugin/src/lib.rsAdded
View file
@@ -0,0 +1,48 @@
+use swc_core::ecma::{
+ ast::Program,
+ transforms::testing::test,
+ visit::{as_folder, FoldWith, VisitMut},
+};
+use swc_core::plugin::{plugin_transform, proxies::TransformPluginProgramMetadata};
+​
+pub struct TransformVisitor;
+​
+impl VisitMut for TransformVisitor {
+ // Implement necessary visit_mut_* methods for actual custom transform.
+ // A comprehensive list of possible visitor methods can be found here:
+ // https://rustdoc.swc.rs/swc_ecma_visit/trait.VisitMut.html
+}
+​
+/// An example plugin function with macro support.
+/// `plugin_transform` macro interop pointers into deserialized structs, as well
+/// as returning ptr back to host.
+///
+/// It is possible to opt out from macro by writing transform fn manually
+/// if plugin need to handle low-level ptr directly via
+/// `__transform_plugin_process_impl(