javascript - Using Webpack to include React from CDN, but not ReactDOM -


in webpack build, load react cdn, not reactdom, requires roundtrip small file.

my webpack configuration has following block of code declaring "externals" not build these files (i instead include cdns).

webpack.config.js

...  externals: {     react: 'react' },  ... 

the problem only including react in externals still builds react because reactdom depends on it.

node_modules/react-dom/index.js

module.exports = require('react/lib/reactdom'); 

adding 'react-dom': 'reactdom' externals removes them both bundle, don't want have include reactdom cdn...

how can configure webpack load react cdn, include reactdom in main bundle?


note: i'm using webpack 2.1.0-beta17 , react 15.1.0.


update tried adding react/lib/reactdom externals.

...  externals: {     react: 'react',     'react/lib/reactdom': 'commonjs react-dom' },  ... 

but following error.

require not defined

[not answer, big comment]

see issues https://github.com/facebook/react/issues/5413, https://github.com/facebook/react/issues/6128, argue having cdn bundle of react+reactdom, float boat, if understand correctly. dan abramov feels it, i'm hopeful. note, however, his comment reactdom lot bigger soon.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -