13

As title. I'm learning Webpack 5, and I just noticed there seems to be a concept called "layer" that is rarely mentioned(or I haven't found) in the documentation. It can be found here (for the intro. of top-level entry field):

 personal: { // ... layer: 'name of layer', // set the layer for an entry point }, }, }; 

and here (for the built-in plugin SplitChunksPlugin):

splitChunks.cacheGroups.{cacheGroup}.layer 

Assign modules to a cache group by module layer.

Are these two layers have the same meaning? If not, what are the definitions? Could you also point out the advantage(s) of using them? (I don't even know how to use it... at all)

3
  • 1
    It's also mentioned by webpack.js.org/configuration/module/#rulelayer : "Specify the layer in which the module should be placed in. A group of modules could be united in one layer which could then be used in split chunks, stats or entry options." Commented Sep 20, 2023 at 14:04
  • I'm going to guess that it's a way of grouping modules - I suppose as a kind of hint to Webpack how to split up modules? Commented Feb 29, 2024 at 20:28
  • @RichardHunter Now I have the same conclusion. I didn't have a deep dive into webpack when I asked the question. Commented Feb 29, 2024 at 23:54

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.