Repository navigation
allowMutablePropsOnTags: cache JSX constant elements with function props - #12975
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 4f9b9c4:
|
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/51305/ |
jridgewell
left a comment
There was a problem hiding this comment.
Can we get a few test cases for nested do expressions?
I think this series of PRs is really clever workaround for the hoisting issue. Thanks!
| // If we allow mutable props, tags with function expressions can be | ||
| // safely hoisted. | ||
| const { mutablePropsAllowed } = state; | ||
| if (mutablePropsAllowed && path.isFunction()) return skip(); |
There was a problem hiding this comment.
I'd propose we traverse with the targetScopeVisitor here, so we could keep the two traversals together.
4f9b9c4 to
425f9f7
Compare
| } | ||
|
|
||
| if (!path.isImmutable()) { | ||
| // If it's not immutable, it may still be a pure expression, such as string concatenation. |
There was a problem hiding this comment.
This was not actually changed; I suggest hiding whitespace changes when reviewing.
allowMutablePropsOnTags allowMutablePropsOnTags: cache JSX const elements w/ fn props
allowMutablePropsOnTags: cache JSX const elements w/ fn propsallowMutablePropsOnTags: cache JSX constant elements with function props
@jridgewell You were right!
I had to split
immutabiltyVisitorandtargetScopeVisitorin two visitors because I had to skip functions when checking for immutability, but traverse them when collecting references.