Does webpack bundle equal peer dependencies multiple times?

Viewed 2364

Let's say I create an npm package called react-web-component that uses and imports react-dom, like so:

import ReactDOM from 'react-dom';

export default {
  create: function (app, tagName, options) {
    // Some code
    ReactDOM.render(app, mountPoint);
  }
};

I would publish it on npm as react-web-component;

Now I create a second project that uses webpack and react and all the other good stuff and I would use my own npm package like so:

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 it bundles the application bundle ReactDom twice or once? And of the answer is twice, is there any chance to get my project to bundle ReactDom only once?

1 Answers
Related