What is the best approach to import es6 modules with Node

87 views
Skip to first unread message

Fábio Antunes

unread,
Jan 15, 2016, 5:50:24 AM1/15/16
to Exploring ES6
Sorry if this is a dumb question but I have strong background in PHP and I only do Javascript on my spare time.

So I was reading Setting up ES6 and one thing that I noticed is that we will have two folders es6 and es5.

Now since our code will be transpiled by babel how should we require modules? relative to each other? Since we can't do
import config from 'es6/config';

That  will break when we try to run es5 code.

Another thing that I was thing is having a script on the package.json that sets the NODE_PATH=./es5 or NODE_PATH=./es6 before running.
So we can import modules like this:
import config from 'config';

Any thoughts?
Reply all
Reply to author
Forward
0 new messages