A Babel plugin to apply import map mappings to ECMAScript modules ahead of time. Current stable version is 1.0.0. This plugin allows transforming bare import specifiers (e.g., 'lit-html') to absolute URLs (e.g., CDN URLs) at build time, based on one or more import map files. It supports loading import maps from JSON files or plain objects, and can merge multiple maps. Unlike runtime import map polyfills, this works purely at the build level, making it suitable for production bundles. Once loaded, the plugin replaces import specifiers statically during Babel transpilation.
npm install babel-plugin-import-mapVerified import paths — ran on the pinned version, not inferred.
Shows how to load an import map file and apply the plugin in a Babel configuration to transform bare ESM imports.
Ensure correct order when passing multiple maps.
Validate import map JSON before loading.
Use a separate plugin or runtime polyfill for dynamic imports.
import * as plugin from 'babel-plugin-import-map'
Use absolute path or path relative to process.cwd()
Ensure import map object has 'imports' key.
No dependency data recorded yet.