Files
klz-cables.com/.pnpm-store/v10/files/6f/516b8c409666bfc24a4207e39408bd634f18ecb89c6635d995ba59199beeeacf6d9f05f6fb8ffd4529193aa8bd7293441ede6e5494c644510c5e75a999704b
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

89 lines
2.5 KiB
Plaintext

import { debug } from '@sentry/core';
import { supportsNativeDebugIds } from '../util.js';
import { generateValueInjectionRules } from './generateValueInjectionRules.js';
/**
* Construct a Turbopack config object from a Next.js config object and a Turbopack options object.
*
* @param userNextConfig - The Next.js config object.
* @param userSentryOptions - The Sentry build options object.
* @param routeManifest - The route manifest object.
* @param nextJsVersion - The Next.js version.
* @param vercelCronsConfig - The Vercel crons configuration from vercel.json.
* @returns The Turbopack config object.
*/
function constructTurbopackConfig({
userNextConfig,
userSentryOptions,
routeManifest,
nextJsVersion,
vercelCronsConfig,
}
) {
// If sourcemaps are disabled, we don't need to enable native debug ids as this will add build time.
const shouldEnableNativeDebugIds =
(supportsNativeDebugIds(nextJsVersion ?? '') && userNextConfig?.turbopack?.debugIds) ??
userSentryOptions?.sourcemaps?.disable !== true;
const newConfig = {
...userNextConfig.turbopack,
...(shouldEnableNativeDebugIds ? { debugIds: true } : {}),
};
const tunnelPath =
userSentryOptions?.tunnelRoute !== undefined &&
userNextConfig.output !== 'export' &&
typeof userSentryOptions.tunnelRoute === 'string'
? `${userNextConfig.basePath ?? ''}${userSentryOptions.tunnelRoute}`
: undefined;
const valueInjectionRules = generateValueInjectionRules({
routeManifest,
nextJsVersion,
tunnelPath,
vercelCronsConfig,
});
for (const { matcher, rule } of valueInjectionRules) {
newConfig.rules = safelyAddTurbopackRule(newConfig.rules, { matcher, rule });
}
return newConfig;
}
/**
* Safely add a Turbopack rule to the existing rules.
*
* @param existingRules - The existing rules.
* @param matcher - The matcher for the rule.
* @param rule - The rule to add.
* @returns The updated rules object.
*/
function safelyAddTurbopackRule(
existingRules,
{ matcher, rule },
) {
if (!existingRules) {
return {
[matcher]: rule,
};
}
// If the rule already exists, we don't want to mess with it.
if (existingRules[matcher]) {
debug.log(
`[@sentry/nextjs] - Turbopack rule already exists for ${matcher}. Please remove it from your Next.js config in order for Sentry to work properly.`,
);
return existingRules;
}
return {
...existingRules,
[matcher]: rule,
};
}
export { constructTurbopackConfig, safelyAddTurbopackRule };
//# sourceMappingURL=constructTurbopackConfig.js.map