@sentry/nuxt 11.0.0-alpha.1 → 11.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +5 -0
  2. package/build/cjs/common/devMode.js +12 -0
  3. package/build/cjs/common/devMode.js.map +1 -0
  4. package/build/cjs/module.js +9 -5
  5. package/build/cjs/module.js.map +1 -1
  6. package/build/cjs/server/sdk.js +2 -25
  7. package/build/cjs/server/sdk.js.map +1 -1
  8. package/build/cjs/vite/addServerConfig.js +33 -4
  9. package/build/cjs/vite/addServerConfig.js.map +1 -1
  10. package/build/cjs/vite/orchestrion.js +3 -0
  11. package/build/cjs/vite/orchestrion.js.map +1 -1
  12. package/build/cjs/vite/sourceMapDeletion.js +35 -0
  13. package/build/cjs/vite/sourceMapDeletion.js.map +1 -0
  14. package/build/cjs/vite/sourceMaps.js +13 -6
  15. package/build/cjs/vite/sourceMaps.js.map +1 -1
  16. package/build/cjs/vite/utils.js +7 -11
  17. package/build/cjs/vite/utils.js.map +1 -1
  18. package/build/esm/common/devMode.js +9 -0
  19. package/build/esm/common/devMode.js.map +1 -0
  20. package/build/esm/module.js +11 -7
  21. package/build/esm/module.js.map +1 -1
  22. package/build/esm/package.json +1 -1
  23. package/build/esm/server/sdk.js +6 -27
  24. package/build/esm/server/sdk.js.map +1 -1
  25. package/build/esm/vite/addServerConfig.js +31 -4
  26. package/build/esm/vite/addServerConfig.js.map +1 -1
  27. package/build/esm/vite/orchestrion.js +3 -0
  28. package/build/esm/vite/orchestrion.js.map +1 -1
  29. package/build/esm/vite/sourceMapDeletion.js +32 -0
  30. package/build/esm/vite/sourceMapDeletion.js.map +1 -0
  31. package/build/esm/vite/sourceMaps.js +13 -6
  32. package/build/esm/vite/sourceMaps.js.map +1 -1
  33. package/build/esm/vite/utils.js +6 -12
  34. package/build/esm/vite/utils.js.map +1 -1
  35. package/build/module/common/devMode.d.ts +4 -0
  36. package/build/module/common/types.d.ts +0 -9
  37. package/build/module/module.json +1 -1
  38. package/build/module/module.mjs +87 -25
  39. package/build/module/runtime/hooks/captureErrorHook.js +2 -1
  40. package/build/module/runtime/hooks/wrapMiddlewareHandler.js +6 -5
  41. package/build/module/runtime/utils/instrumentDatabase.js +26 -6
  42. package/build/module/runtime/utils/instrumentStorage.js +21 -15
  43. package/build/module/runtime/utils/patchEventHandler.js +2 -1
  44. package/build/module/vite/addServerConfig.d.ts +9 -0
  45. package/build/module/vite/sourceMapDeletion.d.ts +3 -0
  46. package/build/module/vite/utils.d.ts +3 -1
  47. package/build/types/common/devMode.d.ts +5 -0
  48. package/build/types/common/devMode.d.ts.map +1 -0
  49. package/build/types/common/types.d.ts +0 -9
  50. package/build/types/common/types.d.ts.map +1 -1
  51. package/build/types/index.types.d.ts +3 -1
  52. package/build/types/index.types.d.ts.map +1 -1
  53. package/build/types/module.d.ts.map +1 -1
  54. package/build/types/runtime/hooks/captureErrorHook.d.ts.map +1 -1
  55. package/build/types/runtime/hooks/wrapMiddlewareHandler.d.ts.map +1 -1
  56. package/build/types/runtime/utils/instrumentDatabase.d.ts.map +1 -1
  57. package/build/types/runtime/utils/instrumentStorage.d.ts.map +1 -1
  58. package/build/types/runtime/utils/patchEventHandler.d.ts.map +1 -1
  59. package/build/types/server/sdk.d.ts.map +1 -1
  60. package/build/types/vite/addServerConfig.d.ts +9 -0
  61. package/build/types/vite/addServerConfig.d.ts.map +1 -1
  62. package/build/types/vite/orchestrion.d.ts.map +1 -1
  63. package/build/types/vite/sourceMapDeletion.d.ts +4 -0
  64. package/build/types/vite/sourceMapDeletion.d.ts.map +1 -0
  65. package/build/types/vite/sourceMaps.d.ts.map +1 -1
  66. package/build/types/vite/utils.d.ts +3 -1
  67. package/build/types/vite/utils.d.ts.map +1 -1
  68. package/package.json +11 -9
