[JS] ES6 Import/Export Syntax Not Working
h
Zavexeon

Does repl.it support Javascript ES6's import/export syntax? For example, I'll have this line: import module from './module.js', but it'll give me a Syntax error. import { module } from './module.js' doesn't seem to work either. I've gotten this to work on other sites, so how come it doesn't work on repl.it?

You are viewing a single comment. View All
Answered by Vandesm14 [earned 5 cycles]
View Answer
amasad

It's mostly so that repl.it is not "magical." Basically anything that you write on the site should work locally. Once we start precompiling your code then we're making it a bit too magical. However, If that's something that's important we can make it work.

Zavexeon

@amasad It would be greatly appreciated. I've used import/export several times on my laptop's built-in text editor and it's worked perfectly fine. It's a very useful feature of ES6 if you want your code to be modular.

I know node.js has a method of importing other files, but personally I prefer plain JS.

GentryDemchak

@amasad what percentage of browsers need to support a feature to consider it no longer "magical"? https://caniuse.com/#search=es6%20module%20import

amasad

@GentryDemchak we run on node.js. which I think this will be supported with mjs in the next release. You can use browser JavaScript using our html environment.