Convert AMD modules (define/require) to ES6 import/export statements using a Babel plugin. Current version 1.0.2, maintained via automated releases. Key differentiator: supports complex AMD patterns including UMD, nested requires, and custom module ID mapping. Provides an option to register ES6 exports as AMD modules for client-side RequireJS compatibility using a configurable define function. Designed for projects migrating from AMD to ES modules while retaining client-side AMD loader support. Alternatives include amd-to-es6 and manual conversion scripts, but this plugin integrates directly into Babel 7 pipelines.
npm install babel-plugin-transform-amd-to-es6Verified import paths — ran on the pinned version, not inferred.
Converts AMD module (define with dependencies and return) into ES6 import/export with optional AMD registration client-side.
Use defineModuleId option to map your AMD module IDs to actual file paths (e.g., strip prefixes).
Test your UMD modules individually; disable umdToAMDModules if you only have native AMD.
Upgrade to Babel 7 (@babel/core). Babel 6 users should use alternative plugins or manual conversion.
Choose a unique function name (e.g., '__registerAMD') to avoid collisions.
Set ignoreNestedRequires: false if you need nested requires converted to dynamic import().
Run npm install --save-dev @babel/core
Use ['transform-amd-to-es6', { options }] inside the plugins array, not ['transform-amd-to-es6', { options }] as separate arguments.Ensure the plugin runs after any syntax plugins. Reorder your Babel plugins: place 'transform-amd-to-es6' last.