A Babel plugin that automatically adds file extensions to import and export specifiers for local modules, useful when using TypeScript with Babel and not writing explicit extensions in source files. Version 1.6.0 is the latest stable release, updated occasionally. It defaults to adding .js extension, with options to specify custom extension, replace existing extensions, and configure observed script extensions. Differentiates itself by focusing solely on extension addition without other transforms.
npm install babel-plugin-add-import-extensionVerified import paths — ran on the pinned version, not inferred.
Installs the plugin, configures it to add .js extension, and shows a simple import transformation.
Ensure imports from node_modules are left untouched as intended; no action needed.
If you need to replace other extensions (e.g., .mjs), add them to observedScriptExtensions.
Use additional Babel plugins for dynamic imports if needed.
Refer to current GitHub repo for issues and documentation.
Run npm install --save-dev babel-plugin-add-import-extension
Ensure plugin is specified as ["babel-plugin-add-import-extension", { extension: 'js' }] not as separate arguments.Upgrade @babel/core to >=7.0.0.