Add option to block-scoping to slow on throw code (#5236)
The let/const plugin can add closures where you don't expect them. This is undesirable in some perf-sensitive projects (ex: React). I added an option that throws whenever the plugin adds a function (as opposed to simply renaming variables when converting to var).
This commit is contained in:
@@ -360,6 +360,12 @@ class BlockScoping {
|
||||
}
|
||||
|
||||
wrapClosure() {
|
||||
if (this.file.opts.throwIfClosureRequired) {
|
||||
throw this.blockPath.buildCodeFrameError(
|
||||
"Compiling let/const in this block would add a closure " +
|
||||
"(throwIfClosureRequired)."
|
||||
);
|
||||
}
|
||||
const block = this.block;
|
||||
|
||||
const outsideRefs = this.outsideLetReferences;
|
||||
|
||||
Reference in New Issue
Block a user