Skip to content

Commit 1bd15f3

Browse files
authored
fix(nuxt): Don't restrict source map assets upload (#13800)
Source maps generated by Vite are only for the Nuxt-part of the application whereas source maps generated by Rollup are only for the Nitro-part of the application. The Nuxt-part of the application has some overlap with the Nitro-part and so it **would** be nice to specify the client/server folder in the `assets` option, but the output is different for every Nitro preset (the files are always located under a different path). Should fix #13703
1 parent e5478ad commit 1bd15f3

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

packages/nuxt/src/vite/sourceMaps.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function setupSourceMaps(moduleOptions: SentryNuxtModuleOptions, nuxt: Nu
3939
}
4040

4141
// Add Sentry plugin
42-
nitroConfig.rollupConfig.plugins.push(sentryRollupPlugin(getPluginOptions(moduleOptions, true)));
42+
nitroConfig.rollupConfig.plugins.push(sentryRollupPlugin(getPluginOptions(moduleOptions)));
4343

4444
// Enable source maps
4545
nitroConfig.rollupConfig.output = nitroConfig?.rollupConfig?.output || {};
@@ -58,10 +58,7 @@ function normalizePath(path: string): string {
5858
return path.replace(/^(\.\.\/)+/, './');
5959
}
6060

61-
function getPluginOptions(
62-
moduleOptions: SentryNuxtModuleOptions,
63-
isNitro = false,
64-
): SentryVitePluginOptions | SentryRollupPluginOptions {
61+
function getPluginOptions(moduleOptions: SentryNuxtModuleOptions): SentryVitePluginOptions | SentryRollupPluginOptions {
6562
const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {};
6663

6764
return {
@@ -70,8 +67,10 @@ function getPluginOptions(
7067
authToken: sourceMapsUploadOptions.authToken ?? process.env.SENTRY_AUTH_TOKEN,
7168
telemetry: sourceMapsUploadOptions.telemetry ?? true,
7269
sourcemaps: {
73-
assets:
74-
sourceMapsUploadOptions.sourcemaps?.assets ?? isNitro ? ['./.output/server/**/*'] : ['./.output/public/**/*'],
70+
// The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server')
71+
// 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).
72+
// 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/**/*'],
73+
assets: sourceMapsUploadOptions.sourcemaps?.assets ?? undefined,
7574
ignore: sourceMapsUploadOptions.sourcemaps?.ignore ?? undefined,
7675
filesToDeleteAfterUpload: sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload ?? undefined,
7776
rewriteSources: (source: string) => normalizePath(source),

0 commit comments

Comments
 (0)