vuejs / babel-plugin-jsx

JSX for Vue 3
https://vue-jsx-explorer.netlify.app
MIT License
1.7k stars 143 forks source link

Can this plugin be used in a browser? #672

Closed Devmond closed 10 months ago

Devmond commented 10 months ago

🧐 Problem Description

There are two questions in the closed issue list asking about how this plugin could be used in a browser, both unfortunately have the same curt response. Can you please state clearly on the read me page whether this plugin is usable in a browser or not?

I have exported a bundle via browserify but the code below doesn't work, it complains about not recognizing the vue plugin.

💻 Sample code

let jsxCode = Babel.transform("", {"presets": ["@vue/babel-plugin-jsx"]}).code;

🚑 Other information

sxzz commented 10 months ago

Sure. See https://github.com/sxzz/vue-jsx-playground/blob/main/src/components/jsx-editor.vue#L42-L43 and some configurations are needed as well. https://github.com/sxzz/vue-jsx-playground/blob/main/vite.config.ts#L18-L20