Skip to content

Concatapult/transform-to-commonjs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Node 6 supports almost whole ES 6 specification but there is not support for ES6 imports :/

This plugin transforms your ES6 imports / exports to commonjs counterparts. NO BABEL, No sourcemapping is needed.

The output is in ES6.

As a result, you can use it with Node 6 for server implementations.

EXAMPLE:

import Foo, { Foo1 } from 'Bar';

export function m() {}
export const n();
export default function () {}

// to

const Foo = require('Bar').default;
const { Foo1 } = require('Bar');

function m() {}
const n;
function defaultFunction() {}

exports.m = m;
exports.n = n;
exports.default = defaultFunction;

How to use

Simply import the registration script as a first line in your server:

require('import-to-commonjs/dist/register');

Known issues

Currently none, but I'm pretty sure I missed some import cases. PRs welcome.

About

Transform ES6 transforms to commonjs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 95.2%
  • JavaScript 4.8%