How do I get the "raw" source code of an AST node in a plugin? #4961
-
I am trying to implement something similiar to this babel plugin as swc-plugin. You can configure a component that will receive the raw, uncompiled JSX markup of its children as a prop, e.g.: Input: <Demo>
<Button>Hello</Button>
</Demo> Output: <Demo code={`<Button>Hello</Button>`}>
<Button>Hello</Button>
</Demo> I noticed that every AST-node has a I am wondering if this is possible at all, maybe I am misunderstanding what the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You may able to try few interfaces around |
Beta Was this translation helpful? Give feedback.
You may able to try few interfaces around
SourceMapper
, like https://github.com/swc-project/swc/blob/main/crates/swc_plugin_proxy/src/source_map/plugin_source_map_proxy.rs#L175=