-
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
Eagerly evaluate inline requires in Jest #7245
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! |
@@ -17,6 +17,17 @@ var ReactPropTypesSecret = require('ReactPropTypesSecret'); | |||
var invariant = require('invariant'); | |||
var warning = require('warning'); | |||
|
|||
var ReactComponentTreeDevtool; | |||
|
|||
if (process.env.NODE_ENV === 'test') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!)