Files
klz-cables.com/.pnpm-store/v10/files/b5/3cd39a18d24310bb8173b6224be5c75de5c64b485a59f1e14c5e1f361aeb8b57e79e4f2532ceb122e6443a9707579213eda26ba0f3b55aa7ab2e83f294b885
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

36 lines
1.6 KiB
Plaintext

import { escapeStringForRegex } from '@sentry/core';
import * as fs from 'fs';
import * as path from 'path';
/**
* Inject templated code into the beginning of a module.
*
* Options:
* - `templatePrefix`: The XXX in `XXXPrefixLoaderTemplate.ts`, to specify which template to use
* - `replacements`: An array of tuples of the form `[<placeholder>, <replacementValue>]`, used for doing global
* string replacement in the template. Note: The replacement is done sequentially, in the order in which the
* replacement values are given. If any placeholder is a substring of any replacement value besides its own, make
* sure to order the tuples in such a way as to avoid over-replacement.
*/
function prefixLoader( userCode) {
// We know one or the other will be defined, depending on the version of webpack being used
const { templatePrefix, replacements } = 'getOptions' in this ? this.getOptions() : this.query;
const templatePath = path.resolve(__dirname, `../templates/${templatePrefix}PrefixLoaderTemplate.js`);
// make sure the template is included when running `webpack watch`
this.addDependency(templatePath);
// Fill in placeholders
let templateCode = fs.readFileSync(templatePath).toString();
replacements.forEach(([placeholder, value]) => {
// eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor -- user input is escaped
const placeholderRegex = new RegExp(escapeStringForRegex(placeholder), 'g');
templateCode = templateCode.replace(placeholderRegex, value);
});
return `${templateCode}\n${userCode}`;
}
export { prefixLoader as default };
//# sourceMappingURL=prefixLoader.js.map