-
Notifications
You must be signed in to change notification settings - Fork 47k
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
[compiler] Clone computation block in change detection mode #30148
Conversation
Summary: In change-detection mode, we previously were spreading the contents of the computation block into the result twice. Other babel passes that cause in-place mutations of the AST would then be causing action at a distance and breaking the overall transform result. This pr creates clones of the nodes instead, so that mutations aren't reflected in both places where the block is used. [ghstack-poisoned]
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Summary: In change-detection mode, we previously were spreading the contents of the computation block into the result twice. Other babel passes that cause in-place mutations of the AST would then be causing action at a distance and breaking the overall transform result. This pr creates clones of the nodes instead, so that mutations aren't reflected in both places where the block is used. ghstack-source-id: b78def8d8d1b8f9978df0a231f64fdeda786a3a3 Pull Request resolved: #30148
Comparing: 2e72ea8...e6c1cd4 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
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.
is it possible to write a test for this? i suppose not because we don't use other babel transforms in our test?
Yeah, not easy to make a test in our infra. I've tested this offline, and it's easy enough to create a repro for this: I did so with a babel config with Forget, babel/plugin-transform-destructuring, and babel/plugin-transform-block-scoping (and Hermes parser for Flow syntax); before this diff, the following program would have uses of
But I don't know if there's a good way to build this as a regression test in the compiler's current setup. |
Summary: In change-detection mode, we previously were spreading the contents of the computation block into the result twice. Other babel passes that cause in-place mutations of the AST would then be causing action at a distance and breaking the overall transform result. This pr creates clones of the nodes instead, so that mutations aren't reflected in both places where the block is used. ghstack-source-id: b78def8d8d1b8f9978df0a231f64fdeda786a3a3 Pull Request resolved: #30148
Stack from ghstack (oldest at bottom):
Summary: In change-detection mode, we previously were spreading the contents of the computation block into the result twice. Other babel passes that cause in-place mutations of the AST would then be causing action at a distance and breaking the overall transform result. This pr creates clones of the nodes instead, so that mutations aren't reflected in both places where the block is used.