Skip to content

Rust api: How to use bundler and transform both jsx? #7375

Closed Answered by MolotovCherry
MolotovCherry asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, I figured, in the Loader sections parse_file_as_module(), we need to pass an EsConfig with jsx true,

Syntax::Es(EsConfig {
    jsx: true,
    ..Default::default()
}),

Then we can fold it with swc_ecma_transforms_react. If I am doing this wrong, please let me know. Seems to work though

        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);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MolotovCherry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant