{"id":19065,"library":"babel-plugin-fully-specified","title":"babel-plugin-fully-specified","description":"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.","status":"active","version":"1.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/tujoworker/fully-specified","tags":["javascript","babel","babel-plugin","import","fully-specified","mandatory file extension"],"install":[{"cmd":"npm install babel-plugin-fully-specified","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-fully-specified","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-fully-specified","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as a peer dependency for plugin execution; the plugin is loaded by Babel which must be present in the project.","package":"@babel/core","optional":false}],"imports":[{"note":"This is a CommonJS plugin; in Node.js, use require(). In browser-based transforms, typically used via babel.config.js where require() is standard.","wrong":"import fullySpecified from 'babel-plugin-fully-specified'","symbol":"default","correct":"module.exports = require('babel-plugin-fully-specified')"},{"note":"In Babel configuration, string references auto-resolve. Explicitly requiring it is unnecessary and may cause issues with Babel's plugin resolution if the plugin is not installed at the config's location.","wrong":"plugins: [require('babel-plugin-fully-specified')]","symbol":"babel-plugin-fully-specified","correct":"plugins: ['babel-plugin-fully-specified']"},{"note":"This plugin does not export any named symbol; only the default export is available. Importing a named symbol will result in undefined.","wrong":"import { BabelPluginFullySpecified } from 'babel-plugin-fully-specified'; plugins: [BabelPluginFullySpecified]","symbol":"BabelPluginFullySpecified"}],"quickstart":{"code":"// Install: npm install --save-dev babel-plugin-fully-specified @babel/core\n// In babel.config.js:\nmodule.exports = {\n  plugins: [\n    ['babel-plugin-fully-specified', {\n      ensureFileExists: false,\n      esExtensionDefault: '.js',\n      tryExtensions: ['.js', '.mjs', '.cjs'],\n      esExtensions: ['.js', '.mjs', '.cjs'],\n      includePackages: [],\n    }]\n  ]\n};\n\n// Input: import { Thing } from './path';\n// Output: import { Thing } from './path/index.js';","lang":"javascript","description":"Configures babel-plugin-fully-specified in babel.config.js with all available options, showing how it transforms a directory import into a fully-specified index.js import."},"warnings":[{"fix":"Manually add file extensions to dynamic import() calls, or use a different plugin that handles dynamic imports.","message":"Dynamic imports are not transformed; they will remain bare-specified.","severity":"breaking","affected_versions":"<=1.3.1"},{"fix":"Update to v1.1.2+ which fixes this behavior to prioritize files before directories.","message":"Plugin may incorrectly prioritize file over directory when both exist (e.g., './path' and './path.js'), potentially resolving to the file without index extension.","severity":"gotcha","affected_versions":"<1.1.2"},{"fix":"Only include packages that are known to be ESM and require fully-specified imports; test thoroughly after enabling.","message":"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.","severity":"breaking","affected_versions":">=1.2.0 <=1.3.1"},{"fix":"Monitor the repository for breaking changes; currently remains in use as of v1.3.1.","message":"The option 'esExtensionDefault' may be renamed in future versions; check changelog for updates.","severity":"deprecated","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":"Configure the Babel plugin to add extensions during build, or manually add the correct extension (e.g., './path/index.js').","cause":"Bare import without extension in ESM context; Node.js requires fully-specified paths for ESM.","error":"Module not found: Error: Can't resolve './path' in '/path/to/file'"},{"fix":"Run 'npm install --save-dev babel-plugin-fully-specified' from the project root where babel.config.js resides.","cause":"Plugin not installed or not in the same node_modules resolution chain as babel.","error":"Error: Cannot find module 'babel-plugin-fully-specified'"},{"fix":"Use require('babel-plugin-fully-specified') or reference it as a string in plugins array.","cause":"Attempting to import the plugin as a default ES import instead of using CommonJS require.","error":"TypeError: (0 , _fullySpecified.default) is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}