-
Notifications
You must be signed in to change notification settings - Fork 47k
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
RFC: Error code system #6874
RFC: Error code system #6874
Conversation
Ironically I had been working on #6876 this morning to make sure that works for us (as well as the other projects using the preset). I think we'd still be able to do what you did and fork that dev transform, would just need to opt-out of the one already packaged (which is the opposite of how it exists today where you opt-in). |
@zpao Haha I moved it from |
Stay here until (if) we decide it's a good thing to do in other projects and then we can "promote" it to fbjs (that's the path we've taken for all the transforms). It might not end up being a good idea for every project and we can move faster and experiment more with it here. |
@keyanzhang updated the pull request. |
1 similar comment
@keyanzhang updated the pull request. |
@keyanzhang updated the pull request. |
Discussed in person, but let's split this out into three parts:
|
This is a work in progress on implementing React's Error Code System. Comments and feedback are more than welcome!
Background
We currently have fbjs-scripts/babel-6/dev-expression as a babel pass. It rewrites all
invariant
calls fromto
If you take a look at
invariant
's implementation, this is why we have the "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings." error message in production.What's new
This PR implements an error code system and changes the rewriting to
where
XYZ
is an error code: an unique identifier (a number string) that references a verbose error message. The mapping is stored inscripts/error-codes/codes.json
.PROD_INVARIANT
is thereactProdInvariant
function that always throw with an error URL like https://facebook.github.io/react/docs/error-decoder.html?invariant=109&args[]=Foo. A demo can be found here.How it works
invariant
is taken. Then it rewrites theinvariant
in production toreactProdInvariant
using error IDs. Add reactProdInvariant and corresponding babel rewrite pass #6948Size comparison