@sentry/nuxt 9.8.0 → 9.10.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/vite/addServerConfig.js +1 -37
- package/build/cjs/vite/addServerConfig.js.map +1 -1
- package/build/cjs/vite/sourceMaps.js +0 -1
- package/build/cjs/vite/sourceMaps.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/vite/addServerConfig.js +2 -38
- package/build/esm/vite/addServerConfig.js.map +1 -1
- package/build/esm/vite/sourceMaps.js +0 -1
- package/build/esm/vite/sourceMaps.js.map +1 -1
- package/build/module/module.json +1 -1
- package/build/module/module.mjs +0 -27
- package/build/module/runtime/utils.d.ts +1 -1
- package/build/module/runtime/utils.js +12 -15
- package/build/types/index.types.d.ts +2 -0
- package/build/types/index.types.d.ts.map +1 -1
- package/build/types/runtime/utils.d.ts +1 -1
- package/build/types/runtime/utils.d.ts.map +1 -1
- package/build/types/vite/addServerConfig.d.ts +1 -2
- package/build/types/vite/addServerConfig.d.ts.map +1 -1
- package/build/types/vite/sourceMaps.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -11,8 +11,7 @@ const SERVER_CONFIG_FILENAME = 'sentry.server.config';
|
|
|
11
11
|
/**
|
|
12
12
|
* 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.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
* 2. Copying the file to the `.output` directory after the build process is finished.
|
|
14
|
+
* By adding a Rollup plugin to the Nitro Rollup options, the Sentry server config is transpiled and emitted to the server build.
|
|
16
15
|
*/
|
|
17
16
|
function addServerConfigToBuild(
|
|
18
17
|
moduleOptions,
|
|
@@ -29,41 +28,6 @@ function addServerConfigToBuild(
|
|
|
29
28
|
|
|
30
29
|
rollupConfig.plugins.push(injectServerConfigPlugin(nitro, serverConfigFile, moduleOptions.debug));
|
|
31
30
|
});
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* When the build process is finished, copy the `sentry.server.config` file to the `.output` directory.
|
|
35
|
-
* This is necessary because we need to reference this file path in the node --import option.
|
|
36
|
-
*/
|
|
37
|
-
nitro.hooks.hook('close', async () => {
|
|
38
|
-
const buildDirResolver = kit.createResolver(nitro.options.buildDir);
|
|
39
|
-
const serverDirResolver = kit.createResolver(nitro.options.output.serverDir);
|
|
40
|
-
const source = buildDirResolver.resolve(`dist/server/${SERVER_CONFIG_FILENAME}.mjs`);
|
|
41
|
-
const destination = serverDirResolver.resolve(`${SERVER_CONFIG_FILENAME}.mjs`);
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
await fs.promises.access(source, fs.constants.F_OK);
|
|
45
|
-
await fs.promises.copyFile(source, destination);
|
|
46
|
-
|
|
47
|
-
if (moduleOptions.debug) {
|
|
48
|
-
core.consoleSandbox(() => {
|
|
49
|
-
// eslint-disable-next-line no-console
|
|
50
|
-
console.log(
|
|
51
|
-
`[Sentry] Successfully added the content of the \`${serverConfigFile}\` file to \`${destination}\``,
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
} catch (error) {
|
|
56
|
-
if (moduleOptions.debug) {
|
|
57
|
-
core.consoleSandbox(() => {
|
|
58
|
-
// eslint-disable-next-line no-console
|
|
59
|
-
console.warn(
|
|
60
|
-
`[Sentry] An error occurred when trying to add the \`${serverConfigFile}\` file to the \`.output\` directory`,
|
|
61
|
-
error,
|
|
62
|
-
);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
31
|
}
|
|
68
32
|
|
|
69
33
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addServerConfig.js","sources":["../../../src/vite/addServerConfig.ts"],"sourcesContent":["import * as fs from 'fs';\nimport { createResolver } from '@nuxt/kit';\nimport { consoleSandbox, logger } from '@sentry/core';\nimport type { Nitro } from 'nitropack';\nimport type { InputPluginOption } from 'rollup';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport {\n QUERY_END_INDICATOR,\n SENTRY_REEXPORTED_FUNCTIONS,\n SENTRY_WRAPPED_ENTRY,\n SENTRY_WRAPPED_FUNCTIONS,\n constructFunctionReExport,\n constructWrappedFunctionExportQuery,\n getFilenameFromNodeStartCommand,\n removeSentryQueryFromPath,\n} from './utils';\nimport { existsSync } from 'node:fs';\n\nconst SERVER_CONFIG_FILENAME = 'sentry.server.config';\n\n/**\n * Adds the `sentry.server.config.ts` file as `sentry.server.config.mjs` to the `.output` directory to be able to reference this file in the node --import option.\n *\n * 1. Adding the file as a rollup import, so it is included in the build (automatically transpiles the file).\n * 2. Copying the file to the `.output` directory after the build process is finished.\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 * When the build process is finished, copy the `sentry.server.config` file to the `.output` directory.\n * This is necessary because we need to reference this file path in the node --import option.\n */\n nitro.hooks.hook('close', async () => {\n const buildDirResolver = createResolver(nitro.options.buildDir);\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const source = buildDirResolver.resolve(`dist/server/${SERVER_CONFIG_FILENAME}.mjs`);\n const destination = serverDirResolver.resolve(`${SERVER_CONFIG_FILENAME}.mjs`);\n\n try {\n await fs.promises.access(source, fs.constants.F_OK);\n await fs.promises.copyFile(source, destination);\n\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Successfully added the content of the \\`${serverConfigFile}\\` file to \\`${destination}\\``,\n );\n });\n }\n } catch (error) {\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] An error occurred when trying to add the \\`${serverConfigFile}\\` file to the \\`.output\\` directory`,\n error,\n );\n });\n }\n }\n });\n}\n\n/**\n * Adds the Sentry server config import at the top of the server entry file to load the SDK on the server.\n * This is necessary for environments where modifying the node option `--import` is not possible.\n * However, only limited tracing instrumentation is supported when doing this.\n */\nexport function addSentryTopImport(moduleOptions: SentryNuxtModuleOptions, nitro: Nitro): void {\n nitro.hooks.hook('close', async () => {\n const fileNameFromCommand =\n nitro.options.commands.preview && getFilenameFromNodeStartCommand(nitro.options.commands.preview);\n\n // other presets ('node-server' or 'vercel') have an index.mjs\n const presetsWithServerFile = ['netlify'];\n\n const entryFileName = fileNameFromCommand\n ? fileNameFromCommand\n : typeof nitro.options.rollupConfig?.output.entryFileNames === 'string'\n ? nitro.options.rollupConfig?.output.entryFileNames\n : presetsWithServerFile.includes(nitro.options.preset)\n ? 'server.mjs'\n : 'index.mjs';\n\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const entryFilePath = serverDirResolver.resolve(entryFileName);\n\n try {\n fs.readFile(entryFilePath, 'utf8', (err, data) => {\n const updatedContent = `import './${SERVER_CONFIG_FILENAME}.mjs';\\n${data}`;\n\n fs.writeFile(entryFilePath, updatedContent, 'utf8', () => {\n if (moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Successfully added the Sentry import to the server entry file \"\\`${entryFilePath}\\`\"`,\n );\n }\n });\n });\n } catch (err) {\n if (moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] An error occurred when trying to add the Sentry import to the server entry file \"\\`${entryFilePath}\\`\":`,\n err,\n );\n }\n }\n });\n}\n\n/**\n * This function modifies the Rollup configuration to include a plugin that wraps the entry file with a dynamic import (`import()`)\n * and adds the Sentry server config with the static `import` declaration.\n *\n * With this, the Sentry server config can be loaded before all other modules of the application (which is needed for import-in-the-middle).\n * See: https://nodejs.org/api/module.html#enabling\n */\nexport function addDynamicImportEntryFileWrapper(\n nitro: Nitro,\n serverConfigFile: string,\n moduleOptions: Omit<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'> &\n Required<Pick<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'>>,\n): void {\n if (!nitro.options.rollupConfig) {\n nitro.options.rollupConfig = { output: {} };\n }\n\n if (nitro.options.rollupConfig?.plugins === null || nitro.options.rollupConfig?.plugins === undefined) {\n nitro.options.rollupConfig.plugins = [];\n } else if (!Array.isArray(nitro.options.rollupConfig.plugins)) {\n // `rollupConfig.plugins` can be a single plugin, so we want to put it into an array so that we can push our own plugin\n nitro.options.rollupConfig.plugins = [nitro.options.rollupConfig.plugins];\n }\n\n nitro.options.rollupConfig.plugins.push(\n wrapEntryWithDynamicImport({\n resolvedSentryConfigPath: createResolver(nitro.options.srcDir).resolve(`/${serverConfigFile}`),\n experimental_entrypointWrappedFunctions: moduleOptions.experimental_entrypointWrappedFunctions,\n }),\n );\n}\n\n/**\n * Rollup plugin to include the Sentry server configuration file to the server build output.\n */\nfunction injectServerConfigPlugin(nitro: Nitro, serverConfigFile: string, debug?: 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.srcDir).resolve(`/${serverConfigFile}`);\n\n if (!existsSync(configPath)) {\n if (debug) {\n logger.log(`[Sentry] Sentry server config file not found: ${configPath}`);\n }\n return;\n }\n\n // Emitting a file adds it to the build output (Rollup is aware of the file, and we can later return the code in resolveId)\n this.emitFile({\n type: 'chunk',\n id: `${filePrefix}${serverConfigFile}`,\n fileName: `${SERVER_CONFIG_FILENAME}.mjs`,\n });\n },\n\n resolveId(source) {\n if (source.startsWith(filePrefix)) {\n const originalFilePath = source.replace(filePrefix, '');\n const configPath = createResolver(nitro.options.rootDir).resolve(`/${originalFilePath}`);\n\n return { id: configPath };\n }\n return null;\n },\n };\n}\n\n/**\n * A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first\n * by using a regular `import` and load the server after that.\n * This also works with serverless `handler` functions, as it re-exports the `handler`.\n */\nfunction wrapEntryWithDynamicImport({\n resolvedSentryConfigPath,\n experimental_entrypointWrappedFunctions,\n debug,\n}: {\n resolvedSentryConfigPath: string;\n experimental_entrypointWrappedFunctions: string[];\n debug?: boolean;\n}): InputPluginOption {\n // In order to correctly import the server config file\n // and dynamically import the nitro runtime, we need to\n // mark the resolutionId with '\\0raw' to fall into the\n // raw chunk group, c.f. https://github.com/nitrojs/nitro/commit/8b4a408231bdc222569a32ce109796a41eac4aa6#diff-e58102d2230f95ddeef2662957b48d847a6e891e354cfd0ae6e2e03ce848d1a2R142\n const resolutionIdPrefix = '\\0raw';\n\n return {\n name: 'sentry-wrap-entry-with-dynamic-import',\n async resolveId(source, importer, options) {\n if (source.includes(`/${SERVER_CONFIG_FILENAME}`)) {\n return { id: source, moduleSideEffects: true };\n }\n\n if (source === 'import-in-the-middle/hook.mjs') {\n // We are importing \"import-in-the-middle\" in the returned code of the `load()` function below\n // By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it\n // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file is included, as not all node builders are including files imported with `module.register()`.\n // Prevents the error \"Failed to register ESM hook Error: Cannot find module 'import-in-the-middle/hook.mjs'\"\n return { id: source, moduleSideEffects: true, external: true };\n }\n\n if (options.isEntry && source.includes('.mjs') && !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const resolution = await this.resolve(source, importer, options);\n\n // If it cannot be resolved or is external, just return it so that Rollup can display an error\n if (!resolution || resolution?.external) return resolution;\n\n const moduleInfo = await this.load(resolution);\n\n moduleInfo.moduleSideEffects = true;\n\n // The enclosing `if` already checks for the suffix in `source`, but a check in `resolution.id` is needed as well to prevent multiple attachment of the suffix\n return resolution.id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ? resolution.id\n : `${resolutionIdPrefix}${resolution.id\n // Concatenates the query params to mark the file (also attaches names of re-exports - this is needed for serverless functions to re-export the handler)\n .concat(SENTRY_WRAPPED_ENTRY)\n .concat(\n constructWrappedFunctionExportQuery(\n moduleInfo.exportedBindings,\n experimental_entrypointWrappedFunctions,\n debug,\n ),\n )\n .concat(QUERY_END_INDICATOR)}`;\n }\n return null;\n },\n load(id: string) {\n if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);\n\n // Mostly useful for serverless `handler` functions\n const reExportedFunctions =\n id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS)\n ? constructFunctionReExport(id, entryId)\n : '';\n\n return (\n // Regular `import` of the Sentry config\n `import ${JSON.stringify(resolvedSentryConfigPath)};\\n` +\n // Dynamic `import()` for the previous, actual entry point.\n // `import()` can be used for any code that should be run after the hooks are registered (https://nodejs.org/api/module.html#enabling)\n `import(${JSON.stringify(entryId)});\\n` +\n // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file wil be included, as not all node builders are including files imported with `module.register()`.\n \"import 'import-in-the-middle/hook.mjs';\\n\" +\n `${reExportedFunctions}\\n`\n );\n }\n\n return null;\n },\n };\n}\n"],"names":["createResolver","consoleSandbox","getFilenameFromNodeStartCommand","existsSync","logger","SENTRY_WRAPPED_ENTRY","constructWrappedFunctionExportQuery","QUERY_END_INDICATOR","removeSentryQueryFromPath","SENTRY_WRAPPED_FUNCTIONS","SENTRY_REEXPORTED_FUNCTIONS","constructFunctionReExport"],"mappings":";;;;;;;;AAkBA,MAAM,sBAAA,GAAyB,sBAAsB;;AAErD;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,sBAAsB;AACtC,EAAE,aAAa;AACf,EAAE,KAAK;AACP,EAAE,gBA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OAAA,CAAA,CAAA,IAAA,CAAA;AACA;AACA,UAAA,2CAAA;AACA,UAAA,CAAA,EAAA,mBAAA,CAAA,EAAA;AACA;AACA;;AAEA,MAAA,OAAA,IAAA;AACA,KAAA;AACA,GAAA;AACA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"addServerConfig.js","sources":["../../../src/vite/addServerConfig.ts"],"sourcesContent":["import * as fs from 'fs';\nimport { createResolver } from '@nuxt/kit';\nimport { logger } from '@sentry/core';\nimport type { Nitro } from 'nitropack';\nimport type { InputPluginOption } from 'rollup';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport {\n QUERY_END_INDICATOR,\n SENTRY_REEXPORTED_FUNCTIONS,\n SENTRY_WRAPPED_ENTRY,\n SENTRY_WRAPPED_FUNCTIONS,\n constructFunctionReExport,\n constructWrappedFunctionExportQuery,\n getFilenameFromNodeStartCommand,\n removeSentryQueryFromPath,\n} from './utils';\nimport { existsSync } from 'node:fs';\n\nconst SERVER_CONFIG_FILENAME = 'sentry.server.config';\n\n/**\n * Adds the `sentry.server.config.ts` file as `sentry.server.config.mjs` to the `.output` directory to be able to reference this file in the node --import option.\n *\n * By adding a Rollup plugin to the Nitro Rollup options, the Sentry server config is transpiled and emitted to the server build.\n */\nexport function addServerConfigToBuild(\n moduleOptions: SentryNuxtModuleOptions,\n nitro: Nitro,\n serverConfigFile: string,\n): void {\n nitro.hooks.hook('rollup:before', (nitro, rollupConfig) => {\n if (rollupConfig?.plugins === null || rollupConfig?.plugins === undefined) {\n rollupConfig.plugins = [];\n } else if (!Array.isArray(rollupConfig.plugins)) {\n // `rollupConfig.plugins` can be a single plugin, so we want to put it into an array so that we can push our own plugin\n rollupConfig.plugins = [rollupConfig.plugins];\n }\n\n rollupConfig.plugins.push(injectServerConfigPlugin(nitro, serverConfigFile, moduleOptions.debug));\n });\n}\n\n/**\n * Adds the Sentry server config import at the top of the server entry file to load the SDK on the server.\n * This is necessary for environments where modifying the node option `--import` is not possible.\n * However, only limited tracing instrumentation is supported when doing this.\n */\nexport function addSentryTopImport(moduleOptions: SentryNuxtModuleOptions, nitro: Nitro): void {\n nitro.hooks.hook('close', async () => {\n const fileNameFromCommand =\n nitro.options.commands.preview && getFilenameFromNodeStartCommand(nitro.options.commands.preview);\n\n // other presets ('node-server' or 'vercel') have an index.mjs\n const presetsWithServerFile = ['netlify'];\n\n const entryFileName = fileNameFromCommand\n ? fileNameFromCommand\n : typeof nitro.options.rollupConfig?.output.entryFileNames === 'string'\n ? nitro.options.rollupConfig?.output.entryFileNames\n : presetsWithServerFile.includes(nitro.options.preset)\n ? 'server.mjs'\n : 'index.mjs';\n\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const entryFilePath = serverDirResolver.resolve(entryFileName);\n\n try {\n fs.readFile(entryFilePath, 'utf8', (err, data) => {\n const updatedContent = `import './${SERVER_CONFIG_FILENAME}.mjs';\\n${data}`;\n\n fs.writeFile(entryFilePath, updatedContent, 'utf8', () => {\n if (moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Successfully added the Sentry import to the server entry file \"\\`${entryFilePath}\\`\"`,\n );\n }\n });\n });\n } catch (err) {\n if (moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] An error occurred when trying to add the Sentry import to the server entry file \"\\`${entryFilePath}\\`\":`,\n err,\n );\n }\n }\n });\n}\n\n/**\n * This function modifies the Rollup configuration to include a plugin that wraps the entry file with a dynamic import (`import()`)\n * and adds the Sentry server config with the static `import` declaration.\n *\n * With this, the Sentry server config can be loaded before all other modules of the application (which is needed for import-in-the-middle).\n * See: https://nodejs.org/api/module.html#enabling\n */\nexport function addDynamicImportEntryFileWrapper(\n nitro: Nitro,\n serverConfigFile: string,\n moduleOptions: Omit<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'> &\n Required<Pick<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'>>,\n): void {\n if (!nitro.options.rollupConfig) {\n nitro.options.rollupConfig = { output: {} };\n }\n\n if (nitro.options.rollupConfig?.plugins === null || nitro.options.rollupConfig?.plugins === undefined) {\n nitro.options.rollupConfig.plugins = [];\n } else if (!Array.isArray(nitro.options.rollupConfig.plugins)) {\n // `rollupConfig.plugins` can be a single plugin, so we want to put it into an array so that we can push our own plugin\n nitro.options.rollupConfig.plugins = [nitro.options.rollupConfig.plugins];\n }\n\n nitro.options.rollupConfig.plugins.push(\n wrapEntryWithDynamicImport({\n resolvedSentryConfigPath: createResolver(nitro.options.srcDir).resolve(`/${serverConfigFile}`),\n experimental_entrypointWrappedFunctions: moduleOptions.experimental_entrypointWrappedFunctions,\n }),\n );\n}\n\n/**\n * Rollup plugin to include the Sentry server configuration file to the server build output.\n */\nfunction injectServerConfigPlugin(nitro: Nitro, serverConfigFile: string, debug?: 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.srcDir).resolve(`/${serverConfigFile}`);\n\n if (!existsSync(configPath)) {\n if (debug) {\n logger.log(`[Sentry] Sentry server config file not found: ${configPath}`);\n }\n return;\n }\n\n // Emitting a file adds it to the build output (Rollup is aware of the file, and we can later return the code in resolveId)\n this.emitFile({\n type: 'chunk',\n id: `${filePrefix}${serverConfigFile}`,\n fileName: `${SERVER_CONFIG_FILENAME}.mjs`,\n });\n },\n\n resolveId(source) {\n if (source.startsWith(filePrefix)) {\n const originalFilePath = source.replace(filePrefix, '');\n const configPath = createResolver(nitro.options.rootDir).resolve(`/${originalFilePath}`);\n\n return { id: configPath };\n }\n return null;\n },\n };\n}\n\n/**\n * A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first\n * by using a regular `import` and load the server after that.\n * This also works with serverless `handler` functions, as it re-exports the `handler`.\n */\nfunction wrapEntryWithDynamicImport({\n resolvedSentryConfigPath,\n experimental_entrypointWrappedFunctions,\n debug,\n}: {\n resolvedSentryConfigPath: string;\n experimental_entrypointWrappedFunctions: string[];\n debug?: boolean;\n}): InputPluginOption {\n // In order to correctly import the server config file\n // and dynamically import the nitro runtime, we need to\n // mark the resolutionId with '\\0raw' to fall into the\n // raw chunk group, c.f. https://github.com/nitrojs/nitro/commit/8b4a408231bdc222569a32ce109796a41eac4aa6#diff-e58102d2230f95ddeef2662957b48d847a6e891e354cfd0ae6e2e03ce848d1a2R142\n const resolutionIdPrefix = '\\0raw';\n\n return {\n name: 'sentry-wrap-entry-with-dynamic-import',\n async resolveId(source, importer, options) {\n if (source.includes(`/${SERVER_CONFIG_FILENAME}`)) {\n return { id: source, moduleSideEffects: true };\n }\n\n if (source === 'import-in-the-middle/hook.mjs') {\n // We are importing \"import-in-the-middle\" in the returned code of the `load()` function below\n // By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it\n // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file is included, as not all node builders are including files imported with `module.register()`.\n // Prevents the error \"Failed to register ESM hook Error: Cannot find module 'import-in-the-middle/hook.mjs'\"\n return { id: source, moduleSideEffects: true, external: true };\n }\n\n if (options.isEntry && source.includes('.mjs') && !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const resolution = await this.resolve(source, importer, options);\n\n // If it cannot be resolved or is external, just return it so that Rollup can display an error\n if (!resolution || resolution?.external) return resolution;\n\n const moduleInfo = await this.load(resolution);\n\n moduleInfo.moduleSideEffects = true;\n\n // The enclosing `if` already checks for the suffix in `source`, but a check in `resolution.id` is needed as well to prevent multiple attachment of the suffix\n return resolution.id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ? resolution.id\n : `${resolutionIdPrefix}${resolution.id\n // Concatenates the query params to mark the file (also attaches names of re-exports - this is needed for serverless functions to re-export the handler)\n .concat(SENTRY_WRAPPED_ENTRY)\n .concat(\n constructWrappedFunctionExportQuery(\n moduleInfo.exportedBindings,\n experimental_entrypointWrappedFunctions,\n debug,\n ),\n )\n .concat(QUERY_END_INDICATOR)}`;\n }\n return null;\n },\n load(id: string) {\n if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);\n\n // Mostly useful for serverless `handler` functions\n const reExportedFunctions =\n id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS)\n ? constructFunctionReExport(id, entryId)\n : '';\n\n return (\n // Regular `import` of the Sentry config\n `import ${JSON.stringify(resolvedSentryConfigPath)};\\n` +\n // Dynamic `import()` for the previous, actual entry point.\n // `import()` can be used for any code that should be run after the hooks are registered (https://nodejs.org/api/module.html#enabling)\n `import(${JSON.stringify(entryId)});\\n` +\n // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file wil be included, as not all node builders are including files imported with `module.register()`.\n \"import 'import-in-the-middle/hook.mjs';\\n\" +\n `${reExportedFunctions}\\n`\n );\n }\n\n return null;\n },\n };\n}\n"],"names":["getFilenameFromNodeStartCommand","createResolver","existsSync","logger","SENTRY_WRAPPED_ENTRY","constructWrappedFunctionExportQuery","QUERY_END_INDICATOR","removeSentryQueryFromPath","SENTRY_WRAPPED_FUNCTIONS","SENTRY_REEXPORTED_FUNCTIONS","constructFunctionReExport"],"mappings":";;;;;;;;AAkBA,MAAM,sBAAA,GAAyB,sBAAsB;;AAErD;AACA;AACA;AACA;AACA;AACO,SAAS,sBAAsB;AACtC,EAAE,aAAa;AACf,EAAE,KAAK;AACP,EAAE,gBAAgB;AAClB,EAAQ;AACR,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK;AAC7D,IAAI,IAAI,YAAY,EAAE,OAAQ,KAAI,IAAK,IAAG,YAAY,EAAE,OAAQ,KAAI,SAAS,EAAE;AAC/E,MAAM,YAAY,CAAC,OAAQ,GAAE,EAAE;AAC/B,KAAM,MAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,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function changeNuxtSourceMapSettings(
|
|
|
139
139
|
nuxt,
|
|
140
140
|
sentryModuleOptions,
|
|
141
141
|
) {
|
|
142
|
-
nuxt.options = nuxt.options || {};
|
|
143
142
|
nuxt.options.sourcemap = nuxt.options.sourcemap ?? { server: undefined, client: undefined };
|
|
144
143
|
|
|
145
144
|
let previousUserSourceMapSetting = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourceMaps.js","sources":["../../../src/vite/sourceMaps.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox } from '@sentry/core';\nimport { type SentryRollupPluginOptions, sentryRollupPlugin } from '@sentry/rollup-plugin';\nimport { type SentryVitePluginOptions, sentryVitePlugin } from '@sentry/vite-plugin';\nimport type { NitroConfig } from 'nitropack';\nimport type { OutputOptions } from 'rollup';\nimport type { SentryNuxtModuleOptions } from '../common/types';\n\n/**\n * Whether the user enabled (true, 'hidden', 'inline') or disabled (false) source maps\n */\nexport type UserSourceMapSetting = 'enabled' | 'disabled' | 'unset' | undefined;\n\n/**\n * Setup source maps for Sentry inside the Nuxt module during build time (in Vite for Nuxt and Rollup for Nitro).\n */\nexport function setupSourceMaps(moduleOptions: SentryNuxtModuleOptions, nuxt: Nuxt): void {\n const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {};\n const sourceMapsEnabled = sourceMapsUploadOptions.enabled ?? true;\n\n nuxt.hook('modules:done', () => {\n if (sourceMapsEnabled && !nuxt.options.dev) {\n changeNuxtSourceMapSettings(nuxt, moduleOptions);\n }\n });\n\n nuxt.hook('vite:extendConfig', async (viteConfig, _env) => {\n if (sourceMapsEnabled && viteConfig.mode !== 'development') {\n const previousUserSourceMapSetting = changeViteSourceMapSettings(viteConfig, moduleOptions);\n\n // Add Sentry plugin\n viteConfig.plugins = viteConfig.plugins || [];\n viteConfig.plugins.push(\n sentryVitePlugin(getPluginOptions(moduleOptions, previousUserSourceMapSetting === 'unset')),\n );\n }\n });\n\n nuxt.hook('nitro:config', (nitroConfig: NitroConfig) => {\n if (sourceMapsEnabled && !nitroConfig.dev) {\n if (!nitroConfig.rollupConfig) {\n nitroConfig.rollupConfig = {};\n }\n\n if (nitroConfig.rollupConfig.plugins === null || nitroConfig.rollupConfig.plugins === undefined) {\n nitroConfig.rollupConfig.plugins = [];\n } else if (!Array.isArray(nitroConfig.rollupConfig.plugins)) {\n // `rollupConfig.plugins` can be a single plugin, so we want to put it into an array so that we can push our own plugin\n nitroConfig.rollupConfig.plugins = [nitroConfig.rollupConfig.plugins];\n }\n\n const previousUserSourceMapSetting = changeRollupSourceMapSettings(nitroConfig, moduleOptions);\n\n // Add Sentry plugin\n nitroConfig.rollupConfig.plugins.push(\n sentryRollupPlugin(getPluginOptions(moduleOptions, previousUserSourceMapSetting === 'unset')),\n );\n }\n });\n}\n\n/**\n * Normalizes the beginning of a path from e.g. ../../../ to ./\n */\nfunction normalizePath(path: string): string {\n return path.replace(/^(\\.\\.\\/)+/, './');\n}\n\n/**\n * Generates source maps upload options for the Sentry Vite and Rollup plugin.\n *\n * Only exported for Testing purposes.\n */\nexport function getPluginOptions(\n moduleOptions: SentryNuxtModuleOptions,\n deleteFilesAfterUpload: boolean,\n): SentryVitePluginOptions | SentryRollupPluginOptions {\n const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {};\n\n if (typeof sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload === 'undefined' && deleteFilesAfterUpload) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Setting `sentry.sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload: [\".*/**/public/**/*.map\"]` to delete generated source maps after they were uploaded to Sentry.',\n );\n });\n }\n\n return {\n org: sourceMapsUploadOptions.org ?? process.env.SENTRY_ORG,\n project: sourceMapsUploadOptions.project ?? process.env.SENTRY_PROJECT,\n authToken: sourceMapsUploadOptions.authToken ?? process.env.SENTRY_AUTH_TOKEN,\n telemetry: sourceMapsUploadOptions.telemetry ?? true,\n url: sourceMapsUploadOptions.url ?? process.env.SENTRY_URL,\n debug: moduleOptions.debug ?? false,\n silent: sourceMapsUploadOptions.silent ?? false,\n errorHandler: sourceMapsUploadOptions.errorHandler,\n release: {\n name: sourceMapsUploadOptions.release?.name,\n ...moduleOptions?.unstable_sentryBundlerPluginOptions?.release,\n },\n _metaOptions: {\n telemetry: {\n metaFramework: 'nuxt',\n },\n },\n ...moduleOptions?.unstable_sentryBundlerPluginOptions,\n\n sourcemaps: {\n // The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server')\n // We cannot determine automatically how the build folder looks like (depends on the preset), so we have to accept that source maps are uploaded multiple times (with the vitePlugin for Nuxt and the rollupPlugin for Nitro).\n // If we could know where the server/client assets are located, we could do something like this (based on the Nitro preset): isNitro ? ['./.output/server/**/*'] : ['./.output/public/**/*'],\n assets: sourceMapsUploadOptions.sourcemaps?.assets ?? undefined,\n ignore: sourceMapsUploadOptions.sourcemaps?.ignore ?? undefined,\n filesToDeleteAfterUpload: sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload\n ? sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload\n : deleteFilesAfterUpload\n ? ['.*/**/public/**/*.map']\n : undefined,\n rewriteSources: (source: string) => normalizePath(source),\n ...moduleOptions?.unstable_sentryBundlerPluginOptions?.sourcemaps,\n },\n };\n}\n\n/* There are 3 ways to set up source maps (https://github.com/getsentry/sentry-javascript/issues/13993)\n 1. User explicitly disabled source maps\n - keep this setting (emit a warning that errors won't be unminified in Sentry)\n - We will not upload anything\n 2. users enabled source map generation (true, hidden, inline).\n - keep this setting (don't do anything - like deletion - besides uploading)\n 3. users did not set source maps generation\n - we enable 'hidden' source maps generation\n - configure `filesToDeleteAfterUpload` to delete all .map files (we emit a log about this)\n\n Nuxt has 3 places to set source maps: vite options, rollup options, nuxt itself\n Ideally, all 3 are enabled to get all source maps.\n */\n\n/** only exported for testing */\nexport function changeNuxtSourceMapSettings(\n nuxt: Nuxt,\n sentryModuleOptions: SentryNuxtModuleOptions,\n): { client: UserSourceMapSetting; server: UserSourceMapSetting } {\n nuxt.options = nuxt.options || {};\n nuxt.options.sourcemap = nuxt.options.sourcemap ?? { server: undefined, client: undefined };\n\n let previousUserSourceMapSetting: { client: UserSourceMapSetting; server: UserSourceMapSetting } = {\n client: undefined,\n server: undefined,\n };\n\n const nuxtSourceMap = nuxt.options.sourcemap;\n\n if (typeof nuxtSourceMap === 'string' || typeof nuxtSourceMap === 'boolean' || typeof nuxtSourceMap === 'undefined') {\n switch (nuxtSourceMap) {\n case false:\n warnExplicitlyDisabledSourceMap('sourcemap');\n previousUserSourceMapSetting = { client: 'disabled', server: 'disabled' };\n break;\n\n case 'hidden':\n case true:\n logKeepSourceMapSetting(sentryModuleOptions, 'sourcemap', (nuxtSourceMap as true).toString());\n previousUserSourceMapSetting = { client: 'enabled', server: 'enabled' };\n break;\n case undefined:\n nuxt.options.sourcemap = { server: 'hidden', client: 'hidden' };\n logSentryEnablesSourceMap('sourcemap.client', 'hidden');\n logSentryEnablesSourceMap('sourcemap.server', 'hidden');\n previousUserSourceMapSetting = { client: 'unset', server: 'unset' };\n break;\n }\n } else {\n if (nuxtSourceMap.client === false) {\n warnExplicitlyDisabledSourceMap('sourcemap.client');\n previousUserSourceMapSetting.client = 'disabled';\n } else if (['hidden', true].includes(nuxtSourceMap.client)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'sourcemap.client', nuxtSourceMap.client.toString());\n previousUserSourceMapSetting.client = 'enabled';\n } else {\n nuxt.options.sourcemap.client = 'hidden';\n logSentryEnablesSourceMap('sourcemap.client', 'hidden');\n previousUserSourceMapSetting.client = 'unset';\n }\n\n if (nuxtSourceMap.server === false) {\n warnExplicitlyDisabledSourceMap('sourcemap.server');\n previousUserSourceMapSetting.server = 'disabled';\n } else if (['hidden', true].includes(nuxtSourceMap.server)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'sourcemap.server', nuxtSourceMap.server.toString());\n previousUserSourceMapSetting.server = 'enabled';\n } else {\n nuxt.options.sourcemap.server = 'hidden';\n logSentryEnablesSourceMap('sourcemap.server', 'hidden');\n previousUserSourceMapSetting.server = 'unset';\n }\n }\n\n return previousUserSourceMapSetting;\n}\n\n/** only exported for testing */\nexport function changeViteSourceMapSettings(\n viteConfig: { build?: { sourcemap?: boolean | 'inline' | 'hidden' } },\n sentryModuleOptions: SentryNuxtModuleOptions,\n): UserSourceMapSetting {\n viteConfig.build = viteConfig.build || {};\n const viteSourceMap = viteConfig.build.sourcemap;\n\n let previousUserSourceMapSetting: UserSourceMapSetting;\n\n if (viteSourceMap === false) {\n warnExplicitlyDisabledSourceMap('vite.build.sourcemap');\n previousUserSourceMapSetting = 'disabled';\n } else if (viteSourceMap && ['hidden', 'inline', true].includes(viteSourceMap)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'vite.build.sourcemap', viteSourceMap.toString());\n previousUserSourceMapSetting = 'enabled';\n } else {\n viteConfig.build.sourcemap = 'hidden';\n logSentryEnablesSourceMap('vite.build.sourcemap', 'hidden');\n previousUserSourceMapSetting = 'unset';\n }\n\n return previousUserSourceMapSetting;\n}\n\n/** only exported for testing */\nexport function changeRollupSourceMapSettings(\n nitroConfig: {\n rollupConfig?: {\n output?: {\n sourcemap?: OutputOptions['sourcemap'];\n sourcemapExcludeSources?: OutputOptions['sourcemapExcludeSources'];\n };\n };\n },\n sentryModuleOptions: SentryNuxtModuleOptions,\n): UserSourceMapSetting {\n nitroConfig.rollupConfig = nitroConfig.rollupConfig || {};\n nitroConfig.rollupConfig.output = nitroConfig.rollupConfig.output || { sourcemap: undefined };\n\n let previousUserSourceMapSetting: UserSourceMapSetting;\n\n const nitroSourceMap = nitroConfig.rollupConfig.output.sourcemap;\n\n if (nitroSourceMap === false) {\n warnExplicitlyDisabledSourceMap('nitro.rollupConfig.output.sourcemap');\n previousUserSourceMapSetting = 'disabled';\n } else if (nitroSourceMap && ['hidden', 'inline', true].includes(nitroSourceMap)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'nitro.rollupConfig.output.sourcemap', nitroSourceMap.toString());\n previousUserSourceMapSetting = 'enabled';\n } else {\n nitroConfig.rollupConfig.output.sourcemap = 'hidden';\n logSentryEnablesSourceMap('nitro.rollupConfig.output.sourcemap', 'hidden');\n previousUserSourceMapSetting = 'unset';\n }\n\n nitroConfig.rollupConfig.output.sourcemapExcludeSources = false;\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Disabled source map setting in the Nuxt config: `nitro.rollupConfig.output.sourcemapExcludeSources`. Source maps will include the actual code to be able to un-minify code snippets in Sentry.',\n );\n });\n\n return previousUserSourceMapSetting;\n}\n\nfunction logKeepSourceMapSetting(\n sentryNuxtModuleOptions: SentryNuxtModuleOptions,\n settingKey: string,\n settingValue: string,\n): void {\n if (sentryNuxtModuleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] We discovered \\`${settingKey}\\` is set to \\`${settingValue}\\`. Sentry will keep this source map setting. This will un-minify the code snippet on the Sentry Issue page.`,\n );\n });\n }\n}\n\nfunction warnExplicitlyDisabledSourceMap(settingKey: string): void {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Parts of source map generation are currently disabled in your Nuxt configuration (\\`${settingKey}: false\\`). This setting is either a default setting or was explicitly set in your configuration. Sentry won't override this setting. Without source maps, code snippets on the Sentry Issues page will remain minified. To show unminified code, enable source maps in \\`${settingKey}\\` (e.g. by setting them to \\`hidden\\`).`,\n );\n });\n}\n\nfunction logSentryEnablesSourceMap(settingKey: string, settingValue: string): void {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(`[Sentry] Enabled source map generation in the build options with \\`${settingKey}: ${settingValue}\\`.`);\n });\n}\n"],"names":["sentryVitePlugin","sentryRollupPlugin","consoleSandbox"],"mappings":";;;;;;AAQA;AACA;AACA;;AAGA;AACA;AACA;AACO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AC,EAAE,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;AACvH,GAAG,CAAC;AACJ;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"sourceMaps.js","sources":["../../../src/vite/sourceMaps.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox } from '@sentry/core';\nimport { type SentryRollupPluginOptions, sentryRollupPlugin } from '@sentry/rollup-plugin';\nimport { type SentryVitePluginOptions, sentryVitePlugin } from '@sentry/vite-plugin';\nimport type { NitroConfig } from 'nitropack';\nimport type { OutputOptions } from 'rollup';\nimport type { SentryNuxtModuleOptions } from '../common/types';\n\n/**\n * Whether the user enabled (true, 'hidden', 'inline') or disabled (false) source maps\n */\nexport type UserSourceMapSetting = 'enabled' | 'disabled' | 'unset' | undefined;\n\n/**\n * Setup source maps for Sentry inside the Nuxt module during build time (in Vite for Nuxt and Rollup for Nitro).\n */\nexport function setupSourceMaps(moduleOptions: SentryNuxtModuleOptions, nuxt: Nuxt): void {\n const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {};\n const sourceMapsEnabled = sourceMapsUploadOptions.enabled ?? true;\n\n nuxt.hook('modules:done', () => {\n if (sourceMapsEnabled && !nuxt.options.dev) {\n changeNuxtSourceMapSettings(nuxt, moduleOptions);\n }\n });\n\n nuxt.hook('vite:extendConfig', async (viteConfig, _env) => {\n if (sourceMapsEnabled && viteConfig.mode !== 'development') {\n const previousUserSourceMapSetting = changeViteSourceMapSettings(viteConfig, moduleOptions);\n\n // Add Sentry plugin\n viteConfig.plugins = viteConfig.plugins || [];\n viteConfig.plugins.push(\n sentryVitePlugin(getPluginOptions(moduleOptions, previousUserSourceMapSetting === 'unset')),\n );\n }\n });\n\n nuxt.hook('nitro:config', (nitroConfig: NitroConfig) => {\n if (sourceMapsEnabled && !nitroConfig.dev) {\n if (!nitroConfig.rollupConfig) {\n nitroConfig.rollupConfig = {};\n }\n\n if (nitroConfig.rollupConfig.plugins === null || nitroConfig.rollupConfig.plugins === undefined) {\n nitroConfig.rollupConfig.plugins = [];\n } else if (!Array.isArray(nitroConfig.rollupConfig.plugins)) {\n // `rollupConfig.plugins` can be a single plugin, so we want to put it into an array so that we can push our own plugin\n nitroConfig.rollupConfig.plugins = [nitroConfig.rollupConfig.plugins];\n }\n\n const previousUserSourceMapSetting = changeRollupSourceMapSettings(nitroConfig, moduleOptions);\n\n // Add Sentry plugin\n nitroConfig.rollupConfig.plugins.push(\n sentryRollupPlugin(getPluginOptions(moduleOptions, previousUserSourceMapSetting === 'unset')),\n );\n }\n });\n}\n\n/**\n * Normalizes the beginning of a path from e.g. ../../../ to ./\n */\nfunction normalizePath(path: string): string {\n return path.replace(/^(\\.\\.\\/)+/, './');\n}\n\n/**\n * Generates source maps upload options for the Sentry Vite and Rollup plugin.\n *\n * Only exported for Testing purposes.\n */\nexport function getPluginOptions(\n moduleOptions: SentryNuxtModuleOptions,\n deleteFilesAfterUpload: boolean,\n): SentryVitePluginOptions | SentryRollupPluginOptions {\n const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {};\n\n if (typeof sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload === 'undefined' && deleteFilesAfterUpload) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Setting `sentry.sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload: [\".*/**/public/**/*.map\"]` to delete generated source maps after they were uploaded to Sentry.',\n );\n });\n }\n\n return {\n org: sourceMapsUploadOptions.org ?? process.env.SENTRY_ORG,\n project: sourceMapsUploadOptions.project ?? process.env.SENTRY_PROJECT,\n authToken: sourceMapsUploadOptions.authToken ?? process.env.SENTRY_AUTH_TOKEN,\n telemetry: sourceMapsUploadOptions.telemetry ?? true,\n url: sourceMapsUploadOptions.url ?? process.env.SENTRY_URL,\n debug: moduleOptions.debug ?? false,\n silent: sourceMapsUploadOptions.silent ?? false,\n errorHandler: sourceMapsUploadOptions.errorHandler,\n release: {\n name: sourceMapsUploadOptions.release?.name,\n ...moduleOptions?.unstable_sentryBundlerPluginOptions?.release,\n },\n _metaOptions: {\n telemetry: {\n metaFramework: 'nuxt',\n },\n },\n ...moduleOptions?.unstable_sentryBundlerPluginOptions,\n\n sourcemaps: {\n // The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server')\n // We cannot determine automatically how the build folder looks like (depends on the preset), so we have to accept that source maps are uploaded multiple times (with the vitePlugin for Nuxt and the rollupPlugin for Nitro).\n // If we could know where the server/client assets are located, we could do something like this (based on the Nitro preset): isNitro ? ['./.output/server/**/*'] : ['./.output/public/**/*'],\n assets: sourceMapsUploadOptions.sourcemaps?.assets ?? undefined,\n ignore: sourceMapsUploadOptions.sourcemaps?.ignore ?? undefined,\n filesToDeleteAfterUpload: sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload\n ? sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload\n : deleteFilesAfterUpload\n ? ['.*/**/public/**/*.map']\n : undefined,\n rewriteSources: (source: string) => normalizePath(source),\n ...moduleOptions?.unstable_sentryBundlerPluginOptions?.sourcemaps,\n },\n };\n}\n\n/* There are 3 ways to set up source maps (https://github.com/getsentry/sentry-javascript/issues/13993)\n 1. User explicitly disabled source maps\n - keep this setting (emit a warning that errors won't be unminified in Sentry)\n - We will not upload anything\n 2. users enabled source map generation (true, hidden, inline).\n - keep this setting (don't do anything - like deletion - besides uploading)\n 3. users did not set source maps generation\n - we enable 'hidden' source maps generation\n - configure `filesToDeleteAfterUpload` to delete all .map files (we emit a log about this)\n\n Nuxt has 3 places to set source maps: vite options, rollup options, nuxt itself\n Ideally, all 3 are enabled to get all source maps.\n */\n\n/** only exported for testing */\nexport function changeNuxtSourceMapSettings(\n nuxt: Nuxt,\n sentryModuleOptions: SentryNuxtModuleOptions,\n): { client: UserSourceMapSetting; server: UserSourceMapSetting } {\n nuxt.options.sourcemap = nuxt.options.sourcemap ?? { server: undefined, client: undefined };\n\n let previousUserSourceMapSetting: { client: UserSourceMapSetting; server: UserSourceMapSetting } = {\n client: undefined,\n server: undefined,\n };\n\n const nuxtSourceMap = nuxt.options.sourcemap;\n\n if (typeof nuxtSourceMap === 'string' || typeof nuxtSourceMap === 'boolean' || typeof nuxtSourceMap === 'undefined') {\n switch (nuxtSourceMap) {\n case false:\n warnExplicitlyDisabledSourceMap('sourcemap');\n previousUserSourceMapSetting = { client: 'disabled', server: 'disabled' };\n break;\n\n case 'hidden':\n case true:\n logKeepSourceMapSetting(sentryModuleOptions, 'sourcemap', (nuxtSourceMap as true).toString());\n previousUserSourceMapSetting = { client: 'enabled', server: 'enabled' };\n break;\n case undefined:\n nuxt.options.sourcemap = { server: 'hidden', client: 'hidden' };\n logSentryEnablesSourceMap('sourcemap.client', 'hidden');\n logSentryEnablesSourceMap('sourcemap.server', 'hidden');\n previousUserSourceMapSetting = { client: 'unset', server: 'unset' };\n break;\n }\n } else {\n if (nuxtSourceMap.client === false) {\n warnExplicitlyDisabledSourceMap('sourcemap.client');\n previousUserSourceMapSetting.client = 'disabled';\n } else if (['hidden', true].includes(nuxtSourceMap.client)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'sourcemap.client', nuxtSourceMap.client.toString());\n previousUserSourceMapSetting.client = 'enabled';\n } else {\n nuxt.options.sourcemap.client = 'hidden';\n logSentryEnablesSourceMap('sourcemap.client', 'hidden');\n previousUserSourceMapSetting.client = 'unset';\n }\n\n if (nuxtSourceMap.server === false) {\n warnExplicitlyDisabledSourceMap('sourcemap.server');\n previousUserSourceMapSetting.server = 'disabled';\n } else if (['hidden', true].includes(nuxtSourceMap.server)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'sourcemap.server', nuxtSourceMap.server.toString());\n previousUserSourceMapSetting.server = 'enabled';\n } else {\n nuxt.options.sourcemap.server = 'hidden';\n logSentryEnablesSourceMap('sourcemap.server', 'hidden');\n previousUserSourceMapSetting.server = 'unset';\n }\n }\n\n return previousUserSourceMapSetting;\n}\n\n/** only exported for testing */\nexport function changeViteSourceMapSettings(\n viteConfig: { build?: { sourcemap?: boolean | 'inline' | 'hidden' } },\n sentryModuleOptions: SentryNuxtModuleOptions,\n): UserSourceMapSetting {\n viteConfig.build = viteConfig.build || {};\n const viteSourceMap = viteConfig.build.sourcemap;\n\n let previousUserSourceMapSetting: UserSourceMapSetting;\n\n if (viteSourceMap === false) {\n warnExplicitlyDisabledSourceMap('vite.build.sourcemap');\n previousUserSourceMapSetting = 'disabled';\n } else if (viteSourceMap && ['hidden', 'inline', true].includes(viteSourceMap)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'vite.build.sourcemap', viteSourceMap.toString());\n previousUserSourceMapSetting = 'enabled';\n } else {\n viteConfig.build.sourcemap = 'hidden';\n logSentryEnablesSourceMap('vite.build.sourcemap', 'hidden');\n previousUserSourceMapSetting = 'unset';\n }\n\n return previousUserSourceMapSetting;\n}\n\n/** only exported for testing */\nexport function changeRollupSourceMapSettings(\n nitroConfig: {\n rollupConfig?: {\n output?: {\n sourcemap?: OutputOptions['sourcemap'];\n sourcemapExcludeSources?: OutputOptions['sourcemapExcludeSources'];\n };\n };\n },\n sentryModuleOptions: SentryNuxtModuleOptions,\n): UserSourceMapSetting {\n nitroConfig.rollupConfig = nitroConfig.rollupConfig || {};\n nitroConfig.rollupConfig.output = nitroConfig.rollupConfig.output || { sourcemap: undefined };\n\n let previousUserSourceMapSetting: UserSourceMapSetting;\n\n const nitroSourceMap = nitroConfig.rollupConfig.output.sourcemap;\n\n if (nitroSourceMap === false) {\n warnExplicitlyDisabledSourceMap('nitro.rollupConfig.output.sourcemap');\n previousUserSourceMapSetting = 'disabled';\n } else if (nitroSourceMap && ['hidden', 'inline', true].includes(nitroSourceMap)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'nitro.rollupConfig.output.sourcemap', nitroSourceMap.toString());\n previousUserSourceMapSetting = 'enabled';\n } else {\n nitroConfig.rollupConfig.output.sourcemap = 'hidden';\n logSentryEnablesSourceMap('nitro.rollupConfig.output.sourcemap', 'hidden');\n previousUserSourceMapSetting = 'unset';\n }\n\n nitroConfig.rollupConfig.output.sourcemapExcludeSources = false;\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Disabled source map setting in the Nuxt config: `nitro.rollupConfig.output.sourcemapExcludeSources`. Source maps will include the actual code to be able to un-minify code snippets in Sentry.',\n );\n });\n\n return previousUserSourceMapSetting;\n}\n\nfunction logKeepSourceMapSetting(\n sentryNuxtModuleOptions: SentryNuxtModuleOptions,\n settingKey: string,\n settingValue: string,\n): void {\n if (sentryNuxtModuleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] We discovered \\`${settingKey}\\` is set to \\`${settingValue}\\`. Sentry will keep this source map setting. This will un-minify the code snippet on the Sentry Issue page.`,\n );\n });\n }\n}\n\nfunction warnExplicitlyDisabledSourceMap(settingKey: string): void {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Parts of source map generation are currently disabled in your Nuxt configuration (\\`${settingKey}: false\\`). This setting is either a default setting or was explicitly set in your configuration. Sentry won't override this setting. Without source maps, code snippets on the Sentry Issues page will remain minified. To show unminified code, enable source maps in \\`${settingKey}\\` (e.g. by setting them to \\`hidden\\`).`,\n );\n });\n}\n\nfunction logSentryEnablesSourceMap(settingKey: string, settingValue: string): void {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(`[Sentry] Enabled source map generation in the build options with \\`${settingKey}: ${settingValue}\\`.`);\n });\n}\n"],"names":["sentryVitePlugin","sentryRollupPlugin","consoleSandbox"],"mappings":";;;;;;AAQA;AACA;AACA;;AAGA;AACA;AACA;AACO,SAAS,eAAe,CAAC,aAAa,EAA2B,IAAI,EAAc;AAC1F,EAAE,MAAM,0BAA0B,aAAa,CAAC,uBAAwB,IAAG,EAAE;AAC7E,EAAE,MAAM,iBAAkB,GAAE,uBAAuB,CAAC,OAAA,IAAW,IAAI;;AAEnE,EAA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import { createResolver } from '@nuxt/kit';
|
|
3
|
-
import {
|
|
3
|
+
import { logger } from '@sentry/core';
|
|
4
4
|
import { getFilenameFromNodeStartCommand, SENTRY_WRAPPED_ENTRY, removeSentryQueryFromPath, SENTRY_WRAPPED_FUNCTIONS, SENTRY_REEXPORTED_FUNCTIONS, constructFunctionReExport, constructWrappedFunctionExportQuery, QUERY_END_INDICATOR } from './utils.js';
|
|
5
5
|
import { existsSync } from 'node:fs';
|
|
6
6
|
|
|
@@ -9,8 +9,7 @@ const SERVER_CONFIG_FILENAME = 'sentry.server.config';
|
|
|
9
9
|
/**
|
|
10
10
|
* 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.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
* 2. Copying the file to the `.output` directory after the build process is finished.
|
|
12
|
+
* By adding a Rollup plugin to the Nitro Rollup options, the Sentry server config is transpiled and emitted to the server build.
|
|
14
13
|
*/
|
|
15
14
|
function addServerConfigToBuild(
|
|
16
15
|
moduleOptions,
|
|
@@ -27,41 +26,6 @@ function addServerConfigToBuild(
|
|
|
27
26
|
|
|
28
27
|
rollupConfig.plugins.push(injectServerConfigPlugin(nitro, serverConfigFile, moduleOptions.debug));
|
|
29
28
|
});
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* When the build process is finished, copy the `sentry.server.config` file to the `.output` directory.
|
|
33
|
-
* This is necessary because we need to reference this file path in the node --import option.
|
|
34
|
-
*/
|
|
35
|
-
nitro.hooks.hook('close', async () => {
|
|
36
|
-
const buildDirResolver = createResolver(nitro.options.buildDir);
|
|
37
|
-
const serverDirResolver = createResolver(nitro.options.output.serverDir);
|
|
38
|
-
const source = buildDirResolver.resolve(`dist/server/${SERVER_CONFIG_FILENAME}.mjs`);
|
|
39
|
-
const destination = serverDirResolver.resolve(`${SERVER_CONFIG_FILENAME}.mjs`);
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
await fs.promises.access(source, fs.constants.F_OK);
|
|
43
|
-
await fs.promises.copyFile(source, destination);
|
|
44
|
-
|
|
45
|
-
if (moduleOptions.debug) {
|
|
46
|
-
consoleSandbox(() => {
|
|
47
|
-
// eslint-disable-next-line no-console
|
|
48
|
-
console.log(
|
|
49
|
-
`[Sentry] Successfully added the content of the \`${serverConfigFile}\` file to \`${destination}\``,
|
|
50
|
-
);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
} catch (error) {
|
|
54
|
-
if (moduleOptions.debug) {
|
|
55
|
-
consoleSandbox(() => {
|
|
56
|
-
// eslint-disable-next-line no-console
|
|
57
|
-
console.warn(
|
|
58
|
-
`[Sentry] An error occurred when trying to add the \`${serverConfigFile}\` file to the \`.output\` directory`,
|
|
59
|
-
error,
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
29
|
}
|
|
66
30
|
|
|
67
31
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addServerConfig.js","sources":["../../../src/vite/addServerConfig.ts"],"sourcesContent":["import * as fs from 'fs';\nimport { createResolver } from '@nuxt/kit';\nimport { consoleSandbox, logger } from '@sentry/core';\nimport type { Nitro } from 'nitropack';\nimport type { InputPluginOption } from 'rollup';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport {\n QUERY_END_INDICATOR,\n SENTRY_REEXPORTED_FUNCTIONS,\n SENTRY_WRAPPED_ENTRY,\n SENTRY_WRAPPED_FUNCTIONS,\n constructFunctionReExport,\n constructWrappedFunctionExportQuery,\n getFilenameFromNodeStartCommand,\n removeSentryQueryFromPath,\n} from './utils';\nimport { existsSync } from 'node:fs';\n\nconst SERVER_CONFIG_FILENAME = 'sentry.server.config';\n\n/**\n * Adds the `sentry.server.config.ts` file as `sentry.server.config.mjs` to the `.output` directory to be able to reference this file in the node --import option.\n *\n * 1. Adding the file as a rollup import, so it is included in the build (automatically transpiles the file).\n * 2. Copying the file to the `.output` directory after the build process is finished.\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 * When the build process is finished, copy the `sentry.server.config` file to the `.output` directory.\n * This is necessary because we need to reference this file path in the node --import option.\n */\n nitro.hooks.hook('close', async () => {\n const buildDirResolver = createResolver(nitro.options.buildDir);\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const source = buildDirResolver.resolve(`dist/server/${SERVER_CONFIG_FILENAME}.mjs`);\n const destination = serverDirResolver.resolve(`${SERVER_CONFIG_FILENAME}.mjs`);\n\n try {\n await fs.promises.access(source, fs.constants.F_OK);\n await fs.promises.copyFile(source, destination);\n\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Successfully added the content of the \\`${serverConfigFile}\\` file to \\`${destination}\\``,\n );\n });\n }\n } catch (error) {\n if (moduleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] An error occurred when trying to add the \\`${serverConfigFile}\\` file to the \\`.output\\` directory`,\n error,\n );\n });\n }\n }\n });\n}\n\n/**\n * Adds the Sentry server config import at the top of the server entry file to load the SDK on the server.\n * This is necessary for environments where modifying the node option `--import` is not possible.\n * However, only limited tracing instrumentation is supported when doing this.\n */\nexport function addSentryTopImport(moduleOptions: SentryNuxtModuleOptions, nitro: Nitro): void {\n nitro.hooks.hook('close', async () => {\n const fileNameFromCommand =\n nitro.options.commands.preview && getFilenameFromNodeStartCommand(nitro.options.commands.preview);\n\n // other presets ('node-server' or 'vercel') have an index.mjs\n const presetsWithServerFile = ['netlify'];\n\n const entryFileName = fileNameFromCommand\n ? fileNameFromCommand\n : typeof nitro.options.rollupConfig?.output.entryFileNames === 'string'\n ? nitro.options.rollupConfig?.output.entryFileNames\n : presetsWithServerFile.includes(nitro.options.preset)\n ? 'server.mjs'\n : 'index.mjs';\n\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const entryFilePath = serverDirResolver.resolve(entryFileName);\n\n try {\n fs.readFile(entryFilePath, 'utf8', (err, data) => {\n const updatedContent = `import './${SERVER_CONFIG_FILENAME}.mjs';\\n${data}`;\n\n fs.writeFile(entryFilePath, updatedContent, 'utf8', () => {\n if (moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Successfully added the Sentry import to the server entry file \"\\`${entryFilePath}\\`\"`,\n );\n }\n });\n });\n } catch (err) {\n if (moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] An error occurred when trying to add the Sentry import to the server entry file \"\\`${entryFilePath}\\`\":`,\n err,\n );\n }\n }\n });\n}\n\n/**\n * This function modifies the Rollup configuration to include a plugin that wraps the entry file with a dynamic import (`import()`)\n * and adds the Sentry server config with the static `import` declaration.\n *\n * With this, the Sentry server config can be loaded before all other modules of the application (which is needed for import-in-the-middle).\n * See: https://nodejs.org/api/module.html#enabling\n */\nexport function addDynamicImportEntryFileWrapper(\n nitro: Nitro,\n serverConfigFile: string,\n moduleOptions: Omit<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'> &\n Required<Pick<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'>>,\n): void {\n if (!nitro.options.rollupConfig) {\n nitro.options.rollupConfig = { output: {} };\n }\n\n if (nitro.options.rollupConfig?.plugins === null || nitro.options.rollupConfig?.plugins === undefined) {\n nitro.options.rollupConfig.plugins = [];\n } else if (!Array.isArray(nitro.options.rollupConfig.plugins)) {\n // `rollupConfig.plugins` can be a single plugin, so we want to put it into an array so that we can push our own plugin\n nitro.options.rollupConfig.plugins = [nitro.options.rollupConfig.plugins];\n }\n\n nitro.options.rollupConfig.plugins.push(\n wrapEntryWithDynamicImport({\n resolvedSentryConfigPath: createResolver(nitro.options.srcDir).resolve(`/${serverConfigFile}`),\n experimental_entrypointWrappedFunctions: moduleOptions.experimental_entrypointWrappedFunctions,\n }),\n );\n}\n\n/**\n * Rollup plugin to include the Sentry server configuration file to the server build output.\n */\nfunction injectServerConfigPlugin(nitro: Nitro, serverConfigFile: string, debug?: 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.srcDir).resolve(`/${serverConfigFile}`);\n\n if (!existsSync(configPath)) {\n if (debug) {\n logger.log(`[Sentry] Sentry server config file not found: ${configPath}`);\n }\n return;\n }\n\n // Emitting a file adds it to the build output (Rollup is aware of the file, and we can later return the code in resolveId)\n this.emitFile({\n type: 'chunk',\n id: `${filePrefix}${serverConfigFile}`,\n fileName: `${SERVER_CONFIG_FILENAME}.mjs`,\n });\n },\n\n resolveId(source) {\n if (source.startsWith(filePrefix)) {\n const originalFilePath = source.replace(filePrefix, '');\n const configPath = createResolver(nitro.options.rootDir).resolve(`/${originalFilePath}`);\n\n return { id: configPath };\n }\n return null;\n },\n };\n}\n\n/**\n * A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first\n * by using a regular `import` and load the server after that.\n * This also works with serverless `handler` functions, as it re-exports the `handler`.\n */\nfunction wrapEntryWithDynamicImport({\n resolvedSentryConfigPath,\n experimental_entrypointWrappedFunctions,\n debug,\n}: {\n resolvedSentryConfigPath: string;\n experimental_entrypointWrappedFunctions: string[];\n debug?: boolean;\n}): InputPluginOption {\n // In order to correctly import the server config file\n // and dynamically import the nitro runtime, we need to\n // mark the resolutionId with '\\0raw' to fall into the\n // raw chunk group, c.f. https://github.com/nitrojs/nitro/commit/8b4a408231bdc222569a32ce109796a41eac4aa6#diff-e58102d2230f95ddeef2662957b48d847a6e891e354cfd0ae6e2e03ce848d1a2R142\n const resolutionIdPrefix = '\\0raw';\n\n return {\n name: 'sentry-wrap-entry-with-dynamic-import',\n async resolveId(source, importer, options) {\n if (source.includes(`/${SERVER_CONFIG_FILENAME}`)) {\n return { id: source, moduleSideEffects: true };\n }\n\n if (source === 'import-in-the-middle/hook.mjs') {\n // We are importing \"import-in-the-middle\" in the returned code of the `load()` function below\n // By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it\n // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file is included, as not all node builders are including files imported with `module.register()`.\n // Prevents the error \"Failed to register ESM hook Error: Cannot find module 'import-in-the-middle/hook.mjs'\"\n return { id: source, moduleSideEffects: true, external: true };\n }\n\n if (options.isEntry && source.includes('.mjs') && !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const resolution = await this.resolve(source, importer, options);\n\n // If it cannot be resolved or is external, just return it so that Rollup can display an error\n if (!resolution || resolution?.external) return resolution;\n\n const moduleInfo = await this.load(resolution);\n\n moduleInfo.moduleSideEffects = true;\n\n // The enclosing `if` already checks for the suffix in `source`, but a check in `resolution.id` is needed as well to prevent multiple attachment of the suffix\n return resolution.id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ? resolution.id\n : `${resolutionIdPrefix}${resolution.id\n // Concatenates the query params to mark the file (also attaches names of re-exports - this is needed for serverless functions to re-export the handler)\n .concat(SENTRY_WRAPPED_ENTRY)\n .concat(\n constructWrappedFunctionExportQuery(\n moduleInfo.exportedBindings,\n experimental_entrypointWrappedFunctions,\n debug,\n ),\n )\n .concat(QUERY_END_INDICATOR)}`;\n }\n return null;\n },\n load(id: string) {\n if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);\n\n // Mostly useful for serverless `handler` functions\n const reExportedFunctions =\n id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS)\n ? constructFunctionReExport(id, entryId)\n : '';\n\n return (\n // Regular `import` of the Sentry config\n `import ${JSON.stringify(resolvedSentryConfigPath)};\\n` +\n // Dynamic `import()` for the previous, actual entry point.\n // `import()` can be used for any code that should be run after the hooks are registered (https://nodejs.org/api/module.html#enabling)\n `import(${JSON.stringify(entryId)});\\n` +\n // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file wil be included, as not all node builders are including files imported with `module.register()`.\n \"import 'import-in-the-middle/hook.mjs';\\n\" +\n `${reExportedFunctions}\\n`\n );\n }\n\n return null;\n },\n };\n}\n"],"names":[],"mappings":";;;;;;AAkBA,MAAM,sBAAA,GAAyB,sBAAsB;;AAErD;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,sBAAsB;AACtC,EAAE,aAAa;AACf,EAAE,KAAK;AACP,EAAE,gBAAgB;AAClB,EAAQ;AACR,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK;AAC7D,IAAI,IAAI,YAAY,EAAE,OAAQ,KAAI,IAAK,IAAG,YAAY,EAAE,OAAQ,KAAI,SAAS,EAAE;AAC/E,MAAM,YAAY,CAAC,OAAQ,GAAE,EAAE;AAC/B,KAAM,MAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE;AACrD;AACA,MAAM,YAAY,CAAC,OAAQ,GAAE,CAAC,YAAY,CAAC,OAAO,CAAC;AACnD;;AAEA,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,gBAAgB,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;AACrG,GAAG,CAAC;;AAEJ;AACA;AACA;AACA;AACA,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CA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,IAAA;AACA,KAAA;AACA,IAAA,IAAA,CAAA,EAAA,EAAA;AACA,MAAA,IAAA,EAAA,CAAA,QAAA,CAAA,CAAA,IAAA,EAAA,oBAAA,CAAA,CAAA,CAAA,EAAA;AACA,QAAA,MAAA,OAAA,GAAA,yBAAA,CAAA,EAAA,CAAA,CAAA,KAAA,CAAA,kBAAA,CAAA,MAAA,CAAA;;AAEA;AACA,QAAA,MAAA,mBAAA;AACA,UAAA,EAAA,CAAA,QAAA,CAAA,wBAAA,CAAA,IAAA,EAAA,CAAA,QAAA,CAAA,2BAAA;AACA,cAAA,yBAAA,CAAA,EAAA,EAAA,OAAA;AACA,cAAA,EAAA;;AAEA,QAAA;AACA;AACA,UAAA,CAAA,OAAA,EAAA,IAAA,CAAA,SAAA,CAAA,wBAAA,CAAA,CAAA,GAAA,CAAA;AACA;AACA;AACA,UAAA,CAAA,OAAA,EAAA,IAAA,CAAA,SAAA,CAAA,OAAA,CAAA,CAAA,IAAA,CAAA;AACA;AACA,UAAA,2CAAA;AACA,UAAA,CAAA,EAAA,mBAAA,CAAA,EAAA;AACA;AACA;;AAEA,MAAA,OAAA,IAAA;AACA,KAAA;AACA,GAAA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"addServerConfig.js","sources":["../../../src/vite/addServerConfig.ts"],"sourcesContent":["import * as fs from 'fs';\nimport { createResolver } from '@nuxt/kit';\nimport { logger } from '@sentry/core';\nimport type { Nitro } from 'nitropack';\nimport type { InputPluginOption } from 'rollup';\nimport type { SentryNuxtModuleOptions } from '../common/types';\nimport {\n QUERY_END_INDICATOR,\n SENTRY_REEXPORTED_FUNCTIONS,\n SENTRY_WRAPPED_ENTRY,\n SENTRY_WRAPPED_FUNCTIONS,\n constructFunctionReExport,\n constructWrappedFunctionExportQuery,\n getFilenameFromNodeStartCommand,\n removeSentryQueryFromPath,\n} from './utils';\nimport { existsSync } from 'node:fs';\n\nconst SERVER_CONFIG_FILENAME = 'sentry.server.config';\n\n/**\n * Adds the `sentry.server.config.ts` file as `sentry.server.config.mjs` to the `.output` directory to be able to reference this file in the node --import option.\n *\n * By adding a Rollup plugin to the Nitro Rollup options, the Sentry server config is transpiled and emitted to the server build.\n */\nexport function addServerConfigToBuild(\n moduleOptions: SentryNuxtModuleOptions,\n nitro: Nitro,\n serverConfigFile: string,\n): void {\n nitro.hooks.hook('rollup:before', (nitro, rollupConfig) => {\n if (rollupConfig?.plugins === null || rollupConfig?.plugins === undefined) {\n rollupConfig.plugins = [];\n } else if (!Array.isArray(rollupConfig.plugins)) {\n // `rollupConfig.plugins` can be a single plugin, so we want to put it into an array so that we can push our own plugin\n rollupConfig.plugins = [rollupConfig.plugins];\n }\n\n rollupConfig.plugins.push(injectServerConfigPlugin(nitro, serverConfigFile, moduleOptions.debug));\n });\n}\n\n/**\n * Adds the Sentry server config import at the top of the server entry file to load the SDK on the server.\n * This is necessary for environments where modifying the node option `--import` is not possible.\n * However, only limited tracing instrumentation is supported when doing this.\n */\nexport function addSentryTopImport(moduleOptions: SentryNuxtModuleOptions, nitro: Nitro): void {\n nitro.hooks.hook('close', async () => {\n const fileNameFromCommand =\n nitro.options.commands.preview && getFilenameFromNodeStartCommand(nitro.options.commands.preview);\n\n // other presets ('node-server' or 'vercel') have an index.mjs\n const presetsWithServerFile = ['netlify'];\n\n const entryFileName = fileNameFromCommand\n ? fileNameFromCommand\n : typeof nitro.options.rollupConfig?.output.entryFileNames === 'string'\n ? nitro.options.rollupConfig?.output.entryFileNames\n : presetsWithServerFile.includes(nitro.options.preset)\n ? 'server.mjs'\n : 'index.mjs';\n\n const serverDirResolver = createResolver(nitro.options.output.serverDir);\n const entryFilePath = serverDirResolver.resolve(entryFileName);\n\n try {\n fs.readFile(entryFilePath, 'utf8', (err, data) => {\n const updatedContent = `import './${SERVER_CONFIG_FILENAME}.mjs';\\n${data}`;\n\n fs.writeFile(entryFilePath, updatedContent, 'utf8', () => {\n if (moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] Successfully added the Sentry import to the server entry file \"\\`${entryFilePath}\\`\"`,\n );\n }\n });\n });\n } catch (err) {\n if (moduleOptions.debug) {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] An error occurred when trying to add the Sentry import to the server entry file \"\\`${entryFilePath}\\`\":`,\n err,\n );\n }\n }\n });\n}\n\n/**\n * This function modifies the Rollup configuration to include a plugin that wraps the entry file with a dynamic import (`import()`)\n * and adds the Sentry server config with the static `import` declaration.\n *\n * With this, the Sentry server config can be loaded before all other modules of the application (which is needed for import-in-the-middle).\n * See: https://nodejs.org/api/module.html#enabling\n */\nexport function addDynamicImportEntryFileWrapper(\n nitro: Nitro,\n serverConfigFile: string,\n moduleOptions: Omit<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'> &\n Required<Pick<SentryNuxtModuleOptions, 'experimental_entrypointWrappedFunctions'>>,\n): void {\n if (!nitro.options.rollupConfig) {\n nitro.options.rollupConfig = { output: {} };\n }\n\n if (nitro.options.rollupConfig?.plugins === null || nitro.options.rollupConfig?.plugins === undefined) {\n nitro.options.rollupConfig.plugins = [];\n } else if (!Array.isArray(nitro.options.rollupConfig.plugins)) {\n // `rollupConfig.plugins` can be a single plugin, so we want to put it into an array so that we can push our own plugin\n nitro.options.rollupConfig.plugins = [nitro.options.rollupConfig.plugins];\n }\n\n nitro.options.rollupConfig.plugins.push(\n wrapEntryWithDynamicImport({\n resolvedSentryConfigPath: createResolver(nitro.options.srcDir).resolve(`/${serverConfigFile}`),\n experimental_entrypointWrappedFunctions: moduleOptions.experimental_entrypointWrappedFunctions,\n }),\n );\n}\n\n/**\n * Rollup plugin to include the Sentry server configuration file to the server build output.\n */\nfunction injectServerConfigPlugin(nitro: Nitro, serverConfigFile: string, debug?: 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.srcDir).resolve(`/${serverConfigFile}`);\n\n if (!existsSync(configPath)) {\n if (debug) {\n logger.log(`[Sentry] Sentry server config file not found: ${configPath}`);\n }\n return;\n }\n\n // Emitting a file adds it to the build output (Rollup is aware of the file, and we can later return the code in resolveId)\n this.emitFile({\n type: 'chunk',\n id: `${filePrefix}${serverConfigFile}`,\n fileName: `${SERVER_CONFIG_FILENAME}.mjs`,\n });\n },\n\n resolveId(source) {\n if (source.startsWith(filePrefix)) {\n const originalFilePath = source.replace(filePrefix, '');\n const configPath = createResolver(nitro.options.rootDir).resolve(`/${originalFilePath}`);\n\n return { id: configPath };\n }\n return null;\n },\n };\n}\n\n/**\n * A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first\n * by using a regular `import` and load the server after that.\n * This also works with serverless `handler` functions, as it re-exports the `handler`.\n */\nfunction wrapEntryWithDynamicImport({\n resolvedSentryConfigPath,\n experimental_entrypointWrappedFunctions,\n debug,\n}: {\n resolvedSentryConfigPath: string;\n experimental_entrypointWrappedFunctions: string[];\n debug?: boolean;\n}): InputPluginOption {\n // In order to correctly import the server config file\n // and dynamically import the nitro runtime, we need to\n // mark the resolutionId with '\\0raw' to fall into the\n // raw chunk group, c.f. https://github.com/nitrojs/nitro/commit/8b4a408231bdc222569a32ce109796a41eac4aa6#diff-e58102d2230f95ddeef2662957b48d847a6e891e354cfd0ae6e2e03ce848d1a2R142\n const resolutionIdPrefix = '\\0raw';\n\n return {\n name: 'sentry-wrap-entry-with-dynamic-import',\n async resolveId(source, importer, options) {\n if (source.includes(`/${SERVER_CONFIG_FILENAME}`)) {\n return { id: source, moduleSideEffects: true };\n }\n\n if (source === 'import-in-the-middle/hook.mjs') {\n // We are importing \"import-in-the-middle\" in the returned code of the `load()` function below\n // By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it\n // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file is included, as not all node builders are including files imported with `module.register()`.\n // Prevents the error \"Failed to register ESM hook Error: Cannot find module 'import-in-the-middle/hook.mjs'\"\n return { id: source, moduleSideEffects: true, external: true };\n }\n\n if (options.isEntry && source.includes('.mjs') && !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const resolution = await this.resolve(source, importer, options);\n\n // If it cannot be resolved or is external, just return it so that Rollup can display an error\n if (!resolution || resolution?.external) return resolution;\n\n const moduleInfo = await this.load(resolution);\n\n moduleInfo.moduleSideEffects = true;\n\n // The enclosing `if` already checks for the suffix in `source`, but a check in `resolution.id` is needed as well to prevent multiple attachment of the suffix\n return resolution.id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ? resolution.id\n : `${resolutionIdPrefix}${resolution.id\n // Concatenates the query params to mark the file (also attaches names of re-exports - this is needed for serverless functions to re-export the handler)\n .concat(SENTRY_WRAPPED_ENTRY)\n .concat(\n constructWrappedFunctionExportQuery(\n moduleInfo.exportedBindings,\n experimental_entrypointWrappedFunctions,\n debug,\n ),\n )\n .concat(QUERY_END_INDICATOR)}`;\n }\n return null;\n },\n load(id: string) {\n if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);\n\n // Mostly useful for serverless `handler` functions\n const reExportedFunctions =\n id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS)\n ? constructFunctionReExport(id, entryId)\n : '';\n\n return (\n // Regular `import` of the Sentry config\n `import ${JSON.stringify(resolvedSentryConfigPath)};\\n` +\n // Dynamic `import()` for the previous, actual entry point.\n // `import()` can be used for any code that should be run after the hooks are registered (https://nodejs.org/api/module.html#enabling)\n `import(${JSON.stringify(entryId)});\\n` +\n // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file wil be included, as not all node builders are including files imported with `module.register()`.\n \"import 'import-in-the-middle/hook.mjs';\\n\" +\n `${reExportedFunctions}\\n`\n );\n }\n\n return null;\n },\n };\n}\n"],"names":[],"mappings":";;;;;;AAkBA,MAAM,sBAAA,GAAyB,sBAAsB;;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A;AACA,cAAA,EAAA;;AAEA,QAAA;AACA;AACA,UAAA,CAAA,OAAA,EAAA,IAAA,CAAA,SAAA,CAAA,wBAAA,CAAA,CAAA,GAAA,CAAA;AACA;AACA;AACA,UAAA,CAAA,OAAA,EAAA,IAAA,CAAA,SAAA,CAAA,OAAA,CAAA,CAAA,IAAA,CAAA;AACA;AACA,UAAA,2CAAA;AACA,UAAA,CAAA,EAAA,mBAAA,CAAA,EAAA;AACA;AACA;;AAEA,MAAA,OAAA,IAAA;AACA,KAAA;AACA,GAAA;AACA;;;;"}
|
|
@@ -137,7 +137,6 @@ function changeNuxtSourceMapSettings(
|
|
|
137
137
|
nuxt,
|
|
138
138
|
sentryModuleOptions,
|
|
139
139
|
) {
|
|
140
|
-
nuxt.options = nuxt.options || {};
|
|
141
140
|
nuxt.options.sourcemap = nuxt.options.sourcemap ?? { server: undefined, client: undefined };
|
|
142
141
|
|
|
143
142
|
let previousUserSourceMapSetting = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourceMaps.js","sources":["../../../src/vite/sourceMaps.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox } from '@sentry/core';\nimport { type SentryRollupPluginOptions, sentryRollupPlugin } from '@sentry/rollup-plugin';\nimport { type SentryVitePluginOptions, sentryVitePlugin } from '@sentry/vite-plugin';\nimport type { NitroConfig } from 'nitropack';\nimport type { OutputOptions } from 'rollup';\nimport type { SentryNuxtModuleOptions } from '../common/types';\n\n/**\n * Whether the user enabled (true, 'hidden', 'inline') or disabled (false) source maps\n */\nexport type UserSourceMapSetting = 'enabled' | 'disabled' | 'unset' | undefined;\n\n/**\n * Setup source maps for Sentry inside the Nuxt module during build time (in Vite for Nuxt and Rollup for Nitro).\n */\nexport function setupSourceMaps(moduleOptions: SentryNuxtModuleOptions, nuxt: Nuxt): void {\n const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {};\n const sourceMapsEnabled = sourceMapsUploadOptions.enabled ?? true;\n\n nuxt.hook('modules:done', () => {\n if (sourceMapsEnabled && !nuxt.options.dev) {\n changeNuxtSourceMapSettings(nuxt, moduleOptions);\n }\n });\n\n nuxt.hook('vite:extendConfig', async (viteConfig, _env) => {\n if (sourceMapsEnabled && viteConfig.mode !== 'development') {\n const previousUserSourceMapSetting = changeViteSourceMapSettings(viteConfig, moduleOptions);\n\n // Add Sentry plugin\n viteConfig.plugins = viteConfig.plugins || [];\n viteConfig.plugins.push(\n sentryVitePlugin(getPluginOptions(moduleOptions, previousUserSourceMapSetting === 'unset')),\n );\n }\n });\n\n nuxt.hook('nitro:config', (nitroConfig: NitroConfig) => {\n if (sourceMapsEnabled && !nitroConfig.dev) {\n if (!nitroConfig.rollupConfig) {\n nitroConfig.rollupConfig = {};\n }\n\n if (nitroConfig.rollupConfig.plugins === null || nitroConfig.rollupConfig.plugins === undefined) {\n nitroConfig.rollupConfig.plugins = [];\n } else if (!Array.isArray(nitroConfig.rollupConfig.plugins)) {\n // `rollupConfig.plugins` can be a single plugin, so we want to put it into an array so that we can push our own plugin\n nitroConfig.rollupConfig.plugins = [nitroConfig.rollupConfig.plugins];\n }\n\n const previousUserSourceMapSetting = changeRollupSourceMapSettings(nitroConfig, moduleOptions);\n\n // Add Sentry plugin\n nitroConfig.rollupConfig.plugins.push(\n sentryRollupPlugin(getPluginOptions(moduleOptions, previousUserSourceMapSetting === 'unset')),\n );\n }\n });\n}\n\n/**\n * Normalizes the beginning of a path from e.g. ../../../ to ./\n */\nfunction normalizePath(path: string): string {\n return path.replace(/^(\\.\\.\\/)+/, './');\n}\n\n/**\n * Generates source maps upload options for the Sentry Vite and Rollup plugin.\n *\n * Only exported for Testing purposes.\n */\nexport function getPluginOptions(\n moduleOptions: SentryNuxtModuleOptions,\n deleteFilesAfterUpload: boolean,\n): SentryVitePluginOptions | SentryRollupPluginOptions {\n const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {};\n\n if (typeof sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload === 'undefined' && deleteFilesAfterUpload) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Setting `sentry.sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload: [\".*/**/public/**/*.map\"]` to delete generated source maps after they were uploaded to Sentry.',\n );\n });\n }\n\n return {\n org: sourceMapsUploadOptions.org ?? process.env.SENTRY_ORG,\n project: sourceMapsUploadOptions.project ?? process.env.SENTRY_PROJECT,\n authToken: sourceMapsUploadOptions.authToken ?? process.env.SENTRY_AUTH_TOKEN,\n telemetry: sourceMapsUploadOptions.telemetry ?? true,\n url: sourceMapsUploadOptions.url ?? process.env.SENTRY_URL,\n debug: moduleOptions.debug ?? false,\n silent: sourceMapsUploadOptions.silent ?? false,\n errorHandler: sourceMapsUploadOptions.errorHandler,\n release: {\n name: sourceMapsUploadOptions.release?.name,\n ...moduleOptions?.unstable_sentryBundlerPluginOptions?.release,\n },\n _metaOptions: {\n telemetry: {\n metaFramework: 'nuxt',\n },\n },\n ...moduleOptions?.unstable_sentryBundlerPluginOptions,\n\n sourcemaps: {\n // The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server')\n // We cannot determine automatically how the build folder looks like (depends on the preset), so we have to accept that source maps are uploaded multiple times (with the vitePlugin for Nuxt and the rollupPlugin for Nitro).\n // If we could know where the server/client assets are located, we could do something like this (based on the Nitro preset): isNitro ? ['./.output/server/**/*'] : ['./.output/public/**/*'],\n assets: sourceMapsUploadOptions.sourcemaps?.assets ?? undefined,\n ignore: sourceMapsUploadOptions.sourcemaps?.ignore ?? undefined,\n filesToDeleteAfterUpload: sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload\n ? sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload\n : deleteFilesAfterUpload\n ? ['.*/**/public/**/*.map']\n : undefined,\n rewriteSources: (source: string) => normalizePath(source),\n ...moduleOptions?.unstable_sentryBundlerPluginOptions?.sourcemaps,\n },\n };\n}\n\n/* There are 3 ways to set up source maps (https://github.com/getsentry/sentry-javascript/issues/13993)\n 1. User explicitly disabled source maps\n - keep this setting (emit a warning that errors won't be unminified in Sentry)\n - We will not upload anything\n 2. users enabled source map generation (true, hidden, inline).\n - keep this setting (don't do anything - like deletion - besides uploading)\n 3. users did not set source maps generation\n - we enable 'hidden' source maps generation\n - configure `filesToDeleteAfterUpload` to delete all .map files (we emit a log about this)\n\n Nuxt has 3 places to set source maps: vite options, rollup options, nuxt itself\n Ideally, all 3 are enabled to get all source maps.\n */\n\n/** only exported for testing */\nexport function changeNuxtSourceMapSettings(\n nuxt: Nuxt,\n sentryModuleOptions: SentryNuxtModuleOptions,\n): { client: UserSourceMapSetting; server: UserSourceMapSetting } {\n nuxt.options = nuxt.options || {};\n nuxt.options.sourcemap = nuxt.options.sourcemap ?? { server: undefined, client: undefined };\n\n let previousUserSourceMapSetting: { client: UserSourceMapSetting; server: UserSourceMapSetting } = {\n client: undefined,\n server: undefined,\n };\n\n const nuxtSourceMap = nuxt.options.sourcemap;\n\n if (typeof nuxtSourceMap === 'string' || typeof nuxtSourceMap === 'boolean' || typeof nuxtSourceMap === 'undefined') {\n switch (nuxtSourceMap) {\n case false:\n warnExplicitlyDisabledSourceMap('sourcemap');\n previousUserSourceMapSetting = { client: 'disabled', server: 'disabled' };\n break;\n\n case 'hidden':\n case true:\n logKeepSourceMapSetting(sentryModuleOptions, 'sourcemap', (nuxtSourceMap as true).toString());\n previousUserSourceMapSetting = { client: 'enabled', server: 'enabled' };\n break;\n case undefined:\n nuxt.options.sourcemap = { server: 'hidden', client: 'hidden' };\n logSentryEnablesSourceMap('sourcemap.client', 'hidden');\n logSentryEnablesSourceMap('sourcemap.server', 'hidden');\n previousUserSourceMapSetting = { client: 'unset', server: 'unset' };\n break;\n }\n } else {\n if (nuxtSourceMap.client === false) {\n warnExplicitlyDisabledSourceMap('sourcemap.client');\n previousUserSourceMapSetting.client = 'disabled';\n } else if (['hidden', true].includes(nuxtSourceMap.client)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'sourcemap.client', nuxtSourceMap.client.toString());\n previousUserSourceMapSetting.client = 'enabled';\n } else {\n nuxt.options.sourcemap.client = 'hidden';\n logSentryEnablesSourceMap('sourcemap.client', 'hidden');\n previousUserSourceMapSetting.client = 'unset';\n }\n\n if (nuxtSourceMap.server === false) {\n warnExplicitlyDisabledSourceMap('sourcemap.server');\n previousUserSourceMapSetting.server = 'disabled';\n } else if (['hidden', true].includes(nuxtSourceMap.server)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'sourcemap.server', nuxtSourceMap.server.toString());\n previousUserSourceMapSetting.server = 'enabled';\n } else {\n nuxt.options.sourcemap.server = 'hidden';\n logSentryEnablesSourceMap('sourcemap.server', 'hidden');\n previousUserSourceMapSetting.server = 'unset';\n }\n }\n\n return previousUserSourceMapSetting;\n}\n\n/** only exported for testing */\nexport function changeViteSourceMapSettings(\n viteConfig: { build?: { sourcemap?: boolean | 'inline' | 'hidden' } },\n sentryModuleOptions: SentryNuxtModuleOptions,\n): UserSourceMapSetting {\n viteConfig.build = viteConfig.build || {};\n const viteSourceMap = viteConfig.build.sourcemap;\n\n let previousUserSourceMapSetting: UserSourceMapSetting;\n\n if (viteSourceMap === false) {\n warnExplicitlyDisabledSourceMap('vite.build.sourcemap');\n previousUserSourceMapSetting = 'disabled';\n } else if (viteSourceMap && ['hidden', 'inline', true].includes(viteSourceMap)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'vite.build.sourcemap', viteSourceMap.toString());\n previousUserSourceMapSetting = 'enabled';\n } else {\n viteConfig.build.sourcemap = 'hidden';\n logSentryEnablesSourceMap('vite.build.sourcemap', 'hidden');\n previousUserSourceMapSetting = 'unset';\n }\n\n return previousUserSourceMapSetting;\n}\n\n/** only exported for testing */\nexport function changeRollupSourceMapSettings(\n nitroConfig: {\n rollupConfig?: {\n output?: {\n sourcemap?: OutputOptions['sourcemap'];\n sourcemapExcludeSources?: OutputOptions['sourcemapExcludeSources'];\n };\n };\n },\n sentryModuleOptions: SentryNuxtModuleOptions,\n): UserSourceMapSetting {\n nitroConfig.rollupConfig = nitroConfig.rollupConfig || {};\n nitroConfig.rollupConfig.output = nitroConfig.rollupConfig.output || { sourcemap: undefined };\n\n let previousUserSourceMapSetting: UserSourceMapSetting;\n\n const nitroSourceMap = nitroConfig.rollupConfig.output.sourcemap;\n\n if (nitroSourceMap === false) {\n warnExplicitlyDisabledSourceMap('nitro.rollupConfig.output.sourcemap');\n previousUserSourceMapSetting = 'disabled';\n } else if (nitroSourceMap && ['hidden', 'inline', true].includes(nitroSourceMap)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'nitro.rollupConfig.output.sourcemap', nitroSourceMap.toString());\n previousUserSourceMapSetting = 'enabled';\n } else {\n nitroConfig.rollupConfig.output.sourcemap = 'hidden';\n logSentryEnablesSourceMap('nitro.rollupConfig.output.sourcemap', 'hidden');\n previousUserSourceMapSetting = 'unset';\n }\n\n nitroConfig.rollupConfig.output.sourcemapExcludeSources = false;\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Disabled source map setting in the Nuxt config: `nitro.rollupConfig.output.sourcemapExcludeSources`. Source maps will include the actual code to be able to un-minify code snippets in Sentry.',\n );\n });\n\n return previousUserSourceMapSetting;\n}\n\nfunction logKeepSourceMapSetting(\n sentryNuxtModuleOptions: SentryNuxtModuleOptions,\n settingKey: string,\n settingValue: string,\n): void {\n if (sentryNuxtModuleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] We discovered \\`${settingKey}\\` is set to \\`${settingValue}\\`. Sentry will keep this source map setting. This will un-minify the code snippet on the Sentry Issue page.`,\n );\n });\n }\n}\n\nfunction warnExplicitlyDisabledSourceMap(settingKey: string): void {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Parts of source map generation are currently disabled in your Nuxt configuration (\\`${settingKey}: false\\`). This setting is either a default setting or was explicitly set in your configuration. Sentry won't override this setting. Without source maps, code snippets on the Sentry Issues page will remain minified. To show unminified code, enable source maps in \\`${settingKey}\\` (e.g. by setting them to \\`hidden\\`).`,\n );\n });\n}\n\nfunction logSentryEnablesSourceMap(settingKey: string, settingValue: string): void {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(`[Sentry] Enabled source map generation in the build options with \\`${settingKey}: ${settingValue}\\`.`);\n });\n}\n"],"names":[],"mappings":";;;;AAQA;AACA;AACA;;AAGA;AACA;AACA;AACO,SAAS,eAAe,CAAC,aAAa,EAA2B,IAAI,EAAc;AAC1F,EAAE,MAAM,0BAA0B,aAAa,CAAC,uBAAwB,IAAG,EAAE;AAC7E,EAAE,MAAM,iBAAkB,GAAE,uBAAuB,CAAC,OAAA,IAAW,IAAI;;AAEnE,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM;AAClC,IAAI,IAAI,iBAAA,IAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;AAChD,MAAM,2BAA2B,CAAC,IAAI,EAAE,aAAa,CAAC;AACtD;AACA,GAAG,CAAC;;AAEJ,EAAE,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,UAAU,EAAE,IAAI,KAAK;AAC7D,IAAI,IAAI,iBAAkB,IAAG,UAAU,CAAC,IAAA,KAAS,aAAa,EAAE;AAChE,MAAM,MAAM,+BAA+B,2BAA2B,CAAC,UAAU,EAAE,aAAa,CAAC;;AAEjG;AACA,MAAM,UAAU,CAAC,OAAQ,GAAE,UAAU,CAAC,OAAA,IAAW,EAAE;AACnD,MAAM,UAAU,CAAC,OAAO,CAAC,IAAI;AAC7B,QAAQ,gBAAgB,CAAC,gBAAgB,CAAC,aAAa,EAAE,4BAA6B,KAAI,OAAO,CAAC,CAAC;AACnG,OAAO;AACP;AACA,GAAG,CAAC;;AAEJ,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,WAAW,KAA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,CAAC,MAAM;AACvB;AACA,IAAI,OAAO,CAAC,IAAI;AAChB,MAAM,CAAC,6FAA6F,EAAE,UAAU,CAAC,0QAA0Q,EAAE,UAAU,CAAC,wCAAwC,CAAC;AACjb,KAAK;AACL,GAAG,CAAC;AACJ;;AAEA,SAAS,yBAAyB,CAAC,UAAU,EAAU,YAAY,EAAgB;AACnF,EAAE,cAAc,CAAC,MAAM;AACvB;AACA,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,mEAAmE,EAAE,UAAU,CAAC,EAAE,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;AACvH,GAAG,CAAC;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"sourceMaps.js","sources":["../../../src/vite/sourceMaps.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema';\nimport { consoleSandbox } from '@sentry/core';\nimport { type SentryRollupPluginOptions, sentryRollupPlugin } from '@sentry/rollup-plugin';\nimport { type SentryVitePluginOptions, sentryVitePlugin } from '@sentry/vite-plugin';\nimport type { NitroConfig } from 'nitropack';\nimport type { OutputOptions } from 'rollup';\nimport type { SentryNuxtModuleOptions } from '../common/types';\n\n/**\n * Whether the user enabled (true, 'hidden', 'inline') or disabled (false) source maps\n */\nexport type UserSourceMapSetting = 'enabled' | 'disabled' | 'unset' | undefined;\n\n/**\n * Setup source maps for Sentry inside the Nuxt module during build time (in Vite for Nuxt and Rollup for Nitro).\n */\nexport function setupSourceMaps(moduleOptions: SentryNuxtModuleOptions, nuxt: Nuxt): void {\n const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {};\n const sourceMapsEnabled = sourceMapsUploadOptions.enabled ?? true;\n\n nuxt.hook('modules:done', () => {\n if (sourceMapsEnabled && !nuxt.options.dev) {\n changeNuxtSourceMapSettings(nuxt, moduleOptions);\n }\n });\n\n nuxt.hook('vite:extendConfig', async (viteConfig, _env) => {\n if (sourceMapsEnabled && viteConfig.mode !== 'development') {\n const previousUserSourceMapSetting = changeViteSourceMapSettings(viteConfig, moduleOptions);\n\n // Add Sentry plugin\n viteConfig.plugins = viteConfig.plugins || [];\n viteConfig.plugins.push(\n sentryVitePlugin(getPluginOptions(moduleOptions, previousUserSourceMapSetting === 'unset')),\n );\n }\n });\n\n nuxt.hook('nitro:config', (nitroConfig: NitroConfig) => {\n if (sourceMapsEnabled && !nitroConfig.dev) {\n if (!nitroConfig.rollupConfig) {\n nitroConfig.rollupConfig = {};\n }\n\n if (nitroConfig.rollupConfig.plugins === null || nitroConfig.rollupConfig.plugins === undefined) {\n nitroConfig.rollupConfig.plugins = [];\n } else if (!Array.isArray(nitroConfig.rollupConfig.plugins)) {\n // `rollupConfig.plugins` can be a single plugin, so we want to put it into an array so that we can push our own plugin\n nitroConfig.rollupConfig.plugins = [nitroConfig.rollupConfig.plugins];\n }\n\n const previousUserSourceMapSetting = changeRollupSourceMapSettings(nitroConfig, moduleOptions);\n\n // Add Sentry plugin\n nitroConfig.rollupConfig.plugins.push(\n sentryRollupPlugin(getPluginOptions(moduleOptions, previousUserSourceMapSetting === 'unset')),\n );\n }\n });\n}\n\n/**\n * Normalizes the beginning of a path from e.g. ../../../ to ./\n */\nfunction normalizePath(path: string): string {\n return path.replace(/^(\\.\\.\\/)+/, './');\n}\n\n/**\n * Generates source maps upload options for the Sentry Vite and Rollup plugin.\n *\n * Only exported for Testing purposes.\n */\nexport function getPluginOptions(\n moduleOptions: SentryNuxtModuleOptions,\n deleteFilesAfterUpload: boolean,\n): SentryVitePluginOptions | SentryRollupPluginOptions {\n const sourceMapsUploadOptions = moduleOptions.sourceMapsUploadOptions || {};\n\n if (typeof sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload === 'undefined' && deleteFilesAfterUpload) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Setting `sentry.sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload: [\".*/**/public/**/*.map\"]` to delete generated source maps after they were uploaded to Sentry.',\n );\n });\n }\n\n return {\n org: sourceMapsUploadOptions.org ?? process.env.SENTRY_ORG,\n project: sourceMapsUploadOptions.project ?? process.env.SENTRY_PROJECT,\n authToken: sourceMapsUploadOptions.authToken ?? process.env.SENTRY_AUTH_TOKEN,\n telemetry: sourceMapsUploadOptions.telemetry ?? true,\n url: sourceMapsUploadOptions.url ?? process.env.SENTRY_URL,\n debug: moduleOptions.debug ?? false,\n silent: sourceMapsUploadOptions.silent ?? false,\n errorHandler: sourceMapsUploadOptions.errorHandler,\n release: {\n name: sourceMapsUploadOptions.release?.name,\n ...moduleOptions?.unstable_sentryBundlerPluginOptions?.release,\n },\n _metaOptions: {\n telemetry: {\n metaFramework: 'nuxt',\n },\n },\n ...moduleOptions?.unstable_sentryBundlerPluginOptions,\n\n sourcemaps: {\n // The server/client files are in different places depending on the nitro preset (e.g. '.output/server' or '.netlify/functions-internal/server')\n // We cannot determine automatically how the build folder looks like (depends on the preset), so we have to accept that source maps are uploaded multiple times (with the vitePlugin for Nuxt and the rollupPlugin for Nitro).\n // If we could know where the server/client assets are located, we could do something like this (based on the Nitro preset): isNitro ? ['./.output/server/**/*'] : ['./.output/public/**/*'],\n assets: sourceMapsUploadOptions.sourcemaps?.assets ?? undefined,\n ignore: sourceMapsUploadOptions.sourcemaps?.ignore ?? undefined,\n filesToDeleteAfterUpload: sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload\n ? sourceMapsUploadOptions.sourcemaps?.filesToDeleteAfterUpload\n : deleteFilesAfterUpload\n ? ['.*/**/public/**/*.map']\n : undefined,\n rewriteSources: (source: string) => normalizePath(source),\n ...moduleOptions?.unstable_sentryBundlerPluginOptions?.sourcemaps,\n },\n };\n}\n\n/* There are 3 ways to set up source maps (https://github.com/getsentry/sentry-javascript/issues/13993)\n 1. User explicitly disabled source maps\n - keep this setting (emit a warning that errors won't be unminified in Sentry)\n - We will not upload anything\n 2. users enabled source map generation (true, hidden, inline).\n - keep this setting (don't do anything - like deletion - besides uploading)\n 3. users did not set source maps generation\n - we enable 'hidden' source maps generation\n - configure `filesToDeleteAfterUpload` to delete all .map files (we emit a log about this)\n\n Nuxt has 3 places to set source maps: vite options, rollup options, nuxt itself\n Ideally, all 3 are enabled to get all source maps.\n */\n\n/** only exported for testing */\nexport function changeNuxtSourceMapSettings(\n nuxt: Nuxt,\n sentryModuleOptions: SentryNuxtModuleOptions,\n): { client: UserSourceMapSetting; server: UserSourceMapSetting } {\n nuxt.options.sourcemap = nuxt.options.sourcemap ?? { server: undefined, client: undefined };\n\n let previousUserSourceMapSetting: { client: UserSourceMapSetting; server: UserSourceMapSetting } = {\n client: undefined,\n server: undefined,\n };\n\n const nuxtSourceMap = nuxt.options.sourcemap;\n\n if (typeof nuxtSourceMap === 'string' || typeof nuxtSourceMap === 'boolean' || typeof nuxtSourceMap === 'undefined') {\n switch (nuxtSourceMap) {\n case false:\n warnExplicitlyDisabledSourceMap('sourcemap');\n previousUserSourceMapSetting = { client: 'disabled', server: 'disabled' };\n break;\n\n case 'hidden':\n case true:\n logKeepSourceMapSetting(sentryModuleOptions, 'sourcemap', (nuxtSourceMap as true).toString());\n previousUserSourceMapSetting = { client: 'enabled', server: 'enabled' };\n break;\n case undefined:\n nuxt.options.sourcemap = { server: 'hidden', client: 'hidden' };\n logSentryEnablesSourceMap('sourcemap.client', 'hidden');\n logSentryEnablesSourceMap('sourcemap.server', 'hidden');\n previousUserSourceMapSetting = { client: 'unset', server: 'unset' };\n break;\n }\n } else {\n if (nuxtSourceMap.client === false) {\n warnExplicitlyDisabledSourceMap('sourcemap.client');\n previousUserSourceMapSetting.client = 'disabled';\n } else if (['hidden', true].includes(nuxtSourceMap.client)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'sourcemap.client', nuxtSourceMap.client.toString());\n previousUserSourceMapSetting.client = 'enabled';\n } else {\n nuxt.options.sourcemap.client = 'hidden';\n logSentryEnablesSourceMap('sourcemap.client', 'hidden');\n previousUserSourceMapSetting.client = 'unset';\n }\n\n if (nuxtSourceMap.server === false) {\n warnExplicitlyDisabledSourceMap('sourcemap.server');\n previousUserSourceMapSetting.server = 'disabled';\n } else if (['hidden', true].includes(nuxtSourceMap.server)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'sourcemap.server', nuxtSourceMap.server.toString());\n previousUserSourceMapSetting.server = 'enabled';\n } else {\n nuxt.options.sourcemap.server = 'hidden';\n logSentryEnablesSourceMap('sourcemap.server', 'hidden');\n previousUserSourceMapSetting.server = 'unset';\n }\n }\n\n return previousUserSourceMapSetting;\n}\n\n/** only exported for testing */\nexport function changeViteSourceMapSettings(\n viteConfig: { build?: { sourcemap?: boolean | 'inline' | 'hidden' } },\n sentryModuleOptions: SentryNuxtModuleOptions,\n): UserSourceMapSetting {\n viteConfig.build = viteConfig.build || {};\n const viteSourceMap = viteConfig.build.sourcemap;\n\n let previousUserSourceMapSetting: UserSourceMapSetting;\n\n if (viteSourceMap === false) {\n warnExplicitlyDisabledSourceMap('vite.build.sourcemap');\n previousUserSourceMapSetting = 'disabled';\n } else if (viteSourceMap && ['hidden', 'inline', true].includes(viteSourceMap)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'vite.build.sourcemap', viteSourceMap.toString());\n previousUserSourceMapSetting = 'enabled';\n } else {\n viteConfig.build.sourcemap = 'hidden';\n logSentryEnablesSourceMap('vite.build.sourcemap', 'hidden');\n previousUserSourceMapSetting = 'unset';\n }\n\n return previousUserSourceMapSetting;\n}\n\n/** only exported for testing */\nexport function changeRollupSourceMapSettings(\n nitroConfig: {\n rollupConfig?: {\n output?: {\n sourcemap?: OutputOptions['sourcemap'];\n sourcemapExcludeSources?: OutputOptions['sourcemapExcludeSources'];\n };\n };\n },\n sentryModuleOptions: SentryNuxtModuleOptions,\n): UserSourceMapSetting {\n nitroConfig.rollupConfig = nitroConfig.rollupConfig || {};\n nitroConfig.rollupConfig.output = nitroConfig.rollupConfig.output || { sourcemap: undefined };\n\n let previousUserSourceMapSetting: UserSourceMapSetting;\n\n const nitroSourceMap = nitroConfig.rollupConfig.output.sourcemap;\n\n if (nitroSourceMap === false) {\n warnExplicitlyDisabledSourceMap('nitro.rollupConfig.output.sourcemap');\n previousUserSourceMapSetting = 'disabled';\n } else if (nitroSourceMap && ['hidden', 'inline', true].includes(nitroSourceMap)) {\n logKeepSourceMapSetting(sentryModuleOptions, 'nitro.rollupConfig.output.sourcemap', nitroSourceMap.toString());\n previousUserSourceMapSetting = 'enabled';\n } else {\n nitroConfig.rollupConfig.output.sourcemap = 'hidden';\n logSentryEnablesSourceMap('nitro.rollupConfig.output.sourcemap', 'hidden');\n previousUserSourceMapSetting = 'unset';\n }\n\n nitroConfig.rollupConfig.output.sourcemapExcludeSources = false;\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n '[Sentry] Disabled source map setting in the Nuxt config: `nitro.rollupConfig.output.sourcemapExcludeSources`. Source maps will include the actual code to be able to un-minify code snippets in Sentry.',\n );\n });\n\n return previousUserSourceMapSetting;\n}\n\nfunction logKeepSourceMapSetting(\n sentryNuxtModuleOptions: SentryNuxtModuleOptions,\n settingKey: string,\n settingValue: string,\n): void {\n if (sentryNuxtModuleOptions.debug) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(\n `[Sentry] We discovered \\`${settingKey}\\` is set to \\`${settingValue}\\`. Sentry will keep this source map setting. This will un-minify the code snippet on the Sentry Issue page.`,\n );\n });\n }\n}\n\nfunction warnExplicitlyDisabledSourceMap(settingKey: string): void {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry] Parts of source map generation are currently disabled in your Nuxt configuration (\\`${settingKey}: false\\`). This setting is either a default setting or was explicitly set in your configuration. Sentry won't override this setting. Without source maps, code snippets on the Sentry Issues page will remain minified. To show unminified code, enable source maps in \\`${settingKey}\\` (e.g. by setting them to \\`hidden\\`).`,\n );\n });\n}\n\nfunction logSentryEnablesSourceMap(settingKey: string, settingValue: string): void {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.log(`[Sentry] Enabled source map generation in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mE,EAAE,UAAU,CAAC,EAAE,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;AACvH,GAAG,CAAC;AACJ;;;;"}
|
package/build/module/module.json
CHANGED
package/build/module/module.mjs
CHANGED
|
@@ -104,32 +104,6 @@ function addServerConfigToBuild(moduleOptions, nitro, serverConfigFile) {
|
|
|
104
104
|
}
|
|
105
105
|
rollupConfig.plugins.push(injectServerConfigPlugin(nitro2, serverConfigFile, moduleOptions.debug));
|
|
106
106
|
});
|
|
107
|
-
nitro.hooks.hook("close", async () => {
|
|
108
|
-
const buildDirResolver = createResolver(nitro.options.buildDir);
|
|
109
|
-
const serverDirResolver = createResolver(nitro.options.output.serverDir);
|
|
110
|
-
const source = buildDirResolver.resolve(`dist/server/${SERVER_CONFIG_FILENAME}.mjs`);
|
|
111
|
-
const destination = serverDirResolver.resolve(`${SERVER_CONFIG_FILENAME}.mjs`);
|
|
112
|
-
try {
|
|
113
|
-
await fs.promises.access(source, fs.constants.F_OK);
|
|
114
|
-
await fs.promises.copyFile(source, destination);
|
|
115
|
-
if (moduleOptions.debug) {
|
|
116
|
-
consoleSandbox(() => {
|
|
117
|
-
console.log(
|
|
118
|
-
`[Sentry] Successfully added the content of the \`${serverConfigFile}\` file to \`${destination}\``
|
|
119
|
-
);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
} catch (error) {
|
|
123
|
-
if (moduleOptions.debug) {
|
|
124
|
-
consoleSandbox(() => {
|
|
125
|
-
console.warn(
|
|
126
|
-
`[Sentry] An error occurred when trying to add the \`${serverConfigFile}\` file to the \`.output\` directory`,
|
|
127
|
-
error
|
|
128
|
-
);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
107
|
}
|
|
134
108
|
function addSentryTopImport(moduleOptions, nitro) {
|
|
135
109
|
nitro.hooks.hook("close", async () => {
|
|
@@ -331,7 +305,6 @@ function getPluginOptions(moduleOptions, deleteFilesAfterUpload) {
|
|
|
331
305
|
};
|
|
332
306
|
}
|
|
333
307
|
function changeNuxtSourceMapSettings(nuxt, sentryModuleOptions) {
|
|
334
|
-
nuxt.options = nuxt.options || {};
|
|
335
308
|
nuxt.options.sourcemap = nuxt.options.sourcemap ?? { server: void 0, client: void 0 };
|
|
336
309
|
let previousUserSourceMapSetting = {
|
|
337
310
|
client: void 0,
|
|
@@ -6,7 +6,7 @@ import type { ComponentPublicInstance } from 'vue';
|
|
|
6
6
|
* Extracts the relevant context information from the error context (H3Event in Nitro Error)
|
|
7
7
|
* and created a structured context object.
|
|
8
8
|
*/
|
|
9
|
-
export declare function extractErrorContext(errorContext: CapturedErrorContext): Context;
|
|
9
|
+
export declare function extractErrorContext(errorContext: CapturedErrorContext | undefined): Context;
|
|
10
10
|
/**
|
|
11
11
|
* Adds Sentry tracing <meta> tags to the returned html page.
|
|
12
12
|
*
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import { captureException,
|
|
1
|
+
import { captureException, getClient, getTraceMetaTags } from "@sentry/core";
|
|
2
2
|
export function extractErrorContext(errorContext) {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (Array.isArray(errorContext.tags)) {
|
|
14
|
-
structuredContext.tags = errorContext.tags || void 0;
|
|
15
|
-
}
|
|
3
|
+
const ctx = {};
|
|
4
|
+
if (!errorContext) {
|
|
5
|
+
return ctx;
|
|
6
|
+
}
|
|
7
|
+
if (errorContext.event) {
|
|
8
|
+
ctx.method = errorContext.event._method;
|
|
9
|
+
ctx.path = errorContext.event._path;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(errorContext.tags)) {
|
|
12
|
+
ctx.tags = errorContext.tags;
|
|
16
13
|
}
|
|
17
|
-
return
|
|
14
|
+
return ctx;
|
|
18
15
|
}
|
|
19
16
|
export function addSentryTracingMetaTags(head) {
|
|
20
17
|
const metaTags = getTraceMetaTags();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Client, Integration, Options, StackParser } from '@sentry/core';
|
|
2
2
|
import type { SentryNuxtClientOptions, SentryNuxtServerOptions } from './common/types';
|
|
3
3
|
import type * as clientSdk from './index.client';
|
|
4
|
+
import type * as serverSdk from './index.server';
|
|
4
5
|
export * from './index.client';
|
|
5
6
|
export * from './index.server';
|
|
6
7
|
export declare function init(options: Options | SentryNuxtClientOptions | SentryNuxtServerOptions): Client | undefined;
|
|
@@ -8,4 +9,5 @@ export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsInteg
|
|
|
8
9
|
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
|
|
9
10
|
export declare const getDefaultIntegrations: (options: Options) => Integration[];
|
|
10
11
|
export declare const defaultStackParser: StackParser;
|
|
12
|
+
export declare const logger: typeof clientSdk.logger | typeof serverSdk.logger;
|
|
11
13
|
//# sourceMappingURL=index.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.types.d.ts","sourceRoot":"","sources":["../../src/index.types.ts"],"names":[],"mappings":"AAAA,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;AAIjD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAG/B,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,uBAAuB,GAAG,uBAAuB,GAAG,MAAM,GAAG,SAAS,CAAC;AACvH,MAAM,CAAC,OAAO,CAAC,MAAM,uBAAuB,EAAE,OAAO,SAAS,CAAC,uBAAuB,CAAC;AACvF,MAAM,CAAC,OAAO,CAAC,MAAM,uBAAuB,EAAE,OAAO,SAAS,CAAC,uBAAuB,CAAC;AACvF,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"}
|
|
1
|
+
{"version":3,"file":"index.types.d.ts","sourceRoot":"","sources":["../../src/index.types.ts"],"names":[],"mappings":"AAAA,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,CAAC,OAAO,UAAU,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,uBAAuB,GAAG,uBAAuB,GAAG,MAAM,GAAG,SAAS,CAAC;AACvH,MAAM,CAAC,OAAO,CAAC,MAAM,uBAAuB,EAAE,OAAO,SAAS,CAAC,uBAAuB,CAAC;AACvF,MAAM,CAAC,OAAO,CAAC,MAAM,uBAAuB,EAAE,OAAO,SAAS,CAAC,uBAAuB,CAAC;AACvF,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"}
|
|
@@ -6,7 +6,7 @@ import type { ComponentPublicInstance } from 'vue';
|
|
|
6
6
|
* Extracts the relevant context information from the error context (H3Event in Nitro Error)
|
|
7
7
|
* and created a structured context object.
|
|
8
8
|
*/
|
|
9
|
-
export declare function extractErrorContext(errorContext: CapturedErrorContext): Context;
|
|
9
|
+
export declare function extractErrorContext(errorContext: CapturedErrorContext | undefined): Context;
|
|
10
10
|
/**
|
|
11
11
|
* Adds Sentry tracing <meta> tags to the returned html page.
|
|
12
12
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,OAAO,EAAE,MAAM,cAAc,CAAC;AAG3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,KAAK,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,oBAAoB,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,OAAO,EAAE,MAAM,cAAc,CAAC;AAG3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,KAAK,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,oBAAoB,GAAG,SAAS,GAAG,OAAO,CAiB3F;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,qBAAqB,CAAC,MAAM,CAAC,GAAG,IAAI,CAMlF;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACvC,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAAC;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,IAAI,CAyBP"}
|
|
@@ -3,8 +3,7 @@ import type { SentryNuxtModuleOptions } from '../common/types';
|
|
|
3
3
|
/**
|
|
4
4
|
* 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.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* 2. Copying the file to the `.output` directory after the build process is finished.
|
|
6
|
+
* By adding a Rollup plugin to the Nitro Rollup options, the Sentry server config is transpiled and emitted to the server build.
|
|
8
7
|
*/
|
|
9
8
|
export declare function addServerConfigToBuild(moduleOptions: SentryNuxtModuleOptions, nitro: Nitro, serverConfigFile: string): void;
|
|
10
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addServerConfig.d.ts","sourceRoot":"","sources":["../../../src/vite/addServerConfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAe/D
|
|
1
|
+
{"version":3,"file":"addServerConfig.d.ts","sourceRoot":"","sources":["../../../src/vite/addServerConfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAe/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;;;;;;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,CAkBN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourceMaps.d.ts","sourceRoot":"","sources":["../../../src/vite/sourceMaps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,KAAK,yBAAyB,EAAsB,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EAAE,KAAK,uBAAuB,EAAoB,MAAM,qBAAqB,CAAC;AAErF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;AAEhF;;GAEG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,uBAAuB,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CA2CxF;AASD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,uBAAuB,EACtC,sBAAsB,EAAE,OAAO,GAC9B,uBAAuB,GAAG,yBAAyB,CA+CrD;AAgBD,gCAAgC;AAChC,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,IAAI,EACV,mBAAmB,EAAE,uBAAuB,GAC3C;IAAE,MAAM,EAAE,oBAAoB,CAAC;IAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"sourceMaps.d.ts","sourceRoot":"","sources":["../../../src/vite/sourceMaps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,M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BAAuB,GAC3C,oBAAoB,CA6BtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/nuxt",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.10.0",
|
|
4
4
|
"description": "Official Sentry SDK for Nuxt (EXPERIMENTAL)",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/nuxt",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@nuxt/kit": "^3.13.2",
|
|
46
|
-
"@sentry/browser": "9.
|
|
47
|
-
"@sentry/core": "9.
|
|
48
|
-
"@sentry/node": "9.
|
|
49
|
-
"@sentry/opentelemetry": "9.
|
|
50
|
-
"@sentry/rollup-plugin": "3.
|
|
51
|
-
"@sentry/vite-plugin": "2.
|
|
52
|
-
"@sentry/vue": "9.
|
|
46
|
+
"@sentry/browser": "9.10.0",
|
|
47
|
+
"@sentry/core": "9.10.0",
|
|
48
|
+
"@sentry/node": "9.10.0",
|
|
49
|
+
"@sentry/opentelemetry": "9.10.0",
|
|
50
|
+
"@sentry/rollup-plugin": "3.2.3",
|
|
51
|
+
"@sentry/vite-plugin": "3.2.3",
|
|
52
|
+
"@sentry/vue": "9.10.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@nuxt/module-builder": "^0.8.4",
|