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

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 (52) 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 -2
  7. package/build/cjs/server/sdk.js.map +1 -1
  8. package/build/cjs/vite/addServerConfig.js +64 -13
  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/utils.js +26 -11
  13. package/build/cjs/vite/utils.js.map +1 -1
  14. package/build/esm/common/devMode.js +9 -0
  15. package/build/esm/common/devMode.js.map +1 -0
  16. package/build/esm/module.js +11 -7
  17. package/build/esm/module.js.map +1 -1
  18. package/build/esm/package.json +1 -1
  19. package/build/esm/server/sdk.js +5 -3
  20. package/build/esm/server/sdk.js.map +1 -1
  21. package/build/esm/vite/addServerConfig.js +62 -14
  22. package/build/esm/vite/addServerConfig.js.map +1 -1
  23. package/build/esm/vite/orchestrion.js +3 -0
  24. package/build/esm/vite/orchestrion.js.map +1 -1
  25. package/build/esm/vite/utils.js +24 -12
  26. package/build/esm/vite/utils.js.map +1 -1
  27. package/build/module/common/devMode.d.ts +4 -0
  28. package/build/module/module.json +1 -1
  29. package/build/module/module.mjs +94 -28
  30. package/build/module/runtime/hooks/captureErrorHook.js +2 -1
  31. package/build/module/runtime/hooks/wrapMiddlewareHandler.js +2 -1
  32. package/build/module/runtime/utils/instrumentDatabase.js +26 -6
  33. package/build/module/runtime/utils/instrumentStorage.js +10 -4
  34. package/build/module/runtime/utils/patchEventHandler.js +2 -1
  35. package/build/module/vite/addServerConfig.d.ts +22 -0
  36. package/build/module/vite/utils.d.ts +14 -1
  37. package/build/types/common/devMode.d.ts +5 -0
  38. package/build/types/common/devMode.d.ts.map +1 -0
  39. package/build/types/index.types.d.ts +0 -1
  40. package/build/types/index.types.d.ts.map +1 -1
  41. package/build/types/module.d.ts.map +1 -1
  42. package/build/types/runtime/hooks/captureErrorHook.d.ts.map +1 -1
  43. package/build/types/runtime/utils/instrumentDatabase.d.ts.map +1 -1
  44. package/build/types/runtime/utils/instrumentStorage.d.ts.map +1 -1
  45. package/build/types/runtime/utils/patchEventHandler.d.ts.map +1 -1
  46. package/build/types/server/sdk.d.ts.map +1 -1
  47. package/build/types/vite/addServerConfig.d.ts +22 -0
  48. package/build/types/vite/addServerConfig.d.ts.map +1 -1
  49. package/build/types/vite/orchestrion.d.ts.map +1 -1
  50. package/build/types/vite/utils.d.ts +14 -1
  51. package/build/types/vite/utils.d.ts.map +1 -1
  52. package/package.json +9 -8
package/README.md CHANGED
@@ -28,4 +28,9 @@ functionality related to Nuxt.
28
28
 
29
29
  ## Troubleshoot
30
30
 
