-
-
Notifications
You must be signed in to change notification settings - Fork 739
feat(minifier): substitute function.call(this) for iife #16619
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
base: main
Are you sure you want to change the base?
feat(minifier): substitute function.call(this) for iife #16619
Conversation
CodSpeed Performance ReportMerging #16619 will not alter performanceComparing Summary
Footnotes
|
| test("(function* test () {foo()}).call(this)", "(function* () {foo()}).call(this)"); | ||
| test("(function* test () {}).call(this)", "(function* () {}).call(this)"); | ||
| test("(async function test(){foo()}).call(this)", "(async function (){foo()}).call(this)"); | ||
| test_same("(function test() {console.log(test.name)}).call(this)"); |
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.
| test_same("(function test() {console.log(test.name)}).call(this)"); | |
| test_same("(function test() {console.log(test.name)}).call(this)"); | |
| test_same("(function () {console.log(arguments)}).call(this)"); | |
| test_same("(function () {console.log(new.target)}).call(this)"); |
We need to handle these two cases.
There's also this behavior difference. But I didn't find a way to trigger it with IIFEs.
The thisArg value is passed without modification as the this value. This is a change from Edition 3, where an undefined or null thisArg is replaced with the global object and ToObject is applied to all other values and that result is passed as the this value. Even though the thisArg is passed without modification, non-strict functions still perform these transformations upon entry to the function.
https://tc39.es/ecma262/2025/multipage/fundamental-objects.html#sec-function.prototype.call
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 actually going to be hard, i have hard time finding a way to check all nodes outside of adding impl for Visit,
i'm actually surprised that scope don't contain more information's
either by setting a bitmask flag or using references like state,
ThisExpression->thisIdentifier->arguments()Super->superMetaProperty->new.target
q, and toughts?
iterating over entire tree is not optimal, eg, loadsh wraps entire codebase in iff like call, and if user imports any iffe package, this can degrade performance just to remove few bytes
sapphi-red
left a comment
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.
See the comment above
there is a need for an asusmption here that user has not modified
Function.prototype.callto do something else