Reputation: 659
Ive started using the tool Browserslist lately to separate my modern and legacy builds. When i tried to run webpack serve
(webpack dev server) to serve the bundles, webpack gave a warning that i havn't ever seen prior to configuring Browserslist. It basically said that i had to set the output.chunkFormat
option before it can serve the bundle, so i did and it works fine now. The option basically specifies the module format of the bundles.
I would like to understand why i need to set it or why webpack cares about the module format of the bundles, as well as what relation it has to Browserslist. Can anyone provide some insight?
Upvotes: 0
Views: 2981
Reputation: 2148
As far as I know, webpack needs to know the environment in advance where your bundled code will run. And Browserslist can provide it with that information.
For instance, if you're going to run your bundled code on browsers supporting ES Modules, webpack would consider outputting ES Modules.
Say you have browserslist installed without a configuration, webpack won't be able to decide what kind of code to output, hence you'll need to specify output.chunkFormat
.
Generally, setting a output.target
would be enough as webpack can derive the environment from it.
Upvotes: 2