Skip to content
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

[Fiber] Make DevTools Config use Static Injection #30522

Merged
merged 5 commits into from
Jul 30, 2024

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Jul 30, 2024

We use static dependency injection. We shouldn't use this dynamic dependency injection we do for DevTools internals. There's also meta programming like spreading and stuff that isn't needed.

This moves the config from injectIntoDevTools to the FiberConfig so it can be statically resolved.

Closure Compiler has some trouble generating optimal code for this anyway so ideally we'd refactor this further but at least this is better and saves a few bytes and avoids some code paths (when minified).

We shouldn't use meta programming like spread that gets deopted.
No need to have a bunch of `fieldName: null,` in the production builds.
Lets third parties specify their own version of their library separate
from the reconciler.
Copy link

vercel bot commented Jul 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2024 0:17am

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jul 30, 2024
@react-sizebot
Copy link

react-sizebot commented Jul 30, 2024

Comparing: bea5a2b...8858f83

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB +0.11% 1.82 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 501.29 kB 500.39 kB = 89.95 kB 89.78 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB +0.16% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 508.41 kB 507.52 kB = 91.12 kB 90.95 kB
facebook-www/ReactDOM-prod.classic.js = 596.31 kB 595.41 kB = 105.76 kB 105.58 kB
facebook-www/ReactDOM-prod.modern.js = 572.61 kB 571.71 kB = 101.96 kB 101.78 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-noop-renderer/cjs/react-noop-renderer.production.js +0.31% 35.20 kB 35.30 kB +1.03% 6.62 kB 6.68 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-persistent.production.js +0.31% 35.32 kB 35.43 kB +1.01% 6.63 kB 6.70 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer.development.js +0.29% 39.31 kB 39.43 kB +0.99% 7.20 kB 7.27 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js +0.29% 39.45 kB 39.57 kB +0.98% 7.22 kB 7.29 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer.production.js +0.28% 35.20 kB 35.29 kB +0.94% 6.62 kB 6.68 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-persistent.production.js +0.28% 35.32 kB 35.42 kB +0.92% 6.63 kB 6.70 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer.development.js +0.26% 39.31 kB 39.42 kB +0.90% 7.20 kB 7.26 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js +0.26% 39.45 kB 39.56 kB +0.90% 7.22 kB 7.28 kB
oss-stable-rc/react-noop-renderer/cjs/react-noop-renderer.production.js +0.22% 35.20 kB 35.27 kB +0.51% 6.62 kB 6.65 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer.production.js +0.22% 35.20 kB 35.27 kB +0.51% 6.62 kB 6.65 kB
oss-stable-rc/react-noop-renderer/cjs/react-noop-renderer-persistent.production.js +0.22% 35.32 kB 35.40 kB +0.50% 6.63 kB 6.67 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-persistent.production.js +0.22% 35.32 kB 35.40 kB +0.50% 6.63 kB 6.67 kB
oss-stable-rc/react-noop-renderer/cjs/react-noop-renderer.development.js +0.21% 39.31 kB 39.40 kB +0.51% 7.20 kB 7.24 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer.development.js +0.21% 39.31 kB 39.40 kB +0.51% 7.20 kB 7.24 kB
oss-stable-rc/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js +0.21% 39.45 kB 39.54 kB +0.51% 7.22 kB 7.25 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js +0.21% 39.45 kB 39.54 kB +0.51% 7.22 kB 7.25 kB
react-native/implementations/ReactNativeRenderer-profiling.fb.js = 397.54 kB 396.74 kB = 69.52 kB 69.36 kB
react-native/implementations/ReactFabric-profiling.fb.js = 391.73 kB 390.94 kB = 68.41 kB 68.22 kB
facebook-www/ReactART-prod.classic.js = 363.20 kB 362.47 kB = 61.80 kB 61.67 kB
react-native/implementations/ReactNativeRenderer-profiling.js = 383.08 kB 382.27 kB = 66.77 kB 66.62 kB
facebook-www/ReactART-prod.modern.js = 346.21 kB 345.47 kB = 59.04 kB 58.91 kB
react-native/implementations/ReactFabric-profiling.js = 373.80 kB 372.99 kB = 65.03 kB 64.88 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-profiling.js = 342.49 kB 341.72 kB = 59.89 kB 59.74 kB
react-native/implementations/ReactFabric-prod.fb.js = 364.24 kB 363.41 kB = 64.11 kB 63.99 kB
react-native/implementations/ReactNativeRenderer-prod.fb.js = 370.08 kB 369.23 kB = 65.17 kB 65.09 kB
react-native/implementations/ReactNativeRenderer-prod.js = 355.82 kB 354.96 kB = 62.51 kB 62.39 kB
react-native/implementations/ReactFabric-prod.js = 346.47 kB 345.62 kB = 60.85 kB 60.78 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-prod.js = 318.55 kB 317.77 kB = 56.42 kB 56.28 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.production.js = 303.53 kB 302.75 kB = 53.99 kB 53.85 kB
oss-stable/react-test-renderer/cjs/react-test-renderer.production.js = 300.44 kB 299.65 kB = 53.43 kB 53.29 kB
oss-stable-rc/react-test-renderer/cjs/react-test-renderer.production.js = 300.40 kB 299.59 kB = 53.41 kB 53.27 kB
oss-stable-semver/react-test-renderer/cjs/react-test-renderer.production.js = 300.40 kB 299.59 kB = 53.41 kB 53.27 kB
oss-experimental/react-art/cjs/react-art.production.js = 298.95 kB 298.11 kB = 51.64 kB 51.47 kB
oss-stable/react-art/cjs/react-art.production.js = 292.01 kB 291.16 kB = 50.43 kB 50.26 kB
oss-stable-rc/react-art/cjs/react-art.production.js = 291.97 kB 291.10 kB = 50.41 kB 50.24 kB
oss-stable-semver/react-art/cjs/react-art.production.js = 291.97 kB 291.10 kB = 50.41 kB 50.24 kB
facebook-www/ReactDOMTesting-dev.classic.js = 1,100.47 kB 1,097.12 kB = 185.85 kB 185.49 kB
facebook-www/ReactDOMTesting-dev.modern.js = 1,063.57 kB 1,060.31 kB = 179.76 kB 179.41 kB
facebook-www/ReactDOM-dev.classic.js = 1,083.56 kB 1,080.22 kB = 181.88 kB 181.53 kB
facebook-www/ReactDOM-dev.modern.js = 1,046.66 kB 1,043.40 kB = 175.88 kB 175.52 kB
oss-experimental/react-dom/cjs/react-dom-profiling.development.js = 966.17 kB 962.99 kB = 163.46 kB 163.09 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.development.js = 966.69 kB 963.49 kB = 164.48 kB 164.09 kB
oss-stable/react-dom/cjs/react-dom-profiling.development.js = 952.40 kB 949.22 kB = 161.48 kB 161.09 kB
oss-stable-rc/react-dom/cjs/react-dom-profiling.development.js = 952.30 kB 949.12 kB = 161.46 kB 161.06 kB
oss-stable-semver/react-dom/cjs/react-dom-profiling.development.js = 952.30 kB 949.12 kB = 161.46 kB 161.06 kB
oss-experimental/react-dom/cjs/react-dom-client.development.js = 949.73 kB 946.55 kB = 160.63 kB 160.27 kB
oss-stable/react-dom/cjs/react-dom-client.development.js = 935.96 kB 932.78 kB = 158.64 kB 158.28 kB
oss-stable-rc/react-dom/cjs/react-dom-client.development.js = 935.86 kB 932.68 kB = 158.61 kB 158.25 kB
oss-stable-semver/react-dom/cjs/react-dom-client.development.js = 935.86 kB 932.68 kB = 158.61 kB 158.25 kB
react-native/implementations/ReactFabric-dev.fb.js = 648.08 kB 645.45 kB = 106.24 kB 106.04 kB
react-native/implementations/ReactFabric-dev.js = 631.33 kB 628.70 kB = 103.32 kB 103.17 kB
react-native/implementations/ReactNativeRenderer-dev.fb.js = 654.47 kB 651.67 kB = 107.68 kB 107.47 kB
react-native/implementations/ReactNativeRenderer-dev.js = 642.27 kB 639.47 kB = 105.44 kB 105.27 kB
facebook-www/ReactART-dev.classic.js = 650.27 kB 647.30 kB = 104.53 kB 104.21 kB
facebook-www/ReactART-dev.modern.js = 626.86 kB 623.97 kB = 100.75 kB 100.46 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-dev.js = 579.53 kB 576.57 kB = 94.56 kB 94.22 kB
oss-experimental/react-art/cjs/react-art.development.js = 563.57 kB 560.61 kB = 91.17 kB 90.84 kB
oss-stable/react-art/cjs/react-art.development.js = 549.45 kB 546.48 kB = 89.32 kB 88.99 kB
oss-stable-rc/react-art/cjs/react-art.development.js = 549.40 kB 546.42 kB = 89.30 kB 88.97 kB
oss-stable-semver/react-art/cjs/react-art.development.js = 549.40 kB 546.42 kB = 89.30 kB 88.97 kB

