5 ms·
I've been working on a very similar tool, interesting to see some competition. :-) https://github.com/alangpierce/sucrase https://github.com/alangpierce/sucras
by alangpierce 8y ago
I've been working on a very similar tool, interesting to see some competition. :-)
https://github.com/alangpierce/sucrase https://github.com/alangpierce/sucrase
In my case, it's still running as JS, but rearchitected to solve the more straightforward problem where you don't need to compile to ES5. I've thought about rewriting it in Rust to see how much faster it gets, though currently I'm trying to get it running in WebAssembly via AssemblyScript ( https://github.com/AssemblyScript/assemblyscript https://github.com/AssemblyScript/assemblyscript ), which has been promising.
I'm curious about the about the Babel performance comparison. Benchmarking JS is tricky because, from my observations, the performance improves by a factor of ~20 if you give it 5-10 seconds for the JIT to fully optimize everything. https://github.com/alangpierce/sucrase/issues/216 https://github.com/alangpierce/sucrase/issues/216 . Rust and WebAssembly both have a significant advantage in that sense when running on small datasets.
- azakai 8y agoThe AssemblyScript conversion sounds very interesting! Is there an issue or PR where I can follow that?
- alangpierce 8y agoYep! Issue (already linked above): https://github.com/alangpierce/sucrase/issues/216 https://github.com/alangpierce/sucrase/issues/216 Most recent prototype branch (doesn't include some patches to AssemblyScript to get it working): https://github.com/alangpierce/sucrase/commits/assemblyscript-prototype https://github.com/alangpierce/sucrase/commits/assemblyscrip... I've also chatted about it a little on the AssemblyScript Slack.
- natural219 8y agoHey man, I just started using sucrase in production at work. Great work with it; just the right features to let me kill Babel, simplify build docs, and still get use some modern niceties (I use it alongside gulp/rollup)
- alangpierce 8y agoGreat to hear. :-) Feedback/questions always welcome, of course! Feel free to file an issue or chat in gitter. Fortunately it's a pretty well-scoped project that's mostly done at this point.
- algesten 8y agoBut then, babel translation isn't typically a continuous operation.
- alangpierce 8y agoYep, certainly agreed. In my wasm experiments so far, wasm is faster when compiling small codebases and JS is faster when compiling very large codebases, so it may even be best to ship both and either automatically decide which one to use or make it a preference. Hopefully the wasm build can be better-optimized to always be faster than JS, though.
- alangpierce 8y agoI just did a little benchmarking of my own. Here's how the three perform on 100 compilations of an ES5 version of Parser.js from the webpack source code: sucrase: 900.720ms swc: 4514.190ms babel: 16126.752ms Sucrase had the jsx and imports transforms enabled, swc had all transforms enabled (they're not configurable), and Babel had @babel/preset-env enabled. So I'm a little skeptical of swc's 20x speedup claim, but certainly depends on a lot of details.