-
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
Fix AMD and Brunch issues #8686
Changes from 1 commit
cebff96
db5b7ab
3302174
fe8d64e
593c70e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,24 +11,24 @@ | |
|
||
'use strict'; | ||
|
||
var React = require('React'); | ||
var ReactDOM = require('ReactDOM'); | ||
|
||
var ReactDOMUMDEntry = Object.assign({ | ||
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: { | ||
ReactInstanceMap: require('ReactInstanceMap'), | ||
}, | ||
}, ReactDOM); | ||
var ReactDOMUMDEntry = ReactDOM; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was only used for that stack trace so we can remove it too now. |
||
if (__DEV__) { | ||
Object.assign( | ||
ReactDOMUMDEntry.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, | ||
{ | ||
// ReactPerf and ReactTestUtils currently only work with the DOM renderer | ||
// so we expose them from here, but only in DEV mode. | ||
ReactPerf: require('ReactPerf'), | ||
ReactTestUtils: require('ReactTestUtils'), | ||
} | ||
); | ||
ReactDOMUMDEntry.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { | ||
// ReactPerf and ReactTestUtils currently only work with the DOM renderer | ||
// so we expose them from here, but only in DEV mode. | ||
ReactPerf: require('ReactPerf'), | ||
ReactTestUtils: require('ReactTestUtils'), | ||
}; | ||
} | ||
|
||
// Inject ReactDOM into React for the addons UMD build that depends on ReactDOM (TransitionGroup). | ||
// We can remove this after we deprecate and remove the addons UMD build. | ||
if (React.addons) { | ||
React.__SECRET_INJECTED_REACT_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOMUMDEntry; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where we inject ourselves into React now. |
||
} | ||
|
||
module.exports = ReactDOMUMDEntry; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,24 +9,22 @@ | |
* @providesModule ReactAddonsDOMDependenciesUMDShim | ||
*/ | ||
|
||
/* globals ReactDOM */ | ||
|
||
'use strict'; | ||
|
||
exports.getReactDOM = function() { | ||
return ReactDOM; | ||
}; | ||
function getReactDOM() { | ||
var ReactWithAddonsUMDEntry = require('ReactWithAddonsUMDEntry'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be safe since we only use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not a huge deal in the grand scheme, but could potentially memoize this so we don't have to enter |
||
// This is injected by the ReactDOM UMD build: | ||
return ReactWithAddonsUMDEntry.__SECRET_INJECTED_REACT_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The worst case (it doesn't exist) is the same worst case we already had before when |
||
} | ||
|
||
exports.getReactInstanceMap = function() { | ||
return ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactInstanceMap; | ||
}; | ||
exports.getReactDOM = getReactDOM; | ||
|
||
if (__DEV__) { | ||
exports.getReactPerf = function() { | ||
return ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactPerf; | ||
return getReactDOM().__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactPerf; | ||
}; | ||
|
||
exports.getReactTestUtils = function() { | ||
return ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactTestUtils; | ||
return getReactDOM().__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactTestUtils; | ||
}; | ||
} |
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 don't think this is safe... doesn't it result in React getting packaged into the ReactDOM bundle? I would expect
build/react-dom.js
just exploded in size.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 don't think so—don't we requite
React
all over the place inReactDOM
? For exampleReactCompositeComponent
(now part ofReactDOM
) usesReact.isValidElement
. I think @sebmarkbage made it work during the package split.. somehow. Maybe with this.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.
(And I'm not seeing any noticeable changes in size, it's all within 100 bytes.)
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.
Ah yea, that get's rewritten to the ReactUMDShim. Sorry, just experiencing some light PTSD thinking about making AMD again. Carry on then :)