31
+ If your server-side auto-instrumentation stops recording spans after bundling (e.g. certain Nitro
32
+ presets), make sure `@sentry/server-runtime-injection` is kept **external** in the Nitro/server build rather than
33
+ inlined, as its runtime module hook must resolve from `node_modules`. `@sentry/node` logs a warning
34
+ the first time an instrumented dependency loads uninstrumented.
35
+
31
36
  If you encounter any issues with error tracking or integrations, refer to the official [Sentry Nuxt SDK documentation](https://docs.sentry.io/platforms/javascript/guides/nuxt/). If the documentation does not provide the necessary information, consider opening an issue on GitHub.
@@ -0,0 +1,12 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+
5
+ const NUXT_DEV_MODE_FLAG = "__SENTRY_NUXT_DEV_MODE__";
6
+ function isNuxtDevRuntime() {
7
+ return NUXT_DEV_MODE_FLAG in core.GLOBAL_OBJ && core.GLOBAL_OBJ[NUXT_DEV_MODE_FLAG] === true;
8
+ }
9
+
10
+ exports.NUXT_DEV_MODE_FLAG = NUXT_DEV_MODE_FLAG;
11
+ exports.isNuxtDevRuntime = isNuxtDevRuntime;
12
+ //# 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":["GLOBAL_OBJ"],"mappings":";;;;AAGO,MAAM,kBAAA,GAAqB;AAG3B,SAAS,gBAAA,GAA4B;AAC1C,EAAA,OAAO,kBAAA,IAAsBA,eAAA,IAAcA,eAAA,CAAW,kBAAkB,CAAA,KAAM,IAAA;AAChF;;;;;"}
@@ -80,6 +80,9 @@ const module$1 = kit.defineNuxtModule({
80
80
  middlewareConfig.addMiddlewareImports();
81
81
  storageConfig.addStorageInstrumentation(nuxt, !isNitroV3);
82
82
  databaseConfig.addDatabaseInstrumentation(nuxt.options.nitro, !isNitroV3, moduleOptions);
83
+ if (isNitroV3) {
84
+ addServerConfig.addDevServerConfigFile(nuxt, serverConfigFile);
85
+ }
83
86
  }
84
87
  if (clientConfigFile || serverConfigFile) {
85
88
  sourceMaps.setupSourceMaps(moduleOptions, nuxt, kit.addVitePlugin);
@@ -124,8 +127,6 @@ const module$1 = kit.defineNuxtModule({
124
127
  }
125
128
  if (serverConfigFile) {
126
129
  middlewareConfig.addMiddlewareInstrumentation(nitro);
127
- }
128
- if (serverConfigFile?.includes(".server.config")) {
129
130
  core.consoleSandbox(() => {
130
131
  const serverDir = nitro.options.output.serverDir;
131
132
  if (serverDir.includes(".netlify") || !!process.env.NETLIFY) {
@@ -140,18 +141,21 @@ const module$1 = kit.defineNuxtModule({
140
141
  }
141
142
  });
142
143
  if (moduleOptions.autoInjectServerSentry !== "experimental_dynamic-import") {
143
- addServerConfig.addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);
144
+ if (!(isNitroV3 && nitro.options.dev)) {
145
+ addServerConfig.addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);
146
+ }
144
147
  if (moduleOptions.debug) {
145
148
  const serverDirResolver = kit.createResolver(nitro.options.output.serverDir);
146
149
  const serverConfigPath = serverDirResolver.resolve("sentry.server.config.mjs");
147
- const serverConfigRelativePath = `.${path.sep}${path.relative(nitro.options.rootDir, serverConfigPath)}`;
150
+ const serverConfigRelativePath = utils.toImportSpecifier(nitro.options.rootDir, serverConfigPath);
151
+ const devConfigRelativePath = isNitroV3 ? utils.toImportSpecifier(nuxt.options.rootDir, path.join(nuxt.options.buildDir, addServerConfig.DEV_SERVER_CONFIG_PATH)) : serverConfigRelativePath;
148
152
  core.consoleSandbox(() => {
149
153
  console.log(
150
154
  `[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/.`
151
155
  );
152
156
  if (nitro.options.dev) {
153
157
  console.log(
154
- `[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.`
158
+ `[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.`
155
159
  );
156
160
  } else {
157
161
  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":["defineNuxtModule","createResolver","findDefaultSdkInitFile","addPluginTemplate","addPlugin","getNitroMajorVersion","setupOrchestrion","addServerPlugin","addMiddlewareImports","addStorageInstrumentation","addDatabaseInstrumentation","setupSourceMaps","addVitePlugin","addOTelCommonJSImportAlias","addTemplate","addMiddlewareInstrumentation","consoleSandbox","addServerConfigToBuild","addSentryTopImport","addDynamicImportEntryFileWrapper"],"mappings":";;;;;;;;;;;;AA0BA,iBAAeA,oBAAA,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,EAA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ACF,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":["defineNuxtModule","createResolver","findDefaultSdkInitFile","addPluginTemplate","addPlugin","getNitroMajorVersion","setupOrchestrion","addServerPlugin","addMiddlewareImports","addStorageInstrumentation","addDatabaseInstrumentation","addDevServerConfigFile","setupSourceMaps","addVitePlugin","addOTelCommonJSImportAlias","addTemplate","addMiddlewareInstrumentation","conso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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,UAAAI,kCAAA,CAAmB,eAAe,KAAK,CAAA;AAAA,QACzC;AAEA,QAAA,IAAI,aAAA,CAAc,2BAA2B,6BAAA,EAA+B;AAC1E,UAAAC,gDAAA,CAAiC,KAAA,EAAO,kBAAkB,aAAa,CAAA;AAEvE,UAAA,IAAI,cAAc,KAAA,EAAO;AACvB,YAAAL,mBAAA,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;;;;"}
@@ -4,10 +4,10 @@ const path = require('node:path');
4
4
  const core = require('@sentry/core');
5
5
  const node = require('@sentry/node');
6
6
  const debugBuild = require('../common/debug-build.js');
7
+ const devMode = require('../common/devMode.js');
7
8
 
8
9
  function init(options) {
9
- let envFallback;
10
- envFallback = core.DEFAULT_ENVIRONMENT;
10
+ const envFallback = devMode.isNuxtDevRuntime() ? core.DEV_ENVIRONMENT : core.DEFAULT_ENVIRONMENT;
11
11
  const sentryOptions = {
12
12
  environment: options.environment ?? process.env.SENTRY_ENVIRONMENT ?? envFallback,
13
13
  ...options
@@ -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 } 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 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 ...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":["DEFAULT_ENVIRONMENT","applySdkMetadata","initNode","getGlobalScope","DEBUG_BUILD","debug"],"mappings":";;;;;;;AAYO,SAAS,KAAK,OAAA,EAAsD;AACzE,EAAA,IAAI,WAAA;AAAA,EACJ,WAAA,GAAAA,wBAAA;AACA,EAAA,MAAA,aAAc,GAAA;AAAA,IACd,WAAA,EAAA,OAAA,CAAA,WAAA,IAAA,OAAA,CAAA,GAAA,CAAA,kBAAA,IAAA,WAAA;AAAA,IAEA,GAAA;AACA,GAAA;AAAkD,EAClDC,qBAAA,CAAA,aAAA,EAAA,MAAA,EAAA,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA;AAEA,EAAA,MAAM,MAAA,GAAAC,SAAgB,CAAA,aAAA,CAAA;AAAA,EAAAC,mBACpB,EAAa,CAAA,iBAAQ,CAAA,4BAA2B,CAAA,OAAA,CAAsB,CAAA;AAAA,EAAAA,mBACnE,EAAA,CAAA,iBAAA,CAAA,0BAAA,CAAA,OAAA,CAA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A,EAAA;AAAA,EAAA,OACT,CAAA,CAAA,QAAA,EAAA,KAAA,EAAA,MAAA,KAAA,iBAAA;AAAA;;;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../../src/server/sdk.ts"],"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":["isNuxtDevRuntime","DEV_ENVIRONMENT","DEFAULT_ENVIRONMENT","applySdkMetadata","initNode","getGlobalScope","DEBUG_BUILD","debug"],"mappings":";;;;;;;;AAaO,SAAS,KAAK,OAAA,EAAsD;AACxD,EACjB,MAAA,WAAA,GAAAA,wBAAA,EAAA,GAAAC,oBAAA,GAAAC,wBAAA;AACA,EAAA,MAAA,aAAe,GAAA;AAAY,IAC3B,WAAA,EAAA,OAAA,CAAA,WAAA,IAAA,OAAA,CAAA,GAAA,CAAA,kBAAA,IAAA,WAAA;AAGA,IAAA,GAAA;AAEA,GAAA;AAAsB,EAAAC,qBACP,CAAA,aAAQ,EAAA,MAAe,EAAA,CAAA,cAAY,CAAA,CAAA;AAAsB,EAAA,MACnE,MAAA,GAAAC,SAAA,CAAA,a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A;AACE,MAAA,OAAA,KAAQ;AACR,IAAA,CAAA;AAAO,IAAA,EACT,EAAA,EAAA,gCAAA;AACA,GAAA;AAAO;AACT,qBACM,CAAA,CAAA,EAAA;AAAiC,EACzC,OAAA,CAAA,CAAA,QAAA,EAAA,KAAA,EAAA,MAAA,KAAA,iBAAA;AACF;;;;;;"}
@@ -1,12 +1,48 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const node_fs = require('node:fs');
4
+ const path$1 = require('node:path');
5
+ const node_url = require('node:url');
4
6
  const kit = require('@nuxt/kit');
5
7
  const core = require('@sentry/core');
6
8
  const fs = require('fs');
9
+ const path = require('path');
10
+ const devMode = require('../common/devMode.js');
7
11
  const utils = require('./utils.js');
8
12
 
9
- const SERVER_CONFIG_FILENAME = "sentry.server.config";
13
+ const DEV_SERVER_CONFIG_PATH = `dev/${utils.SERVER_CONFIG_FILENAME}.mjs`;
14
+ function addDevServerConfigFile(nuxt, serverConfigFile) {
15
+ const configPath = kit.createResolver(nuxt.options.rootDir).resolve(serverConfigFile);
16
+ const importSpecifier = utils.toImportSpecifier(
17
+ nuxt.options.rootDir,
18
+ path.join(nuxt.options.buildDir, DEV_SERVER_CONFIG_PATH)
19
+ );
20
+ 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).`;
21
+ kit.addTemplate({
22
+ filename: DEV_SERVER_CONFIG_PATH,
23
+ write: true,
24
+ getContents: () => [
25
+ "// Generated by @sentry/nuxt. Preload it to enable Sentry during development:",
26
+ `// NODE_OPTIONS='--import ${importSpecifier}' nuxt dev`,
27
+ // A static import would hoist above this assignment, and would make a broken config crash the dev server.
28
+ `globalThis.${devMode.NUXT_DEV_MODE_FLAG} = true;`,
29
+ "try {",
30
+ ` await import(${JSON.stringify(node_url.pathToFileURL(configPath).href)});`,
31
+ "} catch (error) {",
32
+ ` console.warn(${JSON.stringify(failureMessage)}, error);`,
33
+ "}",
34
+ ""
35
+ ].join("\n")
36
+ });
37
+ }
38
+ const CONFIG_EXTENSIONS = [".ts", ".js", ".mjs", ".cjs", ".mts", ".cts"];
39
+ function isServerConfigFile(sourcePath, resolvedPath) {
40
+ if (sourcePath === resolvedPath) {
41
+ return true;
42
+ }
43
+ const name = path$1.basename(sourcePath);
44
+ return name === utils.SERVER_CONFIG_FILENAME || CONFIG_EXTENSIONS.some((ext) => name === `${utils.SERVER_CONFIG_FILENAME}${ext}`);
45
+ }
10
46
  function addServerConfigToBuild(moduleOptions, nitro, serverConfigFile) {
11
47
  nitro.hooks.hook("rollup:before", (nitro2, rollupConfig) => {
12
48
  if (rollupConfig?.plugins === null || rollupConfig?.plugins === void 0) {
@@ -26,7 +62,7 @@ function addSentryTopImport(moduleOptions, nitro) {
26
62
  const entryFilePath = serverDirResolver.resolve(entryFileName);
27
63
  try {
28
64
  fs.readFile(entryFilePath, "utf8", (err, data) => {
29
- const updatedContent = `import './${SERVER_CONFIG_FILENAME}.mjs';
65
+ const updatedContent = `import './${utils.SERVER_CONFIG_FILENAME}.mjs';
30
66
  ${data}`;
31
67
  fs.writeFile(entryFilePath, updatedContent, "utf8", () => {
32
68
  if (moduleOptions.debug) {
@@ -57,7 +93,7 @@ function addDynamicImportEntryFileWrapper(nitro, serverConfigFile, moduleOptions
57
93
  }
58
94
  nitro.options.rollupConfig.plugins.push(
59
95
  wrapEntryWithDynamicImport({
60
- resolvedSentryConfigPath: kit.createResolver(nitro.options.rootDir).resolve(`/${serverConfigFile}`),
96
+ resolvedSentryConfigPath: kit.createResolver(nitro.options.rootDir).resolve(serverConfigFile),
61
97
  experimental_entrypointWrappedFunctions: moduleOptions.experimental_entrypointWrappedFunctions
62
98
  })
63
99
  );
@@ -67,7 +103,7 @@ function injectServerConfigPlugin(nitro, serverConfigFile, isDebug) {
67
103
  return {
68
104
  name: "rollup-plugin-inject-sentry-server-config",
69
105
  buildStart() {
70
- const configPath = kit.createResolver(nitro.options.rootDir).resolve(`/${serverConfigFile}`);
106
+ const configPath = kit.createResolver(nitro.options.rootDir).resolve(serverConfigFile);
71
107
  if (!node_fs.existsSync(configPath)) {
72
108
  if (isDebug) {
73
109
  core.debug.log(`[Sentry] Sentry server config file not found: ${configPath}`);
@@ -77,13 +113,13 @@ function injectServerConfigPlugin(nitro, serverConfigFile, isDebug) {
77
113
  this.emitFile({
78
114
  type: "chunk",
79
115
  id: `${filePrefix}${serverConfigFile}`,
80
- fileName: `${SERVER_CONFIG_FILENAME}.mjs`
116
+ fileName: `${utils.SERVER_CONFIG_FILENAME}.mjs`
81
117
  });
82
118
  },
83
119
  resolveId(source) {
84
120
  if (source.startsWith(filePrefix)) {
85
121
  const originalFilePath = source.replace(filePrefix, "");
86
- const configPath = kit.createResolver(nitro.options.rootDir).resolve(`/${originalFilePath}`);
122
+ const configPath = kit.createResolver(nitro.options.rootDir).resolve(originalFilePath);
87
123
  return { id: configPath };
88
124
  }
89
125
  return null;
@@ -99,11 +135,16 @@ function wrapEntryWithDynamicImport({
99
135
  return {
100
136
  name: "sentry-wrap-entry-with-dynamic-import",
101
137
  async resolveId(source, importer, options) {
102
- if (source.includes(`/${SERVER_CONFIG_FILENAME}`)) {
103
- return { id: source, moduleSideEffects: true };
138
+ const resolvable = utils.toResolvablePath(source);
139
+ if (!resolvable) {
140
+ return null;
141
+ }
142
+ const { path: normalizedSource, wasFileUrl } = resolvable;
143
+ if (isServerConfigFile(normalizedSource, resolvedSentryConfigPath)) {
144
+ return { id: normalizedSource, moduleSideEffects: true };
104
145
  }
105
- if (options.isEntry && source.includes(".mjs") && !source.includes(`.mjs${utils.SENTRY_WRAPPED_ENTRY}`)) {
106
- const resolution = await this.resolve(source, importer, options);
146
+ if (options.isEntry && normalizedSource.includes(".mjs") && !normalizedSource.includes(`.mjs${utils.SENTRY_WRAPPED_ENTRY}`)) {
147
+ const resolution = await this.resolve(normalizedSource, importer, options);
107
148
  if (!resolution || resolution?.external) return resolution;
108
149
  const moduleInfo = await this.load(resolution);
109
150
  moduleInfo.moduleSideEffects = true;
@@ -115,16 +156,23 @@ function wrapEntryWithDynamicImport({
115
156
  )
116
157
  ).concat(utils.QUERY_END_INDICATOR)}`;
117
158
  }
159
+ if (wasFileUrl) {
160
+ const resolved = await this.resolve(normalizedSource, importer, { ...options, isEntry: false });
161
+ if (resolved) return resolved;
162
+ return { id: normalizedSource };
163
+ }
118
164
  return null;
119
165
  },
120
166
  load(id) {
121
167
  if (id.includes(`.mjs${utils.SENTRY_WRAPPED_ENTRY}`)) {
122
168
  const entryId = utils.removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);
123
- const reExportedFunctions = id.includes(utils.SENTRY_WRAPPED_FUNCTIONS) || id.includes(utils.SENTRY_REEXPORTED_FUNCTIONS) ? utils.constructFunctionReExport(id, entryId) : "";
169
+ const entryIdUrl = node_url.pathToFileURL(entryId).href;
170
+ const configUrl = node_url.pathToFileURL(resolvedSentryConfigPath).href;
171
+ const reExportedFunctions = id.includes(utils.SENTRY_WRAPPED_FUNCTIONS) || id.includes(utils.SENTRY_REEXPORTED_FUNCTIONS) ? utils.constructFunctionReExport(id, entryIdUrl) : "";
124
172
  return (
125
173
  // Regular `import` of the Sentry config
126
- `import ${JSON.stringify(resolvedSentryConfigPath)};
127
- import(${JSON.stringify(entryId)});
174
+ `import ${JSON.stringify(configUrl)};
175
+ import(${JSON.stringify(entryIdUrl)});
128
176
  ${reExportedFunctions}
129
177
  `
130
178
  );
@@ -134,7 +182,10 @@ ${reExportedFunctions}
134
182
  };
135
183
  }
136
184
 
185
+ exports.DEV_SERVER_CONFIG_PATH = DEV_SERVER_CONFIG_PATH;
186
+ exports.addDevServerConfigFile = addDevServerConfigFile;
137
187
  exports.addDynamicImportEntryFileWrapper = addDynamicImportEntryFileWrapper;
138
188
  exports.addSentryTopImport = addSentryTopImport;
139
189
  exports.addServerConfigToBuild = addServerConfigToBuild;
190
+ exports.wrapEntryWithDynamicImport = wrapEntryWithDynamicImport;
140
191
  //# sourceMappingURL=addServerConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"addServerConfig.js","sources":["../../../src/vite/addServerConfig.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { createResolver } from '@nuxt/kit';\nimport { debug } from '@sentry/core';\nimport * as fs from 'fs';\nimport type { Nitro } from 'nitropack';\nimport type { InputPluginOption } from 'rollup';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport {\n constructFunctionReExport,\n constructWrappedFunctionExportQuery,\n getFilenameFromNodeStartCommand,\n QUERY_END_INDICATOR,\n removeSentryQueryFromPath,\n SENTRY_REEXPORTED_FUNCTIONS,\n SENTRY_WRAPPED_ENTRY,\n SENTRY_WRAPPED_FUNCTIONS,\n} from './utils';\n\nconst SERVER_CONFIG_FILENAME = 'sentry.server.config';\n\n/**\n * Adds the `sentry.server.config.ts` file as `sentry.server.config.mjs` to the `.output` directory to be able to reference this file in the node --import option.\n *\n * By adding a Rollup plugin to the Nitro Rollup options, the Sentry server config is transpiled and emitted to the server build.\n */\nexport function addServerConfigToBuild(\n moduleOptions: SentryNuxtModuleOptions,\n nitro: Nitro,\n serverConfigFile: string,\n): void {\n nitro.hooks.hook('rollup:before', (nitro, rollupConfig) => {\n if (rollupConfig?.plugins === null || rollupConfig?.plugins === undefined) {\n rollupConfig.plugins = [];\n } else if (!Array.isArray(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 rollupConfig.plugins = [rollupConfig.plugins];\n }\n\n rollupConfig.plugins.push(injectServerConfigPlugin(nitro, serverConfigFile, moduleOptions.debug));\n });\n}\n\n/**\n * Adds the Sentry server config import at the top of the server entry file to load the SDK on the server.\n * This is necessary for environments where modifying the node option `--import` is not possible.\n * However, only limited tracing instrumentation is supported when doing this.\n */\nexport function addSentryTopImport(moduleOptions: SentryNuxtModuleOptions, nitro: Nitro): void {\n nitro.hooks.hook('close', async () => {\n const fileNameFromCommand =\n nitro.options.commands.preview && getFilenameFromNodeStartCommand(nitro.options.commands.preview);\n\n // other presets ('node-server' or 'vercel') have an index.mjs\n const presetsWithServerFile = ['netlify'];\n\n const entryFileName = fileNameFromCommand\n ? fileNameFromCommand\n : typeof nitro.options.rollupConfig?.output.entryFileNames === 'string'\n ? nitro.options.rollupConfig?.output.entryFileNames\n : presetsWithServerFile.includes(nitro.options.preset)\n ? 'server.mjs'\n : 'index.mjs';\n\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const entryFilePath = serverDirResolver.resolve(entryFileName);\n\n try {\n fs.readFile(entryFilePath, 'utf8', (err, data) => {\n const updatedContent = `import './${SERVER_CONFIG_FILENAME}.mjs';\\n${data}`;\n\n fs.writeFile(entryFilePath, updatedContent, 'utf8', () => {\n if (moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Successfully added the Sentry import to the server entry file \"\\`${entryFilePath}\\`\"`,\n );\n }\n });\n });\n } catch (err) {\n if (moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] An error occurred when trying to add the Sentry import to the server entry file \"\\`${entryFilePath}\\`\":`,\n err,\n );\n }\n }\n });\n}\n\n/**\n * This function modifies the Rollup configuration to include a plugin that wraps the entry file with a dynamic import (`import()`)\n * and adds the Sentry server config with the static `import` declaration.\n *\n * With this, the Sentry server config can be loaded before all other modules of the application.\n * See: https://nodejs.org/api/module.html#enabling\n */\nexport function addDynamicImportEntryFileWrapper(\n nitro: Nitro,\n serverConfigFile: string,\n moduleOptions: Omit<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'> &\n Required<Pick<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'>>,\n): void {\n if (!nitro.options.rollupConfig) {\n nitro.options.rollupConfig = { output: {} };\n }\n\n if (nitro.options.rollupConfig?.plugins === null || nitro.options.rollupConfig?.plugins === undefined) {\n nitro.options.rollupConfig.plugins = [];\n } else if (!Array.isArray(nitro.options.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 nitro.options.rollupConfig.plugins = [nitro.options.rollupConfig.plugins];\n }\n\n nitro.options.rollupConfig.plugins.push(\n wrapEntryWithDynamicImport({\n resolvedSentryConfigPath: createResolver(nitro.options.rootDir).resolve(`/${serverConfigFile}`),\n experimental_entrypointWrappedFunctions: moduleOptions.experimental_entrypointWrappedFunctions,\n }),\n );\n}\n\n/**\n * Rollup plugin to include the Sentry server configuration file to the server build output.\n */\nfunction injectServerConfigPlugin(nitro: Nitro, serverConfigFile: string, isDebug?: boolean): InputPluginOption {\n const filePrefix = '\\0virtual:sentry-server-config:';\n\n return {\n name: 'rollup-plugin-inject-sentry-server-config',\n\n buildStart() {\n const configPath = createResolver(nitro.options.rootDir).resolve(`/${serverConfigFile}`);\n\n if (!existsSync(configPath)) {\n if (isDebug) {\n debug.log(`[Sentry] Sentry server config file not found: ${configPath}`);\n }\n return;\n }\n\n // Emitting a file adds it to the build output (Rollup is aware of the file, and we can later return the code in resolveId)\n this.emitFile({\n type: 'chunk',\n id: `${filePrefix}${serverConfigFile}`,\n fileName: `${SERVER_CONFIG_FILENAME}.mjs`,\n });\n },\n\n resolveId(source) {\n if (source.startsWith(filePrefix)) {\n const originalFilePath = source.replace(filePrefix, '');\n const configPath = createResolver(nitro.options.rootDir).resolve(`/${originalFilePath}`);\n\n return { id: configPath };\n }\n return null;\n },\n };\n}\n\n/**\n * A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first\n * by using a regular `import` and load the server after that.\n * This also works with serverless `handler` functions, as it re-exports the `handler`.\n */\nfunction wrapEntryWithDynamicImport({\n resolvedSentryConfigPath,\n experimental_entrypointWrappedFunctions,\n debug,\n}: {\n resolvedSentryConfigPath: string;\n experimental_entrypointWrappedFunctions: string[];\n debug?: boolean;\n}): InputPluginOption {\n // In order to correctly import the server config file\n // and dynamically import the nitro runtime, we need to\n // mark the resolutionId with '\\0raw' to fall into the\n // raw chunk group, c.f. https://github.com/nitrojs/nitro/commit/8b4a408231bdc222569a32ce109796a41eac4aa6#diff-e58102d2230f95ddeef2662957b48d847a6e891e354cfd0ae6e2e03ce848d1a2R142\n const resolutionIdPrefix = '\\0raw';\n\n return {\n name: 'sentry-wrap-entry-with-dynamic-import',\n async resolveId(source, importer, options) {\n if (source.includes(`/${SERVER_CONFIG_FILENAME}`)) {\n return { id: source, moduleSideEffects: true };\n }\n\n if (options.isEntry && source.includes('.mjs') && !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const resolution = await this.resolve(source, importer, options);\n\n // If it cannot be resolved or is external, just return it so that Rollup can display an error\n if (!resolution || resolution?.external) return resolution;\n\n const moduleInfo = await this.load(resolution);\n\n moduleInfo.moduleSideEffects = true;\n\n // The enclosing `if` already checks for the suffix in `source`, but a check in `resolution.id` is needed as well to prevent multiple attachment of the suffix\n return resolution.id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ? resolution.id\n : `${resolutionIdPrefix}${resolution.id\n // Concatenates the query params to mark the file (also attaches names of re-exports - this is needed for serverless functions to re-export the handler)\n .concat(SENTRY_WRAPPED_ENTRY)\n .concat(\n constructWrappedFunctionExportQuery(\n moduleInfo.exportedBindings,\n experimental_entrypointWrappedFunctions,\n debug,\n ),\n )\n .concat(QUERY_END_INDICATOR)}`;\n }\n return null;\n },\n load(id: string) {\n if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);\n\n // Mostly useful for serverless `handler` functions\n const reExportedFunctions =\n id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS)\n ? constructFunctionReExport(id, entryId)\n : '';\n\n return (\n // Regular `import` of the Sentry config\n `import ${JSON.stringify(resolvedSentryConfigPath)};\\n` +\n // Dynamic `import()` for the previous, actual entry point.\n // `import()` can be used for any code that should be run after the hooks are registered (https://nodejs.org/api/module.html#enabling)\n `import(${JSON.stringify(entryId)});\\n` +\n `${reExportedFunctions}\\n`\n );\n }\n\n return null;\n },\n };\n}\n"],"names":["nitro","getFilenameFromNodeStartCommand","createResolver","existsSync","debug","SENTRY_WRAPPED_ENTRY","constructWrappedFunctionExportQuery","QUERY_END_INDICATOR","removeSentryQueryFromPath","SENTRY_WRAPPED_FUNCTIONS","SENTRY_REEXPORTED_FUNCTIONS","constructFunctionReExport"],"mappings":";;;;;;;;AAkBA,MAAM,sBAAA,GAAyB,sBAAA;AAOxB,SAAS,sBAAA,CACd,aAAA,EACA,KAAA,EACA,gBAAA,EACM;AACN,EAAA,KAAA,CAAM,KAAA,CAAM,IAAA,CAAK,eAAA,EAAiB,CAACA,QAAO,YAAA,KAAiB;AACzD,IAAA,IAAI,YAAA,EAAc,OAAA,KAAY,IAAA,IAAQ,YAAA,EAAc,YAAY,MAAA,EAAW;AACzE,MAAA,YAAA,CAAa,UAAU,EAAC;AAAA,IAC1B,WAAW,CAAC,KAAA,CAAM,OAAA,CAAQ,YAAA,CAAa,OAAO,CAAA,EAAG;AAE/C,MAAA,YAAA,CAAa,OAAA,GAAU,CAAC,YAAA,CAAa,OAAO,CAAA;AAAA,IAC9C;AAEA,IAAA,YAAA,CAAa,QAAQ,IAAA,CAAK,wBAAA,CAAyBA,QAAO,gBAAA,EAAkB,aAAA,CAAc,KAAK,CAAC,CAAA;AAAA,EAClG,CAAC,CAAA;AACH;AAOO,SAAS,kBAAA,CAAmB,eAAwC,KAAA,EAAoB;AAC7F,EAAA,KAAA,CAAM,KAAA,CAAM,IAAA,CAAK,OAAA,EAAS,YAAY;AACpC,IAAA,MAAM,mBAAA,GACJ,MAAM,OAAA,CAAQ,QAAA,CAAS,WAAWC,qCAAA,CAAgC,KAAA,CAAM,OAAA,CAAQ,QAAA,CAAS,OAAO,CAAA;AAGlG,IAAA,MAAM,qBAAA,GAAwB,CAAC,SAAS,CAAA;AAExC,IAAA,MAAM,aAAA,GAAg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,CAAU,OAAO,CAAC,CAAA;AAAA,EAC9B,mBAAmB;AAAA;AAAA;AAAA,MAE1B;AAEA,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,GACF;AACF;;;;;;"}
1
+ {"version":3,"file":"addServerConfig.js","sources":["../../../src/vite/addServerConfig.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { basename } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { addTemplate, createResolver } from '@nuxt/kit';\nimport type { Nuxt } from '@nuxt/schema';\nimport { debug } from '@sentry/core';\nimport * as fs from 'fs';\nimport type { Nitro } from 'nitropack';\nimport * as path from 'path';\nimport type { InputPluginOption } from 'rollup';\nimport { NUXT_DEV_MODE_FLAG } from '../common/devMode';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport {\n constructFunctionReExport,\n constructWrappedFunctionExportQuery,\n getFilenameFromNodeStartCommand,\n QUERY_END_INDICATOR,\n removeSentryQueryFromPath,\n SENTRY_REEXPORTED_FUNCTIONS,\n SENTRY_WRAPPED_ENTRY,\n SENTRY_WRAPPED_FUNCTIONS,\n SERVER_CONFIG_FILENAME,\n toImportSpecifier,\n toResolvablePath,\n} from './utils';\n\n/** Path of the generated dev-mode config file, relative to the Nuxt build directory. */\nexport const DEV_SERVER_CONFIG_PATH = `dev/${SERVER_CONFIG_FILENAME}.mjs`;\n\n/**\n * Writes the file users preload with `node --import` to enable Sentry in `nuxt dev` (for Nuxt 5 with Nitro 3).\n *\n * In dev-mode, Nitro v3 has no server bundle to emit into, so Node loads the server config file as it is written.\n */\nexport function addDevServerConfigFile(nuxt: Nuxt, serverConfigFile: string): void {\n const configPath = createResolver(nuxt.options.rootDir).resolve(serverConfigFile);\n const importSpecifier = toImportSpecifier(\n nuxt.options.rootDir,\n path.join(nuxt.options.buildDir, DEV_SERVER_CONFIG_PATH),\n );\n\n const failureMessage =\n `[Sentry] Could not load \\`${path.basename(configPath)}\\`, so Sentry is disabled during development. ` +\n 'Node loads this file without a build step, so it supports neither path aliases (like #import) nor non-erasable TypeScript syntax (like enums).';\n\n addTemplate({\n filename: DEV_SERVER_CONFIG_PATH,\n write: true,\n getContents: () =>\n [\n '// Generated by @sentry/nuxt. Preload it to enable Sentry during development:',\n `// NODE_OPTIONS='--import ${importSpecifier}' nuxt dev`,\n // A static import would hoist above this assignment, and would make a broken config crash the dev server.\n `globalThis.${NUXT_DEV_MODE_FLAG} = true;`,\n 'try {',\n ` await import(${JSON.stringify(pathToFileURL(configPath).href)});`,\n '} catch (error) {',\n ` console.warn(${JSON.stringify(failureMessage)}, error);`,\n '}',\n '',\n ].join('\\n'),\n });\n}\nconst CONFIG_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs', '.mts', '.cts'];\n\nfunction isServerConfigFile(sourcePath: string, resolvedPath: string): boolean {\n if (sourcePath === resolvedPath) {\n return true;\n }\n const name = basename(sourcePath);\n return name === SERVER_CONFIG_FILENAME || CONFIG_EXTENSIONS.some(ext => name === `${SERVER_CONFIG_FILENAME}${ext}`);\n}\n\n/**\n * Adds the `sentry.server.config.ts` file as `sentry.server.config.mjs` to the `.output` directory to be able to reference this file in the node --import option.\n *\n * By adding a Rollup plugin to the Nitro Rollup options, the Sentry server config is transpiled and emitted to the server build.\n */\nexport function addServerConfigToBuild(\n moduleOptions: SentryNuxtModuleOptions,\n nitro: Nitro,\n serverConfigFile: string,\n): void {\n nitro.hooks.hook('rollup:before', (nitro, rollupConfig) => {\n if (rollupConfig?.plugins === null || rollupConfig?.plugins === undefined) {\n rollupConfig.plugins = [];\n } else if (!Array.isArray(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 rollupConfig.plugins = [rollupConfig.plugins];\n }\n\n rollupConfig.plugins.push(injectServerConfigPlugin(nitro, serverConfigFile, moduleOptions.debug));\n });\n}\n\n/**\n * Adds the Sentry server config import at the top of the server entry file to load the SDK on the server.\n * This is necessary for environments where modifying the node option `--import` is not possible.\n * However, only limited tracing instrumentation is supported when doing this.\n */\nexport function addSentryTopImport(moduleOptions: SentryNuxtModuleOptions, nitro: Nitro): void {\n nitro.hooks.hook('close', async () => {\n const fileNameFromCommand =\n nitro.options.commands.preview && getFilenameFromNodeStartCommand(nitro.options.commands.preview);\n\n // other presets ('node-server' or 'vercel') have an index.mjs\n const presetsWithServerFile = ['netlify'];\n\n const entryFileName = fileNameFromCommand\n ? fileNameFromCommand\n : typeof nitro.options.rollupConfig?.output.entryFileNames === 'string'\n ? nitro.options.rollupConfig?.output.entryFileNames\n : presetsWithServerFile.includes(nitro.options.preset)\n ? 'server.mjs'\n : 'index.mjs';\n\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const entryFilePath = serverDirResolver.resolve(entryFileName);\n\n try {\n fs.readFile(entryFilePath, 'utf8', (err, data) => {\n const updatedContent = `import './${SERVER_CONFIG_FILENAME}.mjs';\\n${data}`;\n\n fs.writeFile(entryFilePath, updatedContent, 'utf8', () => {\n if (moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Successfully added the Sentry import to the server entry file \"\\`${entryFilePath}\\`\"`,\n );\n }\n });\n });\n } catch (err) {\n if (moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] An error occurred when trying to add the Sentry import to the server entry file \"\\`${entryFilePath}\\`\":`,\n err,\n );\n }\n }\n });\n}\n\n/**\n * This function modifies the Rollup configuration to include a plugin that wraps the entry file with a dynamic import (`import()`)\n * and adds the Sentry server config with the static `import` declaration.\n *\n * With this, the Sentry server config can be loaded before all other modules of the application.\n * See: https://nodejs.org/api/module.html#enabling\n */\nexport function addDynamicImportEntryFileWrapper(\n nitro: Nitro,\n serverConfigFile: string,\n moduleOptions: Omit<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'> &\n Required<Pick<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'>>,\n): void {\n if (!nitro.options.rollupConfig) {\n nitro.options.rollupConfig = { output: {} };\n }\n\n if (nitro.options.rollupConfig?.plugins === null || nitro.options.rollupConfig?.plugins === undefined) {\n nitro.options.rollupConfig.plugins = [];\n } else if (!Array.isArray(nitro.options.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 nitro.options.rollupConfig.plugins = [nitro.options.rollupConfig.plugins];\n }\n\n nitro.options.rollupConfig.plugins.push(\n wrapEntryWithDynamicImport({\n resolvedSentryConfigPath: createResolver(nitro.options.rootDir).resolve(serverConfigFile),\n experimental_entrypointWrappedFunctions: moduleOptions.experimental_entrypointWrappedFunctions,\n }),\n );\n}\n\n/**\n * Rollup plugin to include the Sentry server configuration file to the server build output.\n */\nfunction injectServerConfigPlugin(nitro: Nitro, serverConfigFile: string, isDebug?: boolean): InputPluginOption {\n const filePrefix = '\\0virtual:sentry-server-config:';\n\n return {\n name: 'rollup-plugin-inject-sentry-server-config',\n\n buildStart() {\n const configPath = createResolver(nitro.options.rootDir).resolve(serverConfigFile);\n\n if (!existsSync(configPath)) {\n if (isDebug) {\n debug.log(`[Sentry] Sentry server config file not found: ${configPath}`);\n }\n return;\n }\n\n // Emitting a file adds it to the build output (Rollup is aware of the file, and we can later return the code in resolveId)\n this.emitFile({\n type: 'chunk',\n id: `${filePrefix}${serverConfigFile}`,\n fileName: `${SERVER_CONFIG_FILENAME}.mjs`,\n });\n },\n\n resolveId(source) {\n if (source.startsWith(filePrefix)) {\n const originalFilePath = source.replace(filePrefix, '');\n const configPath = createResolver(nitro.options.rootDir).resolve(originalFilePath);\n\n return { id: configPath };\n }\n return null;\n },\n };\n}\n\n/**\n * A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first\n * by using a regular `import` and load the server after that.\n * This also works with serverless `handler` functions, as it re-exports the `handler`.\n *\n * Only exported for testing.\n */\nexport function wrapEntryWithDynamicImport({\n resolvedSentryConfigPath,\n experimental_entrypointWrappedFunctions,\n debug,\n}: {\n resolvedSentryConfigPath: string;\n experimental_entrypointWrappedFunctions: string[];\n debug?: boolean;\n}): InputPluginOption {\n // In order to correctly import the server config file\n // and dynamically import the nitro runtime, we need to\n // mark the resolutionId with '\\0raw' to fall into the\n // raw chunk group, c.f. https://github.com/nitrojs/nitro/commit/8b4a408231bdc222569a32ce109796a41eac4aa6#diff-e58102d2230f95ddeef2662957b48d847a6e891e354cfd0ae6e2e03ce848d1a2R142\n const resolutionIdPrefix = '\\0raw';\n\n return {\n name: 'sentry-wrap-entry-with-dynamic-import',\n async resolveId(source, importer, options) {\n // `load()` emits `file://` specifiers because Node's ESM loader rejects bare Windows paths,\n // but Rollup's resolver only understands filesystem paths.\n const resolvable = toResolvablePath(source);\n if (!resolvable) {\n return null;\n }\n const { path: normalizedSource, wasFileUrl } = resolvable;\n\n if (isServerConfigFile(normalizedSource, resolvedSentryConfigPath)) {\n return { id: normalizedSource, moduleSideEffects: true };\n }\n\n if (\n options.isEntry &&\n normalizedSource.includes('.mjs') &&\n !normalizedSource.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ) {\n const resolution = await this.resolve(normalizedSource, importer, options);\n\n // If it cannot be resolved or is external, just return it so that Rollup can display an error\n if (!resolution || resolution?.external) return resolution;\n\n const moduleInfo = await this.load(resolution);\n\n moduleInfo.moduleSideEffects = true;\n\n // The enclosing `if` already checks for the suffix in `source`, but a check in `resolution.id` is needed as well to prevent multiple attachment of the suffix\n return resolution.id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ? resolution.id\n : `${resolutionIdPrefix}${resolution.id\n // Concatenates the query params to mark the file (also attaches names of re-exports - this is needed for serverless functions to re-export the handler)\n .concat(SENTRY_WRAPPED_ENTRY)\n .concat(\n constructWrappedFunctionExportQuery(\n moduleInfo.exportedBindings,\n experimental_entrypointWrappedFunctions,\n debug,\n ),\n )\n .concat(QUERY_END_INDICATOR)}`;\n }\n\n // Pass isEntry:false to avoid re-entering the isEntry branch and double-wrapping\n // (normalizedSource strips the SENTRY_WRAPPED_ENTRY query suffix).\n if (wasFileUrl) {\n const resolved = await this.resolve(normalizedSource, importer, { ...options, isEntry: false });\n if (resolved) return resolved;\n return { id: normalizedSource };\n }\n\n return null;\n },\n load(id: string) {\n if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);\n const entryIdUrl = pathToFileURL(entryId).href;\n const configUrl = pathToFileURL(resolvedSentryConfigPath).href;\n\n // Use entryIdUrl so Node's runtime ESM loader receives file:// on Windows; Rollup normalizes it in resolveId.\n // Mostly useful for serverless `handler` functions\n const reExportedFunctions =\n id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS)\n ? constructFunctionReExport(id, entryIdUrl)\n : '';\n\n return (\n // Regular `import` of the Sentry config\n `import ${JSON.stringify(configUrl)};\\n` +\n // Dynamic `import()` for the previous, actual entry point.\n // `import()` can be used for any code that should be run after the hooks are registered (https://nodejs.org/api/module.html#enabling)\n `import(${JSON.stringify(entryIdUrl)});\\n` +\n `${reExportedFunctions}\\n`\n );\n }\n\n return null;\n },\n };\n}\n"],"names":["SERVER_CONFIG_FILENAME","createResolver","toImportSpecifier","addTemplate","NUXT_DEV_MODE_FLAG","pathToFileURL","basename","nitro","getFilenameFromNodeStartCommand","existsSync","debug","toResolvablePath","SENTRY_WRAPPED_ENTRY","constructWrappedFunctionExportQuery","QUERY_END_INDICATOR","removeSentryQueryFromPath","SENTRY_WRAPPED_FUNCTIONS","SENTRY_REEXPORTED_FUNCTIONS","constructFunctionReExport"],"mappings":";;;;;;;;;;;;AA2BO,MAAM,sBAAA,GAAyB,OAAOA,4BAAsB,CAAA,IAAA;AAO5D,SAAS,sBAAA,CAAuB,MAAY,gBAAA,EAAgC;AACjF,EAAA,MAAM,aAAaC,kBAAA,CAAe,IAAA,CAAK,QAAQ,OAAO,CAAA,CAAE,QAAQ,gBAAgB,CAAA;AAChF,EAAA,MAAM,eAAA,GAAkBC,uBAAA;AAA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AU,SAAS,CAAC,CAAA;AAAA,OAAA,EAGzB,IAAA,CAAK,SAAA,CAAU,UAAU,CAAC,CAAA;AAAA,EACjC,mBAAmB;AAAA;AAAA;AAAA,MAE1B;AAEA,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,GACF;AACF;;;;;;;;;"}
@@ -12,6 +12,9 @@ function setupOrchestrion(nuxt, hasServerConfig, buildTimeInstrumentation) {
12
12
  if (nuxt.options?._prepare) {
13
13
  return;
14
14
  }
15
+ if (nuxt.options?.dev) {
16
+ return;
17
+ }
15
18
  const isCloudflare = !!nitroConfig.preset?.replace(/-/g, "_").startsWith("cloudflare");
16
19
  if (!hasServerConfig && !isCloudflare) {
17
20
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrion.js","sources":["../../../src/vite/orchestrion.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { INSTRUMENTED_MODULE_NAMES } from '@sentry/server-utils/orchestrion/config';\nimport { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/rollup';\nimport type { NitroConfig } from 'nitropack';\n\n// ioredis requires this CommonJS helper to be bundled with it. Leaving it\n// external makes Nitro resolve the default export as a namespace object.\nconst IORedisDependencies = ['standard-as-callback'];\n\n/**\n * Configures Nitro to bundle and transform dependencies that publish tracing\n * events through diagnostics channels.\n *\n * `hasServerConfig` reflects whether a `sentry.server.config` file was found. On Node the SDK is\n * initialized from that file, so orchestrion only makes sense when it exists. On Cloudflare the SDK\n * is initialized through `sentryCloudflareNitroPlugin` instead (no server config file), so the\n * transform must still run there — detected via the Nitro preset.\n */\nexport function setupOrchestrion(nuxt: Nuxt, hasServerConfig: boolean, buildTimeInstrumentation?: boolean): void {\n if (buildTimeInstrumentation === false) {\n return;\n }\n\n nuxt.hook('nitro:config', (nitroConfig: NitroConfig) => {\n if (nuxt.options?._prepare) {\n return;\n }\n\n // On Cloudflare (workerd) the SDK is initialized through `sentryCloudflareNitroPlugin` (no\n // server config file), so the transform must still run there — detected via the Nitro preset.\n // Nitro normalizes preset names, so match any `cloudflare*` spelling.\n const isCloudflare = !!nitroConfig.preset?.replace(/-/g, '_').startsWith('cloudflare');\n\n if (!hasServerConfig && !isCloudflare) {\n return;\n }\n\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 nitroConfig.rollupConfig.plugins = [nitroConfig.rollupConfig.plugins];\n }\n\n nitroConfig.rollupConfig.plugins.push(sentryOrchestrionPlugin({}));\n\n const externals = (nitroConfig.externals ||= {});\n const inline = externals.inline;\n const existingInline = Array.isArray(inline) ? inline : inline ? [inline] : [];\n externals.inline = [...new Set([...existingInline, ...INSTRUMENTED_MODULE_NAMES, ...IORedisDependencies])];\n });\n}\n"],"names":["sentryOrchestrionPlugin","INSTRUMENTED_MODULE_NAMES"],"mappings":";;;;;AAOA,MAAM,mBAAA,GAAsB,CAAC,sBAAsB,CAAA;AAW5C,SAAS,gBAAA,CAAiB,IAAA,EAAY,eAAA,EAA0B,wBAAA,EAA0C;AAC/G,EAAA,IAAI,6BAA6B,KAAA,EAAO;AACtC,IAAA;AAAA,EACF;AAEA,EAAA,IAAA,CAAK,IAAA,CAAK,cAAA,EAAgB,CAAC,WAAA,KAA6B;AACtD,IAAA,IAAI,IAAA,CAAK,SAAS,QAAA,EAAU;AAC1B,MAAA;AAAA,IACF;AAKA,IAAA,MAAM,YAAA,GAAe,CAAC,CAAC,WAAA,CAAY,MAAA,EAAQ,QAAQ,IAAA,EAAM,GAAG,CAAA,CAAE,UAAA,CAAW,YAAY,CAAA;AAErF,IAAA,IAAI,CAAC,eAAA,IAAmB,CAAC,YAAA,EAAc;AACrC,MAAA;AAAA,IACF;AAEA,IAAA,WAAA,CAAY,YAAA,KAAZ,WAAA,CAAY,YAAA,GAAiB,EAAC,CAAA;AAE9B,IAAA,IAAI,YAAY,YAAA,CAAa,OAAA,KAAY,QAAQ,WAAA,CAAY,YAAA,CAAa,YAAY,MAAA,EAAW;AAC/F,MAAA,WAAA,CAAY,YAAA,CAAa,UAAU,EAAC;AAAA,IACtC,WAAW,CAAC,KAAA,CAAM,QAAQ,WAAA,CAAY,YAAA,CAAa,OAAO,CAAA,EAAG;AAC3D,MAAA,WAAA,CAAY,YAAA,CAAa,OAAA,GAAU,CAAC,WAAA,CAAY,aAAa,OAAO,CAAA;AAAA,IACtE;AAEA,IAAA,WAAA,CAAY,aAAa,OAAA,CAAQ,IAAA,CAAKA,8BAAA,CAAwB,EAAE,CAAC,CAAA;AAEjE,IAAA,MAAM,SAAA,GAAa,WAAA,CAAY,SAAA,KAAZ,WAAA,CAAY,YAAc,EAAC,CAAA;AAC9C,IAAA,MAAM,SAAS,SAAA,CAAU,MAAA;AACzB,IAAA,MAAM,cAAA,GAAiB,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,GAAI,SAAS,MAAA,GAAS,CAAC,MAAM,CAAA,GAAI,EAAC;AAC7E,IAAA,SAAA,CAAU,MAAA,GAAS,CAAC,mBAAG,IAAI,GAAA,CAAI,CAAC,GAAG,cAAA,EAAgB,GAAGC,gCAAA,EAA2B,GAAG,mBAAmB,CAAC,CAAC,CAAA;AAAA,EAC3G,CAAC,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"orchestrion.js","sources":["../../../src/vite/orchestrion.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { INSTRUMENTED_MODULE_NAMES } from '@sentry/server-utils/orchestrion/config';\nimport { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/rollup';\nimport type { NitroConfig } from 'nitropack';\n\n// ioredis requires this CommonJS helper to be bundled with it. Leaving it\n// external makes Nitro resolve the default export as a namespace object.\nconst IORedisDependencies = ['standard-as-callback'];\n\n/**\n * Configures Nitro to bundle and transform dependencies that publish tracing\n * events through diagnostics channels.\n *\n * `hasServerConfig` reflects whether a `sentry.server.config` file was found. On Node the SDK is\n * initialized from that file, so orchestrion only makes sense when it exists. On Cloudflare the SDK\n * is initialized through `sentryCloudflareNitroPlugin` instead (no server config file), so the\n * transform must still run there — detected via the Nitro preset.\n */\nexport function setupOrchestrion(nuxt: Nuxt, hasServerConfig: boolean, buildTimeInstrumentation?: boolean): void {\n if (buildTimeInstrumentation === false) {\n return;\n }\n\n nuxt.hook('nitro:config', (nitroConfig: NitroConfig) => {\n if (nuxt.options?._prepare) {\n return;\n }\n\n // `nuxt dev` has no bundle to transform, and inlining the CommonJS drivers into Nitro's dev\n // server breaks them (`ioredis` throws `(0, lodash_1.defaults) is not a function`).\n if (nuxt.options?.dev) {\n return;\n }\n\n // On Cloudflare (workerd) the SDK is initialized through `sentryCloudflareNitroPlugin` (no\n // server config file), so the transform must still run there — detected via the Nitro preset.\n // Nitro normalizes preset names, so match any `cloudflare*` spelling.\n const isCloudflare = !!nitroConfig.preset?.replace(/-/g, '_').startsWith('cloudflare');\n\n if (!hasServerConfig && !isCloudflare) {\n return;\n }\n\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 nitroConfig.rollupConfig.plugins = [nitroConfig.rollupConfig.plugins];\n }\n\n nitroConfig.rollupConfig.plugins.push(sentryOrchestrionPlugin({}));\n\n const externals = (nitroConfig.externals ||= {});\n const inline = externals.inline;\n const existingInline = Array.isArray(inline) ? inline : inline ? [inline] : [];\n externals.inline = [...new Set([...existingInline, ...INSTRUMENTED_MODULE_NAMES, ...IORedisDependencies])];\n });\n}\n"],"names":["sentryOrchestrionPlugin","INSTRUMENTED_MODULE_NAMES"],"mappings":";;;;;AAOA,MAAM,mBAAA,GAAsB,CAAC,sBAAsB,CAAA;AAW5C,SAAS,gBAAA,CAAiB,IAAA,EAAY,eAAA,EAA0B,wBAAA,EAA0C;AAC/G,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A,SAAA,CAAU,MAAA,GAAS,CAAC,mBAAG,IAAI,GAAA,CAAI,CAAC,GAAG,cAAA,EAAgB,GAAGC,gCAAA,EAA2B,GAAG,mBAAmB,CAAC,CAAC,CAAA;AAAA,EAC3G,CAAC,CAAA;AACH;;;;"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const core = require('@sentry/core');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
+ const node_url = require('node:url');
6
7
  const kit = require('@nuxt/kit');
7
8
 
8
9
  async function getNitroMajorVersion() {
@@ -19,17 +20,7 @@ async function getNitroMajorVersion() {
19
20
  }
20
21
  async function findDefaultSdkInitFile(type, nuxt, options) {
21
22
  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
- }
23
+ const relativePaths = possibleFileExtensions.map((ext) => `sentry.${type}.config.${ext}`);
33
24
  const layers = [...nuxt?.options._layers ?? []].reverse();
34
25
  for (const layer of layers) {
35
26
  for (const relativePath of relativePaths) {
@@ -48,6 +39,10 @@ async function findDefaultSdkInitFile(type, nuxt, options) {
48
39
  }
49
40
  return void 0;
50
41
  }
42
+ const SERVER_CONFIG_FILENAME = "sentry.server.config";
43
+ function toImportSpecifier(fromDir, filePath) {
44
+ return `./${path.relative(fromDir, filePath).split(/[\\/]/).join("/")}`;
45
+ }
51
46
  function getFilenameFromNodeStartCommand(nodeCommand) {
52
47
  const regex = /[^/\\]+\.[^/\\]+$/;
53
48
  const match = nodeCommand.match(regex);
@@ -119,6 +114,23 @@ export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };
119
114
  )
120
115
  );
121
116
  }
117
+ function toResolvablePath(source) {
118
+ if (!source.startsWith("file://")) {
119
+ return { path: source, wasFileUrl: false };
120
+ }
121
+ if (source === "file://" || source === "file:///") {
122
+ return void 0;
123
+ }
124
+ try {
125
+ const filePath = node_url.fileURLToPath(source);
126
+ if (!filePath || filePath === "/" || filePath === "\\") {
127
+ return void 0;
128
+ }
129
+ return { path: filePath, wasFileUrl: true };
130
+ } catch {
131
+ return void 0;
132
+ }
133
+ }
122
134
  function addOTelCommonJSImportAlias(nuxt, isNitroV3 = false) {
123
135
  if (!nuxt.options.dev || isNitroV3) {
124
136
  return;
@@ -135,6 +147,7 @@ exports.QUERY_END_INDICATOR = QUERY_END_INDICATOR;
135
147
  exports.SENTRY_REEXPORTED_FUNCTIONS = SENTRY_REEXPORTED_FUNCTIONS;
136
148
  exports.SENTRY_WRAPPED_ENTRY = SENTRY_WRAPPED_ENTRY;
137
149
  exports.SENTRY_WRAPPED_FUNCTIONS = SENTRY_WRAPPED_FUNCTIONS;
150
+ exports.SERVER_CONFIG_FILENAME = SERVER_CONFIG_FILENAME;
138
151
  exports.addOTelCommonJSImportAlias = addOTelCommonJSImportAlias;
139
152
  exports.constructFunctionReExport = constructFunctionReExport;
140
153
  exports.constructWrappedFunctionExportQuery = constructWrappedFunctionExportQuery;
@@ -143,4 +156,6 @@ exports.findDefaultSdkInitFile = findDefaultSdkInitFile;
143
156
  exports.getFilenameFromNodeStartCommand = getFilenameFromNodeStartCommand;
144
157
  exports.getNitroMajorVersion = getNitroMajorVersion;
145
158
  exports.removeSentryQueryFromPath = removeSentryQueryFromPath;
159
+ exports.toImportSpecifier = toImportSpecifier;
160
+ exports.toResolvablePath = toResolvablePath;
146
161
  //# sourceMappingURL=utils.js.map