# babel-plugin-vue-jsx-hmr

> babel plugin for vue3 jsx HMR

Latest version **1.0.2** (published 2026-08-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-vue-jsx-hmr
pnpm add babel-plugin-vue-jsx-hmr
yarn add babel-plugin-vue-jsx-hmr
bun add babel-plugin-vue-jsx-hmr
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2026-08-11 |
| First published | 2024-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 17.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | liyincode |
| Maintainers | liyincode |
| Keywords | babel, plugin, webpack, rspack, rsbuild, vue3, jsx, hmr |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-vue-jsx-hmr
- Repository: https://github.com/liyincode/babel-plugin-vue-jsx-hmr
- Homepage: https://github.com/liyincode/babel-plugin-vue-jsx-hmr#readme
- Issues: https://github.com/liyincode/babel-plugin-vue-jsx-hmr/issues
- npm.io page: https://npm.io/package/babel-plugin-vue-jsx-hmr

## Dependencies (2)

- [@babel/core](https://npm.io/package/@babel/core.md) ^7.24.3
- [@vue/babel-plugin-jsx](https://npm.io/package/@vue/babel-plugin-jsx.md) ^1.2.2

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2026-08-11
- 1.0.1 — 2026-08-11
- 1.0.0 — 2024-04-07
- 1.0.0-beta.2 — 2024-03-31
- 1.0.0-beta.1 — 2024-03-30

## README

# babel-plugin-vue-jsx-hmr [![npm](https://img.shields.io/npm/v/babel-plugin-vue-jsx-hmr)](https://www.npmjs.com/package/babel-plugin-vue-jsx-hmr)

A Babel plugin that adds Vue 3 JSX and TSX HMR support to Webpack and Rspack.

## Usage

### Webpack and Rspack

```bash
npm i -D babel-loader @babel/core @babel/preset-typescript \
  @vue/babel-plugin-jsx babel-plugin-vue-jsx-hmr
```

```js
// webpack.config.cjs or rspack.config.cjs
module.exports = {
    module: {
        rules: [
            {
                test: /\.[jt]sx?$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-typescript'],
                        plugins: [
                            '@vue/babel-plugin-jsx',
                            'babel-plugin-vue-jsx-hmr',
                        ],
                    },
                },
            },
        ],
    },
    resolve: {
        extensions: ['.tsx', '.ts', '.jsx', '...'],
    },
    devServer: {
        hot: true,
    },
}
```

The plugin can remain enabled in production; Webpack and Rspack remove its
injected code when HMR is disabled.

### Vite

Use the official
[`@vitejs/plugin-vue-jsx`](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx)

## HMR detection

HMR injection requires both conditions:

- The component must be exported.
- The component must be declared by calling `defineComponent` in a root-level
  variable or export declaration.

### Supported patterns

```jsx
import { defineComponent } from 'vue'

// named exports w/ variable declaration: ok
export const Foo = defineComponent({})

// named exports referencing variable declaration: ok
const Bar = defineComponent({ render() { return <div>Test</div> }})
export { Bar }

// default export call: ok
export default defineComponent({ render() { return <div>Test</div> }})

// default export referencing variable declaration: ok
const Baz = defineComponent({ render() { return <div>Test</div> }})
export default Baz
```

### Unsupported patterns

```jsx
// not using `defineComponent` call
export const Bar = { ... }

// not exported
const Foo = defineComponent(...)
```

---
_Source: https://npm.io/package/babel-plugin-vue-jsx-hmr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
