Files
klz-cables.com/.pnpm-store/v10/files/6e/829bad536ac634cf266640b1f4852b68cab673182663987ad65a50f1453c6fc7568e5b29f6e491238ea5bf38d62b6f467dce012292a3a0a467b29ac491c4f7
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

73 lines
1.7 KiB
Plaintext

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Florent Cailhol @ooflorent
*/
"use strict";
const { compareChunksNatural } = require("../util/comparators");
const {
assignDeterministicIds,
getFullChunkName,
getUsedChunkIds
} = require("./IdHelpers");
/** @typedef {import("../Compiler")} Compiler */
/**
* @typedef {object} DeterministicChunkIdsPluginOptions
* @property {string=} context context for ids
* @property {number=} maxLength maximum length of ids
*/
const PLUGIN_NAME = "DeterministicChunkIdsPlugin";
class DeterministicChunkIdsPlugin {
/**
* @param {DeterministicChunkIdsPluginOptions=} options options
*/
constructor(options = {}) {
this.options = options;
}
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => {
const chunkGraph = compilation.chunkGraph;
const context = this.options.context
? this.options.context
: compiler.context;
const maxLength = this.options.maxLength || 3;
const compareNatural = compareChunksNatural(chunkGraph);
const usedIds = getUsedChunkIds(compilation);
assignDeterministicIds(
[...chunks].filter((chunk) => chunk.id === null),
(chunk) =>
getFullChunkName(chunk, chunkGraph, context, compiler.root),
compareNatural,
(chunk, id) => {
const size = usedIds.size;
usedIds.add(`${id}`);
if (size === usedIds.size) return false;
chunk.id = id;
chunk.ids = [id];
return true;
},
[10 ** maxLength],
10,
usedIds.size
);
});
});
}
}
module.exports = DeterministicChunkIdsPlugin;