From 09f3f2db2a71e287aee0a2cc8f44d0a07507c994 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Wed, 25 Sep 2024 16:29:18 +0200 Subject: [PATCH 1/2] fix(nuxt): Don't restrict source map assets upload --- packages/nuxt/src/vite/sourceMaps.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/nuxt/src/vite/sourceMaps.ts b/packages/nuxt/src/vite/sourceMaps.ts index 18eed2cbcfd8..2d249ec88c75 100644 --- a/packages/nuxt/src/vite/sourceMaps.ts +++ b/packages/nuxt/src/vite/sourceMaps.ts @@ -60,7 +60,7 @@ function normalizePath(path: string): string { function getPluginOptions( moduleOptions: SentryNuxtModuleOptions, - isNitro = false, + _isNitro = false, ): SentryVitePluginOptions | SentryRollupPluginOptions { const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {}; @@ -70,8 +70,10 @@ function getPluginOptions( authToken: sourceMapsUploadOptions.authToken ?? process.env.SENTRY_AUTH_TOKEN, telemetry: sourceMapsUploadOptions.telemetry ?? true, sourcemaps: { - assets: - sourceMapsUploadOptions.sourcemaps?.assets ?? isNitro ? ['./.output/server/**/*'] : ['./.output/public/**/*'], + // The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server' + // We cannot determine automatically how the build folder looks like (depends on the preset), so we have to accept that sourcemaps are generated multiple times (with Vite for Nuxt and Rollup for Nitro). + // If we could know where the server/client assets are located, we could do something like this (based on the Nitro preset): isNitro ? ['./.output/server/**/*'] : ['./.output/public/**/*'], + assets: sourceMapsUploadOptions.sourcemaps?.assets ?? undefined, ignore: sourceMapsUploadOptions.sourcemaps?.ignore ?? undefined, filesToDeleteAfterUpload: sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload ?? undefined, rewriteSources: (source: string) => normalizePath(source), From 782cea125319fbd268b01e6126e01c81cb3fe940 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Thu, 26 Sep 2024 09:36:57 +0200 Subject: [PATCH 2/2] review comments --- packages/nuxt/src/vite/sourceMaps.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/nuxt/src/vite/sourceMaps.ts b/packages/nuxt/src/vite/sourceMaps.ts index 2d249ec88c75..801d16ab71cf 100644 --- a/packages/nuxt/src/vite/sourceMaps.ts +++ b/packages/nuxt/src/vite/sourceMaps.ts @@ -39,7 +39,7 @@ export function setupSourceMaps(moduleOptions: SentryNuxtModuleOptions, nuxt: Nu } // Add Sentry plugin - nitroConfig.rollupConfig.plugins.push(sentryRollupPlugin(getPluginOptions(moduleOptions, true))); + nitroConfig.rollupConfig.plugins.push(sentryRollupPlugin(getPluginOptions(moduleOptions))); // Enable source maps nitroConfig.rollupConfig.output = nitroConfig?.rollupConfig?.output || {}; @@ -58,10 +58,7 @@ function normalizePath(path: string): string { return path.replace(/^(\.\.\/)+/, './'); } -function getPluginOptions( - moduleOptions: SentryNuxtModuleOptions, - _isNitro = false, -): SentryVitePluginOptions | SentryRollupPluginOptions { +function getPluginOptions(moduleOptions: SentryNuxtModuleOptions): SentryVitePluginOptions | SentryRollupPluginOptions { const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {}; return { @@ -70,8 +67,8 @@ function getPluginOptions( authToken: sourceMapsUploadOptions.authToken ?? process.env.SENTRY_AUTH_TOKEN, telemetry: sourceMapsUploadOptions.telemetry ?? true, sourcemaps: { - // The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server' - // We cannot determine automatically how the build folder looks like (depends on the preset), so we have to accept that sourcemaps are generated multiple times (with Vite for Nuxt and Rollup for Nitro). + // The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server') + // We cannot determine automatically how the build folder looks like (depends on the preset), so we have to accept that sourcemaps are uploaded multiple times (with the vitePlugin for Nuxt and the rollupPlugin for Nitro). // If we could know where the server/client assets are located, we could do something like this (based on the Nitro preset): isNitro ? ['./.output/server/**/*'] : ['./.output/public/**/*'], assets: sourceMapsUploadOptions.sourcemaps?.assets ?? undefined, ignore: sourceMapsUploadOptions.sourcemaps?.ignore ?? undefined,