How do I tell webpack to ignore a duplicate package?

Viewed 121

I'm building a react application that depends on a third-party package (proprietary, not open sourced unfortunately), lets call it tslib. The package.json of tslib depends on many different package, but the two of interest are the following:

    "react-router": "5.1.2",
    "react-router-dom": "^5.1.2",

In the main application (lets call it mainapp), depends on tslib, and has the following in it's package.json:

"dependencies": {
    "@githubrepo/tslib": "39.2.0",
},

it has no other non-dev dependencies. The issue im seeing is that when i build my application locally (note, this does not happen in production envs) using webpack and try to load the index page, i see the following:

enter image description here

Which is actually happening because there are two versions of both react-router and react-router dom being included (discovered using 'webpack-bundle-analyzer'). When I delete the version in my tslib, and re-webpack, the issue goes away. Does anyone know how I can go about fixing this problem using webpack config?

0 Answers
Related