A Babel plugin that transforms indirect imports through barrel files (index.js) into direct imports. Current stable version is 1.0.23. The plugin supports Webpack, Vite, and Jest, resolving imports to improve bundling performance and avoid circular dependencies. Key differentiators include support for package.json exports field, jest.mock/requireActual, Webpack aliases, and caching. It is designed to be used as a Babel plugin with minimal configuration, offering options like alias, extensions, modulesDirs, and moduleIgnorePatterns. Version 1.0.23 adds moduleIgnorePatterns and fixes jest.mock bugs.
npm install babel-plugin-transform-barrelsVerified import paths — ran on the pinned version, not inferred.
Shows installation, basic configuration with all options, and an example import transformation.
Update your config to use 'alias' and 'extensions' instead of the old option names.
Use 'babel-plugin-transform-barrels' as the plugin name in your babel config.
Ensure you have barrel files (index.js) that re-export modules, and that imports point to the barrel directory.
Set executorName to 'jest' when using Jest.
Clear cache manually (e.g., delete the .cache folder) or disable caching during development.
Add executorName: 'webpack' (or 'jest' or 'vite') to the plugin options.
Create an index.js file in the components folder that re-exports the desired modules, or correct the import path.
Ensure alias is an object with string keys and values, e.g., { '@': './src' }.Run npm install --save-dev babel-plugin-transform-barrels.
No dependency data recorded yet.