You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In https://xem.github.io/articles/js13k22 you write: "That's a weird choice from Terser. Especially when we see that it works normally if we write "module: false" in the top-left options... "
That's not a weird choice, and indeed you should have set "module: false".
When you set "module: true" you tell Terser that you will load the code as a module, i.e. via <script type="module">. Inside a module the global variable R is just global to the module, so window.R is something different.
So given your code and configuration, Terser correctly assumed that R is never modified, thus always falsy. The removal of the code is correct in this case.
TL;DR: When you don't use your code as module, then don't tell Terser so.
The text was updated successfully, but these errors were encountered:
Hi Michael, thanks a lot for your explanations! I will add them in the article!
I understand that you've read my making-of that is still in draft :D
I'm not (yet) very familiar with modules, so I had the feeling that something weird was going on.
And indeed, try.terser.org sets the "module" option to true by default and I'm surprised it hadn't bothered me before, as I've happily used it for years now!
Sorry if my blog post seemed aggressive about Terser. In fact it remains my favourite JS minifier <3
Sorry if my blog post seemed aggressive about Terser.
No need to apologise, it didn't sound like that, and even if it did I wouldn't have cared. My favourite JS minifier is still the Google Closure Compiler.
In https://xem.github.io/articles/js13k22 you write: "That's a weird choice from Terser. Especially when we see that it works normally if we write "module: false" in the top-left options... "
That's not a weird choice, and indeed you should have set "module: false".
When you set "module: true" you tell Terser that you will load the code as a module, i.e. via
<script type="module">
. Inside a module the global variableR
is just global to the module, sowindow.R
is something different.You can test with
So given your code and configuration, Terser correctly assumed that
R
is never modified, thus always falsy. The removal of the code is correct in this case.TL;DR: When you don't use your code as module, then don't tell Terser so.
The text was updated successfully, but these errors were encountered: