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

Stop exporting dev-only methods in production builds #32200

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Jan 23, 2025

Summary

Affects OSS and FB builds.

The development entrypoints were setup in #29923 but they were always used i.e. they effectively replaced the standard entrypoints. Now we only use the .development.js entrypoints for dev builds.

It's technically a bug fix though it might be too invasive to do now for act. We can definitely do it for captureOwnerStack though.

How did you test this change?

  • added tests
  • yarn build react/index --type NODE_PROD,NODE_ENV no longer contains exports.act and exports.captureOwnerStack in ~/cjs/react.production.js while ~/cjs/react.development.js still has these exports

cc @sebmarkbage

@react-sizebot
Copy link

react-sizebot commented Jan 23, 2025

Comparing: ae9017c...ddfb804

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.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 514.24 kB 514.24 kB = 91.73 kB 91.74 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 = 557.28 kB 557.28 kB = 98.97 kB 98.97 kB
facebook-www/ReactDOM-prod.classic.js = 595.79 kB 595.79 kB = 104.85 kB 104.85 kB
facebook-www/ReactDOM-prod.modern.js = 586.21 kB 586.21 kB = 103.30 kB 103.30 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/cjs/react.react-server.production.js = 18.72 kB 18.66 kB = 4.97 kB 4.95 kB
oss-stable/react/cjs/react.production.js = 17.02 kB 16.92 kB = 4.45 kB 4.41 kB
oss-stable-semver/react/cjs/react.production.js = 17.00 kB 16.89 kB = 4.42 kB 4.38 kB
facebook-www/React-profiling.classic.js = 21.07 kB 20.93 kB = 5.37 kB 5.31 kB
facebook-www/React-profiling.modern.js = 21.07 kB 20.92 kB = 5.37 kB 5.31 kB
facebook-www/React-prod.classic.js = 20.63 kB 20.49 kB = 5.28 kB 5.23 kB
facebook-www/React-prod.modern.js = 20.63 kB 20.49 kB = 5.28 kB 5.23 kB
facebook-react-native/react/cjs/React-profiling.js = 19.55 kB 19.41 kB = 5.05 kB 5.00 kB
facebook-react-native/react/cjs/React-prod.js = 19.12 kB 18.98 kB = 4.97 kB 4.92 kB
oss-experimental/react/cjs/react.production.js = 18.42 kB 18.21 kB = 4.77 kB 4.70 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.development.js = 32.24 kB 31.60 kB = 5.77 kB 5.69 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.development.js = 32.24 kB 31.60 kB = 5.77 kB 5.69 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.development.js = 32.24 kB 31.60 kB = 5.77 kB 5.69 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.production.js = 28.72 kB 28.15 kB = 5.64 kB 5.56 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.production.js = 28.72 kB 28.15 kB = 5.64 kB 5.56 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.production.js = 28.72 kB 28.15 kB = 5.64 kB 5.56 kB

Generated by 🚫 dangerJS against 03420f6

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy of index.stable.js + act

Copy link
Collaborator Author

@eps1lon eps1lon Jan 23, 2025

Choose a reason for hiding this comment

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

Copy of index.fb.js + act + captureOwnerStack

@@ -571,7 +571,7 @@ function shouldSkipBundle(bundle, bundleType) {
return false;
}

function resolveEntryFork(resolvedEntry, isFBBundle) {
function resolveEntryFork(resolvedEntry, isFBBundle, isDev) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Third arg was always passed but not utilized until now.

@@ -779,13 +779,5 @@ function runActTests(render, unmount, rerender) {
});
}
});
describe('throw in prod mode', () => {
Copy link
Collaborator Author

@eps1lon eps1lon Jan 23, 2025

Choose a reason for hiding this comment

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

Replaced by the test in packages/react-reconciler/src/__tests__/ReactIsomorphicAct-test.js. This is testing React.act not react-dom/test-utils

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.

3 participants