Babel
  • Docs
  • Setup
  • Try it out
  • Videos
  • Blog
  • Donate
  • Team
  • GitHub
Edit

@babel/plugin-transform-modules-amd

This plugin transforms ECMAScript modules to AMD. Note that only the syntax of import/export statements (import "./mod.js") and import expressions (import('./mod.js')) is transformed, as Babel is unaware of the different resolution algorithms between implementations of ECMAScript modules and AMD.

Example

In

export default 42;

Out

define(["exports"], function (exports) {
  "use strict";

  Object.defineProperty(exports, "__esModule", {
    value: true
  });

  exports.default = 42;
});

Installation

npm install --save-dev @babel/plugin-transform-modules-amd

Usage

With a configuration file (Recommended)

{
  "plugins": ["@babel/plugin-transform-modules-amd"]
}

Via CLI

babel --plugins @babel/plugin-transform-modules-amd script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["@babel/plugin-transform-modules-amd"]
});

Options

See options for @babel/plugin-transform-modules-commonjs.

  • Example
  • Installation
  • Usage
    • With a configuration file (Recommended)
    • Via CLI
    • Via Node API
    • Options
Babel
Docs
Learn ES2015
Community
VideosUser ShowcaseStack OverflowSlack ChannelTwitter
More
BlogGitHub OrgGitHub RepoWebsite RepoOld 6.x SiteOld 5.x Site