https://github.com/tomitrescak/transform-to-commonjs
Transform ES6 transforms to commonjs
https://github.com/tomitrescak/transform-to-commonjs
Last synced: 5 months ago
JSON representation
Transform ES6 transforms to commonjs
- Host: GitHub
- URL: https://github.com/tomitrescak/transform-to-commonjs
- Owner: tomitrescak
- Created: 2016-09-06T03:48:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-14T02:03:51.000Z (over 8 years ago)
- Last Synced: 2024-10-29T10:45:29.129Z (7 months ago)
- Language: TypeScript
- Homepage:
- Size: 7.81 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```js
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:
```js
require('import-to-commonjs/dist/register');
```# Known issues
Currently none, but I'm pretty sure I missed some import cases. PRs welcome.