1
export default config = {
  apiUrl : "http://localhost:7543"
}

$ node --version
v6.7.0

Is this possible without transpiling? Is there a way to polyfill in import without having to change my code?

I'd like to pull that in to the console (REPL) and see if the object is set up right. But:

import {config} from './config';
^^^^^^
SyntaxError: Unexpected token import

It looks like I can't use import in the REPL yet. So what's the alternative? Do I need to use ES5/Node require? Is there a polyfill that I can add in to my loader for Nesh?

Ideally I'd like to just open up node console and use paste in a line that uses import without having to change my code.

Michał Perłakowski
  • 88,409
  • 26
  • 156
  • 177
jcollum
  • 43,623
  • 55
  • 191
  • 321

1 Answers1

1

Node.js doesn't support ES Modules. If you want to use them, you have to transpile your code using Babel.

It's not possible to polyfill ES Modules, because they introduce a new syntax, so the code can't even be parsed properly (you get syntax error).

Michał Perłakowski
  • 88,409
  • 26
  • 156
  • 177