Rust api: How to use bundler and transform both jsx? #7375
-
I'm using the bundle example which works well, but I can't figure out how one would adapt this to also transform jsx. Could someone point me in the right direction? 🥺 🙏🏻 |
Beta Was this translation helpful? Give feedback.
Answered by
MolotovCherry
May 11, 2023
Replies: 1 comment
-
Ok, I figured, in the Loader sections Syntax::Es(EsConfig {
jsx: true,
..Default::default()
}), Then we can fold it with let mut jsx_folder = swc_ecma_transforms_react::jsx::<SingleThreadedComments>(
Default::default(),
None,
Default::default(),
Mark::new(),
Mark::new(),
);
let module = module.fold_with(&mut jsx_folder); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
MolotovCherry
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, I figured, in the Loader sections
parse_file_as_module()
, we need to pass an EsConfig with jsx true,Then we can fold it with
swc_ecma_transforms_react
. If I am doing this wrong, please let me know. Seems to work though