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

Use console directly instead of warning() modules #17599

Merged
merged 3 commits into from Dec 14, 2019

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Dec 13, 2019

Picking up where #17568 and #17586 left.
Related to #16753.

This replaces four custom modules in the source with direct calls:

  • shared/warning -> console.error
  • shared/warningWithoutStack -> console.error
  • shared/lowPriorityWarning -> console.warn
  • shared/lowPriorityWarningWithoutStack -> console.warn

To review, you want to look at the second commit because the first one is just a find-replace.

Here's a few points about the new system.

Not Removed in Prod

We're not doing anything special to remove console.error or console.warn calls in prod anymore. If you keep them, they'll be there. We do have a linter plugin that tells you to wrap it in DEV. I audited existing cases where it fails, and added suppressions where it was intentional.

Stack Is Injected Automatically

You don't need to choose whether to inject the stack. If you use console.error, it will be injected automatically, as long as the package from which you're calling it has access to the React object. Alternatively, it will keep your console.error as is in the source (no stack). DevTools would likely pick it up though anyway.

Note: in the future we might completely remove the stack injection and always rely on DevTools and similar mechanisms (e.g. RN integration) to inject it.

Escape Hatches

If you want to use the "raw" console.error or console.warn for whatever reason, you can do it like this:

console['error']('hahaha');

This will use the native console.error in DEV too. Practically, this means we won't try to append the stack, prepend the Warning: marker (which is currently relied on by RN), or go through the WWW whitelist. There's only a few places that we do this.

Gotchas

We have two modules that don't have access to the isomorphic React package: scheduler and react-is. So we can't append the stacks. This means console.error calls inside of these two packages won't get transformed even in DEV for real bundles — they'll stay as console.error. But in our tests, they would be transformed. (I changed this to fail the build.)

We barely have any warnings there, and both are meant to be lightweight. So I think it's okay. The fact that they don't go through the WWW list can be confusing. But in longer term we want to get rid of the special warning entry point altogether. In that world, we would have the list be a list of warnings to mute, and pass everything else through.

To get there, we'll need to enforce that the React warning list matches WWW list 1:1. We'd need to get buy-in from other teams for that to work out. In the meantime, I don't expect we'll add a lot of new warnings to either scheduler or react-is anyway.

If this gotcha ends up being a pain, we can always have a second "compile target" that exists solely to make these warnings go through the WWW list anyway.

Risks

Let's sync WWW carefully after this. We need to verify nothing broke and warnings still fire. I can do this.

Follow-ups

