{"id":20660,"library":"vite-plugin-babel","title":"vite-plugin-babel","description":"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.","status":"active","version":"1.6.0","language":"javascript","source_language":"en","source_url":"https://github.com/owlsdepartment/vite-plugin-babel","tags":["javascript","vite-plugin","vite","babel"],"install":[{"cmd":"npm install vite-plugin-babel","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-babel","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-babel","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for Babel transformation to work.","package":"@babel/core","optional":false},{"reason":"Peer dependency; the plugin is designed to work with Vite versions 2.7 to 8.","package":"vite","optional":false}],"imports":[{"note":"Default export is a function. ESM-only; require() will fail.","wrong":"const vitePluginBabel = require('vite-plugin-babel')","symbol":"vitePluginBabel","correct":"import vitePluginBabel from 'vite-plugin-babel'"},{"note":"Named export also available if you prefer destructuring. Both work, but named export is explicit.","wrong":"import vitePluginBabel from 'vite-plugin-babel'","symbol":"vitePluginBabel","correct":"import { vitePluginBabel } from 'vite-plugin-babel'"},{"note":"Internal helper exported from a subpath. Not part of main public API.","wrong":"import { transformContent } from 'vite-plugin-babel'","symbol":"transformContent","correct":"import { transformContent } from 'vite-plugin-babel/helpers'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport vitePluginBabel from 'vite-plugin-babel';\n\nexport default defineConfig({\n  plugins: [\n    vitePluginBabel({\n      babelConfig: {\n        presets: ['@babel/preset-env'],\n        plugins: ['@babel/plugin-transform-runtime'],\n      },\n      filter: /\\.[jt]sx?$/,\n      include: /src\\/.*/,\n      exclude: /node_modules/,\n      babelHelpers: 'runtime',\n    }),\n  ],\n});","lang":"typescript","description":"Configures Vite with vite-plugin-babel, enabling Babel transforms for JavaScript/TypeScript files in src/ during dev and build."},"warnings":[{"fix":"Upgrade to Vite 2.7+ or pin to vite-plugin-babel@0.x.","message":"Version 1.0.0 dropped support for Vite 2.x and below.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure files are included in Vite's module graph. Use filter/include/exclude options to control which files are transformed.","message":"Babel transformations only apply to files that Vite processes; files excluded by Vite's resolve.alias or optimizeDeps.exclude may not be transformed.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add '@babel/plugin-transform-runtime' to babelConfig.plugins and install @babel/runtime.","message":"When using babelHelpers: 'runtime', you must install @babel/plugin-transform-runtime and @babel/runtime.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Replace filter with include and exclude arrays of glob patterns or regexps.","message":"The 'filter' option (RegExp) is deprecated in favor of 'include' and 'exclude' arrays.","severity":"deprecated","affected_versions":">=1.5.0"},{"fix":"Set esbuild.target to 'esnext' or disable esbuild's transform for .ts files.","message":"If 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install: npm install @babel/core --save-dev","cause":"@babel/core is not installed as a peer dependency.","error":"Error: Cannot find module '@babel/core'"},{"fix":"Use default import: import vitePluginBabel from 'vite-plugin-babel'","cause":"Importing the package incorrectly (e.g., using named import instead of default).","error":"TypeError: vitePluginBabel is not a function"},{"fix":"Replace filter with include/exclude in plugin options.","cause":"Using the deprecated filter option in version >=1.5.0.","error":"Error: The 'filter' option is deprecated. Use 'include' and 'exclude' instead."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}