react/scripts/error-codes
Dan Abramov 1eed302d34 Drop Haste (#11303)
* Use relative paths in packages/react

* Use relative paths in packages/react-art

* Use relative paths in packages/react-cs

* Use relative paths in other packages

* Fix as many issues as I can

This uncovered an interesting problem where ./b from package/src/a would resolve to a different instantiation of package/src/b in Jest.

Either this is a showstopper or we can solve it by completely fobbidding remaining /src/.

* Fix all tests

It seems we can't use relative requires in tests anymore. Otherwise Jest becomes confused between real file and symlink.
https://github.com/facebook/jest/issues/3830

This seems bad... Except that we already *don't* want people to create tests that import individual source files.
All existing cases of us doing so are actually TODOs waiting to be fixed.

So perhaps this requirement isn't too bad because it makes bad code looks bad.

Of course, if we go with this, we'll have to lint against relative requires in tests.
It also makes moving things more painful.

* Prettier

* Remove @providesModule

* Fix remaining Haste imports I missed earlier

* Fix up paths to reflect new flat structure

* Fix Flow

* Fix CJS and UMD builds

* Fix FB bundles

* Fix RN bundles

* Prettier

* Fix lint

* Fix warning printing and error codes

* Fix buggy return

* Fix lint and Flow

* Use Yarn on CI

* Unbreak Jest

* Fix lint

* Fix aliased originals getting included in DEV

Shouldn't affect correctness (they were ignored) but fixes DEV size regression.

* Record sizes

* Fix weird version in package.json

* Tweak bundle labels

* Get rid of output option by introducing react-dom/server.node

* Reconciler should depend on prop-types

* Update sizes last time
2017-10-25 02:55:00 +03:00
..
__tests__ Drop Haste (#11303) 2017-10-25 02:55:00 +03:00
codes.json [CS] Persistent Updates (#11260) 2017-10-18 18:28:23 -07:00
extract-errors.js Drop Haste (#11303) 2017-10-25 02:55:00 +03:00
invertObject.js Update license headers BSD+Patents -> MIT 2017-09-25 18:17:44 -07:00
README.md [Gatsby] "https://facebook.github.io/react/" -> "https://reactjs.org/" (#10970) 2017-09-29 18:43:22 -07:00
replace-invariant-error-codes.js Drop Haste (#11303) 2017-10-25 02:55:00 +03:00
Types.js Update license headers BSD+Patents -> MIT 2017-09-25 18:17:44 -07:00

The error code system substitutes React's invariant error messages with error IDs to provide a better debugging support in production. Check out the blog post here.

Note for cutting a new React release

  1. For each release, we run yarn build -- --extract-errors to update the error codes before calling yarn build. The build step uses codes.json for a production (minified) build; there should be no warning like Error message "foo" cannot be found for a successful release.
  2. The updated codes.json file should be synced back to the master branch. The error decoder page in our documentation site uses codes.json from master; if the json file has been updated, the docs site should also be rebuilt (rake copy_error_codes is included in the default rake release task).
  3. Be certain to run yarn build -- --extract-errors directly in the release branch (if not master) to ensure the correct error codes are generated. These error messages might be changed/removed before cutting a new release, and we don't want to add intermediate/temporary error messages to codes.json. However, if a PR changes an existing error message and there's a specific production test (which is rare), it's ok to update codes.json for that. Please use yarn build -- --extract-errors and don't edit the file manually.

Structure

The error code system consists of 5 parts:

  • codes.json contains the mapping from IDs to error messages. This file is generated by the Gulp plugin and is used by both the Babel plugin and the error decoder page in our documentation. This file is append-only, which means an existing code in the file will never be changed/removed.
  • extract-errors.js is an node script that traverses our codebase and updates codes.json. Use it by calling yarn build -- --extract-errors.
  • replace-invariant-error-codes.js is a Babel pass that rewrites error messages to IDs for a production (minified) build.
  • reactProdInvariant.js is the replacement for invariant in production. This file gets imported by the Babel plugin and should not be used manually.
  • ErrorDecoderComponent is a React component that lives at https://reactjs.org/docs/error-decoder.html. This page takes parameters like ?invariant=109&args[]=Foo and displays a corresponding error message. Our documentation site's Rakefile has a task (bundle exec rake copy_error_codes) for adding the latest codes.json to the error decoder page. This task is included in the default bundle exec rake release task.