@babel/plugin-transform-modules-systemjs

Example

In

  1. export default 42;

Out

  1. System.register([], function(_export, _context) {
  2. return {
  3. setters: [],
  4. execute: function() {
  5. _export("default", 42);
  6. },
  7. };
  8. });

For dynamic import support (import('./lazy.js').then(m => …)), enable the @babel/plugin-syntax-dynamic-import plugin before this one.

Installation

  1. npm install --save-dev @babel/plugin-transform-modules-systemjs

Usage

Without options:

  1. {
  2. "plugins": ["@babel/plugin-transform-modules-systemjs"]
  3. }

With options:

  1. {
  2. "plugins": [
  3. [
  4. "@babel/plugin-transform-modules-systemjs",
  5. {
  6. // outputs SystemJS.register(...)
  7. "systemGlobal": "SystemJS"
  8. }
  9. ]
  10. ]
  11. }

Via CLI

  1. babel --plugins @babel/plugin-transform-modules-systemjs script.js

Via Node API

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