Eagerly evaluate inline requires in Jest#7245
Eagerly evaluate inline requires in Jest#7245gaearon merged 2 commits intofacebook:masterfrom gaearon:jest-fix
Conversation
|
@keyanzhang Do you think we’ll get #7178 in this week? If yes, maybe we don’t need to bother with this fix. |
|
@gaearon I'll get that PR ready in a few days. Just to clarify -- we run these tests with the development build right? |
|
Yeah this seems reasonable. I'm sorry for the pain. I'm however unsure how rollup would solve this as people will use the dev code (react/lib/*), not the production build when writing unit tests. |
|
Yes, we run tests with development CommonJS build. Rollup would solve this because we can move requires back to the top of the file (like Jest prefers) but it would still eliminate dead code in prod. Browserify is not that smart which is why I inlined them, but I won't have to after switching to Rollup. |
|
oh, yeah, that makes sense! |
|
|
||
| var ReactComponentTreeDevtool; | ||
|
|
||
| if (process.env.NODE_ENV === 'test') { |
There was a problem hiding this comment.
I fully expect this to break internally unless we check if (process && process.env && process.env.NODE_ENV = 'test').
There was a problem hiding this comment.
Aah, __DEV__ “works” because it’s how it’s called internally! :steve_jobs_fireworks:
|
Okay, this should work, right? This is getting super hacky. 😢 |
|
|
@zpao Shall we do it? |
|
Sure, but let's make sure this doesn't stick around for long. |
* Eagerly evaluate inline requires in Jest I inlined some requires in #7188 to fix the build size regression. However this caused an issue with Jest due to it resetting module registry between tests. This is a temporary fix to #7240. It should be reverted as part of #7178. * Make the hack work in all environments (cherry picked from commit 15ae585)
I inlined some requires in #7188 to fix the build size regression.
However this caused an issue with Jest due to it resetting module registry between tests.
This is a temporary fix to #7240.
It should be reverted as part of #7178.
Test plan:
build/modules/*into itsnode_modules/react/lib/.basic-click-counter) in the repo runs with minified and unminified React.Reviewers: @zpao @keyanzhang
(Yes I know it’s super ugly. The upside is I know Jest a little better now!)