{"id":14278789,"url":"https://github.com/rspack-contrib/rsbuild-plugin-vue2-jsx","last_synced_at":"2025-04-14T10:13:23.049Z","repository":{"id":253646004,"uuid":"844069269","full_name":"rspack-contrib/rsbuild-plugin-vue2-jsx","owner":"rspack-contrib","description":"An Rsbuild plugin for Vue 2 JSX / TSX support.","archived":false,"fork":false,"pushed_at":"2025-04-01T03:12:03.000Z","size":124,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-14T10:13:19.131Z","etag":null,"topics":["rsbuild","rsbuild-plugin","rspack"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rspack-contrib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-18T09:35:25.000Z","updated_at":"2025-04-01T03:12:05.000Z","dependencies_parsed_at":"2024-11-10T02:18:30.631Z","dependency_job_id":"d5f4bd97-075e-4eca-a47f-105be8ac3f09","html_url":"https://github.com/rspack-contrib/rsbuild-plugin-vue2-jsx","commit_stats":null,"previous_names":["rspack-contrib/rsbuild-plugin-vue2-jsx"],"tags_count":2,"template":false,"template_full_name":"rspack-contrib/rsbuild-plugin-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-vue2-jsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-vue2-jsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-vue2-jsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-vue2-jsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rspack-contrib","download_url":"https://codeload.github.com/rspack-contrib/rsbuild-plugin-vue2-jsx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248860167,"owners_count":21173342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rsbuild","rsbuild-plugin","rspack"],"created_at":"2024-08-23T07:01:03.956Z","updated_at":"2025-04-14T10:13:23.024Z","avatar_url":"https://github.com/rspack-contrib.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Rsbuild Plugins"],"readme":"# @rsbuild/plugin-vue2-jsx\n\nProvides support for Vue 2 JSX / TSX syntax. The plugin internally integrates [@vue/babel-preset-jsx](https://github.com/vuejs/jsx-vue2).\n\n\u003cp\u003e\n  \u003ca href=\"https://npmjs.com/package/@rsbuild/plugin-vue2-jsx\"\u003e\n   \u003cimg src=\"https://img.shields.io/npm/v/@rsbuild/plugin-vue2-jsx?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"npm version\" /\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"license\" /\u003e\n\u003c/p\u003e\n\n## Usage\n\nInstall:\n\n```bash\nnpm add @rsbuild/plugin-vue2-jsx -D\n```\n\nAdd plugin to your `rsbuild.config.ts`:\n\n```ts\n// rsbuild.config.ts\nimport { pluginBabel } from \"@rsbuild/plugin-babel\";\nimport { pluginVue2 } from \"@rsbuild/plugin-vue2\";\nimport { pluginVue2Jsx } from \"@rsbuild/plugin-vue2-jsx\";\n\nexport default {\n  plugins: [\n    pluginBabel({\n      include: /\\.(?:jsx|tsx)$/,\n    }),\n    pluginVue2(),\n    pluginVue2Jsx(),\n  ],\n};\n```\n\nSince the Vue JSX plugin relies on Babel for compilation, you need to additionally add the [@rsbuild/plugin-babel](https://www.npmjs.com/package/@rsbuild/plugin-babel).\n\nBabel compilation will introduce extra overhead, in the example above, we use `include` to match `.jsx` and `.tsx` files, thereby reducing the performance cost brought by Babel.\n\nAfter registering the plugin, you can use Vue's [JSX / TSX syntax](https://github.com/vuejs/jsx-vue2) in `.jsx`, `.tsx`, and `.vue` files.\n\n## Vue SFC\n\nWhen using JSX in Vue SFC, you need to add `lang=\"jsx\"` or `lang=\"tsx\"` to the `\u003cscript\u003e` tag.\n\n- JSX:\n\n```html title=\"App.vue\"\n\u003cscript lang=\"jsx\"\u003e\n  const vnode = \u003cdiv\u003ehello\u003c/div\u003e;\n\u003c/script\u003e\n```\n\n- TSX:\n\n```html title=\"App.vue\"\n\u003cscript lang=\"tsx\"\u003e\n  const vnode = \u003cdiv\u003ehello\u003c/div\u003e;\n\u003c/script\u003e\n```\n\n## Options\n\nIf you need to customize the compilation behavior of Vue JSX, you can use the following configs.\n\n### vueJsxOptions\n\nOptions passed to `@vue/babel-preset-jsx`, please refer to the [@vue/babel-preset-jsx documentation](https://github.com/vuejs/jsx-vue2) for detailed usage.\n\n- **Type:**\n\n```ts\ntype VueJSXPresetOptions = {\n  compositionAPI?: boolean | string;\n  functional?: boolean;\n  injectH?: boolean;\n  vModel?: boolean;\n  vOn?: boolean;\n};\n```\n\n- **Default:**\n\n```ts\nconst defaultOptions = {\n  injectH: true,\n};\n```\n\n- **Example:**\n\n```ts\npluginVue2Jsx({\n  vueJsxOptions: {\n    injectH: false,\n  },\n});\n```\n\n## License\n\n[MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-vue2-jsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-vue2-jsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-vue2-jsx/lists"}