Skip to content

zakodium/babel-plugin-transform-modules-amd

 
 

Repository files navigation

@zakodium/babel-plugin-transform-modules-amd

Transforms modules / require to AMD modules, only if they aren't already AMD modules or require configs.

Zakodium logo

Maintained by Zakodium

NPM version build status Test coverage npm download

Installation

$ npm install @zakodium/babel-plugin-transform-modules-amd

Usage

Via babel.config.js

This is the recommended configuration to support all import, export and CJS require statements.

export default {
  plugins: [
    "@babel/plugin-transform-destructuring",
    "@babel/plugin-transform-export-namespace-from",
    "@zakodium/babel-plugin-transform-modules-amd",
  ],
};

Supported syntax

All import and export statements are supported, but some require to setup your babel config with additional plugins to work.

// ⚠️ Descructuring in CJS require statements is not supported out of the box.
// Use the "@babel/plugin-transform-destructuring" plugin in your babel config to support this syntax.
const { foo } = require("bar");

// ⚠️ Star exports to a namespace is not supported out of the box.
// Use the "@babel/plugin-transform-export-namespace-from" plugin in your babel config to support this syntax.
export * as foo from "bar";

License

See LICENSE.md

About

Transforms ESM / CJS to AMD define statements

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%