Skip to content

Commit

Permalink
fix(nuxt): Re-export all exported bindings (#14086)
Browse files Browse the repository at this point in the history
This was brought up here:
#14064

Only the "root bindings" were exported, which led to not re-exported
functions that were imported from another file before they were exported
(like firebase `server`).
  • Loading branch information
s1gr1d authored Oct 29, 2024
1 parent 22c3865 commit c7378e6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/nuxt/src/vite/addServerConfig.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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}`)
Expand Down

0 comments on commit c7378e6

Please sign in to comment.