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

export default {
  plugins: [
    // This extra plugin is needed if you want to support destructuring when requiring modules
    "@babel/plugin-transform-destructuring",
    "@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 is not supported out of the box
// Make sure to add "@babel/plugin-transform-destructuring" plugin to your babel config
const { foo } = require("foo");

// ⚠️ Exporting to a namespace is not supported out of the box
// Make sure add the "@babel/plugin-transform-export-namespace-from" plugin to your babel config
export * as foo from "./foo";

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%