@sentry/nuxt 10.73.0 → 10.75.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.
@@ -1,10 +1,20 @@
1
1
  import { existsSync } from 'node:fs';
2
+ import { basename } from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
2
4
  import { createResolver } from '@nuxt/kit';
3
5
  import { debug } from '@sentry/core';
4
6
  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';
7
+ import { getFilenameFromNodeStartCommand, SENTRY_WRAPPED_ENTRY, removeSentryQueryFromPath, SENTRY_WRAPPED_FUNCTIONS, SENTRY_REEXPORTED_FUNCTIONS, constructFunctionReExport, toResolvablePath, constructWrappedFunctionExportQuery, QUERY_END_INDICATOR } from './utils.js';
6
8
 
7
9
  const SERVER_CONFIG_FILENAME = "sentry.server.config";
10
+ const CONFIG_EXTENSIONS = [".ts", ".js", ".mjs", ".cjs", ".mts", ".cts"];
11
+ function isServerConfigFile(sourcePath, resolvedPath) {
12
+ if (sourcePath === resolvedPath) {
13
+ return true;
14
+ }
15
+ const name = basename(sourcePath);
16
+ return name === SERVER_CONFIG_FILENAME || CONFIG_EXTENSIONS.some((ext) => name === `${SERVER_CONFIG_FILENAME}${ext}`);
17
+ }
8
18
  function addServerConfigToBuild(moduleOptions, nitro, serverConfigFile) {
9
19
  nitro.hooks.hook("rollup:before", (nitro2, rollupConfig) => {
10
20
  if (rollupConfig?.plugins === null || rollupConfig?.plugins === void 0) {
@@ -55,7 +65,7 @@ function addDynamicImportEntryFileWrapper(nitro, serverConfigFile, moduleOptions
55
65
  }
56
66
  nitro.options.rollupConfig.plugins.push(
57
67
  wrapEntryWithDynamicImport({
58
- resolvedSentryConfigPath: createResolver(nitro.options.rootDir).resolve(`/${serverConfigFile}`),
68
+ resolvedSentryConfigPath: createResolver(nitro.options.rootDir).resolve(serverConfigFile),
59
69
  experimental_entrypointWrappedFunctions: moduleOptions.experimental_entrypointWrappedFunctions
60
70
  })
61
71
  );
@@ -65,7 +75,7 @@ function injectServerConfigPlugin(nitro, serverConfigFile, isDebug) {
65
75
  return {
66
76
  name: "rollup-plugin-inject-sentry-server-config",
67
77
  buildStart() {
68
- const configPath = createResolver(nitro.options.rootDir).resolve(`/${serverConfigFile}`);
78
+ const configPath = createResolver(nitro.options.rootDir).resolve(serverConfigFile);
69
79
  if (!existsSync(configPath)) {
70
80
  if (isDebug) {
71
81
  debug.log(`[Sentry] Sentry server config file not found: ${configPath}`);
@@ -81,7 +91,7 @@ function injectServerConfigPlugin(nitro, serverConfigFile, isDebug) {
81
91
  resolveId(source) {
82
92
  if (source.startsWith(filePrefix)) {
83
93
  const originalFilePath = source.replace(filePrefix, "");
84
- const configPath = createResolver(nitro.options.rootDir).resolve(`/${originalFilePath}`);
94
+ const configPath = createResolver(nitro.options.rootDir).resolve(originalFilePath);
85
95
  return { id: configPath };
86
96
  }
87
97
  return null;
@@ -97,14 +107,19 @@ function wrapEntryWithDynamicImport({
97
107
  return {
98
108
  name: "sentry-wrap-entry-with-dynamic-import",
99
109
  async resolveId(source, importer, options) {
100
- if (source.includes(`/${SERVER_CONFIG_FILENAME}`)) {
101
- return { id: source, moduleSideEffects: true };
110
+ const resolvable = toResolvablePath(source);
111
+ if (!resolvable) {
112
+ return null;
113
+ }
114
+ const { path: normalizedSource, wasFileUrl } = resolvable;
115
+ if (isServerConfigFile(normalizedSource, resolvedSentryConfigPath)) {
116
+ return { id: normalizedSource, moduleSideEffects: true };
102
117
  }
103
118
  if (source === "import-in-the-middle/hook.mjs") {
104
119
  return { id: source, moduleSideEffects: true, external: true };
105
120
  }
106
- if (options.isEntry && source.includes(".mjs") && !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {
107
- const resolution = await this.resolve(source, importer, options);
121
+ if (options.isEntry && normalizedSource.includes(".mjs") && !normalizedSource.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {
122
+ const resolution = await this.resolve(normalizedSource, importer, options);
108
123
  if (!resolution || resolution?.external) return resolution;
109
124
  const moduleInfo = await this.load(resolution);
110
125
  moduleInfo.moduleSideEffects = true;
@@ -116,16 +131,23 @@ function wrapEntryWithDynamicImport({
116
131
  )
117
132
  ).concat(QUERY_END_INDICATOR)}`;
118
133
  }
134
+ if (wasFileUrl) {
135
+ const resolved = await this.resolve(normalizedSource, importer, { ...options, isEntry: false });
136
+ if (resolved) return resolved;
137
+ return { id: normalizedSource };
138
+ }
119
139
  return null;
120
140
  },
121
141
  load(id) {
122
142
  if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {
123
143
  const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);
124
- const reExportedFunctions = id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS) ? constructFunctionReExport(id, entryId) : "";
144
+ const entryIdUrl = pathToFileURL(entryId).href;
145
+ const configUrl = pathToFileURL(resolvedSentryConfigPath).href;
146
+ const reExportedFunctions = id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS) ? constructFunctionReExport(id, entryIdUrl) : "";
125
147
  return (
126
148
  // Regular `import` of the Sentry config
127
- `import ${JSON.stringify(resolvedSentryConfigPath)};
128
- import(${JSON.stringify(entryId)});
149
+ `import ${JSON.stringify(configUrl)};
150
+ import(${JSON.stringify(entryIdUrl)});
129
151
  import 'import-in-the-middle/hook.mjs';
130
152
  ${reExportedFunctions}
131
153
  `
@@ -136,5 +158,5 @@ ${reExportedFunctions}
136
158
  };
137
159
  }
138
160
 
139
- export { addDynamicImportEntryFileWrapper, addSentryTopImport, addServerConfigToBuild };
161
+ export { addDynamicImportEntryFileWrapper, addSentryTopImport, addServerConfigToBuild, wrapEntryWithDynamicImport };
140
162
  //# 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 (which is needed for import-in-the-middle).\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 (source === 'import-in-the-middle/hook.mjs') {\n // We are importing \"import-in-the-middle\" in the returned code of the `load()` function below\n // By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it\n // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file is included, as not all node builders are including files imported with `module.register()`.\n // Prevents the error \"Failed to register ESM hook Error: Cannot find module 'import-in-the-middle/hook.mjs'\"\n return { id: source, moduleSideEffects: true, external: 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 // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file wil be included, as not all node builders are including files imported with `module.register()`.\n \"import 'import-in-the-middle/hook.mjs';\\n\" +\n `${reExportedFunctions}\\n`\n );\n }\n\n return null;\n },\n };\n}\n"],"names":["nitro","debug"],"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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AAA,CAAE,KAAA,CAAM,mBAAmB,MAAM,CAAA;AAG7E,QAAA,MAAM,mBAAA,GACJ,EAAA,CAAG,QAAA,CAAS,wBAAwB,CAAA,IAAK,EAAA,CAAG,QAAA,CAAS,2BAA2B,CAAA,GAC5E,yBAAA,CAA0B,EAAA,EAAI,OAAO,CAAA,GACrC,EAAA;AAEN,QAAA;AAAA;AAAA,UAEE,CAAA,OAAA,EAAU,IAAA,CAAK,SAAA,CAAU,wBAAwB,CAAC,CAAA;AAAA,OAAA,EAGxC,IAAA,CAAK,SAAA,CAAU,OAAO,CAAC,CAAA;AAAA;AAAA,EAG9B,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 { 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 toResolvablePath,\n} from './utils';\n\nconst SERVER_CONFIG_FILENAME = 'sentry.server.config';\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 (which is needed for import-in-the-middle).\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 (source === 'import-in-the-middle/hook.mjs') {\n // We are importing \"import-in-the-middle\" in the returned code of the `load()` function below\n // By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it\n // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file is included, as not all node builders are including files imported with `module.register()`.\n // Prevents the error \"Failed to register ESM hook Error: Cannot find module 'import-in-the-middle/hook.mjs'\"\n return { id: source, moduleSideEffects: true, external: 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 // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file wil be included, as not all node builders are including files imported with `module.register()`.\n \"import 'import-in-the-middle/hook.mjs';\\n\" +\n `${reExportedFunctions}\\n`\n );\n }\n\n return null;\n },\n };\n}\n"],"names":["nitro","debug"],"mappings":";;;;;;;;AAqBA,MAAM,sBAAA,GAAyB,sBAAA;AAE/B,MAAM,oBAAoB,CAAC,KAAA,EAAO,OAAO,MAAA,EAAQ,MAAA,EAAQ,QAAQ,MAAM,CAAA;AAEvE,SAAS,kBAAA,CAAmB,YAAoB,YAAA,EAA+B;AAC7E,EAAA,IAAI,eAAe,YAAA,EAAc;AAC/B,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,MAAM,IAAA,GAAO,SAAS,UAAU,CAAA;AAChC,EAAA,OAAO,IAAA,KAAS,sBAAA,IAA0B,iBAAA,CAAkB,IAAA,CAAK,CAAA,GAAA,KAAO,SAAS,CAAA,EAAG,sBAAsB,CAAA,EAAG,GAAG,CAAA,CAAE,CAAA;AACpH;AAOO,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,IAC1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AGjC,mBAAmB;AAAA;AAAA;AAAA,MAE1B;AAEA,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,GACF;AACF;;;;"}
@@ -1,19 +1,26 @@
1
1
  import { consoleSandbox } from '@sentry/core';
2
2
  import * as fs from 'fs';
3
3
  import * as path from 'path';
4
+ import { fileURLToPath } from 'node:url';
4
5
  import { resolvePath } from '@nuxt/kit';
5
6
 
6
- async function getNitroMajorVersion() {
7
+ async function getNitroMajorVersion(rootDir) {
7
8
  try {
8
9
  const { getPackageInfo } = await import('local-pkg');
9
- const info = await getPackageInfo("nitro");
10
- if (info?.version) {
11
- const major = parseInt(info.version.split(".")[0] ?? "2", 10);
12
- return isNaN(major) ? 2 : major;
10
+ const fromPackage = (dir) => ({ paths: [path.join(dir, "package.json")] });
11
+ let provider = await getPackageInfo("nuxt", fromPackage(rootDir));
12
+ if (provider?.packageJson.dependencies?.["@nuxt/nitro-server"]) {
13
+ provider = await getPackageInfo("@nuxt/nitro-server", fromPackage(provider.rootPath)) ?? provider;
13
14
  }
15
+ if (!provider?.packageJson.dependencies?.nitro) {
16
+ return 2;
17
+ }
18
+ const info = await getPackageInfo("nitro", fromPackage(provider.rootPath));
19
+ const major = parseInt(info?.version?.split(".")[0] ?? "", 10);
20
+ return isNaN(major) ? 3 : major;
14
21
  } catch {
22
+ return 2;
15
23
  }
16
- return 2;
17
24
  }
18
25
  async function findDefaultSdkInitFile(type, nuxt, options) {
19
26
  const possibleFileExtensions = ["ts", "js", "mjs", "cjs", "mts", "cts"];
@@ -117,6 +124,23 @@ export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };
117
124
  )
118
125
  );
119
126
  }
127
+ function toResolvablePath(source) {
128
+ if (!source.startsWith("file://")) {
129
+ return { path: source, wasFileUrl: false };
130
+ }
131
+ if (source === "file://" || source === "file:///") {
132
+ return void 0;
133
+ }
134
+ try {
135
+ const filePath = fileURLToPath(source);
136
+ if (!filePath || filePath === "/" || filePath === "\\") {
137
+ return void 0;
138
+ }
139
+ return { path: filePath, wasFileUrl: true };
140
+ } catch {
141
+ return void 0;
142
+ }
143
+ }
120
144
  function addOTelCommonJSImportAlias(nuxt, isNitroV3 = false) {
121
145
  if (!nuxt.options.dev || isNitroV3) {
122
146
  return;
@@ -129,5 +153,5 @@ function addOTelCommonJSImportAlias(nuxt, isNitroV3 = false) {
129
153
  }
130
154
  }
131
155
 
132
- export { QUERY_END_INDICATOR, SENTRY_REEXPORTED_FUNCTIONS, SENTRY_WRAPPED_ENTRY, SENTRY_WRAPPED_FUNCTIONS, addOTelCommonJSImportAlias, constructFunctionReExport, constructWrappedFunctionExportQuery, extractFunctionReexportQueryParameters, findDefaultSdkInitFile, getFilenameFromNodeStartCommand, getNitroMajorVersion, removeSentryQueryFromPath };
156
+ export { QUERY_END_INDICATOR, SENTRY_REEXPORTED_FUNCTIONS, SENTRY_WRAPPED_ENTRY, SENTRY_WRAPPED_FUNCTIONS, addOTelCommonJSImportAlias, constructFunctionReExport, constructWrappedFunctionExportQuery, extractFunctionReexportQueryParameters, findDefaultSdkInitFile, getFilenameFromNodeStartCommand, getNitroMajorVersion, removeSentryQueryFromPath, toResolvablePath };
133
157
  //# 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":[],"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;AAMA,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,gBAA0B,EAAC;AAEjC,EAAA,IAAI,SAAS,QAAA,EAAU;AACrB,IAAA,KAAA,MAAW,OAAO,sBAAA,EAAw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,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 { fileURLToPath } from 'node:url';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport { resolvePath } from '@nuxt/kit';\n\n/**\n * Gets the major version of the Nitro package used by the app's Nuxt installation.\n * Returns 2 as the default if the version cannot be determined.\n *\n * Nitro v2 is published as `nitropack`, v3 as `nitro`. Resolving `nitro` directly is\n * unreliable: module resolution walks up the directory tree, so in a monorepo an\n * unrelated `nitro` v3 above the app wins even when the app's Nuxt uses `nitropack` v2.\n * Instead, follow the dependency chain Nuxt itself imports Nitro through:\n * `nuxt` -> (`@nuxt/nitro-server` ->) `nitro` | `nitropack`.\n */\nexport async function getNitroMajorVersion(rootDir: string): Promise<number> {\n try {\n const { getPackageInfo } = await import('local-pkg');\n\n // `paths` entries must point at a file: for a bare directory, resolution starts at the\n // directory's parent and skips the directory's own `node_modules`, so a hoisted copy higher\n // up the tree (e.g. a monorepo root) wins over the app's actual dependency.\n const fromPackage = (dir: string): { paths: string[] } => ({ paths: [path.join(dir, 'package.json')] });\n\n // The package that declares the Nitro dependency: `nuxt` itself, or `@nuxt/nitro-server` (Nuxt >= 3.21) when nuxt delegates to it\n let provider = await getPackageInfo('nuxt', fromPackage(rootDir));\n if (provider?.packageJson.dependencies?.['@nuxt/nitro-server']) {\n provider = (await getPackageInfo('@nuxt/nitro-server', fromPackage(provider.rootPath))) ?? provider;\n }\n\n if (!provider?.packageJson.dependencies?.nitro) {\n return 2;\n }\n\n const info = await getPackageInfo('nitro', fromPackage(provider.rootPath));\n const major = parseInt(info?.version?.split('.')[0] ?? '', 10);\n // The provider imports `nitro` (not `nitropack`), so it is at least v3 even if the version is unreadable\n return isNaN(major) ? 3 : major;\n } catch {\n // If local-pkg is unavailable or resolution fails, default to v2\n return 2;\n }\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 * `load()` emits `file://` specifiers because Node's ESM loader rejects bare Windows\n * paths (`ERR_UNSUPPORTED_ESM_URL_SCHEME`), but Rollup's resolver only understands\n * filesystem paths. Returns `undefined` for a malformed `file://` URL.\n *\n * Only exported for testing.\n */\nexport function toResolvablePath(source: string): { path: string; wasFileUrl: boolean } | undefined {\n if (!source.startsWith('file://')) {\n return { path: source, wasFileUrl: false };\n }\n if (source === 'file://' || source === 'file:///') {\n return undefined;\n }\n try {\n const filePath = fileURLToPath(source);\n if (!filePath || filePath === '/' || filePath === '\\\\') {\n return undefined;\n }\n return { path: filePath, wasFileUrl: true };\n } catch {\n return undefined;\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":[],"mappings":";;;;;;AAkBA,eAAsB,qBAAqB,OAAA,EAAkC;AAC3E,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,WAAW,CAAA;AAKnD,IAAA,MAAM,WAAA,GAAc,CAAC,GAAA,MAAsC,EAAE,KAAA,EAAO,CAAC,IAAA,CAAK,IAAA,CAAK,GA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,EAAE,IAAA,EAAM,QAAA,EAAU,UAAA,EAAY,IAAA,EAAK;AAAA,EAC5C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;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;;;;"}
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.7.0"
6
6
  },
7
- "version": "10.73.0"
7
+ "version": "10.75.0"
8
8
  }
@@ -2,6 +2,8 @@ import { resolvePath, createResolver, useNuxt, addServerPlugin, addServerImports
2
2
  import { consoleSandbox, debug } from '@sentry/core';
3
3
  import * as path from 'path';
4
4
  import { existsSync } from 'node:fs';
5
+ import { basename } from 'node:path';
6
+ import { fileURLToPath, pathToFileURL } from 'node:url';
5
7
  import * as fs from 'fs';
6
8
  import { INSTRUMENTED_MODULE_NAMES } from '@sentry/server-utils/orchestrion/config';
7
9
  import { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/rollup';
@@ -9,17 +11,23 @@ import { sentryRollupPlugin } from '@sentry/rollup-plugin';
9
11
  import { sentryVitePlugin } from '@sentry/vite-plugin';
10
12
  import { createSentryBuildPluginManager } from '@sentry/bundler-plugin-core';
11
13
 
12
- async function getNitroMajorVersion() {
14
+ async function getNitroMajorVersion(rootDir) {
13
15
  try {
14
16
  const { getPackageInfo } = await import('local-pkg');
15
- const info = await getPackageInfo("nitro");
16
- if (info?.version) {
17
- const major = parseInt(info.version.split(".")[0] ?? "2", 10);
18
- return isNaN(major) ? 2 : major;
17
+ const fromPackage = (dir) => ({ paths: [path.join(dir, "package.json")] });
18
+ let provider = await getPackageInfo("nuxt", fromPackage(rootDir));
19
+ if (provider?.packageJson.dependencies?.["@nuxt/nitro-server"]) {
20
+ provider = await getPackageInfo("@nuxt/nitro-server", fromPackage(provider.rootPath)) ?? provider;
19
21
  }
22
+ if (!provider?.packageJson.dependencies?.nitro) {
23
+ return 2;
24
+ }
25
+ const info = await getPackageInfo("nitro", fromPackage(provider.rootPath));
26
+ const major = parseInt(info?.version?.split(".")[0] ?? "", 10);
27
+ return isNaN(major) ? 3 : major;
20
28
  } catch {
29
+ return 2;
21
30
  }
22
- return 2;
23
31
  }
24
32
  async function findDefaultSdkInitFile(type, nuxt, options) {
25
33
  const possibleFileExtensions = ["ts", "js", "mjs", "cjs", "mts", "cts"];
@@ -123,6 +131,23 @@ export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };
123
131
  )
124
132
  );
125
133
  }
134
+ function toResolvablePath(source) {
135
+ if (!source.startsWith("file://")) {
136
+ return { path: source, wasFileUrl: false };
137
+ }
138
+ if (source === "file://" || source === "file:///") {
139
+ return void 0;
140
+ }
141
+ try {
142
+ const filePath = fileURLToPath(source);
143
+ if (!filePath || filePath === "/" || filePath === "\\") {
144
+ return void 0;
145
+ }
146
+ return { path: filePath, wasFileUrl: true };
147
+ } catch {
148
+ return void 0;
149
+ }
150
+ }
126
151
  function addOTelCommonJSImportAlias(nuxt, isNitroV3 = false) {
127
152
  if (!nuxt.options.dev || isNitroV3) {
128
153
  return;
@@ -136,6 +161,14 @@ function addOTelCommonJSImportAlias(nuxt, isNitroV3 = false) {
136
161
  }
137
162
 
138
163
  const SERVER_CONFIG_FILENAME = "sentry.server.config";
164
+ const CONFIG_EXTENSIONS = [".ts", ".js", ".mjs", ".cjs", ".mts", ".cts"];
165
+ function isServerConfigFile(sourcePath, resolvedPath) {
166
+ if (sourcePath === resolvedPath) {
167
+ return true;
168
+ }
169
+ const name = basename(sourcePath);
170
+ return name === SERVER_CONFIG_FILENAME || CONFIG_EXTENSIONS.some((ext) => name === `${SERVER_CONFIG_FILENAME}${ext}`);
171
+ }
139
172
  function addServerConfigToBuild(moduleOptions, nitro, serverConfigFile) {
140
173
  nitro.hooks.hook("rollup:before", (nitro2, rollupConfig) => {
141
174
  if (rollupConfig?.plugins === null || rollupConfig?.plugins === void 0) {
@@ -186,7 +219,7 @@ function addDynamicImportEntryFileWrapper(nitro, serverConfigFile, moduleOptions
186
219
  }
187
220
  nitro.options.rollupConfig.plugins.push(
188
221
  wrapEntryWithDynamicImport({
189
- resolvedSentryConfigPath: createResolver(nitro.options.rootDir).resolve(`/${serverConfigFile}`),
222
+ resolvedSentryConfigPath: createResolver(nitro.options.rootDir).resolve(serverConfigFile),
190
223
  experimental_entrypointWrappedFunctions: moduleOptions.experimental_entrypointWrappedFunctions
191
224
  })
192
225
  );
@@ -196,7 +229,7 @@ function injectServerConfigPlugin(nitro, serverConfigFile, isDebug) {
196
229
  return {
197
230
  name: "rollup-plugin-inject-sentry-server-config",
198
231
  buildStart() {
199
- const configPath = createResolver(nitro.options.rootDir).resolve(`/${serverConfigFile}`);
232
+ const configPath = createResolver(nitro.options.rootDir).resolve(serverConfigFile);
200
233
  if (!existsSync(configPath)) {
201
234
  if (isDebug) {
202
235
  debug.log(`[Sentry] Sentry server config file not found: ${configPath}`);
@@ -212,7 +245,7 @@ function injectServerConfigPlugin(nitro, serverConfigFile, isDebug) {
212
245
  resolveId(source) {
213
246
  if (source.startsWith(filePrefix)) {
214
247
  const originalFilePath = source.replace(filePrefix, "");
215
- const configPath = createResolver(nitro.options.rootDir).resolve(`/${originalFilePath}`);
248
+ const configPath = createResolver(nitro.options.rootDir).resolve(originalFilePath);
216
249
  return { id: configPath };
217
250
  }
218
251
  return null;
@@ -228,14 +261,19 @@ function wrapEntryWithDynamicImport({
228
261
  return {
229
262
  name: "sentry-wrap-entry-with-dynamic-import",
230
263
  async resolveId(source, importer, options) {
231
- if (source.includes(`/${SERVER_CONFIG_FILENAME}`)) {
232
- return { id: source, moduleSideEffects: true };
264
+ const resolvable = toResolvablePath(source);
265
+ if (!resolvable) {
266
+ return null;
267
+ }
268
+ const { path: normalizedSource, wasFileUrl } = resolvable;
269
+ if (isServerConfigFile(normalizedSource, resolvedSentryConfigPath)) {
270
+ return { id: normalizedSource, moduleSideEffects: true };
233
271
  }
234
272
  if (source === "import-in-the-middle/hook.mjs") {
235
273
  return { id: source, moduleSideEffects: true, external: true };
236
274
  }
237
- if (options.isEntry && source.includes(".mjs") && !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {
238
- const resolution = await this.resolve(source, importer, options);
275
+ if (options.isEntry && normalizedSource.includes(".mjs") && !normalizedSource.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {
276
+ const resolution = await this.resolve(normalizedSource, importer, options);
239
277
  if (!resolution || resolution?.external) return resolution;
240
278
  const moduleInfo = await this.load(resolution);
241
279
  moduleInfo.moduleSideEffects = true;
@@ -247,16 +285,23 @@ function wrapEntryWithDynamicImport({
247
285
  )
248
286
  ).concat(QUERY_END_INDICATOR)}`;
249
287
  }
288
+ if (wasFileUrl) {
289
+ const resolved = await this.resolve(normalizedSource, importer, { ...options, isEntry: false });
290
+ if (resolved) return resolved;
291
+ return { id: normalizedSource };
292
+ }
250
293
  return null;
251
294
  },
252
295
  load(id) {
253
296
  if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {
254
297
  const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);
255
- const reExportedFunctions = id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS) ? constructFunctionReExport(id, entryId) : "";
298
+ const entryIdUrl = pathToFileURL(entryId).href;
299
+ const configUrl = pathToFileURL(resolvedSentryConfigPath).href;
300
+ const reExportedFunctions = id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS) ? constructFunctionReExport(id, entryIdUrl) : "";
256
301
  return (
257
302
  // Regular `import` of the Sentry config
258
- `import ${JSON.stringify(resolvedSentryConfigPath)};
259
- import(${JSON.stringify(entryId)});
303
+ `import ${JSON.stringify(configUrl)};
304
+ import(${JSON.stringify(entryIdUrl)});
260
305
  import 'import-in-the-middle/hook.mjs';
261
306
  ${reExportedFunctions}
262
307
  `
@@ -749,7 +794,7 @@ var module$1 = defineNuxtModule({
749
794
  });
750
795
  }
751
796
  const serverConfigFile = await findDefaultSdkInitFile("server", nuxt, moduleOptions);
752
- const isNitroV3 = await getNitroMajorVersion() >= 3;
797
+ const isNitroV3 = await getNitroMajorVersion(nuxt.options.rootDir) >= 3;
753
798
  const nuxtMajor = parseInt(nuxt._version?.split(".")[0] ?? "3", 10);
754
799
  const isMinNuxtV4 = nuxtMajor >= 4;
755
800
  if (serverConfigFile) {
@@ -1,4 +1,5 @@
1
1
  import type { Nitro } from 'nitropack';
2
+ import type { InputPluginOption } from 'rollup';
2
3
  import type { SentryNuxtModuleOptions } from '../common/types';
3
4
  /**
4
5
  * 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.
@@ -20,3 +21,15 @@ export declare function addSentryTopImport(moduleOptions: SentryNuxtModuleOption
20
21
  * See: https://nodejs.org/api/module.html#enabling
21
22
  */
22
23
  export declare function addDynamicImportEntryFileWrapper(nitro: Nitro, serverConfigFile: string, moduleOptions: Omit<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'> & Required<Pick<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'>>): void;
24
+ /**
25
+ * A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first
26
+ * by using a regular `import` and load the server after that.
27
+ * This also works with serverless `handler` functions, as it re-exports the `handler`.
28
+ *
29
+ * Only exported for testing.
30
+ */
31
+ export declare function wrapEntryWithDynamicImport({ resolvedSentryConfigPath, experimental_entrypointWrappedFunctions, debug, }: {
32
+ resolvedSentryConfigPath: string;
33
+ experimental_entrypointWrappedFunctions: string[];
34
+ debug?: boolean;
35
+ }): InputPluginOption;
@@ -1,10 +1,16 @@
1
1
  import type { Nuxt } from '@nuxt/schema';
2
2
  import type { SentryNuxtModuleOptions } from '../common/types';
3
3
  /**
4
- * Gets the major version of the installed nitro package.
5
- * Returns 2 as the default if nitro is not found or the version cannot be determined.
4
+ * Gets the major version of the Nitro package used by the app's Nuxt installation.
5
+ * Returns 2 as the default if the version cannot be determined.
6
+ *
7
+ * Nitro v2 is published as `nitropack`, v3 as `nitro`. Resolving `nitro` directly is
8
+ * unreliable: module resolution walks up the directory tree, so in a monorepo an
9
+ * unrelated `nitro` v3 above the app wins even when the app's Nuxt uses `nitropack` v2.
10
+ * Instead, follow the dependency chain Nuxt itself imports Nitro through:
11
+ * `nuxt` -> (`@nuxt/nitro-server` ->) `nitro` | `nitropack`.
6
12
  */
7
- export declare function getNitroMajorVersion(): Promise<number>;
13
+ export declare function getNitroMajorVersion(rootDir: string): Promise<number>;
8
14
  /**
9
15
  * Find the default SDK init file for the given type (client or server).
10
16
  * The sentry.server.config file is prioritized over the instrument.server file.
@@ -45,6 +51,17 @@ export declare function constructWrappedFunctionExportQuery(exportedBindings: Re
45
51
  * Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)
46
52
  */
47
53
  export declare function constructFunctionReExport(pathWithQuery: string, entryId: string): string;
54
+ /**
55
+ * `load()` emits `file://` specifiers because Node's ESM loader rejects bare Windows
56
+ * paths (`ERR_UNSUPPORTED_ESM_URL_SCHEME`), but Rollup's resolver only understands
57
+ * filesystem paths. Returns `undefined` for a malformed `file://` URL.
58
+ *
59
+ * Only exported for testing.
60
+ */
61
+ export declare function toResolvablePath(source: string): {
62
+ path: string;
63
+ wasFileUrl: boolean;
64
+ } | undefined;
48
65
  /**
49
66
  * Sets up alias to work around OpenTelemetry's incomplete ESM imports.
50
67
  * https://github.com/getsentry/sentry-javascript/issues/15204
@@ -1,4 +1,5 @@
1
1
  import type { Nitro } from 'nitropack';
2
+ import type { InputPluginOption } from 'rollup';
2
3
  import type { SentryNuxtModuleOptions } from '../common/types';
3
4
  /**
4
5
  * 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.
@@ -20,4 +21,16 @@ export declare function addSentryTopImport(moduleOptions: SentryNuxtModuleOption
20
21
  * See: https://nodejs.org/api/module.html#enabling
21
22
  */
22
23
  export declare function addDynamicImportEntryFileWrapper(nitro: Nitro, serverConfigFile: string, moduleOptions: Omit<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'> & Required<Pick<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'>>): void;
24
+ /**
25
+ * A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first
26
+ * by using a regular `import` and load the server after that.
27
+ * This also works with serverless `handler` functions, as it re-exports the `handler`.
28
+ *
29
+ * Only exported for testing.
30
+ */
31
+ export declare function wrapEntryWithDynamicImport({ resolvedSentryConfigPath, experimental_entrypointWrappedFunctions, debug, }: {
32
+ resolvedSentryConfigPath: string;
33
+ experimental_entrypointWrappedFunctions: string[];
34
+ debug?: boolean;
35
+ }): InputPluginOption;
23
36
  //# sourceMappingURL=addServerConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"addServerConfig.d.ts","sourceRoot":"","sources":["../../../src/vite/addServerConfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAc/D;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,uBAAuB,EACtC,KAAK,EAAE,KAAK,EACZ,gBAAg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