-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
describe a few compiler assumptions #2883
Conversation
Since you're editing the README, could you please drop this in the Source Map section? Edit: perhaps under a new section called "Source Maps and Debugging" at the bottom of the README. |
@kzc if you are going to add that source map text, please combine it with https://github.com/mishoo/UglifyJS2#uglify-fast-minify-mode - no need to have more than one place describing non-default usage. @Skalman other than missing |
"Uglify breaks debugging with source maps" is the single most frequently created issue in bundler wrapper projects. The explanation doesn't belong in the fast minify mode section - it's completely unrelated. It's up to @Skalman if he wants to add it. |
I added the note on source maps to the bottom of the readme. Let me know if I should move it. |
LGTM |
README.md
Outdated
`Error.prototype.stack` to be anything in particular. | ||
- Getting and setting properties on a plain object does not cause other side effects | ||
(using `.watch()` or `Proxy`). | ||
- Object properties are able to be added (not prevented with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object properties can be added, removed and modified (or writeable
as they call it).
are known to have an adverse effect on debugging with source maps. This is | ||
expected as code is optimized and mappings are often simply not possible as | ||
some code no longer exists. For highest fidelity in source map debugging | ||
disable the Uglify `compress` option and just use `mangle`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just combine this with Uglify Fast Minify Mode
above - no point having a seperate section talking about non-default option usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, it is unrelated to Uglify Fast Minify. This source map debugging section would benefit with its own heading so it is externally linkable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexlamsl, I'm not sure I think that makes sense. That section doesn't include anything about source maps nor debugging.
To me it seems like multiple sections under "Miscellaneous" talk about non-default option usage, including Using native Uglify AST with minify()
, ESTree / SpiderMonkey AST, and Use Acorn for parsing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes more sense to mention under Uglify Fast Minify
that when somebody is terminally confused by a debugger, this option would also be useful.
I am against text dedicated to non-default usage in general because it will cause some people go for it based on misplaced beliefs, e.g. keep_infinity
in #2743 - and then in return we get weird complaints when things don't work the way they expect it to, e.g. #2856
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that you're against any information on source maps? If the text were to be combined with an existing section, I'd suggest "CLI source map options".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options are provided and documented so that people can use them as they see fit. Source map use with uglify is extremely common - particularly when Uglify is used with bundlers.
This paragraphs warrants it own section with a heading as it is a frequently asked question. It may be underneath Uglify Fast Minify with a smaller heading if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that you're against any information on source maps?
Not at all - just not worth attracting unwarranted attention to it.
Source map use with uglify is extremely common.
Confusion when using a debugger isn't as common amongst programmers.
It may be underneath Uglify Fast Minify with a smaller heading if you prefer.
That would at least be better - thanks.
README.md
Outdated
|
||
### Compiler assumptions | ||
|
||
To allow for better optimizations, the compiler makes various assumptions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace the period at the end of the line with a colon.
README.md
Outdated
|
||
To allow for better optimizations, the compiler makes various assumptions. | ||
|
||
- `.toString()` and `.valueOf()` have not been overridden, and don't have side effects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toString()
can be overridden in new functions/classes - it just cannot have side effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a suggestion for how to phrase this? My take:
.toString()
and.valueOf()
don't have side effects, and for built-in objects they have not been overridden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... only if unsafe
is not specified, though I guess that's covered under https://github.com/mishoo/UglifyJS2#the-unsafe-compress-option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a0d408e is good.
The section on It also would be good to demonstrate an advanced $ cat test.js
var s = [ "C", "A", "T" ].join("_");
console.log(s.replace(/_/g, "")); $ bin/uglifyjs test.js --toplevel -c unsafe,passes=2
console.log("CAT"); |
I'm not planning on adding information about |
No worries. Leave that for someone else. |
@alexlamsl OT - do you recall why these two functions were not included with $ echo 'console.log("Abc".toUpperCase(), "Xyz".toLowerCase());' | node0_10_41
ABC xyz $ echo 'console.log("Abc".toUpperCase(), "Xyz".toLowerCase());' | bin/uglifyjs -c unsafe
console.log("Abc".toUpperCase(),"Xyz".toLowerCase()); They both are available in node 0.10. Do they |
Perhaps |
@kzc Turkish Edit: looks like you've just figured it out 😉 |
If I understand the documentation on MDN, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase |
They even mention Turkish explicitly :-)
|
I remember seeing polyfill for I'll test them on various platforms after some sleep – and if it turns out they all work as expected, then a PR for |
My addition rendered
I've created a new README section to describe some of the compiler assumptions. I'd appreciate any suggestions of clarifications.
In particular, I'm unsure about the factual accuracy of the last couple of bullet points:
.watch()
orProxy
).Object.defineProperty()
,Object.defineProperties()
,Object.freeze()
orObject.preventExtensions()
).