Socket
Socket
Sign inDemoInstall

babel-plugin-transform-system-import-commonjs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-system-import-commonjs

Transform ES2015 System.import to CommonJS require


Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-transform-system-import-commonjs

Babel plugin that transforms ES2015 System.import into CommonJS require.

Deprecation notice

** Since import() proposal was accepted, System.import function now is obsolete and this plugin is not recommended to use in new projects. Please use import() function with babel-plugin-transform-import-commonjs instead. **

How this works

This plugin transforms

var myModule = "./path/to/myModule";

System.import(myModule).then(function (module) {
  console.log(module);
});

to

var myModule = "./path/to/myModule";

new Promise(function(resolve) {
  resolve(require(myModule));
}.bind(this)).then(function (module) {
  console.log(module);
});

Requirements

You need support for Promise, use polyfill if needed.

Installation

$ npm install babel-plugin-transform-system-import-commonjs

Usage

.babelrc

{
  "plugins": ["transform-system-import-commonjs"]
}

Via CLI

$ babel --plugins transform-system-import-commonjs script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-system-import-commonjs"]
});

Keywords

FAQs

Package last updated on 16 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc