Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(nuxt): Don't run source maps related code on Nuxt "prepare"
  • Loading branch information
s1gr1d committed Jan 22, 2026
commit ad88f83fa3b67501ca550ab2db960548e6e64935
4 changes: 4 additions & 0 deletions packages/nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ export default defineNuxtModule<ModuleOptions>({
}

nuxt.hooks.hook('nitro:init', nitro => {
if (nuxt.options?._prepare) {
return;
}

if (serverConfigFile) {
addMiddlewareInstrumentation(nitro);
}
Expand Down
38 changes: 25 additions & 13 deletions packages/nuxt/src/vite/sourceMaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function setupSourceMaps(moduleOptions: SentryNuxtModuleOptions, nuxt: Nu
let shouldDeleteFilesFallback = { client: true, server: true };

nuxt.hook('modules:done', () => {
if (sourceMapsEnabled && !nuxt.options.dev) {
if (sourceMapsEnabled && !nuxt.options.dev && !nuxt.options?._prepare) {
Comment thread
s1gr1d marked this conversation as resolved.
// Changing this setting will propagate:
// - for client to viteConfig.build.sourceMap
// - for server to viteConfig.build.sourceMap and nitro.sourceMap
Expand All @@ -49,17 +49,29 @@ export function setupSourceMaps(moduleOptions: SentryNuxtModuleOptions, nuxt: Nu
server: previousSourceMapSettings.server === 'unset',
};

if (
isDebug &&
!moduleOptions.sourcemaps?.filesToDeleteAfterUpload &&
// eslint-disable-next-line deprecation/deprecation
!sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload &&
(shouldDeleteFilesFallback.client || shouldDeleteFilesFallback.server)
) {
// eslint-disable-next-line no-console
console.log(
"[Sentry] As Sentry enabled `'hidden'` source maps, source maps will be automatically deleted after uploading them to Sentry.",
);
if (isDebug && (shouldDeleteFilesFallback.client || shouldDeleteFilesFallback.server)) {
const enabledDeleteFallbacks =
shouldDeleteFilesFallback.client && shouldDeleteFilesFallback.server
? 'client-side and server-side'
: shouldDeleteFilesFallback.server
? 'server-side'
: 'client-side';

if (
!moduleOptions.sourcemaps?.filesToDeleteAfterUpload &&
// eslint-disable-next-line deprecation/deprecation
!sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload
) {
// eslint-disable-next-line no-console
console.log(
`[Sentry] We enabled \`'hidden'\` source maps for your ${enabledDeleteFallbacks} build. Source map files will be automatically deleted after uploading them to Sentry.`,
);
} else {
// eslint-disable-next-line no-console
console.log(
`[Sentry] We enabled \`'hidden'\` source maps for your ${enabledDeleteFallbacks} build. Source map files will be deleted according to your \`sourcemaps.filesToDeleteAfterUpload\` configuration. To use automatic deletion instead, leave \`filesToDeleteAfterUpload\` empty.`,
);
}
}
}
});
Expand Down Expand Up @@ -99,7 +111,7 @@ export function setupSourceMaps(moduleOptions: SentryNuxtModuleOptions, nuxt: Nu
});

nuxt.hook('nitro:config', (nitroConfig: NitroConfig) => {
if (sourceMapsEnabled && !nitroConfig.dev) {
Comment thread
s1gr1d marked this conversation as resolved.
if (sourceMapsEnabled && !nitroConfig.dev && !nuxt.options?._prepare) {
if (!nitroConfig.rollupConfig) {
nitroConfig.rollupConfig = {};
}
Expand Down
Loading