Registry / devops / vite-plugin-babel-compiler

vite-plugin-babel-compiler

JSON →
library0.4.1jsnpmunverified

A Vite plugin that replaces esbuild transpilation with Babel for files matching include/exclude patterns. Version 0.4.1 is the latest stable release; the plugin is actively maintained with infrequent updates. It enables experimental JavaScript features (e.g., decorators, class properties) that esbuild does not support, providing fine-grained control via Babel configurations. Unlike alternative plugins like @mdx-js/rollup or manual esbuild configure, this plugin integrates seamlessly with Vite's build pipeline and supports both development and production builds. Requires @babel/core as a peer dependency and Vite >=2.0.0.

npm install vite-plugin-babel-compiler
INSTALL
IMPORT
SIG · VITE-PLUGIN-BABEL-
V
vite-plugin-babel-compiler
devopsjavascriptv0.4.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import babel from 'vite-plugin-babel-compiler'
const babel = require('vite-plugin-babel-compiler')
ESM-only; default export is the plugin factory function.
babel (named)
import { babel } from 'vite-plugin-babel-compiler'
import { Babel } from 'vite-plugin-babel-compiler'
Named export also available as 'babel' but default is preferred.
type Plugin
import type { Plugin } from 'vite'
Plugin types are from Vite, not this package.

Configures Vite to use Babel compiler with decorator and class property plugins.

import { defineConfig } from 'vite'; import babel from 'vite-plugin-babel-compiler'; export default defineConfig({ plugins: [ babel({ babel: { plugins: [ ['@babel/plugin-proposal-decorators', { legacy: true }], ['@babel/plugin-proposal-class-properties', { loose: true }] ] } }) ] });
Debug
Known issues
breakingVite 5 dropped support for some plugin hooks; this plugin may not work with Vite 5+.
fix
Use vite-plugin-babel-compiler@latest or check compatibility; consider using @vitejs/plugin-babel if available.
affects: >=5.0.0
deprecatedThe `babel` option shape changed in v0.3.0; older configs with top-level options fail silently.
fix
Wrap all Babel options under `babel` key. See README.
affects: >=0.3.0
gotchaInclude/exclude patterns must be arrays of strings or RegExp; misconfiguration causes all files to be transpiled by esbuild.
fix
Ensure `include` and `exclude` are arrays. e.g., `include: ['src/**/*.tsx']`
affects: >=0.0.0
gotchaRunning both dev and build modes: plugin applies to both; avoid double Babel compilation if another plugin also transforms.
fix
Use conditionals: `plugins: [process.env.NODE_ENV === 'development' ? babel({...}) : null]`
affects: >=0.0.0
Errors
Common errors & fixes
Error: Plugin babel-compiler: Must provide @babel/core as a peer dependency.
Missing @babel/core package.
fix
npm install -D @babel/core
TypeError: babel is not a function
Importing default export incorrectly; using named export 'babel' but expecting function.
fix
import babel from 'vite-plugin-babel-compiler' (default) or import { babel } from '...'
Error: Could not resolve 'vite-plugin-babel-compiler'
Package not installed or Vite resolving incorrectly.
fix
npm install -D vite-plugin-babel-compiler
SyntaxError: Invalid or unexpected token (if Babel not applied)
Plugin not configured or include/exclude patterns exclude the file.
fix
Check that the file path matches `include` patterns and is not in `exclude`.
Upgrade
Version history
0.4.1latest on npm
Audit
Dependencies
@babel/corerequiredRequired peer dependency for Babel compilation
viterequiredPeer dependency; plugin designed for Vite >=2.0.0
Agent activity
2 hits · last 30 days
node
2
Resources
vite-plugin-babel-compiler — npm install vite-plugin-babel-compiler · libregistry