Registry / devops / vite-plugin-babel

vite-plugin-babel

JSON →
library1.6.0jsnpmunverified

Integrates Babel transformation directly into Vite's dev server and build pipeline, allowing Babel plugins to run on all processed files during serve, build, and SSR. Version 1.6.0 supports Vite 2.7+ through 8 (inclusive) and requires @babel/core >=7.0.0. Unlike most Vite Babel integrations that only affect build, this plugin applies Babel across all Vite commands, making it useful for polyfills, code transforms, and custom syntax that Babel plugins provide. It's a thin wrapper that adds Babel as a Vite plugin, respecting Vite's cache and file-watching behavior.

npm install vite-plugin-babel
INSTALL
IMPORT
SIG · VITE-PLUGIN-BABEL
V
vite-plugin-babel
devopsjavascriptv1.6.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

vitePluginBabel
import vitePluginBabel from 'vite-plugin-babel'
const vitePluginBabel = require('vite-plugin-babel')
Default export is a function. ESM-only; require() will fail.
vitePluginBabel
import { vitePluginBabel } from 'vite-plugin-babel'
import vitePluginBabel from 'vite-plugin-babel'
Named export also available if you prefer destructuring. Both work, but named export is explicit.
transformContent
import { transformContent } from 'vite-plugin-babel/helpers'
import { transformContent } from 'vite-plugin-babel'
Internal helper exported from a subpath. Not part of main public API.

Configures Vite with vite-plugin-babel, enabling Babel transforms for JavaScript/TypeScript files in src/ during dev and build.

import { defineConfig } from 'vite'; import vitePluginBabel from 'vite-plugin-babel'; export default defineConfig({ plugins: [ vitePluginBabel({ babelConfig: { presets: ['@babel/preset-env'], plugins: ['@babel/plugin-transform-runtime'], }, filter: /\.[jt]sx?$/, include: /src\/.*/, exclude: /node_modules/, babelHelpers: 'runtime', }), ], });
Debug
Known issues
breakingVersion 1.0.0 dropped support for Vite 2.x and below.
fix
Upgrade to Vite 2.7+ or pin to vite-plugin-babel@0.x.
affects: >=1.0.0
gotchaBabel transformations only apply to files that Vite processes; files excluded by Vite's resolve.alias or optimizeDeps.exclude may not be transformed.
fix
Ensure files are included in Vite's module graph. Use filter/include/exclude options to control which files are transformed.
affects: >=1.0.0
gotchaWhen using babelHelpers: 'runtime', you must install @babel/plugin-transform-runtime and @babel/runtime.
fix
Add '@babel/plugin-transform-runtime' to babelConfig.plugins and install @babel/runtime.
affects: >=1.0.0
deprecatedThe 'filter' option (RegExp) is deprecated in favor of 'include' and 'exclude' arrays.
fix
Replace filter with include and exclude arrays of glob patterns or regexps.
affects: >=1.5.0
gotchaIf you use TypeScript, Babel may strip types and conflict with Vite's esbuild transform. Ensure esbuild is configured to not strip types if Babel handles it.
fix
Set esbuild.target to 'esnext' or disable esbuild's transform for .ts files.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module '@babel/core'
@babel/core is not installed as a peer dependency.
fix
Install: npm install @babel/core --save-dev
TypeError: vitePluginBabel is not a function
Importing the package incorrectly (e.g., using named import instead of default).
fix
Use default import: import vitePluginBabel from 'vite-plugin-babel'
Error: The 'filter' option is deprecated. Use 'include' and 'exclude' instead.
Using the deprecated filter option in version >=1.5.0.
fix
Replace filter with include/exclude in plugin options.
Upgrade
Version history
1.6.0latest on npm
Audit
Dependencies
@babel/corerequiredPeer dependency required for Babel transformation to work.
viterequiredPeer dependency; the plugin is designed to work with Vite versions 2.7 to 8.
Agent activity
13 hits · last 30 days
node
10
Resources
vite-plugin-babel — npm install vite-plugin-babel · libregistry