Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inject tmp vars in the params list of IIFEs when possible (#15741)
* Inject tmp vars in the params list of IIFEs when possible * Update packages/babel-traverse/src/scope/index.ts
- Loading branch information
1 parent
230ea2c
commit 4596fe1
Showing
19 changed files
with
70 additions
and
145 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
3 changes: 1 addition & 2 deletions
3
...ages/babel-plugin-proposal-do-expressions/test/fixtures/do-expressions/while-if/output.js
This file contains 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
3 changes: 1 addition & 2 deletions
3
...ages/babel-plugin-proposal-pipeline-operator/test/fixtures/fsharp/indirect-eval/output.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
(function () { | ||
(function (_functionReturn) { | ||
'use strict'; | ||
|
||
var _functionReturn; | ||
var result = (_functionReturn = '(function() { return this; })()', (0, eval)(_functionReturn)); | ||
expect(result).not.toBeUndefined(); | ||
})(); |
3 changes: 1 addition & 2 deletions
3
...ges/babel-plugin-proposal-pipeline-operator/test/fixtures/minimal/indirect-eval/output.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
(function () { | ||
(function (_functionReturn) { | ||
'use strict'; | ||
|
||
var _functionReturn; | ||
var result = (_functionReturn = '(function() { return this; })()', (0, eval)(_functionReturn)); | ||
expect(result).not.toBeUndefined(); | ||
})(); |
3 changes: 1 addition & 2 deletions
3
...n-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-tacit-call/output.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
(function () { | ||
(function (_functionReturn) { | ||
'use strict'; | ||
|
||
var _functionReturn; | ||
var result = (_functionReturn = '(function() { return this; })()', (0, eval)(_functionReturn)); | ||
expect(result).not.toBeUndefined(); | ||
})(); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
5 changes: 1 addition & 4 deletions
5
...cing-operator/test/fixtures/assumption-noDocumentAll/transform-in-default-param/output.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
function foo(foo, qux = (() => { | ||
var _foo$bar; | ||
return (_foo$bar = foo.bar) != null ? _foo$bar : "qux"; | ||
})()) {} | ||
function foo(foo, qux = (_foo$bar => (_foo$bar = foo.bar) != null ? _foo$bar : "qux")()) {} | ||
function bar(bar, qux = bar != null ? bar : "qux") {} |
5 changes: 1 addition & 4 deletions
5
...coalescing-operator/test/fixtures/nullish-coalescing/transform-in-default-param/output.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
function foo(foo, qux = (() => { | ||
var _foo$bar; | ||
return (_foo$bar = foo.bar) !== null && _foo$bar !== void 0 ? _foo$bar : "qux"; | ||
})()) {} | ||
function foo(foo, qux = (_foo$bar => (_foo$bar = foo.bar) !== null && _foo$bar !== void 0 ? _foo$bar : "qux")()) {} | ||
function bar(bar, qux = bar !== null && bar !== void 0 ? bar : "qux") {} |
20 changes: 4 additions & 16 deletions
20
...orm-optional-chaining/test/fixtures/assumption-noDocumentAll/in-function-params/output.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,14 @@ | ||
function f(a = (() => { | ||
var _x; | ||
return (_x = x) == null ? void 0 : _x.y; | ||
})()) {} | ||
function f(a = (_x => (_x = x) == null ? void 0 : _x.y)()) {} | ||
function g({ | ||
a, | ||
b = a == null ? void 0 : a.c | ||
}) {} | ||
function h(a, { | ||
b = (() => { | ||
var _a$b, _a$b$c; | ||
return (_a$b = a.b) == null ? void 0 : (_a$b$c = _a$b.c) == null ? void 0 : _a$b$c.d.e; | ||
})() | ||
b = ((_a$b, _a$b$c) => (_a$b = a.b) == null ? void 0 : (_a$b$c = _a$b.c) == null ? void 0 : _a$b$c.d.e)() | ||
}) {} | ||
function i(a, { | ||
b = (() => { | ||
var _a$b2, _a$b2$c; | ||
return (_a$b2 = a.b) == null ? void 0 : (_a$b2$c = _a$b2.c) == null ? void 0 : _a$b2$c.d; | ||
})().e | ||
b = ((_a$b2, _a$b2$c) => (_a$b2 = a.b) == null ? void 0 : (_a$b2$c = _a$b2.c) == null ? void 0 : _a$b2$c.d)().e | ||
}) {} | ||
function j(a, { | ||
b = (() => { | ||
var _a$b3; | ||
return a == null ? void 0 : (_a$b3 = a.b) == null ? void 0 : _a$b3.c().d.e; | ||
})() | ||
b = (_a$b3 => a == null ? void 0 : (_a$b3 = a.b) == null ? void 0 : _a$b3.c().d.e)() | ||
}) {} |
20 changes: 4 additions & 16 deletions
20
...ugin-transform-optional-chaining/test/fixtures/general/in-function-params-loose/output.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,14 @@ | ||
function f(a = (() => { | ||
var _x; | ||
return (_x = x) == null ? void 0 : _x.y; | ||
})()) {} | ||
function f(a = (_x => (_x = x) == null ? void 0 : _x.y)()) {} | ||
function g({ | ||
a, | ||
b = a == null ? void 0 : a.c | ||
}) {} | ||
function h(a, { | ||
b = (() => { | ||
var _a$b, _a$b$c; | ||
return (_a$b = a.b) == null ? void 0 : (_a$b$c = _a$b.c) == null ? void 0 : _a$b$c.d.e; | ||
})() | ||
b = ((_a$b, _a$b$c) => (_a$b = a.b) == null ? void 0 : (_a$b$c = _a$b.c) == null ? void 0 : _a$b$c.d.e)() | ||
}) {} | ||
function i(a, { | ||
b = (() => { | ||
var _a$b2, _a$b2$c; | ||
return (_a$b2 = a.b) == null ? void 0 : (_a$b2$c = _a$b2.c) == null ? void 0 : _a$b2$c.d; | ||
})().e | ||
b = ((_a$b2, _a$b2$c) => (_a$b2 = a.b) == null ? void 0 : (_a$b2$c = _a$b2.c) == null ? void 0 : _a$b2$c.d)().e | ||
}) {} | ||
function j(a, { | ||
b = (() => { | ||
var _a$b3; | ||
return a == null ? void 0 : (_a$b3 = a.b) == null ? void 0 : _a$b3.c().d.e; | ||
})() | ||
b = (_a$b3 => a == null ? void 0 : (_a$b3 = a.b) == null ? void 0 : _a$b3.c().d.e)() | ||
}) {} |
20 changes: 4 additions & 16 deletions
20
...bel-plugin-transform-optional-chaining/test/fixtures/general/in-function-params/output.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,14 @@ | ||
function f(a = (() => { | ||
var _x; | ||
return (_x = x) === null || _x === void 0 ? void 0 : _x.y; | ||
})()) {} | ||
function f(a = (_x => (_x = x) === null || _x === void 0 ? void 0 : _x.y)()) {} | ||
function g({ | ||
a, | ||
b = a === null || a === void 0 ? void 0 : a.c | ||
}) {} | ||
function h(a, { | ||
b = (() => { | ||
var _a$b, _a$b$c; | ||
return (_a$b = a.b) === null || _a$b === void 0 ? void 0 : (_a$b$c = _a$b.c) === null || _a$b$c === void 0 ? void 0 : _a$b$c.d.e; | ||
})() | ||
b = ((_a$b, _a$b$c) => (_a$b = a.b) === null || _a$b === void 0 ? void 0 : (_a$b$c = _a$b.c) === null || _a$b$c === void 0 ? void 0 : _a$b$c.d.e)() | ||
}) {} | ||
function i(a, { | ||
b = (() => { | ||
var _a$b2, _a$b2$c; | ||
return (_a$b2 = a.b) === null || _a$b2 === void 0 ? void 0 : (_a$b2$c = _a$b2.c) === null || _a$b2$c === void 0 ? void 0 : _a$b2$c.d; | ||
})().e | ||
b = ((_a$b2, _a$b2$c) => (_a$b2 = a.b) === null || _a$b2 === void 0 ? void 0 : (_a$b2$c = _a$b2.c) === null || _a$b2$c === void 0 ? void 0 : _a$b2$c.d)().e | ||
}) {} | ||
function j(a, { | ||
b = (() => { | ||
var _a$b3; | ||
return a === null || a === void 0 ? void 0 : (_a$b3 = a.b) === null || _a$b3 === void 0 ? void 0 : _a$b3.c().d.e; | ||
})() | ||
b = (_a$b3 => a === null || a === void 0 ? void 0 : (_a$b3 = a.b) === null || _a$b3 === void 0 ? void 0 : _a$b3.c().d.e)() | ||
}) {} |
15 changes: 6 additions & 9 deletions
15
...erty-in-object/test/fixtures/to-native-fields/class-expression-in-default-param/output.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
(x = (() => { | ||
var _fooBrandCheck; | ||
return _fooBrandCheck = /*#__PURE__*/new WeakSet(), class { | ||
#foo = void _fooBrandCheck.add(this); | ||
test(other) { | ||
return _fooBrandCheck.has(babelHelpers.checkInRHS(other)); | ||
} | ||
}; | ||
})()) => {}; | ||
(x = (_fooBrandCheck => (_fooBrandCheck = /*#__PURE__*/new WeakSet(), class { | ||
#foo = void _fooBrandCheck.add(this); | ||
test(other) { | ||
return _fooBrandCheck.has(babelHelpers.checkInRHS(other)); | ||
} | ||
}))()) => {}; |
This file contains 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