-
Notifications
You must be signed in to change notification settings - Fork 254
ReactMDL.js bundle: "react" or "react-dom" instead of require('React') or require('ReactDOM') #267
Comments
React and react-dom are not inside the bundle, you have to require them before including reactmdl ;) You can use these urls: https://npmcdn.com/react@0.14.7/dist/react.min.js and https://npmcdn.com/react-dom@0.14.7/dist/react-dom.min.js |
Yes, I know, but So SystemJS module loader needs to map both But forget for it... |
Oh I see.. Thanks for the clarification. I didn't get that at first. I guess it's because of these lines: https://github.com/tleunen/react-mdl/blob/master/webpack.config.js#L3-L4 Feel free to submit a PR to fix the import names :) |
I tried something at my react-mdl fork. |
This change breaks including ReactMDL from a regular script tag. |
module.exports = {
externals: {
react: 'React',
'react-dom': 'ReactDOM'
}, This snippet of config is mapping the module |
#272 |
I'll revert the specific commit. @PavelPZ I don't know your initial issue, but maybe this ticket will help you webpack/webpack#1275 |
I don't think so actually. It is my understanding that |
In v1.4.3 for example, we had this header:
So I'm guessing if someone wants to use the bundled file, with their own code, they would need to configure their webpack to say This following like is ok though, since root is the window. Our config looks ok now so it should be fine, but still I don't really understand why it's these names |
Yeah I see what you mean. I agree that I would also expect the |
I don't know :/ |
Yeah you are right it must be the real For comparison, here is React DOM: As you can see, it is doing what we would expect: module.exports = f(require('react')); and g.ReactDOM = f(g.React); However, it looks like this code was generated by another tool, or handwritten... |
I think your "peerDependencies": {
"react": "0.14.x || ^15.0.0-rc",
"react-dom": "0.14.x || ^15.0.0-rc"
}, I think that NPM sees |
It seems you can specify aliases per output target: externals: {
"react": {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
}
} See |
For the peerDeps, it should be ok, I used this tool to confirm http://semver.npmjs.com/ Good news for the output targets. I'll give it a try when I get some time :) Thanks again @Download |
@tleunen I'm preparing a PR for it |
@tleunen Could you re-open this issue? |
Expanded upon webpack externals config to differentiate between different output targets: * Import `react` and `react-dom` when using `require` * Import `React` and `ReactDOM` when using globals SEE: Dependency names wrong when using React MDL from script tleunen#298 SEE: ReactMDL.js bundle: "react" or "react-dom" instead of require('React') or require('ReactDOM') tleunen#267
Is it possible to have this header in installed
node_modules\react-mdl\out\ReactMDL.js
file?The text was updated successfully, but these errors were encountered: