webpack中bundle、chunk、module的区别

webpack

Webpack Glossary
  1. bundle

    Bundle: Produced from a number of distinct modules, bundles contain the final versions of source files that have already undergone the loading and compilation process.

    译:Bundle:由许多不同的modules生成,包含了源码处理后的最终版本——源码被加载和编译处理;

  2. chunk

    Chunk: This webpack-specific term is used internally to manage the bundling process. Bundles are composed out of chunks, of which there are several types (e.g. entry and child). Typically, chunks directly correspond with the output bundles however, there are some configurations that don’t yield a one-to-one relationship.

    译:chunk:该webpack专业术语用于webpack内部管理bundling的过程中。bundles由许多的chunks组成——这些chunk有不同的类型(比如entrychild)。通常,chunks直接与bundles相对应。然而,有一些配置可以使其不是一对一的关系;

  3. module

    Module: Discrete chunks of functionality that provide a smaller surface area than a full program. Well-written modules provide solid abstractions and encapsulation boundaries which make up a coherent design and clear purpose.

    译:module:非连续的功能块——提供了更小的表面积而不是整个程序。书写良好的modules提供了可靠的抽象及封装边界,组成了统一的设计和清晰的目的;

结合stackoverflow释疑

modulewebpack支持解析的模块;
chunk包含多个module,存在于webpack处理过程中的阶段;
bundle包含一个或多个chunk,是源码经过webpack处理后的最终版本;

The distinction is useful when talking about webpack processes as they are occuring. As modules are chunked together, they can change significantly (especially during plugin processing), so it isn’t accurate to call them bundles at that point, the chunks may not even be emitted as bundles in the final output! Then after webpack is finished it is useful to have a term to refer to all of the emitted, final files (bundles).

译: 这样的区分对于描述webpack的处理过程是有帮助的。由于多个module被组合为一个chunk,他们能够有效地改变(尤其是在插件处理过程中),所以这个时间节点把它们称为bundle并不准确,而且这些chunks可能不会称为最终输出中的bundles!当webpack处理结束后,有必要使用一个术语去表示它的最终输出文件(bundles

析: 这里应该是——所以这个时间节点把它们称为module并不准确;module通常是与源码相关的,webpack将多个module合并为一个chunk,然后进行统一处理有助于提高效率,比如统一进行babel转义等插件操作,所以webpack处理过程中使用了术语chunk表示这些文件;由于不是所有的chunks都会成为最终的输出文件,所以又定义了一个新的术语——bundle


参考文献
  1. Webpack Glossary
  2. stackoverflow
  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Neil-

你们的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值