{"id":19022,"library":"babel-plugin-amd-to-esm","title":"babel-plugin-amd-to-esm","description":"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.","status":"active","version":"2.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/Duncanxyz/babel-plugin-amd-to-esm","tags":["javascript","babel","amd","esm","es6","modules"],"install":[{"cmd":"npm install babel-plugin-amd-to-esm","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-amd-to-esm","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-amd-to-esm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as a peer dependency to run Babel plugins; must be installed separately.","package":"@babel/core","optional":false}],"imports":[{"note":"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.","wrong":"const amdToEsm = require('babel-plugin-amd-to-esm')","symbol":"default","correct":"import amdToEsm from 'babel-plugin-amd-to-esm'"}],"quickstart":{"code":"module.exports = {\n  plugins: [\n    ['babel-plugin-amd-to-esm', {\n      handleESMDependencies: true,\n      rootDir: path.resolve(__dirname, 'src'),\n      alias: { '@': path.resolve(__dirname, 'src') }\n    }]\n  ]\n};","lang":"javascript","description":"Configures babel-plugin-amd-to-esm in .babelrc.js with all options: handleESMDependencies, rootDir, and alias."},"warnings":[{"fix":"Upgrade to >=2.0.0 and set handleESMDependencies: true to use these options.","message":"Options handleESMDependencies, rootDir, and alias are only effective in v2.0.0+ and require handleESMDependencies: true to activate.","severity":"gotcha","affected_versions":"<2.0.0"},{"fix":"Use .babelrc.js with module.exports = { ... } or .babelrc.mjs for ESM.","message":"Using require() instead of import in Babel config is deprecated in Babel 7.8+; prefer using JS config files with module.exports or .mjs.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Manually refactor dynamic requires or use a different tool for dynamic imports.","message":"The plugin does not support dynamic AMD require() calls; only static define() is converted.","severity":"gotcha","affected_versions":"all"},{"fix":"Check generated imports and update code relying on default import behavior; migrate to v2.0.0.","message":"In v2.0.0, default import of dependencies changed: previously a default import was always generated, now it generates named imports if possible.","severity":"breaking","affected_versions":">=1.0.0 <2.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save-dev @babel/core babel-plugin-amd-to-esm","cause":"Package not installed, or Babel version incompatibility (requires @babel/core 7.x).","error":"Error: [BABEL] unknown: Plugin babel-plugin-amd-to-esm is not a valid plugin"},{"fix":"npm install --save-dev babel-plugin-amd-to-esm","cause":"Plugin not installed in project's node_modules.","error":"Error: Cannot find module 'babel-plugin-amd-to-esm'"},{"fix":"Ensure rootDir and alias point to existing directories and dependency paths are correct.","cause":"AMD dependency resolution failed because handleESMDependencies is enabled but the dependency is not found or rootDir/alias misconfigured.","error":"TypeError: Cannot destructure property 'default' of 'undefined' or null."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}