从Webpack文档(
https://webpack.github.io/docs/api-in-modules.html#require-ensure):
Download additional dependencies on demand. The dependencies array lists modules that should be available. When they are,callback is called. If the callback is a function expression,dependencies in that source part are extracted and also loaded on demand. A single request is fired to the server,except if all modules are already available.
如果源部分中的依赖项也是按需提取和加载的,那么为什么还要在依赖项列表中添加任何内容呢?
我见过这样的例子很混乱(https://github.com/webpack/webpack/tree/master/examples/extra-async-chunk):
require.ensure(["./a"],function(require) { require("./b"); require("./d"); });
“b”和“d”不在依赖项列表中,但将按需加载,就像“a”一样.那有什么区别?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。