feat(terser - compress): drop_consle supports passing in an array of …#1445
Merged
fabiosantoscode merged 2 commits intoterser:masterfrom Sep 19, 2023
Merged
feat(terser - compress): drop_consle supports passing in an array of …#1445fabiosantoscode merged 2 commits intoterser:masterfrom
fabiosantoscode merged 2 commits intoterser:masterfrom
Conversation
Contributor
Author
lib/compress/index.js
Outdated
Comment on lines
+484
to
+498
| if (isBoolean) { | ||
| var name = exp.expression; | ||
| while (name.expression) { | ||
| name = name.expression; | ||
| } | ||
| if (is_undeclared_ref(name) && name.name == "console") { | ||
| return make_node(AST_Undefined, self); | ||
| } | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| if (options.indexOf(exp.property) === -1) { | ||
| return; | ||
| } |
Collaborator
There was a problem hiding this comment.
Suggested change
| if (isBoolean) { | |
| var name = exp.expression; | |
| while (name.expression) { | |
| name = name.expression; | |
| } | |
| if (is_undeclared_ref(name) && name.name == "console") { | |
| return make_node(AST_Undefined, self); | |
| } | |
| return; | |
| } | |
| if (options.indexOf(exp.property) === -1) { | |
| return; | |
| } | |
| if (isArray && options.indexOf(exp.property) === -1) { | |
| return; | |
| } |
lib/compress/index.js
Outdated
Comment on lines
+468
to
+471
| var isBoolean = typeof options === "boolean"; | ||
| var isArray = Array.isArray(options); | ||
|
|
||
| if (!isArray && !isBoolean) return; |
Collaborator
There was a problem hiding this comment.
Suggested change
| var isBoolean = typeof options === "boolean"; | |
| var isArray = Array.isArray(options); | |
| if (!isArray && !isBoolean) return; | |
| var isArray = Array.isArray(options); |
We don't need to validate options here, since TS definitions and the docs can help people pass in the correct option.
fabiosantoscode
requested changes
Sep 18, 2023
Collaborator
fabiosantoscode
left a comment
There was a problem hiding this comment.
This is a useful addition!
I'd appreciate it if you could add this new option to the typescript definitions in the tools/ folder, and the docs in README.md
Contributor
Author
|
@fabiosantoscode I resubmitted all the changes you said。 |
fabiosantoscode
approved these changes
Sep 19, 2023
Collaborator
fabiosantoscode
left a comment
There was a problem hiding this comment.
Great stuff! Thanks :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now drop_console can only pass Boolean values.
This is the code in vtk.js, and Vtk Global is window;. If drop_console: true is configured, the console of window will be set to undefined. Because the addition of drop_console: true can also handle console.hasOwnProperty;, I think I can add an array option while supporting the boolean type, so that only the property contained in the array can be handled.
like this....