Let's say I create an npm package called react-web-component that uses and imports react-dom , for example:
import ReactDOM from 'react-dom'; export default { create: function (app, tagName, options) {
I would publish it on npm as react-web-component ;
Now I am creating a second project that uses webpack and react , and all the other good things, and I would use my own npm package, for example:
package.json
{ "devDependencies": { "react-web-component": "^1.0.0", "react": "^15.5.4", "react-dom": "^15.5.4" }, }
index.js
import React from 'react'; import ReactDOM from 'react-dom'; import ReactWebComponent from 'react-web-component'; import App from './App'; ReactWebComponent.create(<App />, 'my-react-web-component');
Woud webpack , when does it bundle the ReactDom application ReactDom twice or once? And the answer is two times, is there a chance that my project will link ReactDom only once?
webpack
Lukas
source share