babel/packages/babel-plugin-transform-modules-amd
Artem Yavorsky 0a2a37c31f Fix export from assignment order for loose mode. (#6863)
* Consider reexports for bindingKindLookup.

* Update test cases according to reexports change

* Fix order for assign reexports.

* void 0 assignation to module keys only for loose mode.

* Create buildReexportsFromMeta helper.

* Update umd/amd fixtures.

* Refactor reexports build.

* Hoist template for reexports.

* Use map as a second argument of Array.from.

* Remove unnecessary export.
2017-11-29 11:58:29 -08:00
..
2017-11-12 08:32:53 -05:00

@babel/plugin-transform-modules-amd

This plugin transforms ES2015 modules to Asynchronous Module Definition (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

.babelrc

{
  "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.