Generated by 🚫 dangerJS against 9484132

Comment on lines +66 to +70
export const extraDevToolsConfig = {
getInspectorDataForInstance,
getInspectorDataForViewTag,
getInspectorDataForViewAtPoint,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will require some changes on React Native side before the sync

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that? I tried to keep it the same as far as what React Native observes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I thought we are calling <renderer>.rendererConfig.getInspectorDataForViewAtPoint on RN side, but we actually use it from RDT global hook, so should be perfectly fine

@sebmarkbage sebmarkbage merged commit 146df7c into facebook:main Jul 30, 2024
185 checks passed
github-actions bot pushed a commit that referenced this pull request Jul 30, 2024
We use static dependency injection. We shouldn't use this dynamic
dependency injection we do for DevTools internals. There's also meta
programming like spreading and stuff that isn't needed.

This moves the config from `injectIntoDevTools` to the FiberConfig so it
can be statically resolved.

Closure Compiler has some trouble generating optimal code for this
anyway so ideally we'd refactor this further but at least this is better
and saves a few bytes and avoids some code paths (when minified).

DiffTrain build for [146df7c](146df7c)
github-actions bot pushed a commit that referenced this pull request Jul 30, 2024
We use static dependency injection. We shouldn't use this dynamic
dependency injection we do for DevTools internals. There's also meta
programming like spreading and stuff that isn't needed.

This moves the config from `injectIntoDevTools` to the FiberConfig so it
can be statically resolved.

Closure Compiler has some trouble generating optimal code for this
anyway so ideally we'd refactor this further but at least this is better
and saves a few bytes and avoids some code paths (when minified).

DiffTrain build for commit 146df7c.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants