-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Moved named hooks code (and tests) from react-devtools-extensions to react-devtools-shared #22260
Moved named hooks code (and tests) from react-devtools-extensions to react-devtools-shared #22260
Conversation
…react-devtools-shared Note that this is purely a move. It does not update any paths/configs/etc. This is to make it easier to review, but it also means that this commit breaks the code temporarily.
This changes the format of files slightly (e.g. removes Facebook copyirght headers, slightly different Prettier formatting) but all tests pass.
This is the commit that should be reviewed.
Comparing: abbc79d...7fa3ab6 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
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.
thanks! regarding the changes in the generated files, if we run update-mock-source-maps
/before/ moving the files around, does that still produce the changes in the files? maybe some dependency got updated that changed the output
Oh, huh. That's a good question! I'm actually not able to run that command in
Not sure what's up here.
This seems like a reasonable explanation though. |
I just deleted |
This commit builds on PR #22260 and makes the following changes: * Adds a DevTools feature flag for named hooks support. (This allows us to disable it entirely for a build via feature flag.) * Adds a new Suspense cache for dynamically imported modules. (This allows a component to suspend while importing an external code chunk– like the hook names parsing code). * DevTools supports a hookNamesModuleLoaderFunction param to import the hook names module. I wish this could be handles as part of the react-devtools-shared package, but I'm not sure how to configure Webpack (4) to serve the chunk from react-devtools-inline. This seemed like a reasonable workaround. The PR also contains an additional unrelated change: * Removes pre-fetch optimization (added in DevTools: Improve named hooks network caching #22198). This optimization was mostly only important for cases where sources needed to be re-downloaded, something which we can now avoid in most cases¹ thanks to using cached responses already loaded by the page. (I tested this locally on Facebook and this change has no negative performance impact. There is still some overhead from serializing the JS through the Bridge but that's constant between the two approaches.) ¹ The case where we don't benefit from cached responses is when DevTools are opened after the page has already loaded certain scripts. This seems uncommon enough that I don't think it justified the added complexity of prefetching.
…react-devtools-shared (facebook#22260)
This commit builds on PR facebook#22260 and makes the following changes: * Adds a DevTools feature flag for named hooks support. (This allows us to disable it entirely for a build via feature flag.) * Adds a new Suspense cache for dynamically imported modules. (This allows a component to suspend while importing an external code chunk– like the hook names parsing code). * DevTools supports a hookNamesModuleLoaderFunction param to import the hook names module. I wish this could be handles as part of the react-devtools-shared package, but I'm not sure how to configure Webpack (4) to serve the chunk from react-devtools-inline. This seemed like a reasonable workaround. The PR also contains an additional unrelated change: * Removes pre-fetch optimization (added in DevTools: Improve named hooks network caching facebook#22198). This optimization was mostly only important for cases where sources needed to be re-downloaded, something which we can now avoid in most cases¹ thanks to using cached responses already loaded by the page. (I tested this locally on Facebook and this change has no negative performance impact. There is still some overhead from serializing the JS through the Bridge but that's constant between the two approaches.) ¹ The case where we don't benefit from cached responses is when DevTools are opened after the page has already loaded certain scripts. This seems uncommon enough that I don't think it justified the added complexity of prefetching.
This is an pre-req for adding the named hooks feature to react-devtools-inline (and eventually the standalone package as well).
This PR is split into three commits to simplify review:
react-devtools-extensions
toreact-devtools-shared
yarn update-mock-source-maps
inreact-devtools-shared
IMO only the third commit needs to be carefully reviewed.
Why did generated code change?
I'm not sure why the 2nd step generated slight differences in generated code. The changes seem to be two things (both explained below). May be worth reviewers spot checking a few files to make sure nothing else unexpected changed?
The good news is that all tests still pass.
Comment header blocks have been altered
Some are removed entirely:
Others remain but have the
@flow
pragma comment removed:Compiled JSX expression have added
__source
metadata.For instance, generated code that previously looked like this:
Now looks like this: