Registry / serialization / babel-plugin-transform-es2015-modules-amd-lazy

babel-plugin-transform-es2015-modules-amd-lazy

JSON →
library2.0.1jsnpmunverified

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.

npm install babel-plugin-transform-es2015-modules-amd-lazy
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TRANS
B
babel-plugin-transform-es2015-modules-amd-lazy
serializationjavascriptv2.0.1
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 (plugin)
module.exports = require('babel-plugin-transform-es2015-modules-amd-lazy')
import plugin from 'babel-plugin-transform-es2015-modules-amd-lazy'
Plugin is CommonJS-only; cannot be imported as ESM. Use require().
plugin in .babelrc or babel.config.js
{ "plugins": ["transform-es2015-modules-amd-lazy"] }
{ "plugins": ["babel-plugin-transform-es2015-modules-amd-lazy"] }
Babel automatically resolves 'babel-plugin-' prefix in plugins array; full name also works but is unnecessary.
plugin options (if any)
{ "plugins": [["transform-es2015-modules-amd-lazy", { "skipUnusedExports": true }]] }
Accepts same options as babel-plugin-transform-es2015-modules-amd: strict, noInterop, etc. Check Babel docs for details.

Shows plugin usage in babel.config.js and the effect: only files with import/export become AMD modules.

// babel.config.js module.exports = { presets: [['@babel/preset-env', { modules: false }]], plugins: ['transform-es2015-modules-amd-lazy'] }; // Input: source.js with import/export import { foo } from './module'; export const bar = foo; // Output: AMD define wrapping // If source.js had no imports/exports, it stays untouched.
Debug
Known issues
gotchaFiles without imports/exports are not transformed at all. This can cause silent omission if you expect all files to be AMD-wrapped.
fix
If you need all files transformed, use the standard babel-plugin-transform-es2015-modules-amd instead.
affects: >=2.0.0
deprecatedThis plugin targets ES2015 modules, not the newer Babel 7 module transform. It may not work with @babel/preset-env's modules option.
fix
Consider using @babel/plugin-transform-modules-amd for new projects, which is better maintained.
affects: >=2.0.0
gotchaPlugin name uses 'es2015' but works with modern ES modules; naming confusion may cause developers to seek alternatives unnecessarily.
fix
This plugin works with ES modules in @babel/core v7; the name is legacy.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-transform-es2015-modules-amd-lazy'
Plugin not installed or not in node_modules.
fix
Run: npm install babel-plugin-transform-es2015-modules-amd-lazy --save-dev
SyntaxError: Unexpected token 'export' (while using without @babel/preset-env)
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.
fix
Add @babel/preset-env with modules: false to your config.
Duplicate module name [...] (when multiple AMD modules have same name)
AMD naming collisions if the module IDs are inferred incorrectly.
fix
Explicitly set module IDs using the 'moduleIds' option or custom resolver.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
@babel/corerequiredRequired Babel core version 7.x to function as a plugin.
Agent activity
17 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
babel-plugin-transform-es2015-modules-amd-lazy — npm install babel-plugin-transform-es2015-modules-amd-lazy · libregistry