我的包中多次包含相同的依赖项 [英] The same dependency is included many times in my bundle

查看:23
本文介绍了我的包中多次包含相同的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的包中,相同的 node_modules/bn.js/lib 依赖被包含在我的生产包中8 次.

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

知道为什么以及如何预防吗?

Any idea why and how to prevent it?

推荐答案

在这种情况下,我能够添加一个 resolve.alias 到我的配置.

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.

这篇关于我的包中多次包含相同的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