webpack“运行时"的要点是什么?档案 [英] What are the point of webpack "runtime" files

查看:26
本文介绍了webpack“运行时"的要点是什么?档案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天使用 webpack 仅用于转译我的核心业务逻辑代码,但仍在为所有外部库(如 jQuery、AngularJS 等)使用 CDN.我想使用 SplitChunksPlugin 将这些供应商库移动到 webpack 中,但是当我按照我在 SO 上找到的示例进行操作时,我创建了供应商包,但同时它也创建了一些我不确定的额外文件.

I am using webpack today for transpiling just my core business logic code, but are still using a CDN for all external libraries like jQuery, AngularJS, etc. I want to move these vendor libraries into webpack by using the SplitChunksPlugin, but when I followed an example I found here at SO I got the vendor bundle to get created, but at the same time it also created some extra files I am not sure about.

对于我在 webpack 配置中声明的每个 entry 模块,webpack 不会同时创建这些文件的运行时"版本"

For every entry module I have declared in the webpack config, webpack not also creates a "runtime" version of these files"

例如,我有一个 company.productA.core.bundle.js taht 我已经使用了一段时间,但是在为拆分块添加配置后,我现在也得到了一个 company.runtime~productA.core.bundle.js.Webpack 对我创建的其他 8 个模块也做了同样的事情.

For example I have a company.productA.core.bundle.js taht I have been using for a while but after adding the config for the split chunks I now also get a company.runtime~productA.core.bundle.js. Webpack has done the same for the other 8 modules I have being created.

我尝试搜索这些是什么,但在 webpack 文档和 SO 上都没有看到任何关于它们的信息.

I have tried searching for what these are but don't see anything about them on both the webpack documentation and SO.

有人可以向我解释这些文件的用途吗?

Can someone explain to me what these files are meant for?

推荐答案

每个运行时文件都包含允许加载块的代码.如果您打开任何这些运行时文件,您将看到通过 Jsonp 加载块的代码.由于您已经要求 webpack 拆分块,您现在可以随时加载任何块.因此对于每个块,webpack 都会发出这些运行时文件,以便它可以正确处理需求.

Each of the runtime files contains code that enables loading of your chunks. If you open any of those runtime files, you will see code that loads your chunks via Jsonp. Since you have asked webpack to split chunks, you are now free to load any chunk any time. Hence for each chunk, webpack emits these runtime files so that it can handle requires correctly.

这篇关于webpack“运行时"的要点是什么?档案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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