-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
feat(terser - compress): drop_consle supports passing in an array of … #1445
Conversation
lib/compress/index.js
Outdated
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; | ||
} |
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.
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
var isBoolean = typeof options === "boolean"; | ||
var isArray = Array.isArray(options); | ||
|
||
if (!isArray && !isBoolean) return; |
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.
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.
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.
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
@fabiosantoscode I resubmitted all the changes you said。 |
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.
Great stuff! Thanks :)
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....