From 511f7f27af35abab75db1b4f8dbd1c2a034b9275 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Mon, 28 Oct 2024 13:12:36 +0100 Subject: [PATCH] fix(nuxt): Re-export all exported bindings --- packages/nuxt/src/vite/addServerConfig.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/nuxt/src/vite/addServerConfig.ts b/packages/nuxt/src/vite/addServerConfig.ts index 4c12c6fd7dc2..8178d3073307 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'; @@ -130,8 +130,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}`)