About the chunkId of webpack

A webpack demo. The code is simple:
`module.exports = {

entry: {
    main: "./src/main.js",
    main2: "./src/main2.js"
},
output: {
    path: path.resolve(__dirname, "dist"),
    filename: "[name].[chunkhash].js"
},
plugins: [
    new HtmlWebpackPlugin({
        title: "my-cli",
        template: "./html/index.html"
    }),
    new CleanWebpackPlugin("dist")
]

} `
main.js

const test = require("./test.js");
console.log(test);

test.js

const str = "test is loaded122";
module.exports = str;

main2.js

const test = require("./test2.js");
console.log(test);

test2.js

const str = "test is loaded22ff";
module.exports = str;

I don"t quite understand why the chunkid of main2.js is 0 and the chunkid of main.js is 1 after it is packaged.
as shown in the figure
and if the require in main2.js is deleted, the chunkid of main.js is 0. Main2.js chunkid is 1, which remains the same if the require of main.js is removed. And there is no chunkId-related code in the two packaged chunk. Ask the great god for an answer.

main2.js

console.log(test);
Mar.02,2021
The generation of

chunkid is unstable, that is to say, the id generated by each package may be different
https://juejin.im/post/5a1bcd.


chunks means code blocks, and those numbers are just id or serial numbers of chunks code blocks. Webpack packages are generated to facilitate mutual reference or split or combination.


new webpack.NamedChunksPlugin () can fix the packaged chunkId, so that the packaged chunkId is the file name

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3881c-2b668.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3881c-2b668.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?