{"id":19192,"library":"babel-plugin-transform-es2015-modules-amd-lazy","title":"Babel Plugin Transform ES2015 Modules to AMD (Lazy)","description":"A Babel transform plugin (v2.0.1, stable) that converts ES2015 modules to AMD format, but only when the file contains import/export statements. Unlike the standard babel-plugin-transform-es2015-modules-amd, this lazy variant skips files without imports or exports, preventing unnecessary wrapping of plain scripts or existing AMD modules. This is particularly useful in transitional or mixed codebases (e.g., combining ES2015, existing AMD modules, and non-module scripts). The plugin is a fork of Atlassian's AMD transform and is designed for legacy projects migrating to ES modules with minimal disruption. It is not intended for pure ES2015 projects.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install babel-plugin-transform-es2015-modules-amd-lazy","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-transform-es2015-modules-amd-lazy","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-transform-es2015-modules-amd-lazy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required Babel core version 7.x to function as a plugin.","package":"@babel/core","optional":false}],"imports":[{"note":"Plugin is CommonJS-only; cannot be imported as ESM. Use require().","wrong":"import plugin from 'babel-plugin-transform-es2015-modules-amd-lazy'","symbol":"default (plugin)","correct":"module.exports = require('babel-plugin-transform-es2015-modules-amd-lazy')"},{"note":"Babel automatically resolves 'babel-plugin-' prefix in plugins array; full name also works but is unnecessary.","wrong":"{\n  \"plugins\": [\"babel-plugin-transform-es2015-modules-amd-lazy\"]\n}","symbol":"plugin in .babelrc or babel.config.js","correct":"{\n  \"plugins\": [\"transform-es2015-modules-amd-lazy\"]\n}"},{"note":"Accepts same options as babel-plugin-transform-es2015-modules-amd: strict, noInterop, etc. Check Babel docs for details.","symbol":"plugin options (if any)","correct":"{\n  \"plugins\": [[\"transform-es2015-modules-amd-lazy\", { \"skipUnusedExports\": true }]]\n}"}],"quickstart":{"code":"// babel.config.js\nmodule.exports = {\n  presets: [['@babel/preset-env', { modules: false }]],\n  plugins: ['transform-es2015-modules-amd-lazy']\n};\n\n// Input: source.js with import/export\nimport { foo } from './module';\nexport const bar = foo;\n\n// Output: AMD define wrapping\n// If source.js had no imports/exports, it stays untouched.\n","lang":"javascript","description":"Shows plugin usage in babel.config.js and the effect: only files with import/export become AMD modules."},"warnings":[{"fix":"If you need all files transformed, use the standard babel-plugin-transform-es2015-modules-amd instead.","message":"Files without imports/exports are not transformed at all. This can cause silent omission if you expect all files to be AMD-wrapped.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Consider using @babel/plugin-transform-modules-amd for new projects, which is better maintained.","message":"This plugin targets ES2015 modules, not the newer Babel 7 module transform. It may not work with @babel/preset-env's modules option.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"This plugin works with ES modules in @babel/core v7; the name is legacy.","message":"Plugin name uses 'es2015' but works with modern ES modules; naming confusion may cause developers to seek alternatives unnecessarily.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run: npm install babel-plugin-transform-es2015-modules-amd-lazy --save-dev","cause":"Plugin not installed or not in node_modules.","error":"Error: Cannot find module 'babel-plugin-transform-es2015-modules-amd-lazy'"},{"fix":"Add @babel/preset-env with modules: false to your config.","cause":"Babel not configured to handle ES module syntax; this plugin only transforms import/export to AMD, but parsing requires @babel/preset-env or @babel/plugin-syntax-async-generators etc.","error":"SyntaxError: Unexpected token 'export' (while using without @babel/preset-env)"},{"fix":"Explicitly set module IDs using the 'moduleIds' option or custom resolver.","cause":"AMD naming collisions if the module IDs are inferred incorrectly.","error":"Duplicate module name [...] (when multiple AMD modules have same name)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}