Files
klz-cables.com/.pnpm-store/v10/files/7d/ceee2c92576e3b774bb809e4205a3858585cf318b56b7ac32b8d09ff8b3f12b800297f424ed0cefddb5fba0fedca6344c6af76567a9640e3ea28342fb40ceb
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

45 lines
1.3 KiB
Plaintext

/*
MIT License http://www.opensource.org/licenses/mit-license.php
*/
"use strict";
const RuntimeModule = require("../RuntimeModule");
const Template = require("../Template");
/** @typedef {import("../Compilation")} Compilation */
class ChunkPrefetchFunctionRuntimeModule extends RuntimeModule {
/**
* @param {"prefetch" | "preload"} type "prefetch" or "preload" chunk type function
* @param {string} runtimeFunction the runtime function name
* @param {string} runtimeHandlers the runtime handlers
*/
constructor(type, runtimeFunction, runtimeHandlers) {
super(`chunk ${type} function`);
this.runtimeFunction = runtimeFunction;
this.runtimeHandlers = runtimeHandlers;
}
/**
* @returns {string | null} runtime code
*/
generate() {
const { runtimeFunction, runtimeHandlers } = this;
const compilation = /** @type {Compilation} */ (this.compilation);
const { runtimeTemplate } = compilation;
return Template.asString([
`${runtimeHandlers} = {};`,
`${runtimeFunction} = ${runtimeTemplate.basicFunction("chunkId", [
// map is shorter than forEach
`Object.keys(${runtimeHandlers}).map(${runtimeTemplate.basicFunction(
"key",
`${runtimeHandlers}[key](chunkId);`
)});`
])}`
]);
}
}
module.exports = ChunkPrefetchFunctionRuntimeModule;