mirror of https://github.com/webpack/webpack.git
fix: `assetsByChunkName` should also included assets from `chunk.auxiliaryFiles` (#19921)
This commit is contained in:
parent
19f5693ebc
commit
ae52500e95
|
@ -805,7 +805,10 @@ const SIMPLE_EXTRACTORS = {
|
|||
}
|
||||
|
||||
object.assetsByChunkName = {};
|
||||
for (const [file, chunks] of compilationFileToChunks) {
|
||||
for (const [file, chunks] of [
|
||||
...compilationFileToChunks,
|
||||
...compilationAuxiliaryFileToChunks
|
||||
]) {
|
||||
for (const chunk of chunks) {
|
||||
const name = chunk.name;
|
||||
if (!name) continue;
|
||||
|
|
|
@ -609,6 +609,12 @@ You can also set it to 'none' to disable any default behavior. Learn more: https
|
|||
webpack x.x.x compiled with 1 warning in X ms"
|
||||
`;
|
||||
|
||||
exports[`StatsTestCases should print correct stats for chunk-assets 1`] = `
|
||||
"asset bundle.js X bytes [emitted] (name: main) 1 related asset
|
||||
./index.js X bytes [built] [code generated]
|
||||
webpack x.x.x compiled successfully in X ms"
|
||||
`;
|
||||
|
||||
exports[`StatsTestCases should print correct stats for chunk-module-id-range 1`] = `
|
||||
"PublicPath: auto
|
||||
asset main1.js X KiB [emitted] (name: main1)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export default "foo"
|
|
@ -0,0 +1,20 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {import("../../../").Stats} stats stats
|
||||
*/
|
||||
validate(stats) {
|
||||
const _stats = stats.toJson({
|
||||
assets: true
|
||||
});
|
||||
let chunks;
|
||||
expect((chunks = Object.keys(_stats.assetsByChunkName))).toHaveLength(1);
|
||||
const chunk = chunks[0];
|
||||
expect(_stats.assetsByChunkName[chunk]).toHaveLength(2);
|
||||
expect(_stats.assetsByChunkName[chunk]).toEqual([
|
||||
"bundle.js",
|
||||
"bundle.js.map"
|
||||
]);
|
||||
}
|
||||
};
|
|
@ -0,0 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
/** @type {import("../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "production",
|
||||
entry: "./index",
|
||||
devtool: "source-map",
|
||||
output: {
|
||||
filename: "bundle.js"
|
||||
}
|
||||
};
|
|
@ -1,6 +1,9 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {import("../../../").MultiStats} stats stats
|
||||
*/
|
||||
validate(stats) {
|
||||
for (let i = 0; i < stats.stats.length; i += 2) {
|
||||
const a = stats.stats[i].compilation.hash;
|
||||
|
|
|
@ -10,6 +10,9 @@ const hashedFiles = {
|
|||
};
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {import("../../../").MultiStats} stats stats
|
||||
*/
|
||||
validate(stats) {
|
||||
for (let i = 0; i < 4; i += 2) {
|
||||
const a = stats.stats[i + 0].toJson({
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {import("../../../").MultiStats} stats stats
|
||||
*/
|
||||
validate(stats) {
|
||||
for (const item of stats.stats) {
|
||||
const json = item.toJson({ assets: true });
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {import("../../../").Stats} stats stats
|
||||
*/
|
||||
validate(stats) {
|
||||
expect(stats.compilation.modules.size).toBe(246);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue