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
ES6 Modules #121
ES6 Modules #121
Conversation
This is really cool, and since this is a compiled library kind of makes sense as well. What is the support like for runnning ES6 code on node (without transpile)? |
During development it's a bit trickier, you either need to recompile to a temp dir every time you want to run tests, or use traceur to patch Node's require method. For a published module, it's much easier. You just create a commonjs or umd build version and point the |
That was the question, if it could be used without transpiling; to which the answer is "no" it sounds like. You have to polyfill/patch/transpile or something, not just use es6 and run. |
You are able to use Traceur to require es6 modules without transpiling. See https://github.com/google/traceur-compiler/wiki/Using-Traceur-with-Node.js. Most people who This es5 umd file is already being generated with browserify, so it would just be a matter of switching to the es6-module-transpiler for the build step. |
Definitely interesting! Will have a closer look after my vacation :) |
Ember is the most notable library authoring in es6 and compiling to es5, but it doesn't really target node/npm. |
Hey @schteppe and @timrwood es6-module-transpiler and Traceur are great, you might also want to check out 6to5. It has a great set of tooling built around it and creates much nicer output. You can run es6 scripts with the |
Oh we also have a bunch of module formatters for whatever environment you want to work in. |
Very cool. Is there any difference in performance that you can measure? Were there any specific difficulties in doing this, or was the process straight forward? |
For very large code bases you'll likely notice a difference if you don't use some kind of watch task which can build only the changes. It looks like you're already using browserify so you can use the 6to5 transform with watchify and be good. |
This is a first pass at converting the source to ES6 modules.
It's still WIP, so tests don't pass yet. I just wanted to see if this was something you were interested in.
One of the benefits of ES6 modules is that you would be able to do something like this.
You can transpile ES6 modules to ES5 using something like square/es6-module-transpiler.
An example of how the output might look is here. https://gist.github.com/timrwood/5f96de256ec9768f70b5
Using the bundle format from the es6-module-transpiler also has some significant file savings over browserify.
After some rough tests, it was around half the un-gzipped size of the browserify build and 66% of the gzipped size. I didn't think it was worth comparing exact file sizes until tests are passing and poly-decomp is included.
Sorry for the brain dump, just wanted to get out all the talking points.
TODO: