diff --git a/packages/nuxt/src/vite/addServerConfig.ts b/packages/nuxt/src/vite/addServerConfig.ts index 85fdefda740d..fe86895a76f2 100644 --- a/packages/nuxt/src/vite/addServerConfig.ts +++ b/packages/nuxt/src/vite/addServerConfig.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import { createResolver } from '@nuxt/kit'; import type { Nuxt } from '@nuxt/schema'; -import { consoleSandbox } from '@sentry/utils'; +import { consoleSandbox, flatten } from '@sentry/utils'; import type { Nitro } from 'nitropack'; import type { InputPluginOption } from 'rollup'; import type { SentryNuxtModuleOptions } from '../common/types'; @@ -129,8 +129,9 @@ function wrapEntryWithDynamicImport(resolvedSentryConfigPath: string): InputPlug moduleInfo.moduleSideEffects = true; - // The key `.` in `exportedBindings` refer to the exports within the file - const exportedFunctions = moduleInfo.exportedBindings?.['.']; + // `exportedBindings` can look like this: `{ '.': [ 'handler' ], './firebase-gen-1.mjs': [ 'server' ] }` + // The key `.` refers to exports within the current file, while other keys show from where exports were imported first. + const exportedFunctions = flatten(Object.values(moduleInfo.exportedBindings || {})); // The enclosing `if` already checks for the suffix in `source`, but a check in `resolution.id` is needed as well to prevent multiple attachment of the suffix return resolution.id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)