Out of scope of this PR, but after landing this I'm planning to rename toWarnDev to toErrorDev (because it's for console.error), and toLowPriorityWarnDev to toWarnDev (because it's for console.warn). Then I plan to audit the warnings and split them into these two levels according to whether they represent real issues or not.

Additionally, I'll remove the cases where we detect presence of custom stack first before appending it. Instead, we'll set the current fiber.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 13, 2019

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 443ef71:

Sandbox Source
staging-microservice-wsvmg Configuration

@sizebot
Copy link

sizebot commented Dec 13, 2019

Details of bundled changes.

Comparing: b6c423d...443ef71

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react.development.js -3.2% -1.5% 113.95 KB 110.33 KB 28.78 KB 28.34 KB UMD_DEV
react.production.min.js 0.0% -0.0% 12.52 KB 12.52 KB 4.9 KB 4.9 KB UMD_PROD
React-dev.js -4.0% -3.2% 71.99 KB 69.11 KB 18.32 KB 17.73 KB FB_WWW_DEV
React-prod.js -0.3% -0.5% 17.75 KB 17.7 KB 4.62 KB 4.6 KB FB_WWW_PROD
React-profiling.js -0.3% -0.5% 17.75 KB 17.7 KB 4.62 KB 4.6 KB FB_WWW_PROFILING
react.development.js -5.2% -2.6% 73.69 KB 69.83 KB 19.16 KB 18.67 KB NODE_DEV
react.production.min.js -0.0% -0.2% 6.81 KB 6.8 KB 2.81 KB 2.81 KB NODE_PROD

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js -0.0% 0.0% 123.32 KB 123.32 KB 38.8 KB 38.8 KB NODE_PROFILING
react-dom-server.browser.development.js -2.8% -1.2% 141.34 KB 137.4 KB 36.95 KB 36.52 KB UMD_DEV
react-dom-server.browser.production.min.js 0.0% -0.1% 20.39 KB 20.39 KB 7.48 KB 7.48 KB UMD_PROD
react-dom-test-utils.development.js -6.5% -3.0% 58.14 KB 54.37 KB 15.73 KB 15.26 KB UMD_DEV
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.88 KB 3.88 KB 1.55 KB 1.55 KB UMD_DEV
ReactDOMServer-dev.js -2.1% -1.2% 141.04 KB 138.03 KB 35.54 KB 35.11 KB FB_WWW_DEV
react-dom-test-utils.development.js -6.7% -3.1% 56.42 KB 52.65 KB 15.42 KB 14.94 KB NODE_DEV
ReactDOMServer-prod.js -0.1% -0.2% 48.91 KB 48.86 KB 11.18 KB 11.16 KB FB_WWW_PROD
react-dom-test-utils.production.min.js 0.0% -0.0% 10.95 KB 10.95 KB 4.09 KB 4.09 KB NODE_PROD
react-dom.development.js -0.4% -0.4% 957.44 KB 953.23 KB 215.79 KB 214.9 KB UMD_DEV
react-dom.production.min.js 0.0% -0.0% 119.36 KB 119.36 KB 38.45 KB 38.44 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 123.05 KB 123.05 KB 39.65 KB 39.65 KB UMD_PROFILING
ReactDOMUnstableNativeDependencies-dev.js -2.8% -4.0% 60.01 KB 58.32 KB 15.45 KB 14.84 KB FB_WWW_DEV
react-dom.development.js -0.4% -0.4% 951.51 KB 947.29 KB 214.21 KB 213.25 KB NODE_DEV
ReactDOMUnstableNativeDependencies-prod.js -4.9% -5.8% 26.49 KB 25.19 KB 5.34 KB 5.03 KB FB_WWW_PROD
react-dom-server.node.development.js -2.8% -1.3% 138.38 KB 134.44 KB 36.19 KB 35.73 KB NODE_DEV
react-dom.production.min.js -0.0% -0.0% 119.51 KB 119.51 KB 37.78 KB 37.78 KB NODE_PROD
react-dom-server.node.production.min.js 0.0% -0.0% 20.73 KB 20.73 KB 7.61 KB 7.61 KB NODE_PROD
ReactTestUtils-dev.js -5.1% -3.5% 54.01 KB 51.23 KB 14.44 KB 13.93 KB FB_WWW_DEV
react-dom-server.browser.development.js -2.9% -1.3% 137.27 KB 133.33 KB 35.96 KB 35.5 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% -0.1% 20.32 KB 20.32 KB 7.46 KB 7.46 KB NODE_PROD
react-dom-unstable-native-dependencies.development.js -1.3% -0.6% 61.58 KB 60.81 KB 16.12 KB 16.02 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js -6.7% -6.8% 10.96 KB 10.23 KB 3.73 KB 3.47 KB UMD_PROD
ReactDOM-dev.js -0.3% -0.4% 977.22 KB 973.92 KB 216.62 KB 215.8 KB FB_WWW_DEV
ReactDOM-prod.js -0.0% -0.0% 402.91 KB 402.86 KB 73.65 KB 73.63 KB FB_WWW_PROD
react-dom-unstable-native-dependencies.development.js -1.3% -0.6% 61.28 KB 60.51 KB 16.03 KB 15.94 KB NODE_DEV
ReactDOM-profiling.js -0.0% -0.0% 403.84 KB 403.79 KB 74.22 KB 74.19 KB FB_WWW_PROFILING
react-dom-unstable-native-dependencies.production.min.js -7.0% -7.3% 10.73 KB 9.97 KB 3.64 KB 3.37 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactFabric-prod.js -0.3% -0.5% 268.43 KB 267.53 KB 46.44 KB 46.19 KB RN_FB_PROD
ReactNativeRenderer-dev.js -0.6% -0.7% 749.96 KB 745.72 KB 158.22 KB 157.17 KB RN_OSS_DEV
ReactFabric-profiling.js -0.3% -0.5% 278.54 KB 277.63 KB 48.3 KB 48.06 KB RN_FB_PROFILING
ReactNativeRenderer-prod.js -0.3% -0.6% 276.78 KB 275.87 KB 47.82 KB 47.55 KB RN_FB_PROD
ReactNativeRenderer-profiling.js -0.3% -0.5% 285.71 KB 284.8 KB 49.53 KB 49.27 KB RN_FB_PROFILING
ReactFabric-dev.js -0.6% -0.7% 754.99 KB 750.73 KB 158.99 KB 157.93 KB RN_OSS_DEV
ReactFabric-prod.js -0.3% -0.5% 268.08 KB 267.18 KB 46.35 KB 46.12 KB RN_OSS_PROD
ReactFabric-profiling.js -0.3% -0.5% 278.19 KB 277.29 KB 48.22 KB 48 KB RN_OSS_PROFILING
ReactFabric-dev.js -0.6% -0.7% 755.17 KB 750.91 KB 159.07 KB 158.02 KB RN_FB_DEV
ReactNativeRenderer-prod.js -0.3% -0.5% 276.39 KB 275.48 KB 47.74 KB 47.48 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js -0.3% -0.5% 285.32 KB 284.41 KB 49.45 KB 49.21 KB RN_OSS_PROFILING
ReactNativeRenderer-dev.js -0.6% -0.7% 750.14 KB 745.89 KB 158.31 KB 157.25 KB RN_FB_DEV

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js -0.7% -0.8% 622.11 KB 618.03 KB 131.9 KB 130.86 KB UMD_DEV
ReactTestRenderer-dev.js -0.5% -0.6% 630.9 KB 627.81 KB 131.04 KB 130.19 KB FB_WWW_DEV
react-test-renderer-shallow.development.js -4.1% -3.4% 39.2 KB 37.58 KB 10.06 KB 9.72 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% 🔺+0.1% 11.6 KB 11.6 KB 3.58 KB 3.58 KB UMD_PROD
react-test-renderer-shallow.development.js -3.1% -2.0% 33.15 KB 32.12 KB 8.59 KB 8.42 KB NODE_DEV
react-test-renderer.development.js -0.7% -0.8% 617.38 KB 613.3 KB 130.71 KB 129.68 KB NODE_DEV
ReactShallowRenderer-dev.js -3.8% -4.6% 34.5 KB 33.2 KB 8.54 KB 8.14 KB FB_WWW_DEV

react-interactions

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-interactions-events/hover.development.js 0.0% +0.1% 7.02 KB 7.02 KB 1.56 KB 1.56 KB UMD_DEV
react-interactions-events/press-legacy.development.js -4.1% -2.7% 24.83 KB 23.81 KB 6.24 KB 6.08 KB UMD_DEV
react-interactions-events/press-legacy.production.min.js -3.1% -4.3% 7.49 KB 7.26 KB 2.85 KB 2.73 KB UMD_PROD
react-interactions-events/keyboard.development.js 0.0% 0.0% 6.1 KB 6.1 KB 2.29 KB 2.29 KB UMD_DEV
ReactEventsPressLegacy-dev.js -7.8% -11.4% 24.28 KB 22.39 KB 6 KB 5.32 KB FB_WWW_DEV
react-interactions-events/keyboard.development.js 0.0% 0.0% 5.92 KB 5.92 KB 2.25 KB 2.25 KB NODE_DEV
ReactEventsPressLegacy-prod.js -2.2% -3.9% 17.14 KB 16.77 KB 3.83 KB 3.68 KB FB_WWW_PROD
react-interactions-events/drag.production.min.js 0.0% 🔺+0.1% 2.9 KB 2.9 KB 1.39 KB 1.39 KB NODE_PROD
react-interactions-events/swipe.production.min.js 0.0% 🔺+0.1% 2.28 KB 2.28 KB 1.06 KB 1.06 KB NODE_PROD
react-interactions-events/context-menu.development.js 0.0% +0.2% 2.69 KB 2.69 KB 1012 B 1014 B UMD_DEV
react-interactions-events/context-menu.production.min.js 0.0% -0.1% 1.4 KB 1.4 KB 737 B 736 B UMD_PROD
ReactEventsPress-dev.js -24.7% -30.9% 7.67 KB 5.78 KB 2.27 KB 1.57 KB FB_WWW_DEV
ReactEventsPress-prod.js -8.0% -11.9% 4.61 KB 4.24 KB 1.24 KB 1.1 KB FB_WWW_PROD
react-interactions-events/hover.development.js 0.0% +0.1% 6.83 KB 6.83 KB 1.52 KB 1.52 KB NODE_DEV
react-interactions-events/press-legacy.development.js -4.1% -2.8% 24.64 KB 23.62 KB 6.19 KB 6.02 KB NODE_DEV
react-interactions-events/press-legacy.production.min.js -3.1% -4.4% 7.31 KB 7.08 KB 2.79 KB 2.67 KB NODE_PROD
react-interactions-events/focus.development.js 0.0% 0.0% 15.7 KB 15.7 KB 3.27 KB 3.27 KB UMD_DEV
react-interactions-events/press.development.js -11.2% -6.2% 9.14 KB 8.12 KB 2.74 KB 2.58 KB UMD_DEV
react-interactions-events/tap.development.js 0.0% 0.0% 18.25 KB 18.25 KB 3.93 KB 3.93 KB UMD_DEV
react-interactions-events/focus.production.min.js 0.0% 🔺+0.1% 5.34 KB 5.34 KB 1.77 KB 1.77 KB UMD_PROD
react-interactions-events/press.production.min.js -8.6% -10.4% 2.66 KB 2.43 KB 1.1 KB 1013 B UMD_PROD
react-interactions-events/press.development.js -11.5% -6.5% 8.86 KB 7.83 KB 2.67 KB 2.5 KB NODE_DEV
react-interactions-events/tap.development.js 0.0% 0.0% 18.07 KB 18.07 KB 3.88 KB 3.88 KB NODE_DEV
react-interactions-events/press.production.min.js -9.7% -11.6% 2.37 KB 2.14 KB 1.02 KB 926 B NODE_PROD

react-noop-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-noop-renderer.development.js -2.5% -1.8% 36.36 KB 35.45 KB 8.27 KB 8.12 KB NODE_DEV
react-noop-renderer-flight-client.production.min.js 0.0% 🔺+0.2% 574 B 574 B 422 B 423 B NODE_PROD
react-noop-renderer-server.development.js 0.0% +0.1% 1.98 KB 1.98 KB 905 B 906 B NODE_DEV
react-noop-renderer-server.production.min.js 0.0% 🔺+0.2% 901 B 901 B 512 B 513 B NODE_PROD
react-noop-renderer-persistent.development.js -2.5% -1.8% 36.47 KB 35.57 KB 8.29 KB 8.14 KB NODE_DEV

react-is

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-is.development.js -20.2% -28.2% 8.74 KB 6.98 KB 2.61 KB 1.87 KB UMD_DEV
react-is.development.js -20.6% -28.8% 8.56 KB 6.79 KB 2.56 KB 1.82 KB NODE_DEV
react-is.production.min.js 0.0% -0.2% 2.52 KB 2.52 KB 909 B 907 B NODE_PROD
ReactIs-dev.js -4.9% -7.5% 7.29 KB 6.93 KB 2.01 KB 1.86 KB FB_WWW_DEV
ReactIs-prod.js -0.6% -1.9% 5.23 KB 5.2 KB 1.26 KB 1.24 KB FB_WWW_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactART-dev.js -0.5% -0.7% 619.46 KB 616.4 KB 128.5 KB 127.61 KB FB_WWW_DEV
ReactART-prod.js -0.0% -0.0% 235.76 KB 235.71 KB 40.1 KB 40.08 KB FB_WWW_PROD
react-art.development.js -0.6% -0.7% 677.23 KB 673.19 KB 146.23 KB 145.23 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 106.43 KB 106.43 KB 32.48 KB 32.48 KB UMD_PROD
react-art.development.js -0.7% -0.8% 607.88 KB 603.83 KB 128.81 KB 127.83 KB NODE_DEV
react-art.production.min.js 0.0% -0.0% 71.4 KB 71.4 KB 21.47 KB 21.47 KB NODE_PROD

react-cache

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactCache-dev.js -20.0% -20.1% 9.38 KB 7.5 KB 3.06 KB 2.45 KB FB_WWW_DEV
ReactCache-prod.js -6.7% -5.5% 5.51 KB 5.14 KB 1.7 KB 1.61 KB FB_WWW_PROD
react-cache.development.js -9.4% -5.1% 10.73 KB 9.72 KB 3.5 KB 3.32 KB UMD_DEV
react-cache.production.min.js -8.7% -5.0% 2.62 KB 2.39 KB 1.29 KB 1.22 KB UMD_PROD
react-cache.development.js -9.6% -5.4% 10.5 KB 9.5 KB 3.42 KB 3.24 KB NODE_DEV
react-cache.production.min.js -9.4% -4.8% 2.43 KB 2.2 KB 1.19 KB 1.13 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-persistent.development.js -0.7% -0.8% 606.34 KB 602.29 KB 126.93 KB 125.87 KB NODE_DEV
react-reconciler-reflection.development.js -5.1% -2.7% 20.02 KB 19 KB 6.42 KB 6.25 KB NODE_DEV
react-reconciler.development.js -0.7% -0.8% 608.87 KB 604.81 KB 128.04 KB 126.98 KB NODE_DEV

create-subscription

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
create-subscription.development.js -12.2% -5.5% 8.34 KB 7.32 KB 2.93 KB 2.76 KB NODE_DEV
create-subscription.production.min.js -10.3% -10.1% 2.22 KB 1.99 KB 1.09 KB 1002 B NODE_PROD

ReactDOM: size: 0.0%, gzip: -0.1%

React: size: 0.0%, gzip: -0.0%

Size changes (experimental)

Generated by 🚫 dangerJS against 443ef71

@sizebot
Copy link

sizebot commented Dec 13, 2019

Details of bundled changes.

Comparing: b6c423d...443ef71

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react.development.js -3.2% -1.5% 113.93 KB 110.3 KB 28.77 KB 28.33 KB UMD_DEV
react.profiling.min.js 0.0% 0.0% 15.83 KB 15.83 KB 5.94 KB 5.94 KB UMD_PROFILING
react.development.js -5.2% -2.6% 73.67 KB 69.81 KB 19.15 KB 18.66 KB NODE_DEV
react.production.min.js -0.0% 🔺+0.1% 6.51 KB 6.51 KB 2.71 KB 2.71 KB NODE_PROD

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-unstable-native-dependencies.production.min.js -7.1% -7.3% 10.71 KB 9.96 KB 3.63 KB 3.36 KB NODE_PROD
react-dom-server.browser.development.js -2.9% -1.3% 137.25 KB 133.31 KB 35.96 KB 35.5 KB NODE_DEV
react-dom.development.js -0.4% -0.4% 957.42 KB 953.21 KB 215.76 KB 214.87 KB UMD_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.86 KB 19.86 KB 7.38 KB 7.38 KB NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.87 KB 3.87 KB 1.54 KB 1.54 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.1% 1.2 KB 1.2 KB 701 B 702 B UMD_PROD
react-dom.profiling.min.js 0.0% -0.0% 119.58 KB 119.58 KB 38.64 KB 38.64 KB UMD_PROFILING
react-dom.development.js -0.4% -0.5% 951.49 KB 947.27 KB 214.19 KB 213.22 KB NODE_DEV
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.7 KB 3.7 KB 1.49 KB 1.49 KB NODE_DEV
react-dom.production.min.js -0.0% 0.0% 116.13 KB 116.13 KB 36.85 KB 36.85 KB NODE_PROD
react-dom-unstable-native-dependencies.development.js -1.3% -0.6% 61.56 KB 60.79 KB 16.11 KB 16.01 KB UMD_DEV
react-dom.profiling.min.js -0.0% 0.0% 119.83 KB 119.82 KB 37.84 KB 37.84 KB NODE_PROFILING
react-dom-unstable-native-dependencies.production.min.js -6.7% -6.8% 10.95 KB 10.22 KB 3.72 KB 3.47 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js -1.3% -0.6% 61.27 KB 60.5 KB 16.03 KB 15.93 KB NODE_DEV
react-dom-server.node.development.js -2.8% -1.3% 138.36 KB 134.42 KB 36.19 KB 35.73 KB NODE_DEV
react-dom-test-utils.development.js -6.5% -3.0% 58.13 KB 54.36 KB 15.73 KB 15.25 KB UMD_DEV
react-dom-server.node.production.min.js 0.0% -0.0% 20.27 KB 20.27 KB 7.53 KB 7.53 KB NODE_PROD
react-dom-test-utils.production.min.js 0.0% -0.0% 11.17 KB 11.17 KB 4.14 KB 4.14 KB UMD_PROD
react-dom-test-utils.development.js -6.7% -3.1% 56.4 KB 52.63 KB 15.41 KB 14.93 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 10.94 KB 10.94 KB 4.08 KB 4.08 KB NODE_PROD
react-dom-server.browser.development.js -2.8% -1.2% 141.31 KB 137.38 KB 36.95 KB 36.52 KB UMD_DEV
react-dom-server.browser.production.min.js 0.0% -0.1% 19.93 KB 19.93 KB 7.39 KB 7.38 KB UMD_PROD

react-interactions

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-interactions-events/press-legacy.production.min.js -3.1% -4.4% 7.29 KB 7.06 KB 2.78 KB 2.66 KB NODE_PROD
react-interactions-events/input.production.min.js 0.0% 🔺+0.1% 1.84 KB 1.84 KB 983 B 984 B UMD_PROD
react-interactions-events/hover.development.js 0.0% +0.1% 6.82 KB 6.82 KB 1.51 KB 1.51 KB NODE_DEV
react-interactions-events/context-menu.development.js 0.0% +0.1% 2.68 KB 2.68 KB 1006 B 1007 B UMD_DEV
react-interactions-events/keyboard.development.js 0.0% 0.0% 6.09 KB 6.09 KB 2.29 KB 2.29 KB UMD_DEV
react-interactions-events/tap.development.js 0.0% 0.0% 18.24 KB 18.24 KB 3.93 KB 3.93 KB UMD_DEV
react-interactions-events/tap.production.min.js 0.0% 0.0% 6.33 KB 6.33 KB 2.38 KB 2.38 KB UMD_PROD
react-interactions-events/context-menu.development.js 0.0% +0.1% 2.49 KB 2.49 KB 960 B 961 B NODE_DEV
react-interactions-events/tap.development.js 0.0% 0.0% 18.06 KB 18.06 KB 3.87 KB 3.87 KB NODE_DEV
react-interactions-events/press-legacy.development.js -4.1% -2.7% 24.81 KB 23.8 KB 6.24 KB 6.07 KB UMD_DEV
react-interactions-events/tap.production.min.js 0.0% 0.0% 6.17 KB 6.17 KB 2.34 KB 2.34 KB NODE_PROD
react-interactions-events/focus.production.min.js 0.0% 🔺+0.1% 5.32 KB 5.32 KB 1.76 KB 1.76 KB UMD_PROD
react-interactions-events/press-legacy.production.min.js -3.1% -4.4% 7.48 KB 7.25 KB 2.84 KB 2.71 KB UMD_PROD
react-interactions-events/focus.development.js 0.0% 0.0% 15.5 KB 15.5 KB 3.22 KB 3.22 KB NODE_DEV
react-interactions-events/press-legacy.development.js -4.1% -2.7% 24.63 KB 23.61 KB 6.18 KB 6.01 KB NODE_DEV
react-interactions-events/input.development.js 0.0% +0.1% 4.34 KB 4.34 KB 1.4 KB 1.4 KB NODE_DEV
react-interactions-events/swipe.development.js 0.0% -0.1% 5.82 KB 5.82 KB 1.58 KB 1.58 KB NODE_DEV
react-interactions-events/press.development.js -11.2% -6.1% 9.13 KB 8.11 KB 2.73 KB 2.57 KB UMD_DEV
react-interactions-events/press.production.min.js -8.6% -10.5% 2.65 KB 2.42 KB 1.1 KB 1004 B UMD_PROD
react-interactions-events/drag.development.js 0.0% 0.0% 6.98 KB 6.98 KB 2.21 KB 2.21 KB NODE_DEV
react-interactions-events/press.development.js -11.6% -6.6% 8.84 KB 7.82 KB 2.66 KB 2.49 KB NODE_DEV
react-interactions-events/drag.production.min.js 0.0% 🔺+0.1% 2.88 KB 2.88 KB 1.38 KB 1.38 KB NODE_PROD
react-interactions-events/hover.development.js 0.0% +0.1% 7 KB 7 KB 1.55 KB 1.56 KB UMD_DEV
react-interactions-events/press.production.min.js -9.7% -11.7% 2.36 KB 2.13 KB 1.01 KB 917 B NODE_PROD
react-interactions-events/scroll.development.js 0.0% -0.1% 6.3 KB 6.3 KB 1.65 KB 1.65 KB UMD_DEV

react-noop-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-noop-renderer.production.min.js 0.0% 0.0% 11.96 KB 11.96 KB 3.82 KB 3.82 KB NODE_PROD
react-noop-renderer-persistent.development.js -2.5% -1.8% 36.46 KB 35.56 KB 8.28 KB 8.13 KB NODE_DEV
react-noop-renderer-persistent.production.min.js 0.0% 0.0% 11.98 KB 11.98 KB 3.83 KB 3.83 KB NODE_PROD
react-noop-renderer.development.js -2.5% -1.8% 36.35 KB 35.44 KB 8.26 KB 8.12 KB NODE_DEV
react-noop-renderer-server.development.js 0.0% +0.1% 1.97 KB 1.97 KB 897 B 898 B NODE_DEV
react-noop-renderer-flight-client.production.min.js 0.0% 🔺+0.2% 561 B 561 B 413 B 414 B NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-persistent.development.js -0.7% -0.8% 606.33 KB 602.27 KB 126.92 KB 125.86 KB NODE_DEV
react-reconciler.development.js -0.7% -0.8% 608.86 KB 604.8 KB 128.03 KB 126.98 KB NODE_DEV
react-reconciler-reflection.development.js -5.1% -2.7% 20.01 KB 18.99 KB 6.42 KB 6.25 KB NODE_DEV

react-is

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-is.development.js -20.6% -28.8% 8.54 KB 6.78 KB 2.55 KB 1.82 KB NODE_DEV
react-is.production.min.js 0.0% 🔺+0.1% 2.5 KB 2.5 KB 902 B 903 B NODE_PROD
react-is.development.js -20.2% -28.3% 8.73 KB 6.96 KB 2.6 KB 1.87 KB UMD_DEV
react-is.production.min.js 0.0% 🔺+0.1% 2.51 KB 2.51 KB 965 B 966 B UMD_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js -0.6% -0.7% 677.21 KB 673.17 KB 146.23 KB 145.23 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 104.41 KB 104.41 KB 31.89 KB 31.89 KB UMD_PROD
react-art.development.js -0.7% -0.8% 607.86 KB 603.81 KB 128.8 KB 127.82 KB NODE_DEV
react-art.production.min.js 0.0% 0.0% 69.42 KB 69.42 KB 21 KB 21 KB NODE_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js -0.7% -0.8% 622.08 KB 618 KB 131.89 KB 130.85 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 71.44 KB 71.44 KB 21.96 KB 21.96 KB UMD_PROD
react-test-renderer.development.js -0.7% -0.8% 617.35 KB 613.27 KB 130.7 KB 129.67 KB NODE_DEV
react-test-renderer-shallow.development.js -4.1% -3.4% 39.18 KB 37.57 KB 10.06 KB 9.72 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% 🔺+0.1% 11.58 KB 11.58 KB 3.57 KB 3.58 KB UMD_PROD
react-test-renderer-shallow.development.js -3.1% -2.0% 33.14 KB 32.11 KB 8.58 KB 8.41 KB NODE_DEV

react-cache

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-cache.development.js -9.4% -5.1% 10.72 KB 9.71 KB 3.49 KB 3.31 KB UMD_DEV
react-cache.production.min.js -8.8% -5.0% 2.61 KB 2.38 KB 1.28 KB 1.21 KB UMD_PROD
react-cache.development.js -9.6% -5.4% 10.49 KB 9.48 KB 3.42 KB 3.23 KB NODE_DEV
react-cache.production.min.js -9.5% -4.9% 2.42 KB 2.19 KB 1.18 KB 1.12 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js -0.6% -0.7% 750.12 KB 745.88 KB 158.31 KB 157.25 KB RN_FB_DEV
ReactNativeRenderer-prod.js -0.3% -0.6% 276.76 KB 275.86 KB 47.81 KB 47.54 KB RN_FB_PROD
ReactNativeRenderer-profiling.js -0.3% -0.5% 285.69 KB 284.79 KB 49.52 KB 49.26 KB RN_FB_PROFILING
ReactFabric-dev.js -0.6% -0.7% 755.16 KB 750.9 KB 159.06 KB 158.01 KB RN_FB_DEV
ReactFabric-prod.js -0.3% -0.5% 268.42 KB 267.51 KB 46.43 KB 46.18 KB RN_FB_PROD
ReactFabric-profiling.js -0.3% -0.5% 278.53 KB 277.62 KB 48.29 KB 48.05 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js -0.6% -0.7% 749.95 KB 745.71 KB 158.21 KB 157.16 KB RN_OSS_DEV
ReactNativeRenderer-prod.js -0.3% -0.5% 276.37 KB 275.47 KB 47.73 KB 47.47 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js -0.3% -0.5% 285.31 KB 284.4 KB 49.45 KB 49.2 KB RN_OSS_PROFILING
ReactFabric-dev.js -0.6% -0.7% 754.98 KB 750.71 KB 158.98 KB 157.92 KB RN_OSS_DEV
ReactFabric-prod.js -0.3% -0.5% 268.07 KB 267.17 KB 46.35 KB 46.11 KB RN_OSS_PROD
ReactFabric-profiling.js -0.3% -0.5% 278.18 KB 277.27 KB 48.21 KB 47.99 KB RN_OSS_PROFILING

create-subscription

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
create-subscription.development.js -12.3% -5.5% 8.33 KB 7.31 KB 2.92 KB 2.76 KB NODE_DEV
create-subscription.production.min.js -10.3% -10.1% 2.21 KB 1.98 KB 1.08 KB 994 B NODE_PROD

Size changes (stable)

Generated by 🚫 dangerJS against 443ef71

@acdlite
Copy link
Collaborator

acdlite commented Dec 13, 2019

If one of our goals is to be more rigorous about adding warnings, I wonder if we could take the same approach we use for the error transform, where we maintain the list of error messages in the source, and only transform the ones that have a matching entry. We use a lint rule to enforce that each message has a matching entry.

This makes adding/editing warnings slightly more annoying but it comes with some benefits:

  • The escape hatch to opt out of transforming a warning is to suppress the lint error that occurs if there's no matching entry in the list.
  • New warnings are more easily caught during code review. Makes it harder to sneak one by accidentally.
  • We always have a list of warnings that is exactly in sync with the ones in the source code.

The downside is that adding a warning means also updating the warning list. But adding some inertia there could be a feature, too. We've gotten feedback that we have too many warnings of varying severity and no way to opt out of them, so it could behoove us to start being more intentional about adding them. (And if we ever do provide a way for developers to opt-out of specific warnings, similar to the one used by www, we would want to track them.)

Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

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

I think this change looks technically okay. Seems like there's a discussion to be had about what Andrew mentioned though.

.eslintrc.js Show resolved Hide resolved
packages/react-reconciler/src/ReactFiberErrorLogger.js Outdated Show resolved Hide resolved
packages/react/src/__tests__/ReactClassEquivalence-test.js Outdated Show resolved Hide resolved
scripts/eslint-rules/warning-args.js Show resolved Hide resolved
@gaearon
Copy link
Collaborator Author

gaearon commented Dec 13, 2019

@acdlite I’m down for this! Follow-up or here?

@acdlite
Copy link
Collaborator

acdlite commented Dec 14, 2019

@gaearon Follow up is fine, good to merge as-is

@gaearon
Copy link
Collaborator Author

gaearon commented Dec 14, 2019

I pushed another commit that makes the "gotchas" clear by failing the build when console.error/warn() can't access the stack. In that case you're forced to use the escape hatch. In a follow-up, we can change that to use the warning list approach instead for the same purpose.

@bvaughn
Copy link
Contributor

bvaughn commented Dec 16, 2019

This PR broke DevTools tests.

After this commit was merged, running yarn test-build-devtools fails with several errors, including:

    Configuration error:
    
    Could not locate module shared/consoleWithStackDev mapped as:
    /Users/bvaughn/Documents/git/react/build/node_modules/shared/consoleWithStackDev.
    
    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/^shared\/([^\/]+)$/": "/Users/bvaughn/Documents/git/react/build/node_modules/shared/$1"
      },
      "resolver": null
    }

NMinhNguyen referenced this pull request in enzymejs/react-shallow-renderer Jan 29, 2020
* Replace all warning/lowPriWarning with console calls

* Replace console.warn/error with a custom wrapper at build time

* Fail the build for console.error/warn() where we can't read the stack
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.

None yet

5 participants