@@ -1 +1 @@
1
- {"version":3,"file":"sourceMaps.js","sources":["../../../src/vite/sourceMaps.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { sentryRollupPlugin, type SentryRollupPluginOptions } from '@sentry/bundler-plugins/rollup';\nimport { sentryVitePlugin, type SentryVitePluginOptions } from '@sentry/bundler-plugins/vite';\nimport type { NitroConfig } from 'nitropack';\nimport type { Plugin } from 'vite';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { validateSourceMapsOptionsPlugin } from './sentryVitePlugin';\n\n/**\n * Whether the user enabled (true, 'hidden', 'inline') or disabled (false) source maps\n */\nexport type UserSourceMapSetting = 'enabled' | 'disabled' | 'unset' | undefined;\n\n/** A valid source map setting */\nexport type SourceMapSetting = boolean | 'hidden' | 'inline';\n\n/**\n * Setup source maps for Sentry inside the Nuxt module during build time (in Vite for Nuxt and Rollup for Nitro).\n */\nexport function setupSourceMaps(\n moduleOptions: SentryNuxtModuleOptions,\n nuxt: Nuxt,\n addVitePlugin: (plugin: Plugin[], options?: { dev?: boolean; build?: boolean }) => void,\n): void {\n const isDebug = moduleOptions.debug;\n\n const sourceMapsEnabled = moduleOptions.sourcemaps?.disable !== true;\n\n // In case we overwrite the source map settings, we default to deleting the files\n const shouldDeleteFilesFallback = { client: true, server: true };\n\n nuxt.hook('modules:done', () => {\n if (sourceMapsEnabled && !nuxt.options.dev && !nuxt.options?._prepare) {\n // Changing this setting will propagate:\n // - for client to viteConfig.build.sourceMap\n // - for server to viteConfig.build.sourceMap and nitro.sourceMap\n // On server, nitro.rollupConfig.output.sourcemap remains unaffected from this change.\n\n // ONLY THIS nuxt.sourcemap.(server/client) setting is the one Sentry will overwrite with 'hidden', if needed.\n const previousSourceMapSettings = changeNuxtSourceMapSettings(nuxt, moduleOptions);\n\n // Mutate in place so the Vite plugin (which captured this object at registration time) sees the updated values\n shouldDeleteFilesFallback.client = previousSourceMapSettings.client === 'unset';\n shouldDeleteFilesFallback.server = previousSourceMapSettings.server === 'unset';\n\n if (isDebug && (shouldDeleteFilesFallback.client || shouldDeleteFilesFallback.server)) {\n const enabledDeleteFallbacks =\n shouldDeleteFilesFallback.client && shouldDeleteFilesFallback.server\n ? 'client-side and server-side'\n : shouldDeleteFilesFallback.server\n ? 'server-side'\n : 'client-side';\n\n if (!moduleOptions.sourcemaps?.filesToDeleteAfterUpload) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] We enabled \\`'hidden'\\` source maps for your ${enabledDeleteFallbacks} build. Source map files will be automatically deleted after uploading them to Sentry.`,\n );\n } else {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] We enabled \\`'hidden'\\` source maps for your ${enabledDeleteFallbacks} build. Source map files will be deleted according to your \\`sourcemaps.filesToDeleteAfterUpload\\` configuration. To use automatic deletion instead, leave \\`filesToDeleteAfterUpload\\` empty.`,\n );\n }\n }\n }\n });\n\n if (sourceMapsEnabled && !nuxt.options.dev && !nuxt.options?._prepare) {\n addVitePlugin(\n [\n validateSourceMapsOptionsPlugin({ nuxt, moduleOptions, sourceMapsEnabled }),\n // Vite plugin is added on the client and server side (plugin runs for both builds)\n ...sentryVitePlugin(getPluginOptions(moduleOptions, shouldDeleteFilesFallback)),\n ],\n { dev: false, build: true }, // Only add source map plugin during build\n );\n }\n\n nuxt.hook('nitro:config', (nitroConfig: NitroConfig) => {\n if (sourceMapsEnabled && !nitroConfig.dev && !nuxt.options?._prepare) {\n nitroConfig.rollupConfig ??= {};\n\n if (nitroConfig.rollupConfig.plugins === null || nitroConfig.rollupConfig.plugins === undefined) {\n nitroConfig.rollupConfig.plugins = [];\n } else if (!Array.isArray(nitroConfig.rollupConfig.plugins)) {\n // `rollupConfig.plugins` can be a single plugin, so we want to put it into an array so that we can push our own plugin\n nitroConfig.rollupConfig.plugins = [nitroConfig.rollupConfig.plugins];\n }\n\n validateNitroSourceMapSettings(nuxt, nitroConfig, moduleOptions);\n\n if (isDebug) {\n // eslint-disable-next-line no-console\n console.log('[Sentry] Adding Sentry Rollup plugin to the server runtime.');\n }\n\n // Add Sentry plugin\n // Runs only on server-side (Nitro)\n nitroConfig.rollupConfig.plugins.push(\n sentryRollupPlugin(getPluginOptions(moduleOptions, shouldDeleteFilesFallback)),\n );\n }\n });\n}\n\n/**\n * Normalizes the beginning of a path from e.g. ../../../ to ./\n */\nfunction normalizePath(path: string): string {\n return path.replace(/^(\\.\\.\\/)+/, './');\n}\n\n/**\n * Generates source maps upload options for the Sentry Vite and Rollup plugin.\n *\n * Only exported for Testing purposes.\n */\nexport function getPluginOptions(\n moduleOptions: SentryNuxtModuleOptions,\n shouldDeleteFilesFallback?: { client: boolean; server: boolean },\n): SentryVitePluginOptions | SentryRollupPluginOptions {\n const sourcemapsOptions = moduleOptions.sourcemaps || {};\n const filesToDeleteAfterUpload = resolveFilesToDeleteAfterUpload(moduleOptions, shouldDeleteFilesFallback);\n\n return {\n applicationKey: moduleOptions.applicationKey,\n org: moduleOptions.org ?? process.env.SENTRY_ORG,\n project: moduleOptions.project ?? process.env.SENTRY_PROJECT,\n authToken: moduleOptions.authToken ?? process.env.SENTRY_AUTH_TOKEN,\n telemetry: moduleOptions.telemetry ?? true,\n url: moduleOptions.sentryUrl ?? process.env.SENTRY_URL,\n headers: moduleOptions.headers,\n debug: moduleOptions.debug ?? false,\n silent: moduleOptions.silent ?? false,\n errorHandler: moduleOptions.errorHandler,\n bundleSizeOptimizations: moduleOptions.bundleSizeOptimizations, // todo: test if this can be overridden by the user\n release: {\n name: moduleOptions.release?.name,\n // Support all release options from BuildTimeOptionsBase\n ...moduleOptions.release,\n ...moduleOptions?.unstable_sentryBundlerPluginOptions?.release,\n },\n _metaOptions: {\n telemetry: {\n metaFramework: 'nuxt',\n },\n },\n ...moduleOptions?.unstable_sentryBundlerPluginOptions,\n\n sourcemaps: {\n disable: moduleOptions.sourcemaps?.disable,\n // The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server')\n // We cannot determine automatically how the build folder looks like (depends on the preset), so we have to accept that source maps are uploaded multiple times (with the vitePlugin for Nuxt and the rollupPlugin for Nitro).\n // 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/**/*'],\n assets: sourcemapsOptions.assets ?? undefined,\n ignore: sourcemapsOptions.ignore ?? undefined,\n filesToDeleteAfterUpload,\n rewriteSources: sourcemapsOptions.rewriteSources ?? normalizePath,\n ...moduleOptions?.unstable_sentryBundlerPluginOptions?.sourcemaps,\n },\n };\n}\n\n/**\n * Determines which files to delete after upload. If the user set `filesToDeleteAfterUpload`, we use\n * that. Otherwise we only delete the source maps Sentry generated itself — i.e. the sides\n * (client/server) whose `sourcemap` setting resolved to `undefined`, where Sentry stepped in and\n * enabled `'hidden'`. Given Nuxt's default of `{ server: true, client: false }`, this isn't the\n * default case: it only kicks in when a side is left `undefined` (whole config or a single sub-key).\n * @see https://nuxt.com/docs/4.x/api/nuxt-config#sourcemap\n */\nfunction resolveFilesToDeleteAfterUpload(\n moduleOptions: SentryNuxtModuleOptions,\n shouldDeleteFilesFallback?: { client: boolean; server: boolean },\n): string | Array<string> | undefined {\n const shouldDeleteFilesAfterUpload = shouldDeleteFilesFallback?.client || shouldDeleteFilesFallback?.server;\n const fallbackFilesToDelete = [\n ...(shouldDeleteFilesFallback?.client ? ['.*/**/public/**/*.map'] : []),\n ...(shouldDeleteFilesFallback?.server\n ? ['.*/**/server/**/*.map', '.*/**/output/**/*.map', '.*/**/function/**/*.map']\n : []),\n ];\n\n const filesToDeleteAfterUpload = moduleOptions.sourcemaps?.filesToDeleteAfterUpload;\n\n if (typeof filesToDeleteAfterUpload === 'undefined' && shouldDeleteFilesAfterUpload && moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Setting \\`sentry.sourcemaps.filesToDeleteAfterUpload: [${fallbackFilesToDelete\n // Logging it as strings in the array\n .map(path => `\"${path}\"`)\n .join(', ')}]\\` to delete generated source maps after they were uploaded to Sentry.`,\n );\n }\n\n return filesToDeleteAfterUpload\n ? filesToDeleteAfterUpload\n : shouldDeleteFilesAfterUpload\n ? fallbackFilesToDelete\n : undefined;\n}\n\n/* There are multiple ways to set up source maps (https://github.com/getsentry/sentry-javascript/issues/13993 and https://github.com/getsentry/sentry-javascript/pull/15859)\n 1. User explicitly disabled source maps\n - keep this setting (emit a warning that errors won't be unminified in Sentry)\n - We will not upload anything\n 2. users enabled source map generation (true, hidden, inline).\n - keep this setting (don't do anything - like deletion - besides uploading)\n 3. users did not set source maps generation\n - we enable 'hidden' source maps generation\n - configure `filesToDeleteAfterUpload` to delete all .map files (we emit a log about this)\n\n Users only have to explicitly enable client source maps. Sentry only overwrites the base Nuxt source map settings as they propagate.\n */\n\n/** only exported for tests */\nexport function extractNuxtSourceMapSetting(\n nuxt: { options: { sourcemap?: SourceMapSetting | { server?: SourceMapSetting; client?: SourceMapSetting } } },\n runtime: 'client' | 'server' | undefined,\n): SourceMapSetting | undefined {\n if (!runtime) {\n return undefined;\n } else {\n return typeof nuxt.options?.sourcemap === 'boolean' || typeof nuxt.options?.sourcemap === 'string'\n ? nuxt.options.sourcemap\n : nuxt.options?.sourcemap?.[runtime];\n }\n}\n\n/** only exported for testing */\nexport function changeNuxtSourceMapSettings(\n nuxt: Nuxt,\n sentryModuleOptions: SentryNuxtModuleOptions,\n): { client: UserSourceMapSetting; server: UserSourceMapSetting } {\n nuxt.options.sourcemap = nuxt.options.sourcemap ?? { server: undefined, client: undefined };\n\n let previousUserSourceMapSetting: { client: UserSourceMapSetting; server: UserSourceMapSetting } = {\n client: undefined,\n server: undefined,\n };\n\n const nuxtSourceMap = nuxt.options.sourcemap;\n const isDebug = sentryModuleOptions.debug;\n\n if (typeof nuxtSourceMap === 'string' || typeof nuxtSourceMap === 'boolean' || typeof nuxtSourceMap === 'undefined') {\n switch (nuxtSourceMap) {\n case false:\n warnExplicitlyDisabledSourceMap('sourcemap', isDebug);\n previousUserSourceMapSetting = { client: 'disabled', server: 'disabled' };\n break;\n\n case 'hidden':\n case true:\n logKeepEnabledSourceMapSetting(sentryModuleOptions, 'sourcemap', (nuxtSourceMap as true).toString());\n previousUserSourceMapSetting = { client: 'enabled', server: 'enabled' };\n break;\n case undefined:\n nuxt.options.sourcemap = { server: 'hidden', client: 'hidden' };\n isDebug && logSentryEnablesSourceMap('sourcemap.client', 'hidden');\n isDebug && logSentryEnablesSourceMap('sourcemap.server', 'hidden');\n previousUserSourceMapSetting = { client: 'unset', server: 'unset' };\n break;\n }\n } else {\n if (nuxtSourceMap.client === false) {\n warnExplicitlyDisabledSourceMap('sourcemap.client', isDebug);\n previousUserSourceMapSetting.client = 'disabled';\n } else if (['hidden', true].includes(nuxtSourceMap.client)) {\n logKeepEnabledSourceMapSetting(sentryModuleOptions, 'sourcemap.client', nuxtSourceMap.client.toString());\n previousUserSourceMapSetting.client = 'enabled';\n } else {\n nuxt.options.sourcemap.client = 'hidden';\n isDebug && logSentryEnablesSourceMap('sourcemap.client', 'hidden');\n previousUserSourceMapSetting.client = 'unset';\n }\n\n if (nuxtSourceMap.server === false) {\n warnExplicitlyDisabledSourceMap('sourcemap.server', isDebug);\n previousUserSourceMapSetting.server = 'disabled';\n } else if (['hidden', true].includes(nuxtSourceMap.server)) {\n logKeepEnabledSourceMapSetting(sentryModuleOptions, 'sourcemap.server', nuxtSourceMap.server.toString());\n previousUserSourceMapSetting.server = 'enabled';\n } else {\n nuxt.options.sourcemap.server = 'hidden';\n isDebug && logSentryEnablesSourceMap('sourcemap.server', 'hidden');\n previousUserSourceMapSetting.server = 'unset';\n }\n }\n\n return previousUserSourceMapSetting;\n}\n\n/** Logs warnings about potentially conflicting source map settings.\n * Configures `sourcemapExcludeSources` in Nitro to make source maps usable in Sentry.\n *\n * only exported for testing\n */\nexport function validateNitroSourceMapSettings(\n nuxt: { options: { sourcemap?: SourceMapSetting | { server?: SourceMapSetting } } },\n nitroConfig: NitroConfig,\n sentryModuleOptions: SentryNuxtModuleOptions,\n): void {\n const isDebug = sentryModuleOptions.debug;\n const nuxtSourceMap = extractNuxtSourceMapSetting(nuxt, 'server');\n\n // NITRO CONFIG ---\n\n validateDifferentSourceMapSettings({\n nuxtSettingKey: 'sourcemap.server',\n nuxtSettingValue: nuxtSourceMap,\n otherSettingKey: 'nitro.sourceMap',\n otherSettingValue: nitroConfig.sourceMap,\n });\n\n // ROLLUP CONFIG ---\n\n nitroConfig.rollupConfig = nitroConfig.rollupConfig || {};\n nitroConfig.rollupConfig.output = nitroConfig.rollupConfig.output || { sourcemap: undefined };\n const nitroRollupSourceMap = nitroConfig.rollupConfig.output.sourcemap;\n\n // We don't override nitro.rollupConfig.output.sourcemap (undefined by default, but overrides all other server-side source map settings)\n if (typeof nitroRollupSourceMap !== 'undefined' && ['hidden', 'inline', true, false].includes(nitroRollupSourceMap)) {\n const settingKey = 'nitro.rollupConfig.output.sourcemap';\n\n validateDifferentSourceMapSettings({\n nuxtSettingKey: 'sourcemap.server',\n nuxtSettingValue: nuxtSourceMap,\n otherSettingKey: settingKey,\n otherSettingValue: nitroRollupSourceMap,\n });\n }\n\n nitroConfig.rollupConfig.output.sourcemapExcludeSources = false;\n if (isDebug) {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Set `sourcemapExcludeSources: false` in the Nuxt config (`nitro.rollupConfig.output`). Source maps will now include the actual code to be able to un-minify code snippets in Sentry.',\n );\n }\n}\n\n/**\n * Validates that source map settings are consistent between Nuxt and Vite/Nitro configurations.\n * Logs a warning if conflicting settings are detected.\n *\n * @internal Only exported for testing.\n */\nexport function validateDifferentSourceMapSettings({\n nuxtSettingKey,\n nuxtSettingValue,\n otherSettingKey,\n otherSettingValue,\n}: {\n nuxtSettingKey: string;\n nuxtSettingValue?: SourceMapSetting;\n otherSettingKey: string;\n otherSettingValue?: SourceMapSetting;\n}): void {\n if (nuxtSettingValue !== otherSettingValue) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Source map generation settings are conflicting. Sentry uses \\`${nuxtSettingKey}: ${nuxtSettingValue}\\`. However, a conflicting setting was discovered (\\`${otherSettingKey}: ${otherSettingValue}\\`). This setting was probably explicitly set in your configuration. Sentry won't override this setting but it may affect source maps generation and upload. Without source maps, code snippets on the Sentry Issues page will remain minified.`,\n );\n }\n}\n\nfunction logKeepEnabledSourceMapSetting(\n sentryNuxtModuleOptions: SentryNuxtModuleOptions,\n settingKey: string,\n settingValue: string,\n): void {\n if (sentryNuxtModuleOptions.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] \\`${settingKey}\\` is enabled with \\`${settingValue}\\`. This will correctly un-minify the code snippet on the Sentry Issue Details page.`,\n );\n }\n}\n\nfunction warnExplicitlyDisabledSourceMap(settingKey: string, isDebug: boolean | undefined): void {\n if (isDebug) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Source map generation is currently disabled in your Vite configuration (\\`${settingKey}: false \\`). This setting is either a default setting or was explicitly set in your configuration. Sentry won't override this setting. Without source maps, code snippets on the Sentry Issues page will remain minified. To show unminified code, enable source maps in \\`${settingKey}\\` (e.g. by setting them to \\`hidden\\`).`,\n );\n } else {\n // eslint-disable-next-line no-console\n console.warn(`[Sentry] Source map generation (\\`${settingKey}\\`) is disabled in your Vite configuration.`);\n }\n}\n\nfunction logSentryEnablesSourceMap(settingKey: string, settingValue: string): void {\n // eslint-disable-next-line no-console\n console.log(`[Sentry] Enabled source map generation in the build options with \\`${settingKey}: ${settingValue}\\`.`);\n}\n"],"names":["validateSourceMapsOptionsPlugin","sentryVitePlugin","sentryRollupPlugin"],"mappings":";;;;;;AAmBO,SAAS,eAAA,CACd,aAAA,EACA,IAAA,EACA,aAAA,EACM;AACN,EAAA,MAAM,UAAU,aAAA,CAAc,KAAA;AAE9B,EAAA,MAAM,iBAAA,GAAoB,aAAA,CAAc,UAAA,EAAY,OAAA,KAAY,IAAA;AAGhE,EAAA,MAAM,yBAAA,GAA4B,EAAE,MAAA,EAAQ,IAAA,EAAM,QAAQ,IAAA,EAAK;AAE/D,EAAA,IAAA,CAAK,IAAA,CAAK,gBAAgB,MAAM;AAC9B,IAAA,IAAI,iBAAA,IAAqB,CAAC,IAAA,CAAK,OAAA,CAAQ,OAAO,C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,KAAA,EAAO;AAEjC,IAAA,OAAA,CAAQ,GAAA;AAAA,MACN,CAAA,WAAA,EAAc,UAAU,CAAA,qBAAA,EAAwB,YAAY,CAAA,oFAAA;AAAA,KAC9D;AAAA,EACF;AACF;AAEA,SAAS,+BAAA,CAAgC,YAAoB,OAAA,EAAoC;AAC/F,EAAA,IAAI,OAAA,EAAS;AAEX,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN,CAAA,mFAAA,EAAsF,UAAU,CAAA,2QAAA,EAA8Q,UAAU,CAAA,wCAAA;AAAA,KAC1X;AAAA,EACF,CAAA,MAAO;AAEL,IAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,kCAAA,EAAqC,UAAU,CAAA,2CAAA,CAA6C,CAAA;AAAA,EAC3G;AACF;AAEA,SAAS,yBAAA,CAA0B,YAAoB,YAAA,EAA4B;AAEjF,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,mEAAA,EAAsE,UAAU,CAAA,EAAA,EAAK,YAAY,CAAA,GAAA,CAAK,CAAA;AACpH;;;;;;;;;"}
1
+ {"version":3,"file":"sourceMaps.js","sources":["../../../src/vite/sourceMaps.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { sentryRollupPlugin, type SentryRollupPluginOptions } from '@sentry/bundler-plugins/rollup';\nimport { sentryVitePlugin, type SentryVitePluginOptions } from '@sentry/bundler-plugins/vite';\nimport { warnOnRemovedBuildOptions } from '@sentry/core';\nimport type { NitroConfig } from 'nitropack';\nimport type { Plugin } from 'vite';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { deleteSourceMapsAfterBuild, withoutSourceMapDeletion } from './sourceMapDeletion';\nimport { validateSourceMapsOptionsPlugin } from './sentryVitePlugin';\n\n/**\n * Whether the user enabled (true, 'hidden', 'inline') or disabled (false) source maps\n */\nexport type UserSourceMapSetting = 'enabled' | 'disabled' | 'unset' | undefined;\n\n/** A valid source map setting */\nexport type SourceMapSetting = boolean | 'hidden' | 'inline';\n\n/**\n * Setup source maps for Sentry inside the Nuxt module during build time (in Vite for Nuxt and Rollup for Nitro).\n */\nexport function setupSourceMaps(\n moduleOptions: SentryNuxtModuleOptions,\n nuxt: Nuxt,\n addVitePlugin: (plugin: Plugin[], options?: { dev?: boolean; build?: boolean }) => void,\n): void {\n // Warn here rather than in `getPluginOptions`, which runs once per bundler (Vite and Nitro's\n // Rollup) and would emit the same warning twice.\n warnOnRemovedBuildOptions(moduleOptions, ['unstable_sentryBundlerPluginOptions']);\n\n const isDebug = moduleOptions.debug;\n\n const sourceMapsEnabled = moduleOptions.sourcemaps?.disable !== true;\n\n // In case we overwrite the source map settings, we default to deleting the files\n const shouldDeleteFilesFallback = { client: true, server: true };\n\n nuxt.hook('modules:done', () => {\n if (sourceMapsEnabled && !nuxt.options.dev && !nuxt.options?._prepare) {\n // Changing this setting will propagate:\n // - for client to viteConfig.build.sourceMap\n // - for server to viteConfig.build.sourceMap and nitro.sourceMap\n // On server, nitro.rollupConfig.output.sourcemap remains unaffected from this change.\n\n // ONLY THIS nuxt.sourcemap.(server/client) setting is the one Sentry will overwrite with 'hidden', if needed.\n const previousSourceMapSettings = changeNuxtSourceMapSettings(nuxt, moduleOptions);\n\n // Mutate in place so the Vite plugin (which captured this object at registration time) sees the updated values\n shouldDeleteFilesFallback.client = previousSourceMapSettings.client === 'unset';\n shouldDeleteFilesFallback.server = previousSourceMapSettings.server === 'unset';\n\n if (isDebug && (shouldDeleteFilesFallback.client || shouldDeleteFilesFallback.server)) {\n const enabledDeleteFallbacks =\n shouldDeleteFilesFallback.client && shouldDeleteFilesFallback.server\n ? 'client-side and server-side'\n : shouldDeleteFilesFallback.server\n ? 'server-side'\n : 'client-side';\n\n if (!moduleOptions.sourcemaps?.filesToDeleteAfterUpload) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] We enabled \\`'hidden'\\` source maps for your ${enabledDeleteFallbacks} build. Source map files will be automatically deleted after uploading them to Sentry.`,\n );\n } else {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] We enabled \\`'hidden'\\` source maps for your ${enabledDeleteFallbacks} build. Source map files will be deleted according to your \\`sourcemaps.filesToDeleteAfterUpload\\` configuration. To use automatic deletion instead, leave \\`filesToDeleteAfterUpload\\` empty.`,\n );\n }\n }\n }\n });\n\n if (sourceMapsEnabled && !nuxt.options.dev && !nuxt.options?._prepare) {\n addVitePlugin(\n [\n validateSourceMapsOptionsPlugin({ nuxt, moduleOptions, sourceMapsEnabled }),\n // Vite plugin is added on the client and server side (plugin runs for both builds)\n ...sentryVitePlugin(withoutSourceMapDeletion(getPluginOptions(moduleOptions, shouldDeleteFilesFallback))),\n ],\n { dev: false, build: true }, // Only add source map plugin during build\n );\n }\n\n nuxt.hook('nitro:config', (nitroConfig: NitroConfig) => {\n if (sourceMapsEnabled && !nitroConfig.dev && !nuxt.options?._prepare) {\n nitroConfig.rollupConfig ??= {};\n\n if (nitroConfig.rollupConfig.plugins === null || nitroConfig.rollupConfig.plugins === undefined) {\n nitroConfig.rollupConfig.plugins = [];\n } else if (!Array.isArray(nitroConfig.rollupConfig.plugins)) {\n // `rollupConfig.plugins` can be a single plugin, so we want to put it into an array so that we can push our own plugin\n nitroConfig.rollupConfig.plugins = [nitroConfig.rollupConfig.plugins];\n }\n\n validateNitroSourceMapSettings(nuxt, nitroConfig, moduleOptions);\n\n if (isDebug) {\n // eslint-disable-next-line no-console\n console.log('[Sentry] Adding Sentry Rollup plugin to the server runtime.');\n }\n\n // Add Sentry plugin\n // Runs only on server-side (Nitro)\n nitroConfig.rollupConfig.plugins.push(\n sentryRollupPlugin(withoutSourceMapDeletion(getPluginOptions(moduleOptions, shouldDeleteFilesFallback))),\n );\n }\n });\n\n nuxt.hook('close', async () => {\n if (sourceMapsEnabled && !nuxt.options.dev && !nuxt.options?._prepare) {\n await deleteSourceMapsAfterBuild(getPluginOptions(moduleOptions, shouldDeleteFilesFallback));\n }\n });\n}\n\n/**\n * Normalizes the beginning of a path from e.g. ../../../ to ./\n */\nfunction normalizePath(path: string): string {\n return path.replace(/^(\\.\\.\\/)+/, './');\n}\n\n/**\n * Generates source maps upload options for the Sentry Vite and Rollup plugin.\n *\n * Only exported for Testing purposes.\n */\nexport function getPluginOptions(\n moduleOptions: SentryNuxtModuleOptions,\n shouldDeleteFilesFallback?: { client: boolean; server: boolean },\n): SentryVitePluginOptions | SentryRollupPluginOptions {\n const sourcemapsOptions = moduleOptions.sourcemaps || {};\n const filesToDeleteAfterUpload = resolveFilesToDeleteAfterUpload(moduleOptions, shouldDeleteFilesFallback);\n\n return {\n applicationKey: moduleOptions.applicationKey,\n org: moduleOptions.org ?? process.env.SENTRY_ORG,\n project: moduleOptions.project ?? process.env.SENTRY_PROJECT,\n authToken: moduleOptions.authToken ?? process.env.SENTRY_AUTH_TOKEN,\n telemetry: moduleOptions.telemetry ?? true,\n url: moduleOptions.sentryUrl ?? process.env.SENTRY_URL,\n headers: moduleOptions.headers,\n debug: moduleOptions.debug ?? false,\n silent: moduleOptions.silent ?? false,\n errorHandler: moduleOptions.errorHandler,\n bundleSizeOptimizations: moduleOptions.bundleSizeOptimizations, // todo: test if this can be overridden by the user\n release: {\n name: moduleOptions.release?.name,\n // Support all release options from BuildTimeOptionsBase\n ...moduleOptions.release,\n },\n moduleMetadata: moduleOptions.moduleMetadata,\n _metaOptions: {\n telemetry: {\n metaFramework: 'nuxt',\n },\n },\n\n sourcemaps: {\n disable: moduleOptions.sourcemaps?.disable,\n // The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server')\n // We cannot determine automatically how the build folder looks like (depends on the preset), so we have to accept that source maps are uploaded multiple times (with the vitePlugin for Nuxt and the rollupPlugin for Nitro).\n // 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/**/*'],\n assets: sourcemapsOptions.assets ?? undefined,\n ignore: sourcemapsOptions.ignore ?? undefined,\n filesToDeleteAfterUpload,\n rewriteSources: sourcemapsOptions.rewriteSources ?? normalizePath,\n resolveSourceMap: sourcemapsOptions.resolveSourceMap,\n },\n };\n}\n\n/**\n * Determines which files to delete after upload. If the user set `filesToDeleteAfterUpload`, we use\n * that. Otherwise we only delete the source maps Sentry generated itself — i.e. the sides\n * (client/server) whose `sourcemap` setting resolved to `undefined`, where Sentry stepped in and\n * enabled `'hidden'`. Given Nuxt's default of `{ server: true, client: false }`, this isn't the\n * default case: it only kicks in when a side is left `undefined` (whole config or a single sub-key).\n * @see https://nuxt.com/docs/4.x/api/nuxt-config#sourcemap\n */\nfunction resolveFilesToDeleteAfterUpload(\n moduleOptions: SentryNuxtModuleOptions,\n shouldDeleteFilesFallback?: { client: boolean; server: boolean },\n): string | Array<string> | undefined {\n const shouldDeleteFilesAfterUpload = shouldDeleteFilesFallback?.client || shouldDeleteFilesFallback?.server;\n const fallbackFilesToDelete = [\n ...(shouldDeleteFilesFallback?.client ? ['.*/**/public/**/*.map'] : []),\n ...(shouldDeleteFilesFallback?.server\n ? ['.*/**/server/**/*.map', '.*/**/output/**/*.map', '.*/**/function/**/*.map']\n : []),\n ];\n\n const filesToDeleteAfterUpload = moduleOptions.sourcemaps?.filesToDeleteAfterUpload;\n\n if (typeof filesToDeleteAfterUpload === 'undefined' && shouldDeleteFilesAfterUpload && moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Setting \\`sentry.sourcemaps.filesToDeleteAfterUpload: [${fallbackFilesToDelete\n // Logging it as strings in the array\n .map(path => `\"${path}\"`)\n .join(', ')}]\\` to delete generated source maps after they were uploaded to Sentry.`,\n );\n }\n\n return filesToDeleteAfterUpload\n ? filesToDeleteAfterUpload\n : shouldDeleteFilesAfterUpload\n ? fallbackFilesToDelete\n : undefined;\n}\n\n/* There are multiple ways to set up source maps (https://github.com/getsentry/sentry-javascript/issues/13993 and https://github.com/getsentry/sentry-javascript/pull/15859)\n 1. User explicitly disabled source maps\n - keep this setting (emit a warning that errors won't be unminified in Sentry)\n - We will not upload anything\n 2. users enabled source map generation (true, hidden, inline).\n - keep this setting (don't do anything - like deletion - besides uploading)\n 3. users did not set source maps generation\n - we enable 'hidden' source maps generation\n - configure `filesToDeleteAfterUpload` to delete all .map files (we emit a log about this)\n\n Users only have to explicitly enable client source maps. Sentry only overwrites the base Nuxt source map settings as they propagate.\n */\n\n/** only exported for tests */\nexport function extractNuxtSourceMapSetting(\n nuxt: { options: { sourcemap?: SourceMapSetting | { server?: SourceMapSetting; client?: SourceMapSetting } } },\n runtime: 'client' | 'server' | undefined,\n): SourceMapSetting | undefined {\n if (!runtime) {\n return undefined;\n } else {\n return typeof nuxt.options?.sourcemap === 'boolean' || typeof nuxt.options?.sourcemap === 'string'\n ? nuxt.options.sourcemap\n : nuxt.options?.sourcemap?.[runtime];\n }\n}\n\n/** only exported for testing */\nexport function changeNuxtSourceMapSettings(\n nuxt: Nuxt,\n sentryModuleOptions: SentryNuxtModuleOptions,\n): { client: UserSourceMapSetting; server: UserSourceMapSetting } {\n nuxt.options.sourcemap = nuxt.options.sourcemap ?? { server: undefined, client: undefined };\n\n let previousUserSourceMapSetting: { client: UserSourceMapSetting; server: UserSourceMapSetting } = {\n client: undefined,\n server: undefined,\n };\n\n const nuxtSourceMap = nuxt.options.sourcemap;\n const isDebug = sentryModuleOptions.debug;\n\n if (typeof nuxtSourceMap === 'string' || typeof nuxtSourceMap === 'boolean' || typeof nuxtSourceMap === 'undefined') {\n switch (nuxtSourceMap) {\n case false:\n warnExplicitlyDisabledSourceMap('sourcemap', isDebug);\n previousUserSourceMapSetting = { client: 'disabled', server: 'disabled' };\n break;\n\n case 'hidden':\n case true:\n logKeepEnabledSourceMapSetting(sentryModuleOptions, 'sourcemap', (nuxtSourceMap as true).toString());\n previousUserSourceMapSetting = { client: 'enabled', server: 'enabled' };\n break;\n case undefined:\n nuxt.options.sourcemap = { server: 'hidden', client: 'hidden' };\n isDebug && logSentryEnablesSourceMap('sourcemap.client', 'hidden');\n isDebug && logSentryEnablesSourceMap('sourcemap.server', 'hidden');\n previousUserSourceMapSetting = { client: 'unset', server: 'unset' };\n break;\n }\n } else {\n if (nuxtSourceMap.client === false) {\n warnExplicitlyDisabledSourceMap('sourcemap.client', isDebug);\n previousUserSourceMapSetting.client = 'disabled';\n } else if (['hidden', true].includes(nuxtSourceMap.client)) {\n logKeepEnabledSourceMapSetting(sentryModuleOptions, 'sourcemap.client', nuxtSourceMap.client.toString());\n previousUserSourceMapSetting.client = 'enabled';\n } else {\n nuxt.options.sourcemap.client = 'hidden';\n isDebug && logSentryEnablesSourceMap('sourcemap.client', 'hidden');\n previousUserSourceMapSetting.client = 'unset';\n }\n\n if (nuxtSourceMap.server === false) {\n warnExplicitlyDisabledSourceMap('sourcemap.server', isDebug);\n previousUserSourceMapSetting.server = 'disabled';\n } else if (['hidden', true].includes(nuxtSourceMap.server)) {\n logKeepEnabledSourceMapSetting(sentryModuleOptions, 'sourcemap.server', nuxtSourceMap.server.toString());\n previousUserSourceMapSetting.server = 'enabled';\n } else {\n nuxt.options.sourcemap.server = 'hidden';\n isDebug && logSentryEnablesSourceMap('sourcemap.server', 'hidden');\n previousUserSourceMapSetting.server = 'unset';\n }\n }\n\n return previousUserSourceMapSetting;\n}\n\n/** Logs warnings about potentially conflicting source map settings.\n * Configures `sourcemapExcludeSources` in Nitro to make source maps usable in Sentry.\n *\n * only exported for testing\n */\nexport function validateNitroSourceMapSettings(\n nuxt: { options: { sourcemap?: SourceMapSetting | { server?: SourceMapSetting } } },\n nitroConfig: NitroConfig,\n sentryModuleOptions: SentryNuxtModuleOptions,\n): void {\n const isDebug = sentryModuleOptions.debug;\n const nuxtSourceMap = extractNuxtSourceMapSetting(nuxt, 'server');\n\n // NITRO CONFIG ---\n\n validateDifferentSourceMapSettings({\n nuxtSettingKey: 'sourcemap.server',\n nuxtSettingValue: nuxtSourceMap,\n otherSettingKey: 'nitro.sourceMap',\n otherSettingValue: nitroConfig.sourceMap,\n });\n\n // ROLLUP CONFIG ---\n\n nitroConfig.rollupConfig = nitroConfig.rollupConfig || {};\n nitroConfig.rollupConfig.output = nitroConfig.rollupConfig.output || { sourcemap: undefined };\n const nitroRollupSourceMap = nitroConfig.rollupConfig.output.sourcemap;\n\n // We don't override nitro.rollupConfig.output.sourcemap (undefined by default, but overrides all other server-side source map settings)\n if (typeof nitroRollupSourceMap !== 'undefined' && ['hidden', 'inline', true, false].includes(nitroRollupSourceMap)) {\n const settingKey = 'nitro.rollupConfig.output.sourcemap';\n\n validateDifferentSourceMapSettings({\n nuxtSettingKey: 'sourcemap.server',\n nuxtSettingValue: nuxtSourceMap,\n otherSettingKey: settingKey,\n otherSettingValue: nitroRollupSourceMap,\n });\n }\n\n nitroConfig.rollupConfig.output.sourcemapExcludeSources = false;\n if (isDebug) {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Set `sourcemapExcludeSources: false` in the Nuxt config (`nitro.rollupConfig.output`). Source maps will now include the actual code to be able to un-minify code snippets in Sentry.',\n );\n }\n}\n\n/**\n * Validates that source map settings are consistent between Nuxt and Vite/Nitro configurations.\n * Logs a warning if conflicting settings are detected.\n *\n * @internal Only exported for testing.\n */\nexport function validateDifferentSourceMapSettings({\n nuxtSettingKey,\n nuxtSettingValue,\n otherSettingKey,\n otherSettingValue,\n}: {\n nuxtSettingKey: string;\n nuxtSettingValue?: SourceMapSetting;\n otherSettingKey: string;\n otherSettingValue?: SourceMapSetting;\n}): void {\n if (nuxtSettingValue !== otherSettingValue) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Source map generation settings are conflicting. Sentry uses \\`${nuxtSettingKey}: ${nuxtSettingValue}\\`. However, a conflicting setting was discovered (\\`${otherSettingKey}: ${otherSettingValue}\\`). This setting was probably explicitly set in your configuration. Sentry won't override this setting but it may affect source maps generation and upload. Without source maps, code snippets on the Sentry Issues page will remain minified.`,\n );\n }\n}\n\nfunction logKeepEnabledSourceMapSetting(\n sentryNuxtModuleOptions: SentryNuxtModuleOptions,\n settingKey: string,\n settingValue: string,\n): void {\n if (sentryNuxtModuleOptions.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] \\`${settingKey}\\` is enabled with \\`${settingValue}\\`. This will correctly un-minify the code snippet on the Sentry Issue Details page.`,\n );\n }\n}\n\nfunction warnExplicitlyDisabledSourceMap(settingKey: string, isDebug: boolean | undefined): void {\n if (isDebug) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Source map generation is currently disabled in your Vite configuration (\\`${settingKey}: false \\`). This setting is either a default setting or was explicitly set in your configuration. Sentry won't override this setting. Without source maps, code snippets on the Sentry Issues page will remain minified. To show unminified code, enable source maps in \\`${settingKey}\\` (e.g. by setting them to \\`hidden\\`).`,\n );\n } else {\n // eslint-disable-next-line no-console\n console.warn(`[Sentry] Source map generation (\\`${settingKey}\\`) is disabled in your Vite configuration.`);\n }\n}\n\nfunction logSentryEnablesSourceMap(settingKey: string, settingValue: string): void {\n // eslint-disable-next-line no-console\n console.log(`[Sentry] Enabled source map generation in the build options with \\`${settingKey}: ${settingValue}\\`.`);\n}\n"],"names":["warnOnRemovedBuildOptions","validateSourceMapsOptionsPlugin","sentryVitePlugin","withoutSourceMapDeletion","sentryRollupPlugin","deleteSourceMapsAfterBuild"],"mappings":";;;;;;;;AAqBO,SAAS,eAAA,CACd,aAAA,EACA,IAAA,EACA,aAAA,EACM;AAGN,EAAAA,8BAAA,CAA0B,aAAA,EAAe,CAAC,qCAAqC,CAAC,CAAA;AAEhF,EAAA,MAAM,UAAU,aAAA,CAAc,KAAA;AAE9B,EAAA,MAAM,iBAAA,GAAoB,aAAA,CAAc,UAAA,EAAY,OAAA,KAAY,IAAA;AAGhE,EAAA,MAAM,yBAAA,GAA4B,EAAE,MAAA,EAAQ,IAAA,EAAM,QAAQ,IAAA,EAAK;AAE/D,EAAA,IAAA,CAAK,IAAA,CAAK,gBAAgB,MAAM;AAC9B,IAAA,IAAI,iBAAA,IAAqB,CAAC,IAAA,CAAK,OAAA,CAAQ,OAAO,CAAC,IAAA,CAAK,SAAS,QAAA,E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Q,IAAA;AAAA,MACN,0EAA0E,cAAc,CAAA,EAAA,EAAK,gBAAgB,CAAA,qDAAA,EAAwD,eAAe,KAAK,iBAAiB,CAAA,+OAAA;AAAA,KAC5M;AAAA,EACF;AACF;AAEA,SAAS,8BAAA,CACP,uBAAA,EACA,UAAA,EACA,YAAA,EACM;AACN,EAAA,IAAI,wBAAwB,KAAA,EAAO;AAEjC,IAAA,OAAA,CAAQ,GAAA;AAAA,MACN,CAAA,WAAA,EAAc,UAAU,CAAA,qBAAA,EAAwB,YAAY,CAAA,oFAAA;AAAA,KAC9D;AAAA,EACF;AACF;AAEA,SAAS,+BAAA,CAAgC,YAAoB,OAAA,EAAoC;AAC/F,EAAA,IAAI,OAAA,EAAS;AAEX,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN,CAAA,mFAAA,EAAsF,UAAU,CAAA,2QAAA,EAA8Q,UAAU,CAAA,wCAAA;AAAA,KAC1X;AAAA,EACF,CAAA,MAAO;AAEL,IAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,kCAAA,EAAqC,UAAU,CAAA,2CAAA,CAA6C,CAAA;AAAA,EAC3G;AACF;AAEA,SAAS,yBAAA,CAA0B,YAAoB,YAAA,EAA4B;AAEjF,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,mEAAA,EAAsE,UAAU,CAAA,EAAA,EAAK,YAAY,CAAA,GAAA,CAAK,CAAA;AACpH;;;;;;;;;"}
@@ -19,17 +19,7 @@ async function getNitroMajorVersion() {
19
19
  }
