From aa44b90ac23c2a2aa3bf28e5c67fa3b755f05423 Mon Sep 17 00:00:00 2001 From: Abdelrahman Awad Date: Fri, 23 Jan 2026 16:11:41 -0500 Subject: [PATCH 1/5] turn off preserve mods --- dev-packages/rollup-utils/npmHelpers.mjs | 6 ------ dev-packages/test-utils/rollup.npm.config.mjs | 1 - packages/browser-utils/rollup.npm.config.mjs | 2 +- packages/browser/rollup.npm.config.mjs | 2 +- packages/core/rollup.npm.config.mjs | 3 +-- packages/nextjs/rollup.npm.config.mjs | 2 ++ packages/node-native/rollup.npm.config.mjs | 1 - packages/node/rollup.npm.config.mjs | 1 - packages/vercel-edge/rollup.npm.config.mjs | 3 --- 9 files changed, 5 insertions(+), 16 deletions(-) diff --git a/dev-packages/rollup-utils/npmHelpers.mjs b/dev-packages/rollup-utils/npmHelpers.mjs index 02a521d86926..62f6c82331e2 100644 --- a/dev-packages/rollup-utils/npmHelpers.mjs +++ b/dev-packages/rollup-utils/npmHelpers.mjs @@ -64,12 +64,6 @@ export function makeBaseNPMConfig(options = {}) { // Include __esModule property when there is a default prop esModule: 'if-default-prop', - // output individual files rather than one big bundle - preserveModules: true, - - // output files relative to the src directory - preserveModulesRoot: 'src', - // Allow wrappers or helper functions generated by rollup to use any ES2015 features generatedCode: { preset: 'es2015', diff --git a/dev-packages/test-utils/rollup.npm.config.mjs b/dev-packages/test-utils/rollup.npm.config.mjs index b684e2efe16b..4f64c4ec7b40 100644 --- a/dev-packages/test-utils/rollup.npm.config.mjs +++ b/dev-packages/test-utils/rollup.npm.config.mjs @@ -6,7 +6,6 @@ export default makeNPMConfigVariants( output: { // set exports to 'named' or 'auto' so that rollup doesn't warn exports: 'named', - preserveModules: false, }, }, }), diff --git a/packages/browser-utils/rollup.npm.config.mjs b/packages/browser-utils/rollup.npm.config.mjs index d28a7a6f54a0..e616bb7c0d70 100644 --- a/packages/browser-utils/rollup.npm.config.mjs +++ b/packages/browser-utils/rollup.npm.config.mjs @@ -9,7 +9,7 @@ export default makeNPMConfigVariants( // set preserveModules to true because we don't want to bundle everything into one file. preserveModules: process.env.SENTRY_BUILD_PRESERVE_MODULES === undefined - ? true + ? false : Boolean(process.env.SENTRY_BUILD_PRESERVE_MODULES), }, }, diff --git a/packages/browser/rollup.npm.config.mjs b/packages/browser/rollup.npm.config.mjs index 40e3cbff5906..64d6215c216c 100644 --- a/packages/browser/rollup.npm.config.mjs +++ b/packages/browser/rollup.npm.config.mjs @@ -11,7 +11,7 @@ export default makeNPMConfigVariants( // set preserveModules to true because we don't want to bundle everything into one file. preserveModules: process.env.SENTRY_BUILD_PRESERVE_MODULES === undefined - ? true + ? false : Boolean(process.env.SENTRY_BUILD_PRESERVE_MODULES), }, }, diff --git a/packages/core/rollup.npm.config.mjs b/packages/core/rollup.npm.config.mjs index c6c96c546930..dbab4cea8926 100644 --- a/packages/core/rollup.npm.config.mjs +++ b/packages/core/rollup.npm.config.mjs @@ -20,10 +20,9 @@ export default makeNPMConfigVariants( output: { // set exports to 'named' or 'auto' so that rollup doesn't warn exports: 'named', - // set preserveModules to true because we don't want to bundle everything into one file. preserveModules: process.env.SENTRY_BUILD_PRESERVE_MODULES === undefined - ? true + ? false : Boolean(process.env.SENTRY_BUILD_PRESERVE_MODULES), }, plugins: [ diff --git a/packages/nextjs/rollup.npm.config.mjs b/packages/nextjs/rollup.npm.config.mjs index 46d47582ab1e..0cbcc4f48c55 100644 --- a/packages/nextjs/rollup.npm.config.mjs +++ b/packages/nextjs/rollup.npm.config.mjs @@ -57,6 +57,8 @@ export default [ output: { virtualDirname: '_virtual/loaders', + dir: 'config/templates', + // this is going to be add-on code, so it doesn't need the trappings of a full module (and in fact actively // shouldn't have them, lest they muck with the module to which we're adding it) sourcemap: false, diff --git a/packages/node-native/rollup.npm.config.mjs b/packages/node-native/rollup.npm.config.mjs index ce79b0ac9bbb..3b140cf9d569 100644 --- a/packages/node-native/rollup.npm.config.mjs +++ b/packages/node-native/rollup.npm.config.mjs @@ -8,7 +8,6 @@ export default makeNPMConfigVariants( dir: 'build', // set exports to 'named' or 'auto' so that rollup doesn't warn exports: 'named', - preserveModules: true, }, }, }), diff --git a/packages/node/rollup.npm.config.mjs b/packages/node/rollup.npm.config.mjs index 93fd1d8c16ca..8f1bfeded3a2 100644 --- a/packages/node/rollup.npm.config.mjs +++ b/packages/node/rollup.npm.config.mjs @@ -9,7 +9,6 @@ export default [ output: { // set exports to 'named' or 'auto' so that rollup doesn't warn exports: 'named', - preserveModules: true, }, }, }), diff --git a/packages/vercel-edge/rollup.npm.config.mjs b/packages/vercel-edge/rollup.npm.config.mjs index efaad1d5ea86..9db47c588a6b 100644 --- a/packages/vercel-edge/rollup.npm.config.mjs +++ b/packages/vercel-edge/rollup.npm.config.mjs @@ -35,9 +35,6 @@ const baseConfig = makeBaseNPMConfig({ bundledBuiltins: ['perf_hooks', 'util'], packageSpecificConfig: { context: 'globalThis', - output: { - preserveModules: false, - }, plugins: [ replacePlugin( { From 8baf80df88b59684b7ea3e603518e60587196783 Mon Sep 17 00:00:00 2001 From: Abdelrahman Awad Date: Fri, 23 Jan 2026 16:14:34 -0500 Subject: [PATCH 2/5] feat: clean dir --- dev-packages/rollup-utils/npmHelpers.mjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev-packages/rollup-utils/npmHelpers.mjs b/dev-packages/rollup-utils/npmHelpers.mjs index 62f6c82331e2..5afecb253363 100644 --- a/dev-packages/rollup-utils/npmHelpers.mjs +++ b/dev-packages/rollup-utils/npmHelpers.mjs @@ -59,6 +59,8 @@ export function makeBaseNPMConfig(options = {}) { // an appropriately-named directory will be added to this base value when we specify either a cjs or esm build dir: hasBundles ? 'build/npm' : 'build', + cleanDir: true, + sourcemap: true, // Include __esModule property when there is a default prop From 8d38b7351ab9e53f40b2590d65976356919bbd22 Mon Sep 17 00:00:00 2001 From: Abdelrahman Awad Date: Fri, 23 Jan 2026 16:22:48 -0500 Subject: [PATCH 3/5] fix: nextjs template dist folder --- dev-packages/rollup-utils/npmHelpers.mjs | 2 -- packages/nextjs/rollup.npm.config.mjs | 14 +++++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dev-packages/rollup-utils/npmHelpers.mjs b/dev-packages/rollup-utils/npmHelpers.mjs index 5afecb253363..62f6c82331e2 100644 --- a/dev-packages/rollup-utils/npmHelpers.mjs +++ b/dev-packages/rollup-utils/npmHelpers.mjs @@ -59,8 +59,6 @@ export function makeBaseNPMConfig(options = {}) { // an appropriately-named directory will be added to this base value when we specify either a cjs or esm build dir: hasBundles ? 'build/npm' : 'build', - cleanDir: true, - sourcemap: true, // Include __esModule property when there is a default prop diff --git a/packages/nextjs/rollup.npm.config.mjs b/packages/nextjs/rollup.npm.config.mjs index 0cbcc4f48c55..a2421a24a891 100644 --- a/packages/nextjs/rollup.npm.config.mjs +++ b/packages/nextjs/rollup.npm.config.mjs @@ -1,4 +1,5 @@ import { makeBaseNPMConfig, makeNPMConfigVariants, makeOtelLoaders } from '@sentry-internal/rollup-utils'; +import path from 'path'; export default [ ...makeNPMConfigVariants( @@ -57,8 +58,6 @@ export default [ output: { virtualDirname: '_virtual/loaders', - dir: 'config/templates', - // this is going to be add-on code, so it doesn't need the trappings of a full module (and in fact actively // shouldn't have them, lest they muck with the module to which we're adding it) sourcemap: false, @@ -103,7 +102,16 @@ import * as serverComponentModule from "__SENTRY_WRAPPING_TARGET_FILE__";${code. ], }, }), - ), + ).map(v => { + // copy the templates into the config/templates directory relative to the esm/cjs build directory + return { + ...v, + output: { + ...v.output, + dir: path.join(v.output.dir, 'config/templates'), + }, + }; + }), ...makeNPMConfigVariants( makeBaseNPMConfig({ entrypoints: ['src/config/loaders/index.ts'], From ae74d1a8bb5f82736ce3bacce3790b4ee638ab51 Mon Sep 17 00:00:00 2001 From: Abdelrahman Awad Date: Fri, 23 Jan 2026 17:29:58 -0500 Subject: [PATCH 4/5] fix: astro output --- packages/astro/package.json | 6 +++--- packages/astro/rollup.npm.config.mjs | 4 +--- .../src/integration/{middleware/index.ts => middleware.ts} | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) rename packages/astro/src/integration/{middleware/index.ts => middleware.ts} (90%) diff --git a/packages/astro/package.json b/packages/astro/package.json index 8dcd69eacde0..b0ac255b90f4 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -34,9 +34,9 @@ }, "./middleware": { "types": "./build/types/integration/middleware/index.types.d.ts", - "node": "./build/esm/integration/middleware/index.js", - "import": "./build/esm/integration/middleware/index.js", - "require": "./build/cjs/integration/middleware/index.js" + "node": "./build/esm/middleware.js", + "import": "./build/esm/middleware.js", + "require": "./build/cjs/middleware.js" }, "./import": { "import": { diff --git a/packages/astro/rollup.npm.config.mjs b/packages/astro/rollup.npm.config.mjs index ca3b338433a7..bd0795207d9f 100644 --- a/packages/astro/rollup.npm.config.mjs +++ b/packages/astro/rollup.npm.config.mjs @@ -2,15 +2,13 @@ import { makeBaseNPMConfig, makeNPMConfigVariants, makeOtelLoaders } from '@sent const variants = makeNPMConfigVariants( makeBaseNPMConfig({ - entrypoints: ['src/index.server.ts', 'src/index.client.ts', 'src/integration/middleware/index.ts'], + entrypoints: ['src/index.server.ts', 'src/index.client.ts', 'src/integration/middleware.ts'], packageSpecificConfig: { output: { dynamicImportInCjs: true, exports: 'named', }, }, - // Astro is Node 18+ no need to add polyfills - addPolyfills: false, }), ); diff --git a/packages/astro/src/integration/middleware/index.ts b/packages/astro/src/integration/middleware.ts similarity index 90% rename from packages/astro/src/integration/middleware/index.ts rename to packages/astro/src/integration/middleware.ts index 46c7ad9531b5..094b418c1079 100644 --- a/packages/astro/src/integration/middleware/index.ts +++ b/packages/astro/src/integration/middleware.ts @@ -1,5 +1,5 @@ import type { MiddlewareResponseHandler } from 'astro'; -import { handleRequest } from '../../server/middleware'; +import { handleRequest } from '../server/middleware'; /** * This export is used by our integration to automatically add the middleware From 07a63ef05aa930e16870cbfafad47e49cb199891 Mon Sep 17 00:00:00 2001 From: Abdelrahman Awad Date: Fri, 23 Jan 2026 17:39:16 -0500 Subject: [PATCH 5/5] fix: nextjs preserve loaders out --- packages/nextjs/rollup.npm.config.mjs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/nextjs/rollup.npm.config.mjs b/packages/nextjs/rollup.npm.config.mjs index a2421a24a891..857206415478 100644 --- a/packages/nextjs/rollup.npm.config.mjs +++ b/packages/nextjs/rollup.npm.config.mjs @@ -56,7 +56,7 @@ export default [ packageSpecificConfig: { output: { - virtualDirname: '_virtual/loaders', + virtualDirname: '_virtual/templates', // this is going to be add-on code, so it doesn't need the trappings of a full module (and in fact actively // shouldn't have them, lest they muck with the module to which we're adding it) @@ -114,11 +114,16 @@ import * as serverComponentModule from "__SENTRY_WRAPPING_TARGET_FILE__";${code. }), ...makeNPMConfigVariants( makeBaseNPMConfig({ - entrypoints: ['src/config/loaders/index.ts'], + entrypoints: [ + 'src/config/loaders/index.ts', + 'src/config/loaders/valueInjectionLoader.ts', + 'src/config/loaders/prefixLoader.ts', + 'src/config/loaders/wrappingLoader.ts', + ], packageSpecificConfig: { output: { - virtualDirname: '_virtual/polyfills', + virtualDirname: '_virtual/loaders', // make it so Rollup calms down about the fact that we're combining default and named exports exports: 'named', @@ -126,7 +131,16 @@ import * as serverComponentModule from "__SENTRY_WRAPPING_TARGET_FILE__";${code. external: ['@rollup/plugin-commonjs', 'rollup'], }, }), - ), + ).map(v => { + // copy the loaders into the config/loaders directory relative to the esm/cjs build directory + return { + ...v, + output: { + ...v.output, + dir: path.join(v.output.dir, 'config/loaders'), + }, + }; + }), ...makeNPMConfigVariants( makeBaseNPMConfig({ entrypoints: ['src/config/polyfills/perf_hooks.js'],