Skip to content
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

Prevent process polyfill to be included in builds because of process … #9518

Merged
merged 1 commit into from
Apr 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions src/isomorphic/children/flattenChildren.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,7 @@
var KeyEscapeUtils = require('KeyEscapeUtils');
var traverseAllChildren = require('traverseAllChildren');
var warning = require('fbjs/lib/warning');

var ReactComponentTreeHook;

if (
typeof process !== 'undefined' &&
process.env &&
process.env.NODE_ENV === 'test'
) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just change this require to be unconditional. It is no longer necessary to do this trickery now. (The original reason for this was related to some Jest behavior that's irrelevant with flat bundles.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should i just var ReactComponentTreeHook = require('ReactComponentTreeHook') at the top of the file?

This ReactComponentTreeHook is later conditionally required in __DEV__ block. What about it then? Should something be adjusted?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should i just var ReactComponentTreeHook = require('ReactComponentTreeHook') at the top of the file?

Yes.

This ReactComponentTreeHook is later conditionally required in DEV block.

You can remove that. It’s unnecessary now.

// Temporary hack.
// Inline requires don't work well with Jest:
// https://github.com/facebook/react/issues/7240
// Remove the inline requires when we don't need them anymore:
// https://github.com/facebook/react/pull/7178
ReactComponentTreeHook = require('ReactComponentTreeHook');
}
var ReactComponentTreeHook = require('ReactComponentTreeHook');

/**
* @param {function} traverseContext Context passed through traversal.
Expand All @@ -48,9 +34,6 @@ function flattenSingleChildIntoContext(
const result = traverseContext;
const keyUnique = result[name] === undefined;
if (__DEV__) {
if (!ReactComponentTreeHook) {
ReactComponentTreeHook = require('ReactComponentTreeHook');
}
if (!keyUnique) {
warning(
false,
Expand Down