20
20
  async function findDefaultSdkInitFile(type, nuxt, options) {
21
21
  const possibleFileExtensions = ["ts", "js", "mjs", "cjs", "mts", "cts"];
22
- const relativePaths = [];
23
- if (type === "server") {
24
- for (const ext of possibleFileExtensions) {
25
- relativePaths.push(`sentry.${type}.config.${ext}`);
26
- relativePaths.push(path.join("public", `instrument.${type}.${ext}`));
27
- }
28
- } else {
29
- for (const ext of possibleFileExtensions) {
30
- relativePaths.push(`sentry.${type}.config.${ext}`);
31
- }
32
- }
22
+ const relativePaths = possibleFileExtensions.map((ext) => `sentry.${type}.config.${ext}`);
33
23
  const layers = [...nuxt?.options._layers ?? []].reverse();
34
24
  for (const layer of layers) {
35
25
  for (const relativePath of relativePaths) {
@@ -48,6 +38,10 @@ async function findDefaultSdkInitFile(type, nuxt, options) {
48
38
  }
49
39
  return void 0;
50
40
  }
41
+ const SERVER_CONFIG_FILENAME = "sentry.server.config";
42
+ function toImportSpecifier(fromDir, filePath) {
43
+ return `./${path.relative(fromDir, filePath).split(/[\\/]/).join("/")}`;
44
+ }
51
45
  function getFilenameFromNodeStartCommand(nodeCommand) {
52
46
  const regex = /[^/\\]+\.[^/\\]+$/;
53
47
  const match = nodeCommand.match(regex);
@@ -135,6 +129,7 @@ exports.QUERY_END_INDICATOR = QUERY_END_INDICATOR;
135
129
  exports.SENTRY_REEXPORTED_FUNCTIONS = SENTRY_REEXPORTED_FUNCTIONS;
136
130
  exports.SENTRY_WRAPPED_ENTRY = SENTRY_WRAPPED_ENTRY;
137
131
  exports.SENTRY_WRAPPED_FUNCTIONS = SENTRY_WRAPPED_FUNCTIONS;
132
+ exports.SERVER_CONFIG_FILENAME = SERVER_CONFIG_FILENAME;
138
133
  exports.addOTelCommonJSImportAlias = addOTelCommonJSImportAlias;
139
134
  exports.constructFunctionReExport = constructFunctionReExport;
140
135
  exports.constructWrappedFunctionExportQuery = constructWrappedFunctionExportQuery;
@@ -143,4 +138,5 @@ exports.findDefaultSdkInitFile = findDefaultSdkInitFile;
143
138
  exports.getFilenameFromNodeStartCommand = getFilenameFromNodeStartCommand;
144
139
  exports.getNitroMajorVersion = getNitroMajorVersion;
145
140
  exports.removeSentryQueryFromPath = removeSentryQueryFromPath;
141
+ exports.toImportSpecifier = toImportSpecifier;
146
142
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../src/vite/utils.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox } from '@sentry/core';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { resolvePath } from '@nuxt/kit';\n\n/**\n * Gets the major version of the installed nitro package.\n * Returns 2 as the default if nitro is not found or the version cannot be determined.\n */\nexport async function getNitroMajorVersion(): Promise<number> {\n try {\n const { getPackageInfo } = await import('local-pkg');\n const info = await getPackageInfo('nitro');\n if (info?.version) {\n const major = parseInt(info.version.split('.')[0] ?? '2', 10);\n return isNaN(major) ? 2 : major;\n }\n } catch {\n // If local-pkg is unavailable or nitro is not found, default to v2\n }\n return 2;\n}\n\n/**\n * Find the default SDK init file for the given type (client or server).\n * The sentry.server.config file is prioritized over the instrument.server file.\n */\nexport async function findDefaultSdkInitFile(\n type: 'server' | 'client',\n nuxt?: Nuxt,\n options?: SentryNuxtModuleOptions,\n): Promise<string | undefined> {\n const possibleFileExtensions = ['ts', 'js', 'mjs', 'cjs', 'mts', 'cts'];\n const relativePaths: string[] = [];\n\n if (type === 'server') {\n for (const ext of possibleFileExtensions) {\n relativePaths.push(`sentry.${type}.config.${ext}`);\n relativePaths.push(path.join('public', `instrument.${type}.${ext}`));\n }\n } else {\n for (const ext of possibleFileExtensions) {\n relativePaths.push(`sentry.${type}.config.${ext}`);\n }\n }\n\n // Get layers from highest priority to lowest\n const layers = [...(nuxt?.options._layers ?? [])].reverse();\n\n for (const layer of layers) {\n for (const relativePath of relativePaths) {\n const fullPath = path.resolve(layer.cwd, relativePath);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n }\n\n // As a fallback, also check CWD (left for pure compatibility)\n const rootDir = options?.configDir ? await resolvePath(options.configDir, { type: 'dir' }) : process.cwd();\n for (const relativePath of relativePaths) {\n const fullPath = path.resolve(rootDir, relativePath);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n\n return undefined;\n}\n\n/**\n * Extracts the filename from a node command with a path.\n */\nexport function getFilenameFromNodeStartCommand(nodeCommand: string): string | null {\n const regex = /[^/\\\\]+\\.[^/\\\\]+$/;\n const match = nodeCommand.match(regex);\n return match ? match[0] : null;\n}\n\nexport const SENTRY_WRAPPED_ENTRY = '?sentry-query-wrapped-entry';\nexport const SENTRY_WRAPPED_FUNCTIONS = '?sentry-query-wrapped-functions=';\nexport const SENTRY_REEXPORTED_FUNCTIONS = '?sentry-query-reexported-functions=';\nexport const QUERY_END_INDICATOR = 'SENTRY-QUERY-END';\n\n/**\n * Strips the Sentry query part from a path.\n * Example: example/path?sentry-query-wrapped-entry?sentry-query-functions-reexport=foo,SENTRY-QUERY-END -> /example/path\n *\n * Only exported for testing.\n */\nexport function removeSentryQueryFromPath(url: string): string {\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const regex = new RegExp(`\\\\${SENTRY_WRAPPED_ENTRY}.*?\\\\${QUERY_END_INDICATOR}`);\n return url.replace(regex, '');\n}\n\n/**\n * Extracts and sanitizes function re-export and function wrap query parameters from a query string.\n * If it is a default export, it is not considered for re-exporting.\n *\n * Only exported for testing.\n */\nexport function extractFunctionReexportQueryParameters(query: string): { wrap: string[]; reexport: string[] } {\n // Regex matches the comma-separated params between the functions query\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const wrapRegex = new RegExp(\n `\\\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR}|\\\\${SENTRY_REEXPORTED_FUNCTIONS})`,\n );\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const reexportRegex = new RegExp(`\\\\${SENTRY_REEXPORTED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR})`);\n\n const wrapMatch = query.match(wrapRegex);\n const reexportMatch = query.match(reexportRegex);\n\n const wrap =\n wrapMatch?.[1]\n ?.split(',')\n .filter(param => param !== '')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')) || [];\n\n const reexport =\n reexportMatch?.[1]\n ?.split(',')\n .filter(param => param !== '' && param !== 'default')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')) || [];\n\n return { wrap, reexport };\n}\n\n/**\n * Constructs a comma-separated string with all functions that need to be re-exported later from the server entry.\n * It uses Rollup's `exportedBindings` to determine the functions to re-export. Functions which should be wrapped\n * (e.g. serverless handlers) are wrapped by Sentry.\n */\nexport function constructWrappedFunctionExportQuery(\n exportedBindings: Record<string, string[]> | null,\n entrypointWrappedFunctions: string[],\n debug?: boolean,\n): string {\n const functionsToExport: { wrap: string[]; reexport: string[] } = {\n wrap: [],\n reexport: [],\n };\n\n // `exportedBindings` can look like this: `{ '.': [ 'handler' ] }` or `{ '.': [], './firebase-gen-1.mjs': [ 'server' ] }`\n // The key `.` refers to exports within the current file, while other keys show from where exports were imported first.\n Object.values(exportedBindings || {}).forEach(functions =>\n functions.forEach(fn => {\n if (entrypointWrappedFunctions.includes(fn)) {\n functionsToExport.wrap.push(fn);\n } else {\n functionsToExport.reexport.push(fn);\n }\n }),\n );\n\n if (debug && functionsToExport.wrap.length === 0) {\n consoleSandbox(() =>\n // eslint-disable-next-line no-console\n console.warn(\n \"[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to Sentry's build options `sentry.experimental_entrypointWrappedFunctions` in `nuxt.config.ts`.\",\n ),\n );\n }\n\n const wrapQuery = functionsToExport.wrap.length\n ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(',')}`\n : '';\n const reexportQuery = functionsToExport.reexport.length\n ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(',')}`\n : '';\n\n return [wrapQuery, reexportQuery].join('');\n}\n\n/**\n * Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)\n */\nexport function constructFunctionReExport(pathWithQuery: string, entryId: string): string {\n const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);\n\n return wrapFunctions\n .reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(\n `async function ${currFunctionName}_sentryWrapped(...args) {\\n` +\n ` const res = await import(${JSON.stringify(entryId)});\\n` +\n ` return res.${currFunctionName}.call(this, ...args);\\n` +\n '}\\n' +\n `export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\\n`,\n ),\n '',\n )\n .concat(\n reexportFunctions.reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),\n '',\n ),\n );\n}\n\n/**\n * Sets up alias to work around OpenTelemetry's incomplete ESM imports.\n * https://github.com/getsentry/sentry-javascript/issues/15204\n *\n * OpenTelemetry's @opentelemetry/resources package has incomplete imports missing\n * the .js file extensions (like execAsync for machine-id detection). This causes module resolution\n * errors in certain Nuxt configurations, particularly when local Nuxt modules in Nuxt 4 are present.\n *\n * @see https://nuxt.com/docs/guide/concepts/esm#aliasing-libraries\n */\nexport function addOTelCommonJSImportAlias(nuxt: Nuxt, isNitroV3 = false): void {\n if (!nuxt.options.dev || isNitroV3) {\n return;\n }\n\n if (!nuxt.options.alias) {\n nuxt.options.alias = {};\n }\n\n if (!nuxt.options.alias['@opentelemetry/resources']) {\n nuxt.options.alias['@opentelemetry/resources'] = '@opentelemetry/resources/build/src/index.js';\n }\n}\n"],"names":["resolvePath","consoleSandbox"],"mappings":";;;;;;;AAWA,eAAsB,oBAAA,GAAwC;AAC5D,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,WAAW,CAAA;AACnD,IAAA,MAAM,IAAA,GAAO,MAAM,cAAA,CAAe,OAAO,CAAA;AACzC,IAAA,IAAI,MAAM,OAAA,EAAS;AACjB,MAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,IAAK,GAAA,EAAK,EAAE,CAAA;AAC5D,MAAA,OAAO,KAAA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,CAAU,OAAO,CAAC,CAAA,CAAA,CAAG,CAAA;AAAA,MACxF;AAAA;AACF,GACF;AACJ;AAYO,SAAS,0BAAA,CAA2B,IAAA,EAAY,SAAA,GAAY,KAAA,EAAa;AAC9E,EAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,GAAA,IAAO,SAAA,EAAW;AAClC,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO;AACvB,IAAA,IAAA,CAAK,OAAA,CAAQ,QAAQ,EAAC;AAAA,EACxB;AAEA,EAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,0BAA0B,CAAA,EAAG;AACnD,IAAA,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,0BAA0B,CAAA,GAAI,6CAAA;AAAA,EACnD;AACF;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../src/vite/utils.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox } from '@sentry/core';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { resolvePath } from '@nuxt/kit';\n\n/**\n * Gets the major version of the installed nitro package.\n * Returns 2 as the default if nitro is not found or the version cannot be determined.\n */\nexport async function getNitroMajorVersion(): Promise<number> {\n try {\n const { getPackageInfo } = await import('local-pkg');\n const info = await getPackageInfo('nitro');\n if (info?.version) {\n const major = parseInt(info.version.split('.')[0] ?? '2', 10);\n return isNaN(major) ? 2 : major;\n }\n } catch {\n // If local-pkg is unavailable or nitro is not found, default to v2\n }\n return 2;\n}\n\n/**\n * Find the default SDK init file for the given type (client or server).\n */\nexport async function findDefaultSdkInitFile(\n type: 'server' | 'client',\n nuxt?: Nuxt,\n options?: SentryNuxtModuleOptions,\n): Promise<string | undefined> {\n const possibleFileExtensions = ['ts', 'js', 'mjs', 'cjs', 'mts', 'cts'];\n const relativePaths = possibleFileExtensions.map(ext => `sentry.${type}.config.${ext}`);\n\n // Get layers from highest priority to lowest\n const layers = [...(nuxt?.options._layers ?? [])].reverse();\n\n for (const layer of layers) {\n for (const relativePath of relativePaths) {\n const fullPath = path.resolve(layer.cwd, relativePath);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n }\n\n // As a fallback, also check CWD (left for pure compatibility)\n const rootDir = options?.configDir ? await resolvePath(options.configDir, { type: 'dir' }) : process.cwd();\n for (const relativePath of relativePaths) {\n const fullPath = path.resolve(rootDir, relativePath);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n\n return undefined;\n}\n\nexport const SERVER_CONFIG_FILENAME = 'sentry.server.config';\n\n/** Builds the value for `node --import`. Node reads it as a URL, so it needs forward slashes on Windows too. */\nexport function toImportSpecifier(fromDir: string, filePath: string): string {\n return `./${path.relative(fromDir, filePath).split(/[\\\\/]/).join('/')}`;\n}\n\n/**\n * Extracts the filename from a node command with a path.\n */\nexport function getFilenameFromNodeStartCommand(nodeCommand: string): string | null {\n const regex = /[^/\\\\]+\\.[^/\\\\]+$/;\n const match = nodeCommand.match(regex);\n return match ? match[0] : null;\n}\n\nexport const SENTRY_WRAPPED_ENTRY = '?sentry-query-wrapped-entry';\nexport const SENTRY_WRAPPED_FUNCTIONS = '?sentry-query-wrapped-functions=';\nexport const SENTRY_REEXPORTED_FUNCTIONS = '?sentry-query-reexported-functions=';\nexport const QUERY_END_INDICATOR = 'SENTRY-QUERY-END';\n\n/**\n * Strips the Sentry query part from a path.\n * Example: example/path?sentry-query-wrapped-entry?sentry-query-functions-reexport=foo,SENTRY-QUERY-END -> /example/path\n *\n * Only exported for testing.\n */\nexport function removeSentryQueryFromPath(url: string): string {\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const regex = new RegExp(`\\\\${SENTRY_WRAPPED_ENTRY}.*?\\\\${QUERY_END_INDICATOR}`);\n return url.replace(regex, '');\n}\n\n/**\n * Extracts and sanitizes function re-export and function wrap query parameters from a query string.\n * If it is a default export, it is not considered for re-exporting.\n *\n * Only exported for testing.\n */\nexport function extractFunctionReexportQueryParameters(query: string): { wrap: string[]; reexport: string[] } {\n // Regex matches the comma-separated params between the functions query\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const wrapRegex = new RegExp(\n `\\\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR}|\\\\${SENTRY_REEXPORTED_FUNCTIONS})`,\n );\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const reexportRegex = new RegExp(`\\\\${SENTRY_REEXPORTED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR})`);\n\n const wrapMatch = query.match(wrapRegex);\n const reexportMatch = query.match(reexportRegex);\n\n const wrap =\n wrapMatch?.[1]\n ?.split(',')\n .filter(param => param !== '')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')) || [];\n\n const reexport =\n reexportMatch?.[1]\n ?.split(',')\n .filter(param => param !== '' && param !== 'default')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')) || [];\n\n return { wrap, reexport };\n}\n\n/**\n * Constructs a comma-separated string with all functions that need to be re-exported later from the server entry.\n * It uses Rollup's `exportedBindings` to determine the functions to re-export. Functions which should be wrapped\n * (e.g. serverless handlers) are wrapped by Sentry.\n */\nexport function constructWrappedFunctionExportQuery(\n exportedBindings: Record<string, string[]> | null,\n entrypointWrappedFunctions: string[],\n debug?: boolean,\n): string {\n const functionsToExport: { wrap: string[]; reexport: string[] } = {\n wrap: [],\n reexport: [],\n };\n\n // `exportedBindings` can look like this: `{ '.': [ 'handler' ] }` or `{ '.': [], './firebase-gen-1.mjs': [ 'server' ] }`\n // The key `.` refers to exports within the current file, while other keys show from where exports were imported first.\n Object.values(exportedBindings || {}).forEach(functions =>\n functions.forEach(fn => {\n if (entrypointWrappedFunctions.includes(fn)) {\n functionsToExport.wrap.push(fn);\n } else {\n functionsToExport.reexport.push(fn);\n }\n }),\n );\n\n if (debug && functionsToExport.wrap.length === 0) {\n consoleSandbox(() =>\n // eslint-disable-next-line no-console\n console.warn(\n \"[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to Sentry's build options `sentry.experimental_entrypointWrappedFunctions` in `nuxt.config.ts`.\",\n ),\n );\n }\n\n const wrapQuery = functionsToExport.wrap.length\n ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(',')}`\n : '';\n const reexportQuery = functionsToExport.reexport.length\n ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(',')}`\n : '';\n\n return [wrapQuery, reexportQuery].join('');\n}\n\n/**\n * Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)\n */\nexport function constructFunctionReExport(pathWithQuery: string, entryId: string): string {\n const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);\n\n return wrapFunctions\n .reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(\n `async function ${currFunctionName}_sentryWrapped(...args) {\\n` +\n ` const res = await import(${JSON.stringify(entryId)});\\n` +\n ` return res.${currFunctionName}.call(this, ...args);\\n` +\n '}\\n' +\n `export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\\n`,\n ),\n '',\n )\n .concat(\n reexportFunctions.reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),\n '',\n ),\n );\n}\n\n/**\n * Sets up alias to work around OpenTelemetry's incomplete ESM imports.\n * https://github.com/getsentry/sentry-javascript/issues/15204\n *\n * OpenTelemetry's @opentelemetry/resources package has incomplete imports missing\n * the .js file extensions (like execAsync for machine-id detection). This causes module resolution\n * errors in certain Nuxt configurations, particularly when local Nuxt modules in Nuxt 4 are present.\n *\n * @see https://nuxt.com/docs/guide/concepts/esm#aliasing-libraries\n */\nexport function addOTelCommonJSImportAlias(nuxt: Nuxt, isNitroV3 = false): void {\n if (!nuxt.options.dev || isNitroV3) {\n return;\n }\n\n if (!nuxt.options.alias) {\n nuxt.options.alias = {};\n }\n\n if (!nuxt.options.alias['@opentelemetry/resources']) {\n nuxt.options.alias['@opentelemetry/resources'] = '@opentelemetry/resources/build/src/index.js';\n }\n}\n"],"names":["resolvePath","consoleSandbox"],"mappings":";;;;;;;AAWA,eAAsB,oBAAA,GAAwC;AAC5D,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,WAAW,CAAA;AACnD,IAAA,MAAM,IAAA,GAAO,MAAM,cAAA,CAAe,OAAO,CAAA;AACzC,IAAA,IAAI,MAAM,OAAA,EAAS;AACjB,MAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,IAAK,GAAA,EAAK,EAAE,CAAA;AAC5D,MAAA,OAAO,KAAA,CAAM,KAAK,CAAA,GAAI,CAAA,GAAI,KAAA;AAAA,IAC5B;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA,OAAO,CAAA;AACT;AAKA,eAAsB,sBAAA,CACpB,IAAA,EACA,IAAA,EACA,OAAA,EAC6B;AAC7B,EAAA,MAAM,yBAAyB,CAAC,IAAA,EAAM,MAAM,KAAA,EAAO,KAAA,EAAO,OAAO,KAAK,CAAA;AACtE,EAAA,MAAM,aAAA,GAAgB,uBAAuB,GAAA,CAAI,CAAA,GAAA,KAAO,UAAU,IAAI,CAAA,QAAA,EAAW,GAAG,CAAA,CAAE,CAAA;AAGtF,EAAA,MAAM,MAAA,GAAS,CAAC,GAAI,IAAA,EAAM,QAAQ,OAAA,IAAW,EAAG,CAAA,CAAE,OAAA,EAAQ;AAE1D,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AAC1B,IAAA,KAAA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XT_DEV_MODE_FLAG] === true;
6
+ }
7
+
8
+ export { NUXT_DEV_MODE_FLAG, isNuxtDevRuntime };
9
+ //# sourceMappingURL=devMode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devMode.js","sources":["../../../src/common/devMode.ts"],"sourcesContent":["import { GLOBAL_OBJ } from '@sentry/core';\n\n/** Global flag set by the generated `<buildDir>/dev/sentry.server.config.mjs`. */\nexport const NUXT_DEV_MODE_FLAG = '__SENTRY_NUXT_DEV_MODE__';\n\n/** Whether the SDK was preloaded by the generated `nuxt dev` server config file. */\nexport function isNuxtDevRuntime(): boolean {\n return NUXT_DEV_MODE_FLAG in GLOBAL_OBJ && GLOBAL_OBJ[NUXT_DEV_MODE_FLAG] === true;\n}\n"],"names":[],"mappings":";;AAGO,MAAM,kBAAA,GAAqB;AAG3B,SAAS,gBAAA,GAA4B;AAC1C,EAAA,OAAO,kBAAA,IAAsB,UAAA,IAAc,UAAA,CAAW,kBAAkB,CAAA,KAAM,IAAA;AAChF;;;;"}
@@ -1,13 +1,13 @@
1
1
  import { defineNuxtModule, createResolver, addPluginTemplate, addPlugin, addServerPlugin, addVitePlugin, addTemplate } from '@nuxt/kit';
2
2
  import { consoleSandbox } from '@sentry/core';
3
3
  import * as path from 'path';
4
- import { addServerConfigToBuild, addSentryTopImport, addDynamicImportEntryFileWrapper } from './vite/addServerConfig.js';
4
+ import { addDevServerConfigFile, addServerConfigToBuild, DEV_SERVER_CONFIG_PATH, addSentryTopImport, addDynamicImportEntryFileWrapper } from './vite/addServerConfig.js';
5
5
  import { addDatabaseInstrumentation } from './vite/databaseConfig.js';
6
6
  import { addMiddlewareImports, addMiddlewareInstrumentation } from './vite/middlewareConfig.js';
7
7
  import { setupOrchestrion } from './vite/orchestrion.js';
8
8
  import { setupSourceMaps } from './vite/sourceMaps.js';
9
9
  import { addStorageInstrumentation } from './vite/storageConfig.js';
10
- import { findDefaultSdkInitFile, getNitroMajorVersion, addOTelCommonJSImportAlias } from './vite/utils.js';
10
+ import { findDefaultSdkInitFile, getNitroMajorVersion, addOTelCommonJSImportAlias, toImportSpecifier } from './vite/utils.js';
11
11
 
12
12
  const module$1 = defineNuxtModule({
13
13
  meta: {
@@ -79,6 +79,9 @@ const module$1 = defineNuxtModule({
79
79
  addMiddlewareImports();
80
80
  addStorageInstrumentation(nuxt, !isNitroV3);
81
81
  addDatabaseInstrumentation(nuxt.options.nitro, !isNitroV3, moduleOptions);
82
+ if (isNitroV3) {
83
+ addDevServerConfigFile(nuxt, serverConfigFile);
84
+ }
82
85
  }
83
86
  if (clientConfigFile || serverConfigFile) {
84
87
  setupSourceMaps(moduleOptions, nuxt, addVitePlugin);
@@ -123,8 +126,6 @@ const module$1 = defineNuxtModule({
123
126
  }
124
127
  if (serverConfigFile) {
125
128
  addMiddlewareInstrumentation(nitro);
126
- }
127
- if (serverConfigFile?.includes(".server.config")) {
128
129
  consoleSandbox(() => {
129
130
  const serverDir = nitro.options.output.serverDir;
130
131
  if (serverDir.includes(".netlify") || !!process.env.NETLIFY) {
@@ -139,18 +140,21 @@ const module$1 = defineNuxtModule({
139
140
  }
140
141
  });
141
142
  if (moduleOptions.autoInjectServerSentry !== "experimental_dynamic-import") {
142
- addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);
143
+ if (!(isNitroV3 && nitro.options.dev)) {
144
+ addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);
145
+ }
143
146
  if (moduleOptions.debug) {
144
147
  const serverDirResolver = createResolver(nitro.options.output.serverDir);
145
148
  const serverConfigPath = serverDirResolver.resolve("sentry.server.config.mjs");
146
- const serverConfigRelativePath = `.${path.sep}${path.relative(nitro.options.rootDir, serverConfigPath)}`;
149
+ const serverConfigRelativePath = toImportSpecifier(nitro.options.rootDir, serverConfigPath);
150
+ const devConfigRelativePath = isNitroV3 ? toImportSpecifier(nuxt.options.rootDir, path.join(nuxt.options.buildDir, DEV_SERVER_CONFIG_PATH)) : serverConfigRelativePath;
147
151
  consoleSandbox(() => {
148
152
  console.log(
149
153
  `[Sentry] Using \`${serverConfigFile}\` for server-side Sentry configuration. To activate Sentry on the Nuxt server-side, this file must be preloaded when starting your application. Make sure to add this where you deploy and/or run your application. Read more here: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/.`
150
154
  );
151
155
  if (nitro.options.dev) {
152
156
  console.log(
153
- `[Sentry] During development, preload Sentry with the NODE_OPTIONS environment variable: \`NODE_OPTIONS='--import ${serverConfigRelativePath}' nuxt dev\`. The file is generated in the build directory (usually '.nuxt'). If you delete the build directory, run \`nuxt dev\` to regenerate it.`
157
+ `[Sentry] During development, preload Sentry with the NODE_OPTIONS environment variable: \`NODE_OPTIONS='--import ${devConfigRelativePath}' nuxt dev\`. The file is generated in the build directory (usually '.nuxt'). If you delete the build directory, run \`nuxt prepare\` to regenerate it.`
154
158
  );
155
159
  } else {
156
160
  console.log(
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sources":["../../src/module.ts"],"sourcesContent":["import {\n addPlugin,\n addPluginTemplate,\n addServerPlugin,\n addTemplate,\n addVitePlugin,\n createResolver,\n defineNuxtModule,\n} from '@nuxt/kit';\n// Needed to make TS evaluate the augmentation of Nitro types (https://github.com/nuxt/nuxt/pull/34039)\nimport type {} from '@nuxt/nitro-server';\n\nimport { consoleSandbox } from '@sentry/core';\nimport * as path from 'path';\nimport type { SentryNuxtModuleOptions } from './common/types';\nimport { addDynamicImportEntryFileWrapper, addSentryTopImport, addServerConfigToBuild } from './vite/addServerConfig';\nimport { addDatabaseInstrumentation } from './vite/databaseConfig';\nimport { addMiddlewareImports, addMiddlewareInstrumentation } from './vite/middlewareConfig';\nimport { setupOrchestrion } from './vite/orchestrion';\nimport { setupSourceMaps } from './vite/sourceMaps';\nimport { addStorageInstrumentation } from './vite/storageConfig';\nimport { addOTelCommonJSImportAlias, findDefaultSdkInitFile, getNitroMajorVersion } from './vite/utils';\n\nexport type ModuleOptions = SentryNuxtModuleOptions;\ntype NuxtPageSubset = { file?: string; path: string };\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@sentry/nuxt/module',\n configKey: 'sentry',\n compatibility: {\n nuxt: '>=3.7.0',\n },\n },\n defaults: {},\n async setup(moduleOptionsParam, nuxt) {\n if (moduleOptionsParam?.enabled === false) {\n return;\n }\n\n const moduleOptions = {\n ...moduleOptionsParam,\n autoInjectServerSentry: moduleOptionsParam.autoInjectServerSentry,\n experimental_entrypointWrappedFunctions: moduleOptionsParam.experimental_entrypointWrappedFunctions || [\n 'default',\n 'handler',\n 'server',\n ],\n };\n\n const moduleDirResolver = createResolver(import.meta.url);\n const buildDirResolver = createResolver(nuxt.options.buildDir);\n\n const clientConfigFile = await findDefaultSdkInitFile('client', nuxt, moduleOptions);\n\n if (clientConfigFile) {\n // Inject the client-side Sentry config file with a side effect import\n addPluginTemplate({\n mode: 'client',\n filename: 'sentry-client-config.mjs',\n order: 0,\n\n // Dynamic import of config file to wrap it within a Nuxt context (here: defineNuxtPlugin)\n // Makes it possible to call useRuntimeConfig() in the user-defined sentry config file\n getContents: () => `\n import { defineNuxtPlugin } from \"#imports\";\n\n export default defineNuxtPlugin({\n name: 'sentry-client-config',\n async setup() {\n await import(\"${buildDirResolver.resolve(`/${clientConfigFile}`)}\")\n }\n });`,\n });\n\n // Add the plugin which loads client integrations etc. -\n // this must run after the sentry-client-config plugin has run, and the client is initialized!\n addPlugin({\n src: moduleDirResolver.resolve('./runtime/plugins/sentry.client'),\n mode: 'client',\n order: 1,\n });\n }\n\n const serverConfigFile = await findDefaultSdkInitFile('server', nuxt, moduleOptions);\n const isNitroV3 = (await getNitroMajorVersion()) >= 3;\n const nuxtMajor = parseInt((nuxt as unknown as { _version: string })._version?.split('.')[0] ?? '3', 10);\n const isMinNuxtV4 = nuxtMajor >= 4;\n\n // Orchestrion runs on both the Node path (gated on a server config file) and the Cloudflare path\n // (which has no server config file — the SDK is set up via `sentryCloudflareNitroPlugin`). The\n // Cloudflare detection happens inside, keyed off the resolved Nitro preset.\n setupOrchestrion(nuxt, !!serverConfigFile, moduleOptions.buildTimeInstrumentation);\n\n if (serverConfigFile) {\n if (isNitroV3) {\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/handler.server'));\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/update-route-name.server'));\n } else {\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/handler-legacy.server'));\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/update-route-name-legacy.server'));\n }\n\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/sentry.server'));\n\n if (isMinNuxtV4) {\n addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/route-detector.server'), mode: 'server' });\n } else {\n addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/route-detector-legacy.server'), mode: 'server' });\n }\n\n // Preps the middleware instrumentation module.\n addMiddlewareImports();\n addStorageInstrumentation(nuxt, !isNitroV3);\n addDatabaseInstrumentation(nuxt.options.nitro, !isNitroV3, moduleOptions);\n }\n\n if (clientConfigFile || serverConfigFile) {\n setupSourceMaps(moduleOptions, nuxt, addVitePlugin);\n }\n\n addOTelCommonJSImportAlias(nuxt, isNitroV3);\n\n let pagesData: NuxtPageSubset[] = [];\n\n nuxt.hooks.hook('pages:extend', pages => {\n pagesData = pages\n .map(page => ({ file: page.file, path: page.path }))\n .filter(page => {\n // Check for dynamic parameter (e.g., :userId or [userId])\n return page.path.includes(':') || page?.file?.includes('[');\n });\n });\n\n if (isMinNuxtV4) {\n const pagesDataVirtualModuleId = '#sentry/nuxt-pages-data.mjs';\n\n // Vite virtual plugin (for the Vite SSR build, where addPlugin mode:'server' plugins are bundled)\n addVitePlugin({\n name: 'sentry-nuxt-pages-data-virtual',\n resolveId: id => (id === pagesDataVirtualModuleId ? `\\0${pagesDataVirtualModuleId}` : null),\n load: id =>\n id === `\\0${pagesDataVirtualModuleId}` ? `export default ${JSON.stringify(pagesData, null, 2)};` : undefined,\n });\n } else {\n // Nuxt v3: register as a build template (accessible via #build/)\n addTemplate({\n filename: 'sentry--nuxt-pages-data.mjs',\n getContents: () => `export default ${JSON.stringify(pagesData, null, 2)};`,\n });\n }\n\n // Add the sentry config file to the include array\n nuxt.hook('prepare:types', options => {\n const tsConfig = options.tsConfig as { include?: string[] };\n\n if (!tsConfig.include) {\n tsConfig.include = [];\n }\n\n // Add type references for useRuntimeConfig in root files for nuxt v4\n // Should be relative to `root/.nuxt`\n if (clientConfigFile) {\n const relativePath = path.relative(nuxt.options.buildDir, clientConfigFile);\n tsConfig.include.push(relativePath);\n }\n if (serverConfigFile) {\n const relativePath = path.relative(nuxt.options.buildDir, serverConfigFile);\n tsConfig.include.push(relativePath);\n }\n });\n\n nuxt.hooks.hook('nitro:init', nitro => {\n if (nuxt.options?._prepare) {\n return;\n }\n\n if (serverConfigFile) {\n addMiddlewareInstrumentation(nitro);\n }\n\n if (serverConfigFile?.includes('.server.config')) {\n consoleSandbox(() => {\n const serverDir = nitro.options.output.serverDir;\n\n // Netlify env: https://docs.netlify.com/configure-builds/environment-variables/#build-metadata\n if (serverDir.includes('.netlify') || !!process.env.NETLIFY) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Warning: The Sentry SDK detected a Netlify build. Server-side support for the Sentry Nuxt SDK on Netlify is currently unreliable due to technical limitations of serverless functions. Traces are not collected, and errors may occasionally not be reported. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',\n );\n }\n\n // Vercel env: https://vercel.com/docs/projects/environment-variables/system-environment-variables#VERCEL\n if (serverDir.includes('.vercel') || !!process.env.VERCEL) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Warning: The Sentry SDK detected a Vercel build. The Sentry Nuxt SDK currently does not support tracing on Vercel. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',\n );\n }\n });\n\n if (moduleOptions.autoInjectServerSentry !== 'experimental_dynamic-import') {\n addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);\n\n if (moduleOptions.debug) {\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const serverConfigPath = serverDirResolver.resolve('sentry.server.config.mjs');\n\n // For the default nitro node-preset build output this relative path would be: ./.output/server/sentry.server.config.mjs\n const serverConfigRelativePath = `.${path.sep}${path.relative(nitro.options.rootDir, serverConfigPath)}`;\n\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Using \\`${serverConfigFile}\\` for server-side Sentry configuration. To activate Sentry on the Nuxt server-side, this file must be preloaded when starting your application. Make sure to add this where you deploy and/or run your application. Read more here: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/.`,\n );\n\n if (nitro.options.dev) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] During development, preload Sentry with the NODE_OPTIONS environment variable: \\`NODE_OPTIONS='--import ${serverConfigRelativePath}' nuxt dev\\`. The file is generated in the build directory (usually '.nuxt'). If you delete the build directory, run \\`nuxt dev\\` to regenerate it.`,\n );\n } else {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] When running your built application, preload Sentry via a command-line flag (\\`node --import ${serverConfigRelativePath} [...]\\`) or via an environment variable (\\`NODE_OPTIONS='--import ${serverConfigRelativePath}' node [...]\\`).`,\n );\n }\n });\n }\n }\n\n if (moduleOptions.autoInjectServerSentry === 'top-level-import') {\n addSentryTopImport(moduleOptions, nitro);\n }\n\n if (moduleOptions.autoInjectServerSentry === 'experimental_dynamic-import') {\n addDynamicImportEntryFileWrapper(nitro, serverConfigFile, moduleOptions);\n\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes.',\n );\n });\n }\n }\n }\n });\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;;AA0BA,iBAAe,gBAAA,CAAgC;AAAA,EAC7C,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM,qBA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AAA,CAAc,2BAA2B,kBAAA,EAAoB;AAC/D,UAAA,kBAAA,CAAmB,eAAe,KAAK,CAAA;AAAA,QACzC;AAEA,QAAA,IAAI,aAAA,CAAc,2BAA2B,6BAAA,EAA+B;AAC1E,UAAA,gCAAA,CAAiC,KAAA,EAAO,kBAAkB,aAAa,CAAA;AAEvE,UAAA,IAAI,cAAc,KAAA,EAAO;AACvB,YAAA,cAAA,CAAe,MAAM;AAEnB,cAAA,OAAA,CAAQ,GAAA;AAAA,gBACN;AAAA,eACF;AAAA,YACF,CAAC,CAAA;AAAA,UACH;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AACF,CAAC,CAAA;;;;"}
1
+ {"version":3,"file":"module.js","sources":["../../src/module.ts"],"sourcesContent":["import {\n addPlugin,\n addPluginTemplate,\n addServerPlugin,\n addTemplate,\n addVitePlugin,\n createResolver,\n defineNuxtModule,\n} from '@nuxt/kit';\n// Needed to make TS evaluate the augmentation of Nitro types (https://github.com/nuxt/nuxt/pull/34039)\nimport type {} from '@nuxt/nitro-server';\n\nimport { consoleSandbox } from '@sentry/core';\nimport * as path from 'path';\nimport type { SentryNuxtModuleOptions } from './common/types';\nimport {\n addDevServerConfigFile,\n addDynamicImportEntryFileWrapper,\n addSentryTopImport,\n addServerConfigToBuild,\n DEV_SERVER_CONFIG_PATH,\n} from './vite/addServerConfig';\nimport { addDatabaseInstrumentation } from './vite/databaseConfig';\nimport { addMiddlewareImports, addMiddlewareInstrumentation } from './vite/middlewareConfig';\nimport { setupOrchestrion } from './vite/orchestrion';\nimport { setupSourceMaps } from './vite/sourceMaps';\nimport { addStorageInstrumentation } from './vite/storageConfig';\nimport {\n addOTelCommonJSImportAlias,\n findDefaultSdkInitFile,\n getNitroMajorVersion,\n toImportSpecifier,\n} from './vite/utils';\n\nexport type ModuleOptions = SentryNuxtModuleOptions;\ntype NuxtPageSubset = { file?: string; path: string };\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@sentry/nuxt/module',\n configKey: 'sentry',\n compatibility: {\n nuxt: '>=3.7.0',\n },\n },\n defaults: {},\n async setup(moduleOptionsParam, nuxt) {\n if (moduleOptionsParam?.enabled === false) {\n return;\n }\n\n const moduleOptions = {\n ...moduleOptionsParam,\n autoInjectServerSentry: moduleOptionsParam.autoInjectServerSentry,\n experimental_entrypointWrappedFunctions: moduleOptionsParam.experimental_entrypointWrappedFunctions || [\n 'default',\n 'handler',\n 'server',\n ],\n };\n\n const moduleDirResolver = createResolver(import.meta.url);\n const buildDirResolver = createResolver(nuxt.options.buildDir);\n\n const clientConfigFile = await findDefaultSdkInitFile('client', nuxt, moduleOptions);\n\n if (clientConfigFile) {\n // Inject the client-side Sentry config file with a side effect import\n addPluginTemplate({\n mode: 'client',\n filename: 'sentry-client-config.mjs',\n order: 0,\n\n // Dynamic import of config file to wrap it within a Nuxt context (here: defineNuxtPlugin)\n // Makes it possible to call useRuntimeConfig() in the user-defined sentry config file\n getContents: () => `\n import { defineNuxtPlugin } from \"#imports\";\n\n export default defineNuxtPlugin({\n name: 'sentry-client-config',\n async setup() {\n await import(\"${buildDirResolver.resolve(`/${clientConfigFile}`)}\")\n }\n });`,\n });\n\n // Add the plugin which loads client integrations etc. -\n // this must run after the sentry-client-config plugin has run, and the client is initialized!\n addPlugin({\n src: moduleDirResolver.resolve('./runtime/plugins/sentry.client'),\n mode: 'client',\n order: 1,\n });\n }\n\n const serverConfigFile = await findDefaultSdkInitFile('server', nuxt, moduleOptions);\n const isNitroV3 = (await getNitroMajorVersion()) >= 3;\n const nuxtMajor = parseInt((nuxt as unknown as { _version: string })._version?.split('.')[0] ?? '3', 10);\n const isMinNuxtV4 = nuxtMajor >= 4;\n\n // Orchestrion runs on both the Node path (gated on a server config file) and the Cloudflare path\n // (which has no server config file — the SDK is set up via `sentryCloudflareNitroPlugin`). The\n // Cloudflare detection happens inside, keyed off the resolved Nitro preset.\n setupOrchestrion(nuxt, !!serverConfigFile, moduleOptions.buildTimeInstrumentation);\n\n if (serverConfigFile) {\n if (isNitroV3) {\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/handler.server'));\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/update-route-name.server'));\n } else {\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/handler-legacy.server'));\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/update-route-name-legacy.server'));\n }\n\n addServerPlugin(moduleDirResolver.resolve('./runtime/plugins/sentry.server'));\n\n if (isMinNuxtV4) {\n addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/route-detector.server'), mode: 'server' });\n } else {\n addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/route-detector-legacy.server'), mode: 'server' });\n }\n\n // Preps the middleware instrumentation module.\n addMiddlewareImports();\n addStorageInstrumentation(nuxt, !isNitroV3);\n addDatabaseInstrumentation(nuxt.options.nitro, !isNitroV3, moduleOptions);\n\n // Outside `nitro:init` so that `nuxt prepare` writes the file before the first `nuxt dev`.\n if (isNitroV3) {\n addDevServerConfigFile(nuxt, serverConfigFile);\n }\n }\n\n if (clientConfigFile || serverConfigFile) {\n setupSourceMaps(moduleOptions, nuxt, addVitePlugin);\n }\n\n addOTelCommonJSImportAlias(nuxt, isNitroV3);\n\n let pagesData: NuxtPageSubset[] = [];\n\n nuxt.hooks.hook('pages:extend', pages => {\n pagesData = pages\n .map(page => ({ file: page.file, path: page.path }))\n .filter(page => {\n // Check for dynamic parameter (e.g., :userId or [userId])\n return page.path.includes(':') || page?.file?.includes('[');\n });\n });\n\n if (isMinNuxtV4) {\n const pagesDataVirtualModuleId = '#sentry/nuxt-pages-data.mjs';\n\n // Vite virtual plugin (for the Vite SSR build, where addPlugin mode:'server' plugins are bundled)\n addVitePlugin({\n name: 'sentry-nuxt-pages-data-virtual',\n resolveId: id => (id === pagesDataVirtualModuleId ? `\\0${pagesDataVirtualModuleId}` : null),\n load: id =>\n id === `\\0${pagesDataVirtualModuleId}` ? `export default ${JSON.stringify(pagesData, null, 2)};` : undefined,\n });\n } else {\n // Nuxt v3: register as a build template (accessible via #build/)\n addTemplate({\n filename: 'sentry--nuxt-pages-data.mjs',\n getContents: () => `export default ${JSON.stringify(pagesData, null, 2)};`,\n });\n }\n\n // Add the sentry config file to the include array\n nuxt.hook('prepare:types', options => {\n const tsConfig = options.tsConfig as { include?: string[] };\n\n if (!tsConfig.include) {\n tsConfig.include = [];\n }\n\n // Add type references for useRuntimeConfig in root files for nuxt v4\n // Should be relative to `root/.nuxt`\n if (clientConfigFile) {\n const relativePath = path.relative(nuxt.options.buildDir, clientConfigFile);\n tsConfig.include.push(relativePath);\n }\n if (serverConfigFile) {\n const relativePath = path.relative(nuxt.options.buildDir, serverConfigFile);\n tsConfig.include.push(relativePath);\n }\n });\n\n nuxt.hooks.hook('nitro:init', nitro => {\n if (nuxt.options?._prepare) {\n return;\n }\n\n if (serverConfigFile) {\n addMiddlewareInstrumentation(nitro);\n\n consoleSandbox(() => {\n const serverDir = nitro.options.output.serverDir;\n\n // Netlify env: https://docs.netlify.com/configure-builds/environment-variables/#build-metadata\n if (serverDir.includes('.netlify') || !!process.env.NETLIFY) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Warning: The Sentry SDK detected a Netlify build. Server-side support for the Sentry Nuxt SDK on Netlify is currently unreliable due to technical limitations of serverless functions. Traces are not collected, and errors may occasionally not be reported. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',\n );\n }\n\n // Vercel env: https://vercel.com/docs/projects/environment-variables/system-environment-variables#VERCEL\n if (serverDir.includes('.vercel') || !!process.env.VERCEL) {\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] Warning: The Sentry SDK detected a Vercel build. The Sentry Nuxt SDK currently does not support tracing on Vercel. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/',\n );\n }\n });\n\n if (moduleOptions.autoInjectServerSentry !== 'experimental_dynamic-import') {\n // Nitro 3 (in Nuxt 5) is not bundled in dev mode. See `addDevServerConfigFile` for how we add the file now.\n if (!(isNitroV3 && nitro.options.dev)) {\n addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);\n }\n\n if (moduleOptions.debug) {\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const serverConfigPath = serverDirResolver.resolve('sentry.server.config.mjs');\n\n // For the default nitro node-preset build output this relative path would be: ./.output/server/sentry.server.config.mjs\n const serverConfigRelativePath = toImportSpecifier(nitro.options.rootDir, serverConfigPath);\n const devConfigRelativePath = isNitroV3\n ? toImportSpecifier(nuxt.options.rootDir, path.join(nuxt.options.buildDir, DEV_SERVER_CONFIG_PATH))\n : serverConfigRelativePath;\n\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Using \\`${serverConfigFile}\\` for server-side Sentry configuration. To activate Sentry on the Nuxt server-side, this file must be preloaded when starting your application. Make sure to add this where you deploy and/or run your application. Read more here: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/.`,\n );\n\n if (nitro.options.dev) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] During development, preload Sentry with the NODE_OPTIONS environment variable: \\`NODE_OPTIONS='--import ${devConfigRelativePath}' nuxt dev\\`. The file is generated in the build directory (usually '.nuxt'). If you delete the build directory, run \\`nuxt prepare\\` to regenerate it.`,\n );\n } else {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] When running your built application, preload Sentry via a command-line flag (\\`node --import ${serverConfigRelativePath} [...]\\`) or via an environment variable (\\`NODE_OPTIONS='--import ${serverConfigRelativePath}' node [...]\\`).`,\n );\n }\n });\n }\n }\n\n if (moduleOptions.autoInjectServerSentry === 'top-level-import') {\n addSentryTopImport(moduleOptions, nitro);\n }\n\n if (moduleOptions.autoInjectServerSentry === 'experimental_dynamic-import') {\n addDynamicImportEntryFileWrapper(nitro, serverConfigFile, moduleOptions);\n\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Wrapping the server entry file with a dynamic `import()`, so Sentry can be preloaded before the server initializes.',\n );\n });\n }\n }\n }\n });\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;;AAqCA,iBAAe,gBAAA,CAAgC;AAAA,EAC7C,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM,qBAAA;AAAA,IACN,SAAA,EAAW,QAAA;AAAA,IACX,aAAA,EAAe;AAAA,MACb,IAAA,EAAM;AAAA;AACR,GACF;AAAA,EACA,UAAU,EAAC;AAAA,EACX,MAAM,KAAA,CAAM,kBAAA,EAAoB,IAAA,EAAM;AACpC,IAAA,IAAI,kBAAA,EAAoB,YAAY,KAAA,EAAO;AACzC,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,aAAA,GAAgB;AAAA,MACpB,GAAG,kBAAA;AAAA,MACH,wBAAwB,kBAAA,CAAmB,sBAAA;AAAA,MAC3C,uCAAA,EAAyC,mBAAmB,uCAAA,IAA2C;AAAA,QACrG,SAAA;AAAA,QACA,SAAA;AAAA,QACA;AAAA;AACF,KACF;AAEA,IAAA,MAAM,iBAAA,GAAoB,cAAA,CAAe,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACxD,IAAA,MAAM,gBAAA,GAAmB,cAAA,CAAe,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AAE7D,IAAA,MAAM,gBAAA,GAAmB,MAAM,sBAAA,CAAuB,QAAA,EAAU,MAAM,aAAa,CAAA;AAEnF,IAAA,IAAI,gBAAA,EAAkB;AAEpB,MAAA,iBAAA,CAAkB;AAAA,QAChB,IAAA,EAAM,QAAA;AAAA,QACN,QAAA,EAAU,0BAAA;AAAA,QACV,KAAA,EAAO,CAAA;AAAA;AAAA;AAAA,QAIP,aAAa,MAAM;AAAA;;AAAA;AAAA;AAAA;AAAA,4BAAA,EAMG,gBAAA,CAAiB,OAAA,CAAQ,CAAA,CAAA,EAAI,gBAAgB,EAAE,CAAC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M;AAEnB,cAAA,OAAA,CAAQ,GAAA;AAAA,gBACN,oBAAoB,gBAAgB,CAAA,sSAAA;AAAA,eACtC;AAEA,cAAA,IAAI,KAAA,CAAM,QAAQ,GAAA,EAAK;AAErB,gBAAA,OAAA,CAAQ,GAAA;AAAA,kBACN,oHAAoH,qBAAqB,CAAA,uJAAA;AAAA,iBAC3I;AAAA,cACF,CAAA,MAAO;AAEL,gBAAA,OAAA,CAAQ,GAAA;AAAA,kBACN,CAAA,sGAAA,EAAyG,wBAAwB,CAAA,mEAAA,EAAsE,wBAAwB,CAAA,gBAAA;AAAA,iBACjO;AAAA,cACF;AAAA,YACF,CAAC,CAAA;AAAA,UACH;AAAA,QACF;AAEA,QAAA,IAAI,aAAA,CAAc,2BAA2B,kBAAA,EAAoB;AAC/D,UAAA,kBAAA,CAAmB,eAAe,KAAK,CAAA;AAAA,QACzC;AAEA,QAAA,IAAI,aAAA,CAAc,2BAA2B,6BAAA,EAA+B;AAC1E,UAAA,gCAAA,CAAiC,KAAA,EAAO,kBAAkB,aAAa,CAAA;AAEvE,UAAA,IAAI,cAAc,KAAA,EAAO;AACvB,YAAA,cAAA,CAAe,MAAM;AAEnB,cAAA,OAAA,CAAQ,GAAA;AAAA,gBACN;AAAA,eACF;AAAA,YACF,CAAC,CAAA;AAAA,UACH;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AACF,CAAC,CAAA;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"11.0.0-alpha.1"}
1
+ {"type":"module","version":"11.0.0-beta.0"}
@@ -1,14 +1,15 @@
1
1
  import * as path from 'node:path';
2
- import { applySdkMetadata, getGlobalScope, vercelWaitUntil, debug, flush, DEV_ENVIRONMENT, DEFAULT_ENVIRONMENT } from '@sentry/core';
3
- import { init as init$1, getDefaultIntegrations, httpIntegration } from '@sentry/node';
2
+ import { DEV_ENVIRONMENT, DEFAULT_ENVIRONMENT, applySdkMetadata, getGlobalScope, debug } from '@sentry/core';
3
+ import { init as init$1 } from '@sentry/node';
4
4
  import { DEBUG_BUILD } from '../common/debug-build.js';
5
+ import { isNuxtDevRuntime } from '../common/devMode.js';
5
6
 
6
7
  function init(options) {
7
- let envFallback;
8
- envFallback = import.meta.dev ? DEV_ENVIRONMENT : DEFAULT_ENVIRONMENT;
8
+ let isDevBuild = false;
9
+ isDevBuild = !!import.meta.dev;
10
+ const envFallback = isDevBuild || isNuxtDevRuntime() ? DEV_ENVIRONMENT : DEFAULT_ENVIRONMENT;
9
11
  const sentryOptions = {
10
12
  environment: options.environment ?? process.env.SENTRY_ENVIRONMENT ?? envFallback,
11
- defaultIntegrations: getNuxtDefaultIntegrations(options),
12
13
  ...options
13
14
  };
14
15
  applySdkMetadata(sentryOptions, "nuxt", ["nuxt", "node"]);
@@ -49,28 +50,6 @@ function clientSourceMapErrorFilter(options) {
49
50
  { id: "NuxtClientSourceMapErrorFilter" }
50
51
  );
51
52
  }
52
- function getNuxtDefaultIntegrations(options) {
53
- return [
54
- ...getDefaultIntegrations(options).filter((integration) => integration.name !== "Http"),
55
- // The httpIntegration is added as defaultIntegration, so users can still overwrite it
56
- httpIntegration({
57
- instrumentation: {
58
- responseHook: () => {
59
- vercelWaitUntil(flushSafelyWithTimeout());
60
- }
61
- }
62
- })
63
- ];
64
- }
65
- async function flushSafelyWithTimeout() {
66
- try {
67
- DEBUG_BUILD && debug.log("Flushing events...");
68
- await flush(2e3);
69
- DEBUG_BUILD && debug.log("Done flushing events");
70
- } catch (e) {
71
- DEBUG_BUILD && debug.log("Error while flushing events:\n", e);
72
- }
73
- }
74
53
  function isCacheEvent(e) {
75
54
  return e.contexts?.trace?.origin === "auto.cache.nuxt";
76
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../../src/server/sdk.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { Client, Event, EventProcessor, Integration } from '@sentry/core';\nimport {\n applySdkMetadata,\n debug,\n DEFAULT_ENVIRONMENT,\n DEV_ENVIRONMENT,\n flush,\n getGlobalScope,\n vercelWaitUntil,\n} from '@sentry/core';\nimport {\n getDefaultIntegrations as getDefaultNodeIntegrations,\n httpIntegration,\n init as initNode,\n type NodeOptions,\n} from '@sentry/node';\nimport { DEBUG_BUILD } from '../common/debug-build';\nimport type { SentryNuxtServerOptions } from '../common/types';\n\n/**\n * Initializes the server-side of the Nuxt SDK\n *\n * @param options Configuration options for the SDK.\n */\nexport function init(options: SentryNuxtServerOptions): Client | undefined {\n let envFallback: string;\n /*! rollup-include-cjs-only */\n envFallback = DEFAULT_ENVIRONMENT;\n /*! rollup-include-cjs-only-end */\n\n /*! rollup-include-esm-only */\n envFallback = import.meta.dev ? DEV_ENVIRONMENT : DEFAULT_ENVIRONMENT;\n /*! rollup-include-esm-only-end */\n\n const sentryOptions = {\n environment: options.environment ?? process.env.SENTRY_ENVIRONMENT ?? envFallback,\n defaultIntegrations: getNuxtDefaultIntegrations(options),\n ...options,\n };\n\n applySdkMetadata(sentryOptions, 'nuxt', ['nuxt', 'node']);\n\n const client = initNode(sentryOptions);\n\n getGlobalScope().addEventProcessor(lowQualityTransactionsFilter(options));\n getGlobalScope().addEventProcessor(clientSourceMapErrorFilter(options));\n\n return client;\n}\n\n/**\n * Filter out transactions for resource requests which we don't want to send to Sentry\n * for quota reasons.\n *\n * Only exported for testing\n */\nexport function lowQualityTransactionsFilter(options: SentryNuxtServerOptions): EventProcessor {\n return Object.assign(\n (event => {\n if (event.type !== 'transaction' || !event.transaction || isCacheEvent(event)) {\n return event;\n }\n\n // Check if this looks like a parametrized route (contains :param or :param() patterns)\n const hasRouteParameters = /\\/:[^(/\\s]*(\\([^)]*\\))?[^/\\s]*/.test(event.transaction);\n\n if (hasRouteParameters) {\n return event;\n }\n\n // We don't want to send transaction for file requests, so everything ending with a *.someExtension should be filtered out\n // path.extname will return an empty string for normal page requests\n if (path.extname(event.transaction)) {\n options.debug &&\n DEBUG_BUILD &&\n debug.log('NuxtLowQualityTransactionsFilter filtered transaction: ', event.transaction);\n return null;\n }\n return event;\n }) satisfies EventProcessor,\n { id: 'NuxtLowQualityTransactionsFilter' },\n );\n}\n\n/**\n * The browser devtools try to get the source maps, but as client source maps may not be available there is going to be an error (no problem for the application though).\n *\n * Only exported for testing\n */\nexport function clientSourceMapErrorFilter(options: SentryNuxtServerOptions): EventProcessor {\n return Object.assign(\n (event => {\n const errorMsg = event.exception?.values?.[0]?.value;\n if (errorMsg?.match(/^ENOENT: no such file or directory, open '.*\\/_nuxt\\/.*\\.js\\.map'/)) {\n options.debug && DEBUG_BUILD && debug.log('NuxtClientSourceMapErrorFilter filtered error: ', errorMsg);\n return null;\n }\n return event;\n }) satisfies EventProcessor,\n { id: 'NuxtClientSourceMapErrorFilter' },\n );\n}\n\nfunction getNuxtDefaultIntegrations(options: NodeOptions): Integration[] {\n return [\n ...getDefaultNodeIntegrations(options).filter(integration => integration.name !== 'Http'),\n // The httpIntegration is added as defaultIntegration, so users can still overwrite it\n httpIntegration({\n instrumentation: {\n responseHook: () => {\n // Makes it possible to end the tracing span before closing the Vercel lambda (https://vercel.com/docs/functions/functions-api-reference#waituntil)\n vercelWaitUntil(flushSafelyWithTimeout());\n },\n },\n }),\n ];\n}\n\n/**\n * Flushes pending Sentry events with a 2-second timeout and in a way that cannot create unhandled promise rejections.\n */\nasync function flushSafelyWithTimeout(): Promise<void> {\n try {\n DEBUG_BUILD && debug.log('Flushing events...');\n await flush(2000);\n DEBUG_BUILD && debug.log('Done flushing events');\n } catch (e) {\n DEBUG_BUILD && debug.log('Error while flushing events:\\n', e);\n }\n}\n\n/**\n * Checks if the event is a cache event.\n */\nfunction isCacheEvent(e: Event): boolean {\n return e.contexts?.trace?.origin === 'auto.cache.nuxt';\n}\n"],"names":["initNode"],"mappings":";;;;;AAyBO,SAAS,KAAK,OAAA,EAAsD;AACzE,EAAA,IAAI,WAAA;AAAA,EACJ,WAAA,GAAA,MAAA,CAAA,IAAA,CAAA,GAAA,GAAA,eAAA,GAAA,mBAAA;AAC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"],"sourcesContent":["import * as path from 'node:path';\nimport type { Client, Event, EventProcessor } from '@sentry/core';\nimport { applySdkMetadata, debug, DEFAULT_ENVIRONMENT, DEV_ENVIRONMENT, getGlobalScope } from '@sentry/core';\nimport { init as initNode } from '@sentry/node';\nimport { DEBUG_BUILD } from '../common/debug-build';\nimport { isNuxtDevRuntime } from '../common/devMode';\nimport type { SentryNuxtServerOptions } from '../common/types';\n\n/**\n * Initializes the server-side of the Nuxt SDK\n *\n * @param options Configuration options for the SDK.\n */\nexport function init(options: SentryNuxtServerOptions): Client | undefined {\n let isDevBuild = false;\n /*! rollup-include-esm-only */\n isDevBuild = !!import.meta.dev;\n /*! rollup-include-esm-only-end */\n\n // Nitro v3 does not bundle the Sentry server config file, so `import.meta.dev` stays undefined there\n const envFallback = isDevBuild || isNuxtDevRuntime() ? DEV_ENVIRONMENT : DEFAULT_ENVIRONMENT;\n\n const sentryOptions = {\n environment: options.environment ?? process.env.SENTRY_ENVIRONMENT ?? envFallback,\n ...options,\n };\n\n applySdkMetadata(sentryOptions, 'nuxt', ['nuxt', 'node']);\n\n const client = initNode(sentryOptions);\n\n getGlobalScope().addEventProcessor(lowQualityTransactionsFilter(options));\n getGlobalScope().addEventProcessor(clientSourceMapErrorFilter(options));\n\n return client;\n}\n\n/**\n * Filter out transactions for resource requests which we don't want to send to Sentry\n * for quota reasons.\n *\n * Only exported for testing\n */\nexport function lowQualityTransactionsFilter(options: SentryNuxtServerOptions): EventProcessor {\n return Object.assign(\n (event => {\n if (event.type !== 'transaction' || !event.transaction || isCacheEvent(event)) {\n return event;\n }\n\n // Check if this looks like a parametrized route (contains :param or :param() patterns)\n const hasRouteParameters = /\\/:[^(/\\s]*(\\([^)]*\\))?[^/\\s]*/.test(event.transaction);\n\n if (hasRouteParameters) {\n return event;\n }\n\n // We don't want to send transaction for file requests, so everything ending with a *.someExtension should be filtered out\n // path.extname will return an empty string for normal page requests\n if (path.extname(event.transaction)) {\n options.debug &&\n DEBUG_BUILD &&\n debug.log('NuxtLowQualityTransactionsFilter filtered transaction: ', event.transaction);\n return null;\n }\n return event;\n }) satisfies EventProcessor,\n { id: 'NuxtLowQualityTransactionsFilter' },\n );\n}\n\n/**\n * The browser devtools try to get the source maps, but as client source maps may not be available there is going to be an error (no problem for the application though).\n *\n * Only exported for testing\n */\nexport function clientSourceMapErrorFilter(options: SentryNuxtServerOptions): EventProcessor {\n return Object.assign(\n (event => {\n const errorMsg = event.exception?.values?.[0]?.value;\n if (errorMsg?.match(/^ENOENT: no such file or directory, open '.*\\/_nuxt\\/.*\\.js\\.map'/)) {\n options.debug && DEBUG_BUILD && debug.log('NuxtClientSourceMapErrorFilter filtered error: ', errorMsg);\n return null;\n }\n return event;\n }) satisfies EventProcessor,\n { id: 'NuxtClientSourceMapErrorFilter' },\n );\n}\n\n/**\n * Checks if the event is a cache event.\n */\nfunction isCacheEvent(e: Event): boolean {\n return e.contexts?.trace?.origin === 'auto.cache.nuxt';\n}\n"],"names":["initNode"],"mappings":";;;;;;AAaO,SAAS,KAAK,OAAA,EAAsD;AACzE,EAAA,IAAI,UAAA,GAAa,KAAA;AAAA,EACjB,UAAA,GAAA,CAAA,CAAA,MAAA,CAAA,IAAA,CAAA,GAAA;AACA,EAAA,MAAA,WAAe,GAAA,UAAY,IAAA,gBAAA,EAAA,GAAA,eAAA,GAAA,mBAAA;AAAA,EAC3B,MAAA,aAAA,GAAA;AAGA,IAAA,WAAM,EAAA,OAAc,CAAA,WAAc,IAAA,OAAA,CAAA,GAAA,CAAA,kBAAqB,IAAA,WAAkB;AAEzE,IAAA,GAAA;AAAsB,GAAA;AACkD,EAAA,gBACnE,CAAA,aAAA,EAAA,MAAA,EAAA,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA;AAAA,EACL,MAAA,MAAA,GAAAA,MAAA,CAAA,aAAA,CAAA;AAEA,EAAA,cAAA,EAAA,CAAiB,iBAAe,CAAA,4BAAwB,CAAA,OAAA,CAAA,CAAA;AAExD,EAAA,cAAM,oBAA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O;AAAA,GAAA;AACT;AACuC,SACzC,YAAA,CAAA,CAAA,EAAA;AACF,EAAA,OAAA,CAAA,CAAA,QAAA,EAAA,KAAA,EAAA,MAAA,KAAA,iBAAA;AAKA;;;;"}
@@ -1,10 +1,37 @@
1
1
  import { existsSync } from 'node:fs';
2
- import { createResolver } from '@nuxt/kit';
2
+ import { pathToFileURL } from 'node:url';
3
+ import { createResolver, addTemplate } from '@nuxt/kit';
3
4
  import { debug } from '@sentry/core';
4
5
  import * as fs from 'fs';
5
- import { getFilenameFromNodeStartCommand, SENTRY_WRAPPED_ENTRY, removeSentryQueryFromPath, SENTRY_WRAPPED_FUNCTIONS, SENTRY_REEXPORTED_FUNCTIONS, constructFunctionReExport, constructWrappedFunctionExportQuery, QUERY_END_INDICATOR } from './utils.js';
6
+ import * as path from 'path';
7
+ import { NUXT_DEV_MODE_FLAG } from '../common/devMode.js';
8
+ import { SERVER_CONFIG_FILENAME, toImportSpecifier, getFilenameFromNodeStartCommand, SENTRY_WRAPPED_ENTRY, removeSentryQueryFromPath, SENTRY_WRAPPED_FUNCTIONS, SENTRY_REEXPORTED_FUNCTIONS, constructFunctionReExport, constructWrappedFunctionExportQuery, QUERY_END_INDICATOR } from './utils.js';
6
9
 
7
- const SERVER_CONFIG_FILENAME = "sentry.server.config";
10
+ const DEV_SERVER_CONFIG_PATH = `dev/${SERVER_CONFIG_FILENAME}.mjs`;
11
+ function addDevServerConfigFile(nuxt, serverConfigFile) {
12
+ const configPath = createResolver(nuxt.options.rootDir).resolve(`/${serverConfigFile}`);
13
+ const importSpecifier = toImportSpecifier(
14
+ nuxt.options.rootDir,
15
+ path.join(nuxt.options.buildDir, DEV_SERVER_CONFIG_PATH)
16
+ );
17
+ const failureMessage = `[Sentry] Could not load \`${path.basename(configPath)}\`, so Sentry is disabled during development. Node loads this file without a build step, so it supports neither path aliases (like #import) nor non-erasable TypeScript syntax (like enums).`;
18
+ addTemplate({
19
+ filename: DEV_SERVER_CONFIG_PATH,
20
+ write: true,
21
+ getContents: () => [
22
+ "// Generated by @sentry/nuxt. Preload it to enable Sentry during development:",
23
+ `// NODE_OPTIONS='--import ${importSpecifier}' nuxt dev`,
24
+ // A static import would hoist above this assignment, and would make a broken config crash the dev server.
25
+ `globalThis.${NUXT_DEV_MODE_FLAG} = true;`,
26
+ "try {",
27
+ ` await import(${JSON.stringify(pathToFileURL(configPath).href)});`,
28
+ "} catch (error) {",
29
+ ` console.warn(${JSON.stringify(failureMessage)}, error);`,
30
+ "}",
31
+ ""
32
+ ].join("\n")
33
+ });
34
+ }
8
35
  function addServerConfigToBuild(moduleOptions, nitro, serverConfigFile) {
9
36
  nitro.hooks.hook("rollup:before", (nitro2, rollupConfig) => {
10
37
  if (rollupConfig?.plugins === null || rollupConfig?.plugins === void 0) {
@@ -132,5 +159,5 @@ ${reExportedFunctions}
132
159
  };
133
160
  }
134
161
 
135
- export { addDynamicImportEntryFileWrapper, addSentryTopImport, addServerConfigToBuild };
162
+ export { DEV_SERVER_CONFIG_PATH, addDevServerConfigFile, addDynamicImportEntryFileWrapper, addSentryTopImport, addServerConfigToBuild };
136
163
  //# sourceMappingURL=addServerConfig.js.map