-
-
Notifications
You must be signed in to change notification settings - Fork 256
☄ Make tokens optional to improve performance #563
Conversation
What does Babel use it for anyway? |
The generator seems to use it for whitespace stuff, https://github.com/babel/babel/blob/02473a72c160545ed225482515b569d26fc41ea5/packages/babel-generator/src/index.js#L14 I just had an idea, what if we instead of babel-generator use prettier. Have you tried that? I wonder if that works. :) |
What if we expose the option as a Babylon plugin? This would allow to push this plugin from a Babel plugin if it needs it. |
@danez It a lot slower though (forgot how much but at least >2x). I definetely wouldn't be opposed to it (I believe someone brought it up earlier so I tested a while ago). |
There's probably a lot of low hanging fruit for making prettier fast by the way. Performance has been okay for our use case so far so we didn't look into it at all. But, it's likely never going to be as fast as the current printer since it has to do more work. |
I was thinking we could make some of it's operations no-op (do the default print) if we don't care about specific formatting that can be slow but not sure if that is viable |
Why would you use prettier if you're not going to use its 80-columns formatting abilities? It seems like it defeats the purpose of the tool. Also, I'm not really sure that the overhead of prettier is really a good idea. I don't think that printing code in a human-looking way is worth spending more time. You pay the cost of printing every single time, you only look at the output once in a while. |
Was just whether it would be worth looking into perf issues so we don't have maintain 2 printers |
Oh I see. I didn't consider the overhead of maintenance. |
Ok I totally ignored your "The generator seems to use it for whitespace stuff, " @danez Let's just remove the usage in Babel then. We don't care about the output format and we shouldn't encourage anyone else to care about it either (will be minified, etc). We got the quotes option to be removed earlier (babel/babel#5154). So same idea. Just hardcode the whitespace/quote stuff. Ok nvm the printer is using |
Adding tokens to the ast is significant slower and most tools don't ever use them anyway
Adding tokens to the ast is significant slower and most tools
don't ever use them anyway. Babel uses it so we need to enable it there.
With tokens:
Without: