vite-babel-plugin
raw JSON → 0.0.2 verified Sat Apr 25 auth: no javascript deprecated
A Vite plugin that enables Babel transformation during the build process, allowing developers to apply custom Babel plugins and presets. Current version is 0.0.2, but it is marked as deprecated/unmaintained. It only supports Vite 1.x (vite@^1.0.0-rc.9 || ^1.0.0), which is also deprecated. For modern Vite projects (v2+), use official Vite plugins or @rollup/plugin-babel. This plugin is more of a proof-of-concept than a production-ready tool.
Common errors
error Cannot find module 'vite-babel-plugin' ↓
cause Package not installed or installed as devDependency incorrectly.
fix
Run 'npm install vite-babel-plugin --save-dev' and ensure node_modules is present.
error TypeError: viteBabel is not a function ↓
cause Using default import when named export was intended; or vice versa.
fix
Use 'import viteBabel from 'vite-babel-plugin'' for default or 'import { viteBabel } from 'vite-babel-plugin'' for named.
error Error: Vite version 2.x is not supported ↓
cause Incompatible Vite version; plugin requires Vite 1.x.
fix
Downgrade Vite to 1.x or use an alternative Babel plugin for Vite 2+.
Warnings
deprecated Package is deprecated; no updates since 2020. Use @rollup/plugin-babel or official Vite plugins instead. ↓
fix Migrate to @rollup/plugin-babel with Vite's rollupOptions.
breaking Only works with Vite 1.x; incompatible with Vite 2+. ↓
fix Upgrade Vite to v2+ and switch to compatible Babel integration.
gotcha Babel config should not include @babel/preset-env for library mode, as it may transform ES modules incorrectly. ↓
fix Use module:false in @babel/preset-env targets or avoid preset-env for library builds.
Install
npm install vite-babel-plugin yarn add vite-babel-plugin pnpm add vite-babel-plugin Imports
- default wrong
const viteBabel = require('vite-babel-plugin')correctimport viteBabel from 'vite-babel-plugin' - viteBabel (named) wrong
import viteBabel from 'vite-babel-plugin'correctimport { viteBabel } from 'vite-babel-plugin' - types (if any)
import type { ViteBabelOptions } from 'vite-babel-plugin'
Quickstart
import { defineConfig } from 'vite';
import viteBabel from 'vite-babel-plugin';
export default defineConfig({
plugins: [
viteBabel({
babelConfig: {
plugins: [['@babel/plugin-transform-arrow-functions', { spec: true }]],
presets: ['@babel/preset-env']
}
})
]
});