@sentry/nuxt 11.0.0-beta.2 → 11.0.0-rc.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.
- package/build/cjs/module.js +1 -1
- package/build/cjs/module.js.map +1 -1
- package/build/cjs/vite/addServerConfig.js +14 -10
- package/build/cjs/vite/addServerConfig.js.map +1 -1
- package/build/esm/module.js +1 -1
- package/build/esm/module.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/vite/addServerConfig.js +14 -10
- package/build/esm/vite/addServerConfig.js.map +1 -1
- package/build/module/module.json +1 -1
- package/build/module/module.mjs +15 -11
- package/build/module/runtime/utils/instrumentDatabase.js +25 -23
- package/build/module/vite/addServerConfig.d.ts +1 -1
- package/build/types/index.types.d.ts +1 -0
- package/build/types/index.types.d.ts.map +1 -1
- package/build/types/vite/addServerConfig.d.ts +1 -1
- package/build/types/vite/addServerConfig.d.ts.map +1 -1
- package/package.json +10 -10
package/build/cjs/module.js
CHANGED
|
@@ -68,7 +68,7 @@ const module$1 = kit.defineNuxtModule({
|
|
|
68
68
|
const usesDeprecatedInjectMode = moduleOptions.autoInjectServerSentry === "top-level-import" || moduleOptions.autoInjectServerSentry === "experimental_dynamic-import";
|
|
69
69
|
if (serverConfigFile) {
|
|
70
70
|
if (!usesDeprecatedInjectMode) {
|
|
71
|
-
addServerConfig.addServerConfigPlugin(nuxt, serverConfigFile);
|
|
71
|
+
addServerConfig.addServerConfigPlugin(nuxt, serverConfigFile, !isNitroV3);
|
|
72
72
|
}
|
|
73
73
|
if (isNitroV3) {
|
|
74
74
|
kit.addServerPlugin(moduleDirResolver.resolve("./runtime/plugins/handler.server"));
|
package/build/cjs/module.js.map
CHANGED
|
@@ -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 {\n addDynamicImportEntryFileWrapper,\n addServerConfigShimWithWarning,\n addSentryTopImport,\n addServerConfigPlugin,\n addServerConfigToBuild,\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 { 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 // oxlint-disable-next-line typescript/no-deprecated -- supported until removal\n autoInjectServerSentry: moduleOptionsParam.autoInjectServerSentry,\n // oxlint-disable-next-line typescript/no-deprecated -- supported until removal\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(nuxt.options.rootDir)) >= 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 // The deprecated inject modes replace the default in-bundle initialization until their removal\n const usesDeprecatedInjectMode =\n moduleOptions.autoInjectServerSentry === 'top-level-import' ||\n moduleOptions.autoInjectServerSentry === 'experimental_dynamic-import';\n\n if (serverConfigFile) {\n if (!usesDeprecatedInjectMode) {\n addServerConfigPlugin(nuxt, serverConfigFile);\n }\n\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, isNitroV3);\n\n if (!usesDeprecatedInjectMode) {\n addServerConfigShimWithWarning(nitro);\n\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Bundled \\`${serverConfigFile}\\` into the Nitro server build. The SDK initializes itself at server startup — no \\`node --import\\` preload needed.`,\n );\n });\n }\n } else {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] \\`autoInjectServerSentry: '${moduleOptions.autoInjectServerSentry}'\\` is deprecated and will be removed in a future major version. The Sentry server config is bundled into the Nitro server build by default now. Remove the option to use the default behavior.`,\n );\n });\n\n if (moduleOptions.autoInjectServerSentry === 'top-level-import') {\n // Nitro 3 (in Nuxt 5) is not bundled in dev mode, so there is no build to emit into.\n if (!(isNitroV3 && nitro.options.dev)) {\n addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);\n }\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});\n"],"names":["defineNuxtModule","createResolver","findDefaultSdkInitFile","addPluginTemplate","addPlugin","getNitroMajorVersion","setupOrchestrion","addServerConfigPlugin","addServerPlugin","addMiddlewareImports","addStorageInstrumentation","addDatabaseInstrumentation","setupSourceMaps","addVitePlugin","addOTelCommonJSImportAlias","addTemplate","addMiddlewareInstrumentation","addServerConfigShimWithWarning","consoleSandbox","addServerConfig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
|
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 addDynamicImportEntryFileWrapper,\n addServerConfigShimWithWarning,\n addSentryTopImport,\n addServerConfigPlugin,\n addServerConfigToBuild,\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 { 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 // oxlint-disable-next-line typescript/no-deprecated -- supported until removal\n autoInjectServerSentry: moduleOptionsParam.autoInjectServerSentry,\n // oxlint-disable-next-line typescript/no-deprecated -- supported until removal\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(nuxt.options.rootDir)) >= 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 // The deprecated inject modes replace the default in-bundle initialization until their removal\n const usesDeprecatedInjectMode =\n moduleOptions.autoInjectServerSentry === 'top-level-import' ||\n moduleOptions.autoInjectServerSentry === 'experimental_dynamic-import';\n\n if (serverConfigFile) {\n if (!usesDeprecatedInjectMode) {\n addServerConfigPlugin(nuxt, serverConfigFile, !isNitroV3);\n }\n\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, isNitroV3);\n\n if (!usesDeprecatedInjectMode) {\n addServerConfigShimWithWarning(nitro);\n\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Bundled \\`${serverConfigFile}\\` into the Nitro server build. The SDK initializes itself at server startup — no \\`node --import\\` preload needed.`,\n );\n });\n }\n } else {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] \\`autoInjectServerSentry: '${moduleOptions.autoInjectServerSentry}'\\` is deprecated and will be removed in a future major version. The Sentry server config is bundled into the Nitro server build by default now. Remove the option to use the default behavior.`,\n );\n });\n\n if (moduleOptions.autoInjectServerSentry === 'top-level-import') {\n // Nitro 3 (in Nuxt 5) is not bundled in dev mode, so there is no build to emit into.\n if (!(isNitroV3 && nitro.options.dev)) {\n addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);\n }\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});\n"],"names":["defineNuxtModule","createResolver","findDefaultSdkInitFile","addPluginTemplate","addPlugin","getNitroMajorVersion","setupOrchestrion","addServerConfigPlugin","addServerPlugin","addMiddlewareImports","addStorageInstrumentation","addDatabaseInstrumentation","setupSourceMaps","addVitePlugin","addOTelCommonJSImportAlias","addTemplate","addMiddlewareInstrumentation","addServerConfigShimWithWarning","consoleSandbox","addServerConfigToBuild","addSentryTopImport","addDynamicImportEntryFileWrapper"],"mappings":";;;;;;;;;;;;AAgCA,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;AAAA,MAEH,wBAAwB,kBAAA,CAAmB,sBAAA;AAAA;AAAA,MAE3C,uCAAA,EAAyC,mBAAmB,uCAAA,IAA2C;AAAA,QACrG,SAAA;AAAA,QACA,SAAA;AAAA,QACA;AAAA;AACF,KACF;AAEA,IAAA,MAAM,iBAAA,GAAoBC,kBAAA,CAAe,2PAAe,CAAA;AACxD,IAAA,MAAM,gBAAA,GAAmBA,kBAAA,CAAe,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AAE7D,IAAA,MAAM,gBAAA,GAAmB,MAAMC,4BAAA,CAAuB,QAAA,EAAU,MAAM,aAAa,CAAA;AAEnF,IAAA,IAAI,gBAAA,EAAkB;AAEpB,MAAAC,qBAAA,CAAkB;AAAA,QAChB,IAAA,EAAM,QAAA;AAAA,QACN,QAAA,EAAU,0BAAA;AAAA,QACV,KAAA,EAAO,CAAA;AAAA;AAAA;AAAA,QAIP,aAAa,MAAM;AAAA;;AAAA;AAAA;AAAA;AAAA,4BAAA,EAMG,gBAAA,C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BAAA,OAAA,CAAQ,GAAA;AAAA,kBACN;AAAA,iBACF;AAAA,cACF,CAAC,CAAA;AAAA,YACH;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AACF,CAAC,CAAA;;;;"}
|
|
@@ -56,7 +56,7 @@ ${data}`;
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
function addServerConfigPlugin(nuxt, serverConfigFile) {
|
|
59
|
+
function addServerConfigPlugin(nuxt, serverConfigFile, isLegacyNitro) {
|
|
60
60
|
const configPath = kit.createResolver(nuxt.options.rootDir).resolve(serverConfigFile);
|
|
61
61
|
const runtimeFlagsTemplate = kit.addTemplate({
|
|
62
62
|
filename: "sentry-runtime-flags.mjs",
|
|
@@ -77,11 +77,13 @@ export default () => {};
|
|
|
77
77
|
`
|
|
78
78
|
});
|
|
79
79
|
kit.addServerPlugin(configPluginTemplate.dst);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
if (isLegacyNitro) {
|
|
81
|
+
nuxt.options.nitro.moduleSideEffects = [
|
|
82
|
+
...nuxt.options.nitro.moduleSideEffects ?? [],
|
|
83
|
+
configPath,
|
|
84
|
+
runtimeFlagsTemplate.dst
|
|
85
|
+
];
|
|
86
|
+
}
|
|
85
87
|
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
86
88
|
if (utils.isCloudflarePreset(nitroConfig.preset)) {
|
|
87
89
|
nitroConfig.plugins = (nitroConfig.plugins ?? []).filter((plugin) => plugin !== configPluginTemplate.dst);
|
|
@@ -89,10 +91,12 @@ export default () => {};
|
|
|
89
91
|
}
|
|
90
92
|
const plugins = nitroConfig.plugins ?? [];
|
|
91
93
|
nitroConfig.plugins = [configPluginTemplate.dst, ...plugins.filter((plugin) => plugin !== configPluginTemplate.dst)];
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
if (isLegacyNitro) {
|
|
95
|
+
const externals = nitroConfig.externals ?? (nitroConfig.externals = {});
|
|
96
|
+
const inline = externals.inline;
|
|
97
|
+
const existingInline = Array.isArray(inline) ? inline : inline ? [inline] : [];
|
|
98
|
+
externals.inline = [...existingInline, configPath, configPluginTemplate.dst, runtimeFlagsTemplate.dst];
|
|
99
|
+
}
|
|
96
100
|
});
|
|
97
101
|
nuxt.hook("nitro:init", (nitro) => {
|
|
98
102
|
if (nuxt.options._prepare || !utils.isCloudflarePreset(nitro.options.preset)) {
|
|
@@ -1 +1 @@
|
|
|
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 { addServerPlugin, addTemplate, createResolver } from '@nuxt/kit';\nimport type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox, debug } from '@sentry/core';\nimport * as fs from 'fs';\nimport type { Nitro } from 'nitropack';\nimport type { InputPluginOption } from 'rollup';\nimport { NUXT_DEV_MODE_FLAG, NUXT_PRERENDER_FLAG } from '../common/devMode';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport {\n constructFunctionReExport,\n constructWrappedFunctionExportQuery,\n getFilenameFromNodeStartCommand,\n isCloudflarePreset,\n QUERY_END_INDICATOR,\n removeSentryQueryFromPath,\n SENTRY_REEXPORTED_FUNCTIONS,\n SENTRY_WRAPPED_ENTRY,\n SENTRY_WRAPPED_FUNCTIONS,\n SERVER_CONFIG_FILENAME,\n toResolvablePath,\n} from './utils';\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 * Registers a Nitro plugin that statically imports the Sentry server config, so the SDK initializes\n * at server startup without a `node --import` preload.\n */\nexport function addServerConfigPlugin(nuxt: Nuxt, serverConfigFile: string): void {\n const configPath = createResolver(nuxt.options.rootDir).resolve(serverConfigFile);\n\n // `Sentry.init` reads these flags, and a statement above the config import would not survive\n // import hoisting — so they live in their own module which is imported first.\n const runtimeFlagsTemplate = addTemplate({\n filename: 'sentry-runtime-flags.mjs',\n write: true,\n getContents: () =>\n [\n '// Generated by @sentry/nuxt. Sets runtime flags before the Sentry server config evaluates.',\n `globalThis.${NUXT_DEV_MODE_FLAG} = import.meta.dev === true;`,\n `globalThis.${NUXT_PRERENDER_FLAG} = import.meta.prerender === true;`,\n '',\n ].join('\\n'),\n });\n\n const configPluginTemplate = addTemplate({\n filename: 'sentry-server-config-plugin.mjs',\n write: true,\n getContents: () =>\n `import ${JSON.stringify(runtimeFlagsTemplate.dst)};\\nimport ${JSON.stringify(configPath)};\\nexport default () => {};\\n`,\n });\n\n addServerPlugin(configPluginTemplate.dst);\n\n // Nitro treeshakes side-effect-only imports outside its runtime dir, which would silently drop\n // the top-level `Sentry.init` and the flag assignments.\n nuxt.options.nitro.moduleSideEffects = [\n ...(nuxt.options.nitro.moduleSideEffects ?? []),\n configPath,\n runtimeFlagsTemplate.dst,\n ];\n\n nuxt.hook('nitro:config', nitroConfig => {\n // Early skip for explicitly configured Cloudflare presets. The authoritative check runs on\n // `nitro:init`: env-derived presets (`NITRO_PRESET`, Cloudflare Pages CI) resolve only inside Nitro.\n if (isCloudflarePreset(nitroConfig.preset)) {\n nitroConfig.plugins = (nitroConfig.plugins ?? []).filter(plugin => plugin !== configPluginTemplate.dst);\n return;\n }\n\n // Front the config plugin so `Sentry.init` evaluates before plugins registered by other Nuxt\n // modules (Nitro appends scanned user plugins after the configured ones anyway).\n const plugins = nitroConfig.plugins ?? [];\n nitroConfig.plugins = [configPluginTemplate.dst, ...plugins.filter(plugin => plugin !== configPluginTemplate.dst)];\n\n // The Nitro v2 dev bundle would otherwise externalize these files, making Node load the raw\n // `.ts` config — which needs type stripping (Node >= 22.18). Inlining keeps them transpiled.\n const externals = (nitroConfig.externals ??= {});\n const inline = externals.inline;\n const existingInline = Array.isArray(inline) ? inline : inline ? [inline] : [];\n externals.inline = [...existingInline, configPath, configPluginTemplate.dst, runtimeFlagsTemplate.dst];\n });\n\n // On Cloudflare the SDK is set up through `sentryCloudflareNitroPlugin`; the Node SDK config\n // must not end up in the worker bundle. `nitro.options.preset` is resolved here.\n nuxt.hook('nitro:init', nitro => {\n if (nuxt.options._prepare || !isCloudflarePreset(nitro.options.preset)) {\n return;\n }\n\n nitro.options.plugins = (nitro.options.plugins ?? []).filter(plugin => plugin !== configPluginTemplate.dst);\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Found \\`${basename(configPath)}\\`, but the Nitro preset targets Cloudflare, where this file is not used. Set up the SDK with \\`sentryCloudflareNitroPlugin\\` instead: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/cloudflare-workers/`,\n );\n });\n });\n}\n\n/**\n * Writes a shim to the former `--import` config path, so existing `node --import` start commands\n * keep working now that the config is bundled into the server build.\n */\nexport function addServerConfigShimWithWarning(nitro: Nitro): void {\n nitro.hooks.hook('close', async () => {\n if (nitro.options.dev || nitro.options.preset === 'nitro-prerender' || isCloudflarePreset(nitro.options.preset)) {\n return;\n }\n\n const shimPath = createResolver(nitro.options.output.serverDir).resolve(`${SERVER_CONFIG_FILENAME}.mjs`);\n const contents = [\n '// Generated by @sentry/nuxt.',\n '// The Sentry server config is bundled into the server build and initializes automatically.',\n '// This file only keeps existing `node --import ./.output/server/sentry.server.config.mjs` commands working.',\n \"console.warn('[Sentry] The `--import` flag for the Sentry server config is no longer needed and should be removed.');\",\n '',\n ].join('\\n');\n\n try {\n await fs.promises.writeFile(shimPath, contents, 'utf8');\n } catch (error) {\n // A missing shim breaks `node --import` start commands, so always warn (`debug` is off at build time).\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(`[Sentry] Could not write the \\`--import\\` compatibility shim to ${shimPath}`, error);\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 // oxlint-disable-next-line typescript/no-deprecated -- supported until removal\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":["basename","SERVER_CONFIG_FILENAME","nitro","getFilenameFromNodeStartCommand","createResolver","addTemplate","NUXT_DEV_MODE_FLAG","NUXT_PRERENDER_FLAG","addServerPlugin","isCloudflarePreset","consoleSandbox","existsSync","debug","toResolvablePath","SENTRY_WRAPPED_ENTRY","constructWrappedFunctionExportQuery","QUERY_END_INDICATOR","removeSentryQueryFromPath","pathToFileURL","SENTRY_WRAPPED_FUNCTIONS","SENTRY_REEXPORTED_FUNCTIONS","constructFunctionReExport"],"mappings":";;;;;;;;;;;AAyBA,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,GAAOA,cAAS,UAAU,CAAA;AAChC,EAAA,OAAO,IAAA,KAASC,4BAAA,IAA0B,iBAAA,CAAkB,IAAA,CAAK,CAAA,GAAA,KAAO,SAAS,CAAA,EAAGA,4BAAsB,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,CAACC,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,C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,EAAiB;AAAA,MAChC;AAEA,MAAA,OAAO,IAAA;AAAA,IACT,CAAA;AAAA,IACA,KAAK,EAAA,EAAY;AACf,MAAA,IAAI,EAAA,CAAG,QAAA,CAAS,CAAA,IAAA,EAAOF,0BAAoB,EAAE,CAAA,EAAG;AAC9C,QAAA,MAAM,UAAUG,+BAAA,CAA0B,EAAE,CAAA,CAAE,KAAA,CAAM,mBAAmB,MAAM,CAAA;AAC7E,QAAA,MAAM,UAAA,GAAaC,sBAAA,CAAc,OAAO,CAAA,CAAE,IAAA;AAC1C,QAAA,MAAM,SAAA,GAAYA,sBAAA,CAAc,wBAAwB,CAAA,CAAE,IAAA;AAI1D,QAAA,MAAM,mBAAA,GACJ,EAAA,CAAG,QAAA,CAASC,8BAAwB,CAAA,IAAK,EAAA,CAAG,QAAA,CAASC,iCAA2B,CAAA,GAC5EC,+BAAA,CAA0B,EAAA,EAAI,UAAU,CAAA,GACxC,EAAA;AAEN,QAAA;AAAA;AAAA,UAEE,CAAA,OAAA,EAAU,IAAA,CAAK,SAAA,CAAU,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;;;;;;;;;"}
|
|
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 { addServerPlugin, addTemplate, createResolver } from '@nuxt/kit';\nimport type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox, debug } from '@sentry/core';\nimport * as fs from 'fs';\nimport type { Nitro } from 'nitropack';\nimport type { InputPluginOption } from 'rollup';\nimport { NUXT_DEV_MODE_FLAG, NUXT_PRERENDER_FLAG } from '../common/devMode';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport {\n constructFunctionReExport,\n constructWrappedFunctionExportQuery,\n getFilenameFromNodeStartCommand,\n isCloudflarePreset,\n QUERY_END_INDICATOR,\n removeSentryQueryFromPath,\n SENTRY_REEXPORTED_FUNCTIONS,\n SENTRY_WRAPPED_ENTRY,\n SENTRY_WRAPPED_FUNCTIONS,\n SERVER_CONFIG_FILENAME,\n toResolvablePath,\n} from './utils';\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 * Registers a Nitro plugin that statically imports the Sentry server config, so the SDK initializes\n * at server startup without a `node --import` preload.\n */\nexport function addServerConfigPlugin(nuxt: Nuxt, serverConfigFile: string, isLegacyNitro: boolean): void {\n const configPath = createResolver(nuxt.options.rootDir).resolve(serverConfigFile);\n\n // `Sentry.init` reads these flags, and a statement above the config import would not survive\n // import hoisting — so they live in their own module which is imported first.\n const runtimeFlagsTemplate = addTemplate({\n filename: 'sentry-runtime-flags.mjs',\n write: true,\n getContents: () =>\n [\n '// Generated by @sentry/nuxt. Sets runtime flags before the Sentry server config evaluates.',\n `globalThis.${NUXT_DEV_MODE_FLAG} = import.meta.dev === true;`,\n `globalThis.${NUXT_PRERENDER_FLAG} = import.meta.prerender === true;`,\n '',\n ].join('\\n'),\n });\n\n const configPluginTemplate = addTemplate({\n filename: 'sentry-server-config-plugin.mjs',\n write: true,\n getContents: () =>\n `import ${JSON.stringify(runtimeFlagsTemplate.dst)};\\nimport ${JSON.stringify(configPath)};\\nexport default () => {};\\n`,\n });\n\n addServerPlugin(configPluginTemplate.dst);\n\n // Nitro v2 treeshakes side-effect-only imports outside its runtime dir, which would silently drop\n // the top-level `Sentry.init` and the flag assignments.\n // Nitro v3 dropped the option and keeps both.\n if (isLegacyNitro) {\n nuxt.options.nitro.moduleSideEffects = [\n ...(nuxt.options.nitro.moduleSideEffects ?? []),\n configPath,\n runtimeFlagsTemplate.dst,\n ];\n }\n\n nuxt.hook('nitro:config', nitroConfig => {\n // Early skip for explicitly configured Cloudflare presets. The authoritative check runs on\n // `nitro:init`: env-derived presets (`NITRO_PRESET`, Cloudflare Pages CI) resolve only inside Nitro.\n if (isCloudflarePreset(nitroConfig.preset)) {\n nitroConfig.plugins = (nitroConfig.plugins ?? []).filter(plugin => plugin !== configPluginTemplate.dst);\n return;\n }\n\n // Front the config plugin so `Sentry.init` evaluates before plugins registered by other Nuxt\n // modules (Nitro appends scanned user plugins after the configured ones anyway).\n const plugins = nitroConfig.plugins ?? [];\n nitroConfig.plugins = [configPluginTemplate.dst, ...plugins.filter(plugin => plugin !== configPluginTemplate.dst)];\n\n // The Nitro v2 dev bundle would otherwise externalize these files, making Node load the raw\n // `.ts` config — which needs type stripping (Node >= 22.18). Inlining keeps them transpiled.\n // Nitro v3 has no `externals` option; its dev server runs the config through Vite's transform.\n if (isLegacyNitro) {\n const externals = (nitroConfig.externals ??= {});\n const inline = externals.inline;\n const existingInline = Array.isArray(inline) ? inline : inline ? [inline] : [];\n externals.inline = [...existingInline, configPath, configPluginTemplate.dst, runtimeFlagsTemplate.dst];\n }\n });\n\n // On Cloudflare the SDK is set up through `sentryCloudflareNitroPlugin`; the Node SDK config\n // must not end up in the worker bundle. `nitro.options.preset` is resolved here.\n nuxt.hook('nitro:init', nitro => {\n if (nuxt.options._prepare || !isCloudflarePreset(nitro.options.preset)) {\n return;\n }\n\n nitro.options.plugins = (nitro.options.plugins ?? []).filter(plugin => plugin !== configPluginTemplate.dst);\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Found \\`${basename(configPath)}\\`, but the Nitro preset targets Cloudflare, where this file is not used. Set up the SDK with \\`sentryCloudflareNitroPlugin\\` instead: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/cloudflare-workers/`,\n );\n });\n });\n}\n\n/**\n * Writes a shim to the former `--import` config path, so existing `node --import` start commands\n * keep working now that the config is bundled into the server build.\n */\nexport function addServerConfigShimWithWarning(nitro: Nitro): void {\n nitro.hooks.hook('close', async () => {\n if (nitro.options.dev || nitro.options.preset === 'nitro-prerender' || isCloudflarePreset(nitro.options.preset)) {\n return;\n }\n\n const shimPath = createResolver(nitro.options.output.serverDir).resolve(`${SERVER_CONFIG_FILENAME}.mjs`);\n const contents = [\n '// Generated by @sentry/nuxt.',\n '// The Sentry server config is bundled into the server build and initializes automatically.',\n '// This file only keeps existing `node --import ./.output/server/sentry.server.config.mjs` commands working.',\n \"console.warn('[Sentry] The `--import` flag for the Sentry server config is no longer needed and should be removed.');\",\n '',\n ].join('\\n');\n\n try {\n await fs.promises.writeFile(shimPath, contents, 'utf8');\n } catch (error) {\n // A missing shim breaks `node --import` start commands, so always warn (`debug` is off at build time).\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(`[Sentry] Could not write the \\`--import\\` compatibility shim to ${shimPath}`, error);\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 // oxlint-disable-next-line typescript/no-deprecated -- supported until removal\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":["basename","SERVER_CONFIG_FILENAME","nitro","getFilenameFromNodeStartCommand","createResolver","addTemplate","NUXT_DEV_MODE_FLAG","NUXT_PRERENDER_FLAG","addServerPlugin","isCloudflarePreset","consoleSandbox","existsSync","debug","toResolvablePath","SENTRY_WRAPPED_ENTRY","constructWrappedFunctionExportQuery","QUERY_END_INDICATOR","removeSentryQueryFromPath","pathToFileURL","SENTRY_WRAPPED_FUNCTIONS","SENTRY_REEXPORTED_FUNCTIONS","constructFunctionReExport"],"mappings":";;;;;;;;;;;AAyBA,MAAM,oBAAoB,CAAC,KAAA,EAAO,OAAO,MAAA,EAAQ,MAAA,EAAQ,QAAQ,MAAM,C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CAA2B,CAAA,GAC5EC,+BAAA,CAA0B,EAAA,EAAI,UAAU,CAAA,GACxC,EAAA;AAEN,QAAA;AAAA;AAAA,UAEE,CAAA,OAAA,EAAU,IAAA,CAAK,SAAA,CAAU,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;;;;;;;;;"}
|
package/build/esm/module.js
CHANGED
|
@@ -67,7 +67,7 @@ const module$1 = defineNuxtModule({
|
|
|
67
67
|
const usesDeprecatedInjectMode = moduleOptions.autoInjectServerSentry === "top-level-import" || moduleOptions.autoInjectServerSentry === "experimental_dynamic-import";
|
|
68
68
|
if (serverConfigFile) {
|
|
69
69
|
if (!usesDeprecatedInjectMode) {
|
|
70
|
-
addServerConfigPlugin(nuxt, serverConfigFile);
|
|
70
|
+
addServerConfigPlugin(nuxt, serverConfigFile, !isNitroV3);
|
|
71
71
|
}
|
|
72
72
|
if (isNitroV3) {
|
|
73
73
|
addServerPlugin(moduleDirResolver.resolve("./runtime/plugins/handler.server"));
|
package/build/esm/module.js.map
CHANGED
|
@@ -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 {\n addDynamicImportEntryFileWrapper,\n addServerConfigShimWithWarning,\n addSentryTopImport,\n addServerConfigPlugin,\n addServerConfigToBuild,\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 { 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 // oxlint-disable-next-line typescript/no-deprecated -- supported until removal\n autoInjectServerSentry: moduleOptionsParam.autoInjectServerSentry,\n // oxlint-disable-next-line typescript/no-deprecated -- supported until removal\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(nuxt.options.rootDir)) >= 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 // The deprecated inject modes replace the default in-bundle initialization until their removal\n const usesDeprecatedInjectMode =\n moduleOptions.autoInjectServerSentry === 'top-level-import' ||\n moduleOptions.autoInjectServerSentry === 'experimental_dynamic-import';\n\n if (serverConfigFile) {\n if (!usesDeprecatedInjectMode) {\n addServerConfigPlugin(nuxt, serverConfigFile);\n }\n\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, isNitroV3);\n\n if (!usesDeprecatedInjectMode) {\n addServerConfigShimWithWarning(nitro);\n\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Bundled \\`${serverConfigFile}\\` into the Nitro server build. The SDK initializes itself at server startup — no \\`node --import\\` preload needed.`,\n );\n });\n }\n } else {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] \\`autoInjectServerSentry: '${moduleOptions.autoInjectServerSentry}'\\` is deprecated and will be removed in a future major version. The Sentry server config is bundled into the Nitro server build by default now. Remove the option to use the default behavior.`,\n );\n });\n\n if (moduleOptions.autoInjectServerSentry === 'top-level-import') {\n // Nitro 3 (in Nuxt 5) is not bundled in dev mode, so there is no build to emit into.\n if (!(isNitroV3 && nitro.options.dev)) {\n addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);\n }\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});\n"],"names":[],"mappings":";;;;;;;;;;;AAgCA,iBAAe,gBAAA,CAAgC;AAAA,EAC7C,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM,qBAAA;AAAA,IACN,SAAA,EAAW,QAAA;AAAA,IACX,aAAA,EAAe;AAAA,MACb,IAAA,EAAM;AAAA;AACR,GACF;AAAA,EACA,UAAU,EAAC;AAAA,EACX,MAAM,KAAA,CAAM,kBAAA,EAAoB,IAAA,EAAM;AACpC,IAAA,IAAI,kBAAA,EAAoB,YAAY,KAAA,EAAO;AACzC,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,aAAA,GAAgB;AAAA,MACpB,GAAG,kBAAA;AAAA;AAAA,MAEH,wBAAwB,kBAAA,CAAmB,sBAAA;AAAA;AAAA,MAE3C,uCAAA,EAAyC,mBAAmB,uCAAA,IAA2C;AAAA,QACrG,SAAA;AAA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CAAA;AAED,UAAA,IAAI,aAAA,CAAc,2BAA2B,kBAAA,EAAoB;AAE/D,YAAA,IAAI,EAAE,SAAA,IAAa,KAAA,CAAM,OAAA,CAAQ,GAAA,CAAA,EAAM;AACrC,cAAA,sBAAA,CAAuB,aAAA,EAAe,OAAO,gBAAgB,CAAA;AAAA,YAC/D;AACA,YAAA,kBAAA,CAAmB,eAAe,KAAK,CAAA;AAAA,UACzC;AAEA,UAAA,IAAI,aAAA,CAAc,2BAA2B,6BAAA,EAA+B;AAC1E,YAAA,gCAAA,CAAiC,KAAA,EAAO,kBAAkB,aAAa,CAAA;AAEvE,YAAA,IAAI,cAAc,KAAA,EAAO;AACvB,cAAA,cAAA,CAAe,MAAM;AAEnB,gBAAA,OAAA,CAAQ,GAAA;AAAA,kBACN;AAAA,iBACF;AAAA,cACF,CAAC,CAAA;AAAA,YACH;AAAA,UACF;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 addDynamicImportEntryFileWrapper,\n addServerConfigShimWithWarning,\n addSentryTopImport,\n addServerConfigPlugin,\n addServerConfigToBuild,\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 { 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 // oxlint-disable-next-line typescript/no-deprecated -- supported until removal\n autoInjectServerSentry: moduleOptionsParam.autoInjectServerSentry,\n // oxlint-disable-next-line typescript/no-deprecated -- supported until removal\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(nuxt.options.rootDir)) >= 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 // The deprecated inject modes replace the default in-bundle initialization until their removal\n const usesDeprecatedInjectMode =\n moduleOptions.autoInjectServerSentry === 'top-level-import' ||\n moduleOptions.autoInjectServerSentry === 'experimental_dynamic-import';\n\n if (serverConfigFile) {\n if (!usesDeprecatedInjectMode) {\n addServerConfigPlugin(nuxt, serverConfigFile, !isNitroV3);\n }\n\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, isNitroV3);\n\n if (!usesDeprecatedInjectMode) {\n addServerConfigShimWithWarning(nitro);\n\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Bundled \\`${serverConfigFile}\\` into the Nitro server build. The SDK initializes itself at server startup — no \\`node --import\\` preload needed.`,\n );\n });\n }\n } else {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] \\`autoInjectServerSentry: '${moduleOptions.autoInjectServerSentry}'\\` is deprecated and will be removed in a future major version. The Sentry server config is bundled into the Nitro server build by default now. Remove the option to use the default behavior.`,\n );\n });\n\n if (moduleOptions.autoInjectServerSentry === 'top-level-import') {\n // Nitro 3 (in Nuxt 5) is not bundled in dev mode, so there is no build to emit into.\n if (!(isNitroV3 && nitro.options.dev)) {\n addServerConfigToBuild(moduleOptions, nitro, serverConfigFile);\n }\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});\n"],"names":[],"mappings":";;;;;;;;;;;AAgCA,iBAAe,gBAAA,CAAgC;AAAA,EAC7C,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM,qBAAA;AAAA,IACN,SAAA,EAAW,QAAA;AAAA,IACX,aAAA,EAAe;AAAA,MACb,IAAA,EAAM;AAAA;AACR,GACF;AAAA,EACA,UAAU,EAAC;AAAA,EACX,MAAM,KAAA,CAAM,kBAAA,EAAoB,IAAA,EAAM;AACpC,IAAA,IAAI,kBAAA,EAAoB,YAAY,KAAA,EAAO;AACzC,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,aAAA,GAAgB;AAAA,MACpB,GAAG,kBAAA;AAAA;AAAA,MAEH,wBAAwB,kBAAA,CAAmB,sBAAA;AAAA;AAAA,MAE3C,uCAAA,EAAyC,mBAAmB,uCAAA,IAA2C;AAAA,QACrG,SAAA;AAAA,QACA,SAAA;AAAA,QACA;AAAA;AACF,KACF;AAEA,IAAA,MAAM,iBAAA,GAAoB,cAAA,CAAe,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACxD,IAAA,MAAM,gBAAA,GAAmB,cAA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EAAM;AACrC,cAAA,sBAAA,CAAuB,aAAA,EAAe,OAAO,gBAAgB,CAAA;AAAA,YAC/D;AACA,YAAA,kBAAA,CAAmB,eAAe,KAAK,CAAA;AAAA,UACzC;AAEA,UAAA,IAAI,aAAA,CAAc,2BAA2B,6BAAA,EAA+B;AAC1E,YAAA,gCAAA,CAAiC,KAAA,EAAO,kBAAkB,aAAa,CAAA;AAEvE,YAAA,IAAI,cAAc,KAAA,EAAO;AACvB,cAAA,cAAA,CAAe,MAAM;AAEnB,gBAAA,OAAA,CAAQ,GAAA;AAAA,kBACN;AAAA,iBACF;AAAA,cACF,CAAC,CAAA;AAAA,YACH;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AACF,CAAC,CAAA;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"11.0.0-
|
|
1
|
+
{"type":"module","version":"11.0.0-rc.0"}
|
|
@@ -54,7 +54,7 @@ ${data}`;
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
function addServerConfigPlugin(nuxt, serverConfigFile) {
|
|
57
|
+
function addServerConfigPlugin(nuxt, serverConfigFile, isLegacyNitro) {
|
|
58
58
|
const configPath = createResolver(nuxt.options.rootDir).resolve(serverConfigFile);
|
|
59
59
|
const runtimeFlagsTemplate = addTemplate({
|
|
60
60
|
filename: "sentry-runtime-flags.mjs",
|
|
@@ -75,11 +75,13 @@ export default () => {};
|
|
|
75
75
|
`
|
|
76
76
|
});
|
|
77
77
|
addServerPlugin(configPluginTemplate.dst);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
if (isLegacyNitro) {
|
|
79
|
+
nuxt.options.nitro.moduleSideEffects = [
|
|
80
|
+
...nuxt.options.nitro.moduleSideEffects ?? [],
|
|
81
|
+
configPath,
|
|
82
|
+
runtimeFlagsTemplate.dst
|
|
83
|
+
];
|
|
84
|
+
}
|
|
83
85
|
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
84
86
|
if (isCloudflarePreset(nitroConfig.preset)) {
|
|
85
87
|
nitroConfig.plugins = (nitroConfig.plugins ?? []).filter((plugin) => plugin !== configPluginTemplate.dst);
|
|
@@ -87,10 +89,12 @@ export default () => {};
|
|
|
87
89
|
}
|
|
88
90
|
const plugins = nitroConfig.plugins ?? [];
|
|
89
91
|
nitroConfig.plugins = [configPluginTemplate.dst, ...plugins.filter((plugin) => plugin !== configPluginTemplate.dst)];
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
if (isLegacyNitro) {
|
|
93
|
+
const externals = nitroConfig.externals ?? (nitroConfig.externals = {});
|
|
94
|
+
const inline = externals.inline;
|
|
95
|
+
const existingInline = Array.isArray(inline) ? inline : inline ? [inline] : [];
|
|
96
|
+
externals.inline = [...existingInline, configPath, configPluginTemplate.dst, runtimeFlagsTemplate.dst];
|
|
97
|
+
}
|
|
94
98
|
});
|
|
95
99
|
nuxt.hook("nitro:init", (nitro) => {
|
|
96
100
|
if (nuxt.options._prepare || !isCloudflarePreset(nitro.options.preset)) {
|
|
@@ -1 +1 @@
|
|
|
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 { addServerPlugin, addTemplate, createResolver } from '@nuxt/kit';\nimport type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox, debug } from '@sentry/core';\nimport * as fs from 'fs';\nimport type { Nitro } from 'nitropack';\nimport type { InputPluginOption } from 'rollup';\nimport { NUXT_DEV_MODE_FLAG, NUXT_PRERENDER_FLAG } from '../common/devMode';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport {\n constructFunctionReExport,\n constructWrappedFunctionExportQuery,\n getFilenameFromNodeStartCommand,\n isCloudflarePreset,\n QUERY_END_INDICATOR,\n removeSentryQueryFromPath,\n SENTRY_REEXPORTED_FUNCTIONS,\n SENTRY_WRAPPED_ENTRY,\n SENTRY_WRAPPED_FUNCTIONS,\n SERVER_CONFIG_FILENAME,\n toResolvablePath,\n} from './utils';\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 * Registers a Nitro plugin that statically imports the Sentry server config, so the SDK initializes\n * at server startup without a `node --import` preload.\n */\nexport function addServerConfigPlugin(nuxt: Nuxt, serverConfigFile: string): void {\n const configPath = createResolver(nuxt.options.rootDir).resolve(serverConfigFile);\n\n // `Sentry.init` reads these flags, and a statement above the config import would not survive\n // import hoisting — so they live in their own module which is imported first.\n const runtimeFlagsTemplate = addTemplate({\n filename: 'sentry-runtime-flags.mjs',\n write: true,\n getContents: () =>\n [\n '// Generated by @sentry/nuxt. Sets runtime flags before the Sentry server config evaluates.',\n `globalThis.${NUXT_DEV_MODE_FLAG} = import.meta.dev === true;`,\n `globalThis.${NUXT_PRERENDER_FLAG} = import.meta.prerender === true;`,\n '',\n ].join('\\n'),\n });\n\n const configPluginTemplate = addTemplate({\n filename: 'sentry-server-config-plugin.mjs',\n write: true,\n getContents: () =>\n `import ${JSON.stringify(runtimeFlagsTemplate.dst)};\\nimport ${JSON.stringify(configPath)};\\nexport default () => {};\\n`,\n });\n\n addServerPlugin(configPluginTemplate.dst);\n\n // Nitro treeshakes side-effect-only imports outside its runtime dir, which would silently drop\n // the top-level `Sentry.init` and the flag assignments.\n nuxt.options.nitro.moduleSideEffects = [\n ...(nuxt.options.nitro.moduleSideEffects ?? []),\n configPath,\n runtimeFlagsTemplate.dst,\n ];\n\n nuxt.hook('nitro:config', nitroConfig => {\n // Early skip for explicitly configured Cloudflare presets. The authoritative check runs on\n // `nitro:init`: env-derived presets (`NITRO_PRESET`, Cloudflare Pages CI) resolve only inside Nitro.\n if (isCloudflarePreset(nitroConfig.preset)) {\n nitroConfig.plugins = (nitroConfig.plugins ?? []).filter(plugin => plugin !== configPluginTemplate.dst);\n return;\n }\n\n // Front the config plugin so `Sentry.init` evaluates before plugins registered by other Nuxt\n // modules (Nitro appends scanned user plugins after the configured ones anyway).\n const plugins = nitroConfig.plugins ?? [];\n nitroConfig.plugins = [configPluginTemplate.dst, ...plugins.filter(plugin => plugin !== configPluginTemplate.dst)];\n\n // The Nitro v2 dev bundle would otherwise externalize these files, making Node load the raw\n // `.ts` config — which needs type stripping (Node >= 22.18). Inlining keeps them transpiled.\n const externals = (nitroConfig.externals ??= {});\n const inline = externals.inline;\n const existingInline = Array.isArray(inline) ? inline : inline ? [inline] : [];\n externals.inline = [...existingInline, configPath, configPluginTemplate.dst, runtimeFlagsTemplate.dst];\n });\n\n // On Cloudflare the SDK is set up through `sentryCloudflareNitroPlugin`; the Node SDK config\n // must not end up in the worker bundle. `nitro.options.preset` is resolved here.\n nuxt.hook('nitro:init', nitro => {\n if (nuxt.options._prepare || !isCloudflarePreset(nitro.options.preset)) {\n return;\n }\n\n nitro.options.plugins = (nitro.options.plugins ?? []).filter(plugin => plugin !== configPluginTemplate.dst);\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Found \\`${basename(configPath)}\\`, but the Nitro preset targets Cloudflare, where this file is not used. Set up the SDK with \\`sentryCloudflareNitroPlugin\\` instead: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/cloudflare-workers/`,\n );\n });\n });\n}\n\n/**\n * Writes a shim to the former `--import` config path, so existing `node --import` start commands\n * keep working now that the config is bundled into the server build.\n */\nexport function addServerConfigShimWithWarning(nitro: Nitro): void {\n nitro.hooks.hook('close', async () => {\n if (nitro.options.dev || nitro.options.preset === 'nitro-prerender' || isCloudflarePreset(nitro.options.preset)) {\n return;\n }\n\n const shimPath = createResolver(nitro.options.output.serverDir).resolve(`${SERVER_CONFIG_FILENAME}.mjs`);\n const contents = [\n '// Generated by @sentry/nuxt.',\n '// The Sentry server config is bundled into the server build and initializes automatically.',\n '// This file only keeps existing `node --import ./.output/server/sentry.server.config.mjs` commands working.',\n \"console.warn('[Sentry] The `--import` flag for the Sentry server config is no longer needed and should be removed.');\",\n '',\n ].join('\\n');\n\n try {\n await fs.promises.writeFile(shimPath, contents, 'utf8');\n } catch (error) {\n // A missing shim breaks `node --import` start commands, so always warn (`debug` is off at build time).\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(`[Sentry] Could not write the \\`--import\\` compatibility shim to ${shimPath}`, error);\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 // oxlint-disable-next-line typescript/no-deprecated -- supported until removal\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":["nitro","debug"],"mappings":";;;;;;;;;AAyBA,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,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AC9F,QAAA,IAAI,UAAU,OAAO,QAAA;AACrB,QAAA,OAAO,EAAE,IAAI,gBAAA,EAAiB;AAAA,MAChC;AAEA,MAAA,OAAO,IAAA;AAAA,IACT,CAAA;AAAA,IACA,KAAK,EAAA,EAAY;AACf,MAAA,IAAI,EAAA,CAAG,QAAA,CAAS,CAAA,IAAA,EAAO,oBAAoB,EAAE,CAAA,EAAG;AAC9C,QAAA,MAAM,UAAU,yBAAA,CAA0B,EAAE,CAAA,CAAE,KAAA,CAAM,mBAAmB,MAAM,CAAA;AAC7E,QAAA,MAAM,UAAA,GAAa,aAAA,CAAc,OAAO,CAAA,CAAE,IAAA;AAC1C,QAAA,MAAM,SAAA,GAAY,aAAA,CAAc,wBAAwB,CAAA,CAAE,IAAA;AAI1D,QAAA,MAAM,mBAAA,GACJ,EAAA,CAAG,QAAA,CAAS,wBAAwB,CAAA,IAAK,EAAA,CAAG,QAAA,CAAS,2BAA2B,CAAA,GAC5E,yBAAA,CAA0B,EAAA,EAAI,UAAU,CAAA,GACxC,EAAA;AAEN,QAAA;AAAA;AAAA,UAEE,CAAA,OAAA,EAAU,IAAA,CAAK,SAAA,CAAU,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;;;;"}
|
|
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 { addServerPlugin, addTemplate, createResolver } from '@nuxt/kit';\nimport type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox, debug } from '@sentry/core';\nimport * as fs from 'fs';\nimport type { Nitro } from 'nitropack';\nimport type { InputPluginOption } from 'rollup';\nimport { NUXT_DEV_MODE_FLAG, NUXT_PRERENDER_FLAG } from '../common/devMode';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport {\n constructFunctionReExport,\n constructWrappedFunctionExportQuery,\n getFilenameFromNodeStartCommand,\n isCloudflarePreset,\n QUERY_END_INDICATOR,\n removeSentryQueryFromPath,\n SENTRY_REEXPORTED_FUNCTIONS,\n SENTRY_WRAPPED_ENTRY,\n SENTRY_WRAPPED_FUNCTIONS,\n SERVER_CONFIG_FILENAME,\n toResolvablePath,\n} from './utils';\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 * Registers a Nitro plugin that statically imports the Sentry server config, so the SDK initializes\n * at server startup without a `node --import` preload.\n */\nexport function addServerConfigPlugin(nuxt: Nuxt, serverConfigFile: string, isLegacyNitro: boolean): void {\n const configPath = createResolver(nuxt.options.rootDir).resolve(serverConfigFile);\n\n // `Sentry.init` reads these flags, and a statement above the config import would not survive\n // import hoisting — so they live in their own module which is imported first.\n const runtimeFlagsTemplate = addTemplate({\n filename: 'sentry-runtime-flags.mjs',\n write: true,\n getContents: () =>\n [\n '// Generated by @sentry/nuxt. Sets runtime flags before the Sentry server config evaluates.',\n `globalThis.${NUXT_DEV_MODE_FLAG} = import.meta.dev === true;`,\n `globalThis.${NUXT_PRERENDER_FLAG} = import.meta.prerender === true;`,\n '',\n ].join('\\n'),\n });\n\n const configPluginTemplate = addTemplate({\n filename: 'sentry-server-config-plugin.mjs',\n write: true,\n getContents: () =>\n `import ${JSON.stringify(runtimeFlagsTemplate.dst)};\\nimport ${JSON.stringify(configPath)};\\nexport default () => {};\\n`,\n });\n\n addServerPlugin(configPluginTemplate.dst);\n\n // Nitro v2 treeshakes side-effect-only imports outside its runtime dir, which would silently drop\n // the top-level `Sentry.init` and the flag assignments.\n // Nitro v3 dropped the option and keeps both.\n if (isLegacyNitro) {\n nuxt.options.nitro.moduleSideEffects = [\n ...(nuxt.options.nitro.moduleSideEffects ?? []),\n configPath,\n runtimeFlagsTemplate.dst,\n ];\n }\n\n nuxt.hook('nitro:config', nitroConfig => {\n // Early skip for explicitly configured Cloudflare presets. The authoritative check runs on\n // `nitro:init`: env-derived presets (`NITRO_PRESET`, Cloudflare Pages CI) resolve only inside Nitro.\n if (isCloudflarePreset(nitroConfig.preset)) {\n nitroConfig.plugins = (nitroConfig.plugins ?? []).filter(plugin => plugin !== configPluginTemplate.dst);\n return;\n }\n\n // Front the config plugin so `Sentry.init` evaluates before plugins registered by other Nuxt\n // modules (Nitro appends scanned user plugins after the configured ones anyway).\n const plugins = nitroConfig.plugins ?? [];\n nitroConfig.plugins = [configPluginTemplate.dst, ...plugins.filter(plugin => plugin !== configPluginTemplate.dst)];\n\n // The Nitro v2 dev bundle would otherwise externalize these files, making Node load the raw\n // `.ts` config — which needs type stripping (Node >= 22.18). Inlining keeps them transpiled.\n // Nitro v3 has no `externals` option; its dev server runs the config through Vite's transform.\n if (isLegacyNitro) {\n const externals = (nitroConfig.externals ??= {});\n const inline = externals.inline;\n const existingInline = Array.isArray(inline) ? inline : inline ? [inline] : [];\n externals.inline = [...existingInline, configPath, configPluginTemplate.dst, runtimeFlagsTemplate.dst];\n }\n });\n\n // On Cloudflare the SDK is set up through `sentryCloudflareNitroPlugin`; the Node SDK config\n // must not end up in the worker bundle. `nitro.options.preset` is resolved here.\n nuxt.hook('nitro:init', nitro => {\n if (nuxt.options._prepare || !isCloudflarePreset(nitro.options.preset)) {\n return;\n }\n\n nitro.options.plugins = (nitro.options.plugins ?? []).filter(plugin => plugin !== configPluginTemplate.dst);\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Found \\`${basename(configPath)}\\`, but the Nitro preset targets Cloudflare, where this file is not used. Set up the SDK with \\`sentryCloudflareNitroPlugin\\` instead: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/cloudflare-workers/`,\n );\n });\n });\n}\n\n/**\n * Writes a shim to the former `--import` config path, so existing `node --import` start commands\n * keep working now that the config is bundled into the server build.\n */\nexport function addServerConfigShimWithWarning(nitro: Nitro): void {\n nitro.hooks.hook('close', async () => {\n if (nitro.options.dev || nitro.options.preset === 'nitro-prerender' || isCloudflarePreset(nitro.options.preset)) {\n return;\n }\n\n const shimPath = createResolver(nitro.options.output.serverDir).resolve(`${SERVER_CONFIG_FILENAME}.mjs`);\n const contents = [\n '// Generated by @sentry/nuxt.',\n '// The Sentry server config is bundled into the server build and initializes automatically.',\n '// This file only keeps existing `node --import ./.output/server/sentry.server.config.mjs` commands working.',\n \"console.warn('[Sentry] The `--import` flag for the Sentry server config is no longer needed and should be removed.');\",\n '',\n ].join('\\n');\n\n try {\n await fs.promises.writeFile(shimPath, contents, 'utf8');\n } catch (error) {\n // A missing shim breaks `node --import` start commands, so always warn (`debug` is off at build time).\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(`[Sentry] Could not write the \\`--import\\` compatibility shim to ${shimPath}`, error);\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 // oxlint-disable-next-line typescript/no-deprecated -- supported until removal\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":["nitro","debug"],"mappings":";;;;;;;;;AAyBA,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,CA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A,IACT;AAAA,GACF;AACF;;;;"}
|
package/build/module/module.json
CHANGED
package/build/module/module.mjs
CHANGED
|
@@ -204,7 +204,7 @@ ${data}`;
|
|
|
204
204
|
}
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
|
-
function addServerConfigPlugin(nuxt, serverConfigFile) {
|
|
207
|
+
function addServerConfigPlugin(nuxt, serverConfigFile, isLegacyNitro) {
|
|
208
208
|
const configPath = createResolver(nuxt.options.rootDir).resolve(serverConfigFile);
|
|
209
209
|
const runtimeFlagsTemplate = addTemplate({
|
|
210
210
|
filename: "sentry-runtime-flags.mjs",
|
|
@@ -225,11 +225,13 @@ export default () => {};
|
|
|
225
225
|
`
|
|
226
226
|
});
|
|
227
227
|
addServerPlugin(configPluginTemplate.dst);
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
228
|
+
if (isLegacyNitro) {
|
|
229
|
+
nuxt.options.nitro.moduleSideEffects = [
|
|
230
|
+
...nuxt.options.nitro.moduleSideEffects ?? [],
|
|
231
|
+
configPath,
|
|
232
|
+
runtimeFlagsTemplate.dst
|
|
233
|
+
];
|
|
234
|
+
}
|
|
233
235
|
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
234
236
|
if (isCloudflarePreset(nitroConfig.preset)) {
|
|
235
237
|
nitroConfig.plugins = (nitroConfig.plugins ?? []).filter((plugin) => plugin !== configPluginTemplate.dst);
|
|
@@ -237,10 +239,12 @@ export default () => {};
|
|
|
237
239
|
}
|
|
238
240
|
const plugins = nitroConfig.plugins ?? [];
|
|
239
241
|
nitroConfig.plugins = [configPluginTemplate.dst, ...plugins.filter((plugin) => plugin !== configPluginTemplate.dst)];
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
if (isLegacyNitro) {
|
|
243
|
+
const externals = nitroConfig.externals ?? (nitroConfig.externals = {});
|
|
244
|
+
const inline = externals.inline;
|
|
245
|
+
const existingInline = Array.isArray(inline) ? inline : inline ? [inline] : [];
|
|
246
|
+
externals.inline = [...existingInline, configPath, configPluginTemplate.dst, runtimeFlagsTemplate.dst];
|
|
247
|
+
}
|
|
244
248
|
});
|
|
245
249
|
nuxt.hook("nitro:init", (nitro) => {
|
|
246
250
|
if (nuxt.options._prepare || !isCloudflarePreset(nitro.options.preset)) {
|
|
@@ -865,7 +869,7 @@ var module$1 = defineNuxtModule({
|
|
|
865
869
|
const usesDeprecatedInjectMode = moduleOptions.autoInjectServerSentry === "top-level-import" || moduleOptions.autoInjectServerSentry === "experimental_dynamic-import";
|
|
866
870
|
if (serverConfigFile) {
|
|
867
871
|
if (!usesDeprecatedInjectMode) {
|
|
868
|
-
addServerConfigPlugin(nuxt, serverConfigFile);
|
|
872
|
+
addServerConfigPlugin(nuxt, serverConfigFile, !isNitroV3);
|
|
869
873
|
}
|
|
870
874
|
if (isNitroV3) {
|
|
871
875
|
addServerPlugin(moduleDirResolver.resolve("./runtime/plugins/handler.server"));
|
|
@@ -2,7 +2,7 @@ import { DB_SYSTEM_NAME, DB_NAMESPACE, SENTRY_OP, DB_QUERY_SUMMARY, DB_QUERY_TEX
|
|
|
2
2
|
import { DB_QUERY } from '@sentry/conventions/op';
|
|
3
3
|
import { debug, startSpan, getClient, hasSpanStreamingEnabled, DB_SPAN_NAME_FALLBACK, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_STATUS_ERROR, captureException, addBreadcrumb } from '@sentry/core';
|
|
4
4
|
import { flushIfServerless } from '@sentry/core/server';
|
|
5
|
-
import {
|
|
5
|
+
import { sanitizeSqlQueryWithSummary, sanitizeSqlQuery } from '@sentry/server-utils';
|
|
6
6
|
import { getDatabaseSpanData } from './database-span-data.js';
|
|
7
7
|
|
|
8
8
|
const patchedStatement = /* @__PURE__ */ new WeakSet();
|
|
@@ -34,17 +34,18 @@ function instrumentDatabase(db, config) {
|
|
|
34
34
|
[DB_SYSTEM_NAME]: config?.connector ?? db.dialect,
|
|
35
35
|
...getDatabaseSpanData(config)
|
|
36
36
|
};
|
|
37
|
+
const dialect = db.dialect === "mysql" ? "mysql" : void 0;
|
|
37
38
|
db.prepare = new Proxy(db.prepare, {
|
|
38
39
|
apply(target, thisArg, args) {
|
|
39
40
|
const [query] = args;
|
|
40
|
-
return instrumentPreparedStatement(target.apply(thisArg, args), query, metadata);
|
|
41
|
+
return instrumentPreparedStatement(target.apply(thisArg, args), query, metadata, dialect);
|
|
41
42
|
}
|
|
42
43
|
});
|
|
43
44
|
db.sql = new Proxy(db.sql, {
|
|
44
45
|
apply(target, thisArg, args) {
|
|
45
46
|
const [strings, ...values] = args;
|
|
46
47
|
const query = strings ? buildSqlTemplateQuery(strings, values) : "";
|
|
47
|
-
const opts = createStartSpanOptions(query, metadata);
|
|
48
|
+
const opts = createStartSpanOptions(query, metadata, dialect);
|
|
48
49
|
return startSpan(
|
|
49
50
|
opts,
|
|
50
51
|
handleSpanStart(() => target.apply(thisArg, args))
|
|
@@ -54,8 +55,8 @@ function instrumentDatabase(db, config) {
|
|
|
54
55
|
db.exec = new Proxy(db.exec, {
|
|
55
56
|
apply(target, thisArg, args) {
|
|
56
57
|
return startSpan(
|
|
57
|
-
createStartSpanOptions(args[0], metadata),
|
|
58
|
-
handleSpanStart(() => target.apply(thisArg, args), { query: args[0] })
|
|
58
|
+
createStartSpanOptions(args[0], metadata, dialect),
|
|
59
|
+
handleSpanStart(() => target.apply(thisArg, args), { query: args[0], dialect })
|
|
59
60
|
);
|
|
60
61
|
}
|
|
61
62
|
});
|
|
@@ -73,39 +74,39 @@ function buildSqlTemplateQuery(strings, values) {
|
|
|
73
74
|
}
|
|
74
75
|
return query.trim();
|
|
75
76
|
}
|
|
76
|
-
function instrumentPreparedStatement(statement, query, data) {
|
|
77
|
+
function instrumentPreparedStatement(statement, query, data, dialect) {
|
|
77
78
|
statement.bind = new Proxy(statement.bind, {
|
|
78
79
|
apply(target, thisArg, args) {
|
|
79
|
-
return instrumentPreparedStatementQueries(target.apply(thisArg, args), query, data);
|
|
80
|
+
return instrumentPreparedStatementQueries(target.apply(thisArg, args), query, data, dialect);
|
|
80
81
|
}
|
|
81
82
|
});
|
|
82
|
-
return instrumentPreparedStatementQueries(statement, query, data);
|
|
83
|
+
return instrumentPreparedStatementQueries(statement, query, data, dialect);
|
|
83
84
|
}
|
|
84
|
-
function instrumentPreparedStatementQueries(statement, query, data) {
|
|
85
|
+
function instrumentPreparedStatementQueries(statement, query, data, dialect) {
|
|
85
86
|
if (patchedStatement.has(statement)) {
|
|
86
87
|
return statement;
|
|
87
88
|
}
|
|
88
89
|
statement.get = new Proxy(statement.get, {
|
|
89
90
|
apply(target, thisArg, args) {
|
|
90
91
|
return startSpan(
|
|
91
|
-
createStartSpanOptions(query, data),
|
|
92
|
-
handleSpanStart(() => target.apply(thisArg, args), { query })
|
|
92
|
+
createStartSpanOptions(query, data, dialect),
|
|
93
|
+
handleSpanStart(() => target.apply(thisArg, args), { query, dialect })
|
|
93
94
|
);
|
|
94
95
|
}
|
|
95
96
|
});
|
|
96
97
|
statement.run = new Proxy(statement.run, {
|
|
97
98
|
apply(target, thisArg, args) {
|
|
98
99
|
return startSpan(
|
|
99
|
-
createStartSpanOptions(query, data),
|
|
100
|
-
handleSpanStart(() => target.apply(thisArg, args), { query })
|
|
100
|
+
createStartSpanOptions(query, data, dialect),
|
|
101
|
+
handleSpanStart(() => target.apply(thisArg, args), { query, dialect })
|
|
101
102
|
);
|
|
102
103
|
}
|
|
103
104
|
});
|
|
104
105
|
statement.all = new Proxy(statement.all, {
|
|
105
106
|
apply(target, thisArg, args) {
|
|
106
107
|
return startSpan(
|
|
107
|
-
createStartSpanOptions(query, data),
|
|
108
|
-
handleSpanStart(() => target.apply(thisArg, args), { query })
|
|
108
|
+
createStartSpanOptions(query, data, dialect),
|
|
109
|
+
handleSpanStart(() => target.apply(thisArg, args), { query, dialect })
|
|
109
110
|
);
|
|
110
111
|
}
|
|
111
112
|
});
|
|
@@ -117,7 +118,7 @@ function handleSpanStart(fn, breadcrumbOpts) {
|
|
|
117
118
|
try {
|
|
118
119
|
const result = await fn();
|
|
119
120
|
if (breadcrumbOpts) {
|
|
120
|
-
createBreadcrumb(breadcrumbOpts.query);
|
|
121
|
+
createBreadcrumb(breadcrumbOpts.query, breadcrumbOpts.dialect);
|
|
121
122
|
}
|
|
122
123
|
return result;
|
|
123
124
|
} catch (error) {
|
|
@@ -134,23 +135,24 @@ function handleSpanStart(fn, breadcrumbOpts) {
|
|
|
134
135
|
}
|
|
135
136
|
};
|
|
136
137
|
}
|
|
137
|
-
function createBreadcrumb(query) {
|
|
138
|
+
function createBreadcrumb(query, dialect) {
|
|
139
|
+
const queryText = query ? sanitizeSqlQuery(query, dialect) : void 0;
|
|
138
140
|
addBreadcrumb({
|
|
139
141
|
category: "query",
|
|
140
|
-
message:
|
|
142
|
+
message: queryText,
|
|
141
143
|
data: {
|
|
142
|
-
"db.query.text":
|
|
144
|
+
"db.query.text": queryText
|
|
143
145
|
}
|
|
144
146
|
});
|
|
145
147
|
}
|
|
146
|
-
function createStartSpanOptions(query, data) {
|
|
147
|
-
const querySummary = query
|
|
148
|
+
function createStartSpanOptions(query, data, dialect) {
|
|
149
|
+
const { queryText, querySummary } = sanitizeSqlQueryWithSummary(query, dialect);
|
|
148
150
|
const client = getClient();
|
|
149
|
-
const name = client && hasSpanStreamingEnabled(client) ? querySummary || data[DB_NAMESPACE] || DB_SPAN_NAME_FALLBACK :
|
|
151
|
+
const name = client && hasSpanStreamingEnabled(client) ? querySummary || data[DB_NAMESPACE] || DB_SPAN_NAME_FALLBACK : queryText ?? DB_SPAN_NAME_FALLBACK;
|
|
150
152
|
return {
|
|
151
153
|
name,
|
|
152
154
|
attributes: {
|
|
153
|
-
[DB_QUERY_TEXT]:
|
|
155
|
+
[DB_QUERY_TEXT]: queryText,
|
|
154
156
|
[DB_QUERY_SUMMARY]: querySummary,
|
|
155
157
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: SENTRY_ORIGIN,
|
|
156
158
|
[SENTRY_OP]: DB_QUERY,
|
|
@@ -18,7 +18,7 @@ export declare function addSentryTopImport(moduleOptions: SentryNuxtModuleOption
|
|
|
18
18
|
* Registers a Nitro plugin that statically imports the Sentry server config, so the SDK initializes
|
|
19
19
|
* at server startup without a `node --import` preload.
|
|
20
20
|
*/
|
|
21
|
-
export declare function addServerConfigPlugin(nuxt: Nuxt, serverConfigFile: string): void;
|
|
21
|
+
export declare function addServerConfigPlugin(nuxt: Nuxt, serverConfigFile: string, isLegacyNitro: boolean): void;
|
|
22
22
|
/**
|
|
23
23
|
* Writes a shim to the former `--import` config path, so existing `node --import` start commands
|
|
24
24
|
* keep working now that the config is bundled into the server build.
|
|
@@ -6,6 +6,7 @@ export * from './index.client';
|
|
|
6
6
|
export * from './index.server';
|
|
7
7
|
export declare function init(options: Options | SentryNuxtClientOptions | SentryNuxtServerOptions): Client | undefined;
|
|
8
8
|
export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
|
|
9
|
+
export declare const consoleIntegration: typeof serverSdk.consoleIntegration;
|
|
9
10
|
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
|
|
10
11
|
export declare const startSpan: typeof clientSdk.startSpan;
|
|
11
12
|
export declare const startSpanManual: typeof clientSdk.startSpanManual;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.types.d.ts","sourceRoot":"","sources":["../../src/index.types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACvF,OAAO,KAAK,KAAK,SAAS,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAIjD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAG/B,MAAM,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E,MAAM,CAAC,OAAO,CAAC,MAAM,iBAAiB,EAAE,OAAO,SAAS,CAAC,iBAAiB,CAAC;AAC3E,MAAM,CAAC,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,SAAS,CAAC,cAAc,CAAC;AAErE,MAAM,CAAC,OAAO,CAAC,MAAM,gBAAgB,EAAE,OAAO,SAAS,CAAC,gBAAgB,CAAC;AACzE,MAAM,CAAC,OAAO,CAAC,MAAM,sBAAsB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,WAAW,EAAE,CAAC;AACjF,MAAM,CAAC,OAAO,CAAC,MAAM,kBAAkB,EAAE,WAAW,CAAC;AAErD,MAAM,CAAC,OAAO,CAAC,MAAM,MAAM,EAAE,OAAO,SAAS,CAAC,MAAM,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AAE/E,MAAM,CAAC,OAAO,CAAC,MAAM,qBAAqB,EAAE,OAAO,SAAS,CAAC,qBAAqB,CAAC;AACnF,MAAM,CAAC,OAAO,CAAC,MAAM,uBAAuB,EAAE,OAAO,SAAS,CAAC,uBAAuB,CAAC;AACvF,MAAM,CAAC,OAAO,CAAC,MAAM,gCAAgC,EAAE,OAAO,SAAS,CAAC,gCAAgC,CAAC;AACzG,MAAM,CAAC,OAAO,CAAC,MAAM,sBAAsB,EAAE,OAAO,SAAS,CAAC,sBAAsB,CAAC;AACrF,MAAM,CAAC,OAAO,CAAC,MAAM,0BAA0B,EAAE,OAAO,SAAS,CAAC,0BAA0B,CAAC;AAC7F,MAAM,CAAC,OAAO,CAAC,MAAM,kBAAkB,EAAE,OAAO,SAAS,CAAC,kBAAkB,CAAC;AAC7E,MAAM,CAAC,OAAO,CAAC,MAAM,kBAAkB,EAAE,OAAO,SAAS,CAAC,kBAAkB,CAAC"}
|
|
@@ -18,7 +18,7 @@ export declare function addSentryTopImport(moduleOptions: SentryNuxtModuleOption
|
|
|
18
18
|
* Registers a Nitro plugin that statically imports the Sentry server config, so the SDK initializes
|
|
19
19
|
* at server startup without a `node --import` preload.
|
|
20
20
|
*/
|
|
21
|
-
export declare function addServerConfigPlugin(nuxt: Nuxt, serverConfigFile: string): void;
|
|
21
|
+
export declare function addServerConfigPlugin(nuxt: Nuxt, serverConfigFile: string, isLegacyNitro: boolean): void;
|
|
22
22
|
/**
|
|
23
23
|
* Writes a shim to the former `--import` config path, so existing `node --import` start commands
|
|
24
24
|
* keep working now that the config is bundled into the server build.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addServerConfig.d.ts","sourceRoot":"","sources":["../../../src/vite/addServerConfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAyB/D;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,uBAAuB,EACtC,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,MAAM,GACvB,IAAI,CAWN;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,uBAAuB,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CA0C7F;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"addServerConfig.d.ts","sourceRoot":"","sources":["../../../src/vite/addServerConfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAyB/D;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,uBAAuB,EACtC,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,MAAM,GACvB,IAAI,CAWN;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,uBAAuB,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CA0C7F;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI,CA4ExG;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAyBjE;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,MAAM,EACxB,aAAa,EAAE,IAAI,CAAC,uBAAuB,EAAE,yCAAyC,CAAC,GACrF,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,yCAAyC,CAAC,CAAC,GACnF,IAAI,CAmBN;AAyCD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,wBAAwB,EACxB,uCAAuC,EACvC,KAAK,GACN,EAAE;IACD,wBAAwB,EAAE,MAAM,CAAC;IACjC,uCAAuC,EAAE,MAAM,EAAE,CAAC;IAClD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GAAG,iBAAiB,CAwFpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/nuxt",
|
|
3
|
-
"version": "11.0.0-
|
|
3
|
+
"version": "11.0.0-rc.0",
|
|
4
4
|
"description": "Official Sentry SDK for Nuxt",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/nuxt",
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@nuxt/kit": "^4.5.2",
|
|
57
|
-
"@sentry/browser": "11.0.0-
|
|
58
|
-
"@sentry/cloudflare": "11.0.0-
|
|
59
|
-
"@sentry/conventions": "^0.
|
|
60
|
-
"@sentry/core": "11.0.0-
|
|
61
|
-
"@sentry/node": "11.0.0-
|
|
62
|
-
"@sentry/bundler-plugins": "11.0.0-
|
|
63
|
-
"@sentry/server-runtime-injection": "11.0.0-
|
|
64
|
-
"@sentry/server-utils": "11.0.0-
|
|
65
|
-
"@sentry/vue": "11.0.0-
|
|
57
|
+
"@sentry/browser": "11.0.0-rc.0",
|
|
58
|
+
"@sentry/cloudflare": "11.0.0-rc.0",
|
|
59
|
+
"@sentry/conventions": "^0.23.0",
|
|
60
|
+
"@sentry/core": "11.0.0-rc.0",
|
|
61
|
+
"@sentry/node": "11.0.0-rc.0",
|
|
62
|
+
"@sentry/bundler-plugins": "11.0.0-rc.0",
|
|
63
|
+
"@sentry/server-runtime-injection": "11.0.0-rc.0",
|
|
64
|
+
"@sentry/server-utils": "11.0.0-rc.0",
|
|
65
|
+
"@sentry/vue": "11.0.0-rc.0",
|
|
66
66
|
"local-pkg": "^1.1.2"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|