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
88 lines
2.3 KiB
Plaintext
88 lines
2.3 KiB
Plaintext
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
const path = require('path');
|
|
const util = require('../util.js');
|
|
|
|
/**
|
|
* Generate the value injection rules for client and server in turbopack config.
|
|
*/
|
|
function generateValueInjectionRules({
|
|
routeManifest,
|
|
nextJsVersion,
|
|
tunnelPath,
|
|
vercelCronsConfig,
|
|
}
|
|
|
|
) {
|
|
const rules = [];
|
|
const isomorphicValues = {};
|
|
let clientValues = {};
|
|
let serverValues = {};
|
|
|
|
if (nextJsVersion) {
|
|
// This is used to determine version-based dev-symbolication behavior
|
|
isomorphicValues._sentryNextJsVersion = nextJsVersion;
|
|
}
|
|
|
|
if (routeManifest) {
|
|
clientValues._sentryRouteManifest = JSON.stringify(routeManifest);
|
|
}
|
|
|
|
// Inject tunnel route path for both client and server
|
|
if (tunnelPath) {
|
|
isomorphicValues._sentryRewritesTunnelPath = tunnelPath;
|
|
}
|
|
|
|
// Inject Vercel crons config for server-side cron auto-instrumentation
|
|
if (vercelCronsConfig) {
|
|
serverValues._sentryVercelCronsConfig = JSON.stringify(vercelCronsConfig);
|
|
}
|
|
// Inject server modules (matching webpack's __SENTRY_SERVER_MODULES__ behavior)
|
|
// Use process.cwd() to get the project directory at build time
|
|
serverValues.__SENTRY_SERVER_MODULES__ = util.getPackageModules(process.cwd());
|
|
|
|
if (Object.keys(isomorphicValues).length > 0) {
|
|
clientValues = { ...clientValues, ...isomorphicValues };
|
|
serverValues = { ...serverValues, ...isomorphicValues };
|
|
}
|
|
|
|
// Client value injection
|
|
if (Object.keys(clientValues).length > 0) {
|
|
rules.push({
|
|
matcher: '**/instrumentation-client.*',
|
|
rule: {
|
|
loaders: [
|
|
{
|
|
loader: path.resolve(__dirname, '..', 'loaders', 'valueInjectionLoader.js'),
|
|
options: {
|
|
values: clientValues,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|
|
}
|
|
|
|
// Server value injection
|
|
if (Object.keys(serverValues).length > 0) {
|
|
rules.push({
|
|
matcher: '**/instrumentation.*',
|
|
rule: {
|
|
loaders: [
|
|
{
|
|
loader: path.resolve(__dirname, '..', 'loaders', 'valueInjectionLoader.js'),
|
|
options: {
|
|
values: serverValues,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|
|
}
|
|
|
|
return rules;
|
|
}
|
|
|
|
exports.generateValueInjectionRules = generateValueInjectionRules;
|
|
//# sourceMappingURL=generateValueInjectionRules.js.map
|