Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for ES6 modules #40

Open
Pauan opened this issue Sep 17, 2016 · 2 comments
Open

Support for ES6 modules #40

Pauan opened this issue Sep 17, 2016 · 2 comments

Comments

@Pauan
Copy link

Pauan commented Sep 17, 2016

I like a lot of the features in Earl Grey, but one feature that I feel is lacking is proper support for ES6 modules.

My intention is to write client-side browser applications. I know that I can use Webpack to bundle CommonJS files (and I do use Webpack), but ES6 modules have many advantages:

http://www.2ality.com/2014/09/es6-modules-final.html

The basic gist of it is that ES6 modules are static, which means better compile-time error checking, faster code execution, dead code elimination (e.g. Rollup and Webpack2), support for macros, and better support for cyclic dependencies.

I'm not sure exactly what changes will need to be made in Earl Grey to support ES6 modules, but I think it's something that needs to be thought about at some point, because ES6 modules are the future.

@breuleux
Copy link
Owner

Well, I want to compile EG to a version of JavaScript that's natively supported by V8 in the latest version of node (so that no additional transpiling would be needed on the server side). As far as I can tell, ES6 modules are not yet supported in node (nor in any major browser it seems), so I'd rather wait until they are. Hopefully it is not be too long before then. Support should be easy: EG's require statement is closer in functionality to ES6's import statement than to node's require.

@Pauan
Copy link
Author

Pauan commented Sep 20, 2016

That's totally understandable. CommonJS is the right choice for Node (at least for now). But for web browsers, you already need to use bundlers like Webpack/Rollup/etc. and they support ES6 modules (which are compiled into a single optimized ES5 file).

I think an additional flag to determine whether to output to CommonJS or ES6 would be a good idea. But I can understand you wanting to wait until ES6 modules are natively supported. As long as you are at least considering the option, then I'm happy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants