Skip to content

[Fresh] Make transform resilient to plugin order#15883

Merged
gaearon merged 3 commits intofacebook:masterfrom
gaearon:fresh-rn-more
Jun 14, 2019
Merged

[Fresh] Make transform resilient to plugin order#15883
gaearon merged 3 commits intofacebook:masterfrom
gaearon:fresh-rn-more

Conversation

@gaearon
Copy link
Copy Markdown
Collaborator

@gaearon gaearon commented Jun 14, 2019

First commit makes Fresh integration tests run in two modes: with and without destructuring transform. This adds failing tests because currently we're not resilient to the plugin order issues. If destructuring transform visits our nodes first, we can't recover info about Hook signatures later. (Look at it with ?w=1.)

Second commit solves this problem by adding an early traversal that collects Hook calls. In general early traversals should be avoided. But that's the only way we can collect signatures before they're mangled. To mitigate the perf concern, we make sure this early traversal doesn't do any mutations. So at least it won't have cause cascade issues. It's also very simple. This fixes the new tests.

The last commit is just a minor refactoring.

gaearon added 3 commits June 14, 2019 14:37
Destructuring transform messes up the way we collect signatures for Hooks. This adds failing tests.
This introduces a bit of a perf penalty but makes our plugin resilient to presence of destructuring transform and their order. Fixes new tests.
@sizebot
Copy link
Copy Markdown

sizebot commented Jun 14, 2019

Details of bundled changes.

Comparing: 2fe8fd2...3d654b2

react-fresh

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-fresh-runtime.development.js 0.0% +0.1% 6.55 KB 6.55 KB 2.37 KB 2.37 KB NODE_DEV
react-fresh-runtime.production.min.js 0.0% 🔺+0.1% 1.86 KB 1.86 KB 989 B 990 B NODE_PROD
react-fresh-babel.development.js +0.8% +4.4% 21.51 KB 21.67 KB 4.46 KB 4.65 KB NODE_DEV
react-fresh-babel.production.min.js 0.0% 🔺+0.2% 6.29 KB 6.3 KB 2.16 KB 2.17 KB NODE_PROD

Generated by 🚫 dangerJS

@gaearon gaearon merged commit de7a09c into facebook:master Jun 14, 2019
@gaearon gaearon deleted the fresh-rn-more branch June 14, 2019 13:57
gaearon added a commit to gaearon/react that referenced this pull request Jun 19, 2019
* Run Fresh tests in two modes: with and without destructuring

Destructuring transform messes up the way we collect signatures for Hooks. This adds failing tests.

* Extract collecting calls to Hooks into a separate visitor

This introduces a bit of a perf penalty but makes our plugin resilient to presence of destructuring transform and their order. Fixes new tests.

* Inline some logic into the call visitor
rickhanlonii pushed a commit to rickhanlonii/react that referenced this pull request Jun 25, 2019
* Run Fresh tests in two modes: with and without destructuring

Destructuring transform messes up the way we collect signatures for Hooks. This adds failing tests.

* Extract collecting calls to Hooks into a separate visitor

This introduces a bit of a perf penalty but makes our plugin resilient to presence of destructuring transform and their order. Fixes new tests.

* Inline some logic into the call visitor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants