Babel plugin that resolves and maps module extensions in import/require statements. Version 1.0.0 is the latest stable release, with maintenance releases planned when necessary. It transforms extensionless imports to explicit extensions (e.g., './dir/lib' -> './dir/lib.js'), configurable via srcExtensions, dstExtension, and extensionsToKeep options. Unlike babel-plugin-extension-resolver, it supports TypeScript, dynamic imports, and export from syntax. Works with CommonJS and ES modules.
npm install babel-plugin-module-extension-resolverVerified import paths — ran on the pinned version, not inferred.
Shows basic usage: installation, .babelrc configuration, and how extensionless imports are resolved to .js (or .json kept).
Update .babelrc to use new option names: set 'srcExtensions', 'dstExtension', and 'extensionsToKeep' instead of 'extensions' and 'map'.
Upgrade Node.js to version 8 or higher.
Upgrade to v1.0.0-rc.2 or later to resolve dynamic imports.
Ensure all relative import paths start with './' or '../' to be resolved. For absolute or bare specifiers, consider using other plugins or webpack aliases.
Pass '--keep-file-extension' to Babel CLI or set 'extensionsToKeep' to preserve specific extensions like '.mjs'.
Set 'dstExtension' option to '.mjs' or '.cjs' as needed. For ES modules with TypeScript, set "modules": false in @babel/preset-env.
Run 'npm install -D babel-plugin-module-extension-resolver' and use 'module-extension-resolver' (not full path) in .babelrc.
Use ES module syntax (import) instead of require, or set @babel/preset-env modules to 'auto' or 'commonjs'.
Ensure options are specified as: ["module-extension-resolver", { ... }].Verify the source file exists with one of the srcExtensions. Check 'srcExtensions' list includes the file extension used. If file is .ts, ensure '.ts' is in srcExtensions.
Update Babel to version 7.8.0 or later, or ensure @babel/plugin-syntax-dynamic-import is included.
No dependency data recorded yet.