-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Switch from Terser to escodegen #12410
Comments
Semi-relevant: I've noticed we also have
|
Would be good to experiment with! When I implemented the initial acorn integration I wrote this:
Perhaps things have changed since then, worth checking. |
|
escodegen has options for formatting - you can either output pretty-printed code, or a compact one. Of course, it will never match Terser's minified output, but IIUC from your comment the original issue, that's a non-goal anyway, since we use Closure Compiler for proper minification. |
Can it be switched to Terser at least? They should be API-compatible (Terser is strict successor), and, for now, it would at least get rid of one old-ish dependency. (UPD: looking at versions, it seems to be UglifyJS@1.x, which actually is even older, and maybe not as compatible as I thought...) |
I'm a big fan of any kind of cleanups / simplifications that can be done in this area! |
Specifically if we can delete another checked in module from third_party I would be very happy. |
I actually just noticed that we never had them documented on the wiki page apparently. That's odd, but just added for visibility: https://github.com/estools/escodegen/wiki/API#optionformat |
Okay, but where is it called from? I can't find a single place that would use it aside from one test... |
Well, there is more here... See the full context in the link there, I just quoted one sentence, which was maybe not clear enough, sorry. To summarize the context too, we do expect closure to be used when code size is absolutely critical. But we don't run closure by default, due to speed and also that it may break custom code a user adds that isn't closure-safe. And the breakage issue means that some users can't use closure at all. So while we don't work to squeeze every last byte out of non-closure builds, we do want them to be tiny. So a significant regression would not be good, I think. That's why I ended up adding terser - it was easy, and it made a big difference at the time.
Correct, that code uses Uglify1, which is a different API. Those passes would be needed to be rewritten to use a modern AST. But after removing fastcomp we need a lot fewer of them... |
Makes sense. I guess worth experimenting with As for the Closure breaking the code - it should be happening only under advanced optimisations, right? In a "simple" mode it does pretty much the same things as Terser does, so perhaps we could just switch between them. |
Hmm... I'll look into fixing that! |
Heh, glad we found it I guess 😅 |
But how was it possible we removed too much? Do we lack test coverage? |
I'm still looking, but I'm pretty sure the wasm backend path never applied safe heap on user code, and yes, we lacked a test so this was missed... |
Oh, and the other place we use |
This removes some TODOs from wasm2js where we thought about running more of the old passes. I think that's not a good idea - they will not run as our wasm2js output gets less and less like asm.js anyhow. We'll need to write new acorn passes there, if we want to. This removes safeHeap which we should be running (see #12410 (comment)), but as it would be the only thing we use the js optimizer for from emcc.py, and that isn't a recent regression, remove that too and I'll rewrite it for acorn. See #11860
Terser itself switched away from ESCodegen to astring - perhaps relevant to cinsider astring here as well? |
Does anyone feel like working on this? |
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant. |
Note that they switched it only in test utils, not as an implementation. astring could be an interesting alternative but can't be used until davidbonnet/astring#203 is resolved as Emscripten relies on at least whitespace minification. |
Raising an issue for tracking: such switch should simplify and speed up code generation, and allow us to avoid custom patches we have in Terser.
Background (#11303 (comment)):
The text was updated successfully, but these errors were encountered: