Registry / web-framework / vite-plugin-barrel

vite-plugin-barrel

JSON →
library0.4.1jsnpmunverified

Vite plugin to optimize barrel (re-export) file imports, improving build performance for packages with many exports like @mui/icons-material. Current stable version is 0.4.1, released monthly. Requires Vite ^5 and Node >=18. Uses SWC under the hood via swc-plugin-barrel; watch out for @swc/core version compatibility. Key differentiator: dedicated barrel-import optimization for Vite, inspired by Next.js optimizePackageImports, with integration support for @vitejs/plugin-react-swc.

npm install vite-plugin-barrel
INSTALL
IMPORT
SIG · VITE-PLUGIN-BARREL
V
vite-plugin-barrel
web-frameworkjavascriptv0.4.1
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

barrel
import { barrel } from 'vite-plugin-barrel'
import barrel from 'vite-plugin-barrel'
Named export, not default.
swc_plugin_barrel
import { swc_plugin_barrel } from 'vite-plugin-barrel'
const { swc_plugin_barrel } = require('vite-plugin-barrel')
ESM only; no CJS distribution.
defineConfig from vite
import { defineConfig } from 'vite'

Configures vite-plugin-barrel to optimize imports from @mui/material and @mui/icons-material, improving build performance by 50%+.

import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { barrel } from 'vite-plugin-barrel'; export default defineConfig({ plugins: [ react(), barrel({ packages: ['@mui/material', '@mui/icons-material'], }), ], });
Debug
Known issues
breakingv0.4.x requires @swc/core compatibility with v1.7.0-v1.7.27; v0.2.x-0.3.x requires @swc/core 1.6.x.
fix
Pin @swc/core to match plugin version range as documented.
affects: >=0.2.0
gotchaIf using @vitejs/plugin-react-swc, the swc_plugin_barrel must be passed to react plugin via its plugins option, and barrel() must be called with experimental.integration: 'plugin-react-swc'.
fix
Follow the integration example in README, passing swc_plugin_barrel to react's plugins array.
affects: >=0.2.0
gotchaOnly works with named imports from barrel packages; default imports or deep imports may not be optimized.
fix
Use named imports like import { Button } from '@mui/material' instead of import Mui from '@mui/material'.
affects: >=0.1.0
gotchaThe cache root defaults to node_modules/.cache; ensure this path is writable.
fix
If cache issues, set cacheRoot option explicitly.
affects: >=0.4.1
Errors
Common errors & fixes
Error: The swc_plugin_barrel package is not compatible with the current @swc/core version.
Mismatched @swc/core version installed.
fix
Check swc_compat_range_docs and install compatible @swc/core (e.g., npm install @swc/core@1.6.7 for v0.2.x-0.3.x).
TypeError: barrel is not a function
Default import instead of named import.
fix
Use import { barrel } from 'vite-plugin-barrel'.
Cannot find module 'vite-plugin-barrel' or its corresponding type declarations.
Missing package or incorrect installation.
fix
Run pnpm add vite-plugin-barrel and ensure tsconfig includes types.
Upgrade
Version history
0.4.1latest on npm
Audit
Dependencies
viterequiredpeer dependency, required ^5
Agent activity
4 hits · last 30 days
node
4
Resources
vite-plugin-barrel — npm install vite-plugin-barrel · libregistry