A
A
asdasdqwe2021-12-25 09:28:10
webpack
asdasdqwe, 2021-12-25 09:28:10

What does runtimeChunk: 'single' do?

Everywhere they write something like:
runtimeChunk: 'single' - allows you to split the runtime code into a separate fragment

But what does this even mean? webpack creates a runtime.js file, and there are obscure functions. Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2021-12-26
@asdasdqwe

Webpack has some runtime code that allows it to emulate modules inside a bundle and load chunks. By default, this code is located in a chunk that contains the entry point module (the module from which your entire js program starts).
But you can also have several entry points, each one will essentially be assembled into its own bundle. Sometimes there is a need for several such bundles to work on one page. And each will have webpack runtime code embedded in it. Not only is this a duplication of code, it will conflict with each other when loading chunks unless you redefine the webpack global variable name to be different for each such bundle.
To solve these problems, it is usedruntimeChunk: 'single', which takes out the entire webpack runtime code into a separate chunk and allows you to reuse it for all bundles.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question