babel-plugin-fully-specified
raw JSON →A Babel plugin (v1.3.1) that automatically adds mandatory file extensions to import paths, transforming bare specifiers like './path' into fully-specified paths like './path/index.js'. It targets authors of ESM packages with 'type': 'module' in package.json, ensuring compliance with Node.js ESM mandatory file extension rules. The plugin resolves directory imports to index files with the correct extension, supports TypeScript/TSX, and offers options for custom extension lists and package inclusion. Alternative tools include manual rewriting or other Babel plugins, but this plugin's focus on batch transformation for build pipelines sets it apart. Released in Jan 2026, it has active maintenance and supports dynamic import detection but not transformation.
Common errors
error Module not found: Error: Can't resolve './path' in '/path/to/file' ↓
error Error: Cannot find module 'babel-plugin-fully-specified' ↓
error TypeError: (0 , _fullySpecified.default) is not a function ↓
Warnings
breaking Dynamic imports are not transformed; they will remain bare-specified. ↓
gotcha Plugin may incorrectly prioritize file over directory when both exist (e.g., './path' and './path.js'), potentially resolving to the file without index extension. ↓
breaking For packages listed in includePackages, the plugin adds extensions to all imports from those packages, which may break Node.js resolution for packages that are not fully-specified already. ↓
deprecated The option 'esExtensionDefault' may be renamed in future versions; check changelog for updates. ↓
Install
npm install babel-plugin-fully-specified yarn add babel-plugin-fully-specified pnpm add babel-plugin-fully-specified Imports
- default wrong
import fullySpecified from 'babel-plugin-fully-specified'correctmodule.exports = require('babel-plugin-fully-specified') - babel-plugin-fully-specified wrong
plugins: [require('babel-plugin-fully-specified')]correctplugins: ['babel-plugin-fully-specified'] - BabelPluginFullySpecified wrong
import { BabelPluginFullySpecified } from 'babel-plugin-fully-specified'; plugins: [BabelPluginFullySpecified]correctInternal server error