Registry / devops / babel-plugin-amd-to-esm

babel-plugin-amd-to-esm

JSON →
library2.0.4jsnpmunverified

A Babel plugin that converts AMD modules (using define()) to ES modules (import/export). Version 2.0.4 includes features like arrow function support, handling ES module dependencies (since v2.0.0), and options for rootDir and alias. It is actively maintained with bug fixes and documentation updates. Key differentiator: it specifically targets AMD-to-ESM conversion for legacy codebases, with support for handling mixed AMD/ESM dependency graphs, unlike generic AMD transform tools.

npm install babel-plugin-amd-to-esm
INSTALL
IMPORT
SIG · BABEL-PLUGIN-AMD-T
B
babel-plugin-amd-to-esm
devopsjavascriptv2.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import amdToEsm from 'babel-plugin-amd-to-esm'
const amdToEsm = require('babel-plugin-amd-to-esm')
The plugin is a CommonJS module; require() works but the Babel config expects the plugin to be passed as a string or function. Typically used without importing directly.

Configures babel-plugin-amd-to-esm in .babelrc.js with all options: handleESMDependencies, rootDir, and alias.

module.exports = { plugins: [ ['babel-plugin-amd-to-esm', { handleESMDependencies: true, rootDir: path.resolve(__dirname, 'src'), alias: { '@': path.resolve(__dirname, 'src') } }] ] };
Debug
Known issues
gotchaOptions handleESMDependencies, rootDir, and alias are only effective in v2.0.0+ and require handleESMDependencies: true to activate.
fix
Upgrade to >=2.0.0 and set handleESMDependencies: true to use these options.
affects: <2.0.0
deprecatedUsing require() instead of import in Babel config is deprecated in Babel 7.8+; prefer using JS config files with module.exports or .mjs.
fix
Use .babelrc.js with module.exports = { ... } or .babelrc.mjs for ESM.
affects: >=2.0.0
gotchaThe plugin does not support dynamic AMD require() calls; only static define() is converted.
fix
Manually refactor dynamic requires or use a different tool for dynamic imports.
affects: all
breakingIn v2.0.0, default import of dependencies changed: previously a default import was always generated, now it generates named imports if possible.
fix
Check generated imports and update code relying on default import behavior; migrate to v2.0.0.
affects: >=1.0.0 <2.0.0
Errors
Common errors & fixes
Error: [BABEL] unknown: Plugin babel-plugin-amd-to-esm is not a valid plugin
Package not installed, or Babel version incompatibility (requires @babel/core 7.x).
fix
npm install --save-dev @babel/core babel-plugin-amd-to-esm
Error: Cannot find module 'babel-plugin-amd-to-esm'
Plugin not installed in project's node_modules.
fix
npm install --save-dev babel-plugin-amd-to-esm
TypeError: Cannot destructure property 'default' of 'undefined' or null.
AMD dependency resolution failed because handleESMDependencies is enabled but the dependency is not found or rootDir/alias misconfigured.
fix
Ensure rootDir and alias point to existing directories and dependency paths are correct.
Upgrade
Version history
2.0.4latest on npm
Audit
Dependencies
@babel/corerequiredRequired as a peer dependency to run Babel plugins; must be installed separately.
Agent activity
4 hits · last 30 days
node
4
Resources
babel-plugin-amd-to-esm — npm install babel-plugin-amd-to-esm · libregistry