Fix error code transform to look for fbjs/lib/invariant#9158
Fix error code transform to look for fbjs/lib/invariant#9158gaearon wants to merge 5 commits intofacebook:masterfrom
Conversation
|
Did the jest test not fail? What does this fix? |
|
It did not fail because it was testing for a pattern we are not using anymore. var invariant = require('invariant');gets transformed into var _prodInvariant = require('reactProdInvariant');
var invariant = require('invariant');However we stopped using I fixed both the transform and the test to reflect that it should be looking for As for what it fixes, I don’t know. I don’t understand why the original code was necessary. These are the lines that became dead code with #9078 (and that I’m trying to fix in this PR), but the prod invariant is inserted anyway later so maybe the branch I’m fixing is not necessary in the first place. This is the part I’m confused about. Regardless, this PR just makes it run the same way it used to run before, and should be safe. |
|
@gaearon you're right, the branch isn't really necessary. Firstly when a The reason why it still worked is because even though |
|
Want to send a PR? 😄 |
|
Sure, I can just push to your branch if you don't mind |
|
Seems like it failed? |
|
Yea sorry I forgot to update the tests. Now it should be fine! |
Since we now refer to it as
fbjs/lib/invariant, this code path became dead.I can’t actually reproduce any issue on master so I’m not sure I understand why this was necessary in the first place. @keyanzhang Maybe you can explain?
I have checked that the code path is hit again now after this change.