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

79 lines
2.3 KiB
Plaintext

// src/webpack/context.ts
import { resolve } from "path";
import sources from "webpack-sources";
import { Parser } from "acorn";
function createContext(compilation) {
return {
parse(code, opts = {}) {
return Parser.parse(code, {
sourceType: "module",
ecmaVersion: "latest",
locations: true,
...opts
});
},
addWatchFile(id) {
(compilation.fileDependencies ?? compilation.compilationDependencies).add(
resolve(process.cwd(), id)
);
},
emitFile(emittedFile) {
const outFileName = emittedFile.fileName || emittedFile.name;
if (emittedFile.source && outFileName) {
compilation.emitAsset(
outFileName,
sources ? new sources.RawSource(
typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
) : {
source: () => emittedFile.source,
size: () => emittedFile.source.length
}
);
}
},
getWatchFiles() {
return Array.from(
compilation.fileDependencies ?? compilation.compilationDependencies
);
}
};
}
// src/utils.ts
import { isAbsolute, normalize } from "path";
function normalizeAbsolutePath(path) {
if (isAbsolute(path))
return normalize(path);
else
return path;
}
// src/webpack/loaders/load.ts
async function load(source, map) {
const callback = this.async();
const { unpluginName } = this.query;
const plugin = this._compiler?.$unpluginContext[unpluginName];
let id = this.resource;
if (!plugin?.load || !id)
return callback(null, source, map);
const context = {
error: (error) => this.emitError(typeof error === "string" ? new Error(error) : error),
warn: (error) => this.emitWarning(typeof error === "string" ? new Error(error) : error)
};
if (id.startsWith(plugin.__virtualModulePrefix))
id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
const res = await plugin.load.call(
Object.assign(this._compilation && createContext(this._compilation), context),
normalizeAbsolutePath(id)
);
if (res == null)
callback(null, source, map);
else if (typeof res !== "string")
callback(null, res.code, res.map ?? map);
else
callback(null, res, map);
}
export {
load as default
};