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
refactor(zone.js): use .toString()
directly for improved tree shakability
#55412
Closed
Conversation
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
dgp1130
added
action: review
The PR is still awaiting reviews from at least one requested reviewer
area: zones
labels
Apr 18, 2024
dgp1130
changed the title
refactor(zone.js): use
refactor(zone.js): use Apr 18, 2024
Object.prototype.toString
directly for improved tree shakability.toString()
directly for improved tree shakability
dgp1130
force-pushed
the
zone-tree-shaking
branch
from
April 18, 2024 23:57
b61ab85
to
47c912d
Compare
atscott
approved these changes
Apr 19, 2024
Whoops, accidentally deleted the branch. |
…ved tree shakability These lines were not tree shakable by Closure Compiler because `.toString()` is special cased as a "pure" function eligible to eliminated if it's return value is unused. However `.toString.call` circumvents this and makes Closure Compiler think the function may have side effects. Switching to `.toString()` should be fine here as `process.toString()` in Node outputs `[object process]` so this should be safe. Presumably the original motivation for this roundabout approach was for type safety reasons which no longer apply as `_global` is `any`.
dgp1130
force-pushed
the
zone-tree-shaking
branch
from
April 29, 2024 23:58
47c912d
to
0920c9f
Compare
JiaLiPassion
approved these changes
Apr 30, 2024
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.
LGTM!
dgp1130
added
action: merge
The PR is ready for merge by the caretaker
target: patch
This PR is targeted for the next patch release
target: minor
This PR is targeted for the next minor release
target: major
This PR is targeted for the next major release
and removed
action: review
The PR is still awaiting reviews from at least one requested reviewer
target: patch
This PR is targeted for the next patch release
target: minor
This PR is targeted for the next minor release
labels
Apr 30, 2024
AndrewKushnir
added
target: minor
This PR is targeted for the next minor release
and removed
target: major
This PR is targeted for the next major release
labels
Apr 30, 2024
This PR was merged into the repository by commit 3312727. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
action: merge
The PR is ready for merge by the caretaker
area: zones
target: minor
This PR is targeted for the next minor release
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.
These lines were not tree shakable by Closure Compiler because
.toString()
is special cased as a "pure" function eligible to eliminated if it's return value is unused. However.toString.call
circumvents this and makes Closure Compiler think the function may have side effects. Switching to.toString()
should be fine here asprocess.toString()
in Node outputs[object process]
so this should be safe. Presumably the original motivation for this roundabout approach was for type safety reasons which no longer apply as_global
isany
.At least I'm assuming the original reason was for type safety. @JiaLiPassion do you happen to have any historical context why we might have used
{}.toString.call
? It appears to have already been that way when Zone.js was synced into angular/angular.