The same dependency is included many times in my bundle

Viewed 797

In my bundle, the same node_modules/bn.js/lib dependency is included 8 times in my production bundle.

enter image description here

Any idea why and how to prevent it?

1 Answers

In this case, I was able to add a resolve.alias to my config.

const p = require('path')

module.exports = {
  resolve: {
    alias: {
      'bn.js': p.join(__dirname, 'node_modules/bn.js/lib/bn.js'),
    }
  },
  // ...
}

Not sure if that's the right way, but it's no longer duplicated in my bundle.

Related