-
Notifications
You must be signed in to change notification settings - Fork 1.2k
describe a few compiler assumptions #2883
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
Changes from 3 commits
48ce5b0
b3128f0
46f893b
90508c6
600ed69
a0d408e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1102,3 +1102,26 @@ To enable fast minify mode with the API use: | |
| ```js | ||
| UglifyJS.minify(code, { compress: false, mangle: true }); | ||
| ``` | ||
|
|
||
| ### Compiler assumptions | ||
|
|
||
| To allow for better optimizations, the compiler makes various assumptions. | ||
|
|
||
| - `.toString()` and `.valueOf()` have not been overridden, and don't have side effects. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have a suggestion for how to phrase this? My take:
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... only if
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a0d408e is good. |
||
| - `undefined`, `NaN` and `Infinity` have not been externally redefined. | ||
| - `arguments.callee`, `arguments.caller` and `Function.prototype.caller` are not used. | ||
| - The code doesn't expect the contents of `Function.prototype.toString()` or | ||
| `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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Object properties can be added, removed and modified (or |
||
| `Object.defineProperty()`, `Object.defineProperties()`, `Object.freeze()`, | ||
| `Object.preventExtensions()` or `Object.seal()`). | ||
|
|
||
| ### Source maps and debugging | ||
|
|
||
| Various `compress` transforms that simplify, rearrange, inline and remove code | ||
| 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`. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just combine this with
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes more sense to mention under 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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".
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not at all - just not worth attracting unwarranted attention to it.
Confusion when using a debugger isn't as common amongst programmers.
That would at least be better - thanks. |
||
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.