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.
For every entry
module I have declared in the webpack config, webpack not also creates a "runtime" version of these files"
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.
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?
Runtime. The runtime, along with the manifest data, is all the code webpack needs to connect your modularized application while it's running in the browser. It contains the loading and resolving logic needed to connect your modules as they interact.
This is why webpack exists. It's a tool that lets you bundle your JavaScript applications (supporting both ESM and CommonJS), and it can be extended to support many different assets such as images, fonts and stylesheets.
Webpack is an aggressive and powerful module bundler for JavaScript applications. It packages all the modules in your application into one or more bundles (often, just one) and serves it to the browser.
Webpack enables use of loaders to preprocess files. This allows you to bundle any static resource way beyond JavaScript. You can easily write your own loaders using Node. js.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With