@sentry/bundler-plugins 11.12.0 → 11.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  2. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  3. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  4. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  5. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  6. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  7. package/build/cjs/_virtual/_rolldown/runtime.js +22 -0
  8. package/build/cjs/babel-plugin/component-annotation.js +14 -32
  9. package/build/cjs/babel-plugin/component-annotation.js.map +1 -1
  10. package/build/cjs/babel-plugin/constants.js +140 -122
  11. package/build/cjs/babel-plugin/constants.js.map +1 -1
  12. package/build/cjs/babel-plugin/experimental.js +204 -307
  13. package/build/cjs/babel-plugin/experimental.js.map +1 -1
  14. package/build/cjs/babel-plugin/index.js +315 -437
  15. package/build/cjs/babel-plugin/index.js.map +1 -1
  16. package/build/cjs/bun/index.js +81 -117
  17. package/build/cjs/bun/index.js.map +1 -1
  18. package/build/cjs/core/build-plugin-manager.js +626 -702
  19. package/build/cjs/core/build-plugin-manager.js.map +1 -1
  20. package/build/cjs/core/cli.js +134 -129
  21. package/build/cjs/core/cli.js.map +1 -1
  22. package/build/cjs/core/component-annotate-hooks.js +16 -27
  23. package/build/cjs/core/component-annotate-hooks.js.map +1 -1
  24. package/build/cjs/core/component-annotation-oxc-ast.js +10 -21
  25. package/build/cjs/core/component-annotation-oxc-ast.js.map +1 -1
  26. package/build/cjs/core/component-annotation-oxc-fragments.js +45 -74
  27. package/build/cjs/core/component-annotation-oxc-fragments.js.map +1 -1
  28. package/build/cjs/core/component-annotation-oxc-jsx.js +116 -156
  29. package/build/cjs/core/component-annotation-oxc-jsx.js.map +1 -1
  30. package/build/cjs/core/component-annotation-oxc-walk.js +62 -123
  31. package/build/cjs/core/component-annotation-oxc-walk.js.map +1 -1
  32. package/build/cjs/core/component-annotation-oxc.js +68 -103
  33. package/build/cjs/core/component-annotation-oxc.js.map +1 -1
  34. package/build/cjs/core/debug-id-upload.js +223 -234
  35. package/build/cjs/core/debug-id-upload.js.map +1 -1
  36. package/build/cjs/core/get-code-injection-position.js +59 -74
  37. package/build/cjs/core/get-code-injection-position.js.map +1 -1
  38. package/build/cjs/core/glob.js +9 -7
  39. package/build/cjs/core/glob.js.map +1 -1
  40. package/build/cjs/core/index.js +77 -61
  41. package/build/cjs/core/index.js.map +1 -1
  42. package/build/cjs/core/logger.js +17 -26
  43. package/build/cjs/core/logger.js.map +1 -1
  44. package/build/cjs/core/options-mapping.js +95 -117
  45. package/build/cjs/core/options-mapping.js.map +1 -1
  46. package/build/cjs/core/sentry/telemetry.js +90 -105
  47. package/build/cjs/core/sentry/telemetry.js.map +1 -1
  48. package/build/cjs/core/sentry/transports.js +92 -99
  49. package/build/cjs/core/sentry/transports.js.map +1 -1
  50. package/build/cjs/core/sourcemap-settings.js +98 -61
  51. package/build/cjs/core/sourcemap-settings.js.map +1 -1
  52. package/build/cjs/core/upload-filter.js +41 -46
  53. package/build/cjs/core/upload-filter.js.map +1 -1
  54. package/build/cjs/core/utils.js +228 -219
  55. package/build/cjs/core/utils.js.map +1 -1
  56. package/build/cjs/core/version.js +4 -5
  57. package/build/cjs/core/version.js.map +1 -1
  58. package/build/cjs/esbuild/index.js +180 -211
  59. package/build/cjs/esbuild/index.js.map +1 -1
  60. package/build/cjs/loader-utils/index.js +5 -10
  61. package/build/cjs/rollup/debug-id-injection.js +22 -38
  62. package/build/cjs/rollup/debug-id-injection.js.map +1 -1
  63. package/build/cjs/rollup/debug-id-stamping.js +14 -24
  64. package/build/cjs/rollup/debug-id-stamping.js.map +1 -1
  65. package/build/cjs/rollup/index.js +192 -246
  66. package/build/cjs/rollup/index.js.map +1 -1
  67. package/build/cjs/rollup/source-map-handling.js +151 -175
  68. package/build/cjs/rollup/source-map-handling.js.map +1 -1
  69. package/build/cjs/vite/index.js +19 -21
  70. package/build/cjs/vite/index.js.map +1 -1
  71. package/build/cjs/vite/source-map-hooks.js +112 -89
  72. package/build/cjs/vite/source-map-hooks.js.map +1 -1
  73. package/build/cjs/webpack/component-annotation-transform.js +20 -26
  74. package/build/cjs/webpack/component-annotation-transform.js.map +1 -1
  75. package/build/cjs/webpack/index.js +271 -340
  76. package/build/cjs/webpack/index.js.map +1 -1
  77. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  78. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  79. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  80. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  81. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  82. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  83. package/build/esm/_virtual/_rolldown/runtime.js +2 -0
  84. package/build/esm/babel-plugin/component-annotation.js +13 -29
  85. package/build/esm/babel-plugin/component-annotation.js.map +1 -1
  86. package/build/esm/babel-plugin/constants.js +140 -120
  87. package/build/esm/babel-plugin/constants.js.map +1 -1
  88. package/build/esm/babel-plugin/experimental.js +204 -305
  89. package/build/esm/babel-plugin/experimental.js.map +1 -1
  90. package/build/esm/babel-plugin/index.js +311 -434
  91. package/build/esm/babel-plugin/index.js.map +1 -1
  92. package/build/esm/bun/index.js +76 -101
  93. package/build/esm/bun/index.js.map +1 -1
  94. package/build/esm/core/build-plugin-manager.js +621 -683
  95. package/build/esm/core/build-plugin-manager.js.map +1 -1
  96. package/build/esm/core/cli.js +134 -127
  97. package/build/esm/core/cli.js.map +1 -1
  98. package/build/esm/core/component-annotate-hooks.js +16 -25
  99. package/build/esm/core/component-annotate-hooks.js.map +1 -1
  100. package/build/esm/core/component-annotation-oxc-ast.js +9 -19
  101. package/build/esm/core/component-annotation-oxc-ast.js.map +1 -1
  102. package/build/esm/core/component-annotation-oxc-fragments.js +44 -72
  103. package/build/esm/core/component-annotation-oxc-fragments.js.map +1 -1
  104. package/build/esm/core/component-annotation-oxc-jsx.js +115 -154
  105. package/build/esm/core/component-annotation-oxc-jsx.js.map +1 -1
  106. package/build/esm/core/component-annotation-oxc-walk.js +61 -121
  107. package/build/esm/core/component-annotation-oxc-walk.js.map +1 -1
  108. package/build/esm/core/component-annotation-oxc.js +65 -96
  109. package/build/esm/core/component-annotation-oxc.js.map +1 -1
  110. package/build/esm/core/debug-id-upload.js +218 -213
  111. package/build/esm/core/debug-id-upload.js.map +1 -1
  112. package/build/esm/core/get-code-injection-position.js +59 -72
  113. package/build/esm/core/get-code-injection-position.js.map +1 -1
  114. package/build/esm/core/glob.js +9 -5
  115. package/build/esm/core/glob.js.map +1 -1
  116. package/build/esm/core/index.js +62 -47
  117. package/build/esm/core/index.js.map +1 -1
  118. package/build/esm/core/logger.js +17 -24
  119. package/build/esm/core/logger.js.map +1 -1
  120. package/build/esm/core/options-mapping.js +95 -115
  121. package/build/esm/core/options-mapping.js.map +1 -1
  122. package/build/esm/core/sentry/telemetry.js +89 -102
  123. package/build/esm/core/sentry/telemetry.js.map +1 -1
  124. package/build/esm/core/sentry/transports.js +90 -83
  125. package/build/esm/core/sentry/transports.js.map +1 -1
  126. package/build/esm/core/sourcemap-settings.js +96 -59
  127. package/build/esm/core/sourcemap-settings.js.map +1 -1
  128. package/build/esm/core/upload-filter.js +39 -30
  129. package/build/esm/core/upload-filter.js.map +1 -1
  130. package/build/esm/core/utils.js +221 -209
  131. package/build/esm/core/utils.js.map +1 -1
  132. package/build/esm/core/version.js +4 -3
  133. package/build/esm/core/version.js.map +1 -1
  134. package/build/esm/esbuild/index.js +176 -195
  135. package/build/esm/esbuild/index.js.map +1 -1
  136. package/build/esm/loader-utils/index.js +4 -3
  137. package/build/esm/package.json +1 -1
  138. package/build/esm/rollup/debug-id-injection.js +22 -36
  139. package/build/esm/rollup/debug-id-injection.js.map +1 -1
  140. package/build/esm/rollup/debug-id-stamping.js +14 -22
  141. package/build/esm/rollup/debug-id-stamping.js.map +1 -1
  142. package/build/esm/rollup/index.js +189 -226
  143. package/build/esm/rollup/index.js.map +1 -1
  144. package/build/esm/rollup/source-map-handling.js +149 -159
  145. package/build/esm/rollup/source-map-handling.js.map +1 -1
  146. package/build/esm/vite/index.js +19 -18
  147. package/build/esm/vite/index.js.map +1 -1
  148. package/build/esm/vite/source-map-hooks.js +109 -72
  149. package/build/esm/vite/source-map-hooks.js.map +1 -1
  150. package/build/esm/webpack/component-annotation-transform.js +17 -24
  151. package/build/esm/webpack/component-annotation-transform.js.map +1 -1
  152. package/build/esm/webpack/index.js +268 -322
  153. package/build/esm/webpack/index.js.map +1 -1
  154. package/build/types/core/build-plugin-manager.d.ts +16 -5
  155. package/build/types/core/build-plugin-manager.d.ts.map +1 -1
  156. package/build/types/core/cli.d.ts +6 -1
  157. package/build/types/core/cli.d.ts.map +1 -1
  158. package/build/types/core/debug-id-upload.d.ts +7 -4
  159. package/build/types/core/debug-id-upload.d.ts.map +1 -1
  160. package/build/types/core/index.d.ts +3 -3
  161. package/build/types/core/index.d.ts.map +1 -1
  162. package/build/types/core/options-mapping.d.ts +4 -3
  163. package/build/types/core/options-mapping.d.ts.map +1 -1
  164. package/build/types/core/sentry/telemetry.d.ts.map +1 -1
  165. package/build/types/core/sourcemap-settings.d.ts +10 -1
  166. package/build/types/core/sourcemap-settings.d.ts.map +1 -1
  167. package/build/types/core/types.d.ts +25 -1
  168. package/build/types/core/types.d.ts.map +1 -1
  169. package/build/types/core/utils.d.ts +4 -0
  170. package/build/types/core/utils.d.ts.map +1 -1
  171. package/build/types/core/version.d.ts +1 -1
  172. package/build/types/esbuild/index.d.ts +2 -2
  173. package/build/types/esbuild/index.d.ts.map +1 -1
  174. package/build/types/rollup/index.d.ts +2 -2
  175. package/build/types/rollup/index.d.ts.map +1 -1
  176. package/build/types/rollup/source-map-handling.d.ts.map +1 -1
  177. package/build/types/vite/index.d.ts +3 -3
  178. package/build/types/vite/index.d.ts.map +1 -1
  179. package/build/types/vite/source-map-hooks.d.ts.map +1 -1
  180. package/build/types/webpack/index.d.ts +7 -3
  181. package/build/types/webpack/index.d.ts.map +1 -1
  182. package/package.json +8 -15
  183. package/build/cjs/loader-utils/index.js.map +0 -1
  184. package/build/esm/loader-utils/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"build-plugin-manager.js","sources":["../../../src/core/build-plugin-manager.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport { closeSession, DEFAULT_ENVIRONMENT, makeSession, setMeasurement, startSpan } from '@sentry/core';\nimport * as dotenv from 'dotenv';\nimport * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { escape as escapeGlob } from 'glob';\nimport { SentryCliAdapter } from './cli';\nimport type { NormalizedOptions } from './options-mapping';\nimport { normalizeUserOptions, validateOptions } from './options-mapping';\nimport type { Logger } from './logger';\nimport { createLogger } from './logger';\nimport { allowedToSendTelemetry, createSentryInstance, safeFlushTelemetry } from './sentry/telemetry';\nimport type { Options, SentrySDKBuildFlags } from './types';\nimport { arrayify, getProjects, getTurborepoEnvPassthroughWarning, stripQueryAndHashFromPath } from './utils';\nimport {\n defaultRewriteSourcesHook,\n prepareArtifactForUpload,\n prepareBundleForDebugIdUpload,\n writePreparedArtifact,\n} from './debug-id-upload';\nimport { globFiles } from './glob';\nimport type { SourceMapDecision, SourceMapKind } from './sourcemap-settings';\nimport { decideSourceMapHandling } from './sourcemap-settings';\nimport type { UploadFilter } from './upload-filter';\nimport { createUploadFilter } from './upload-filter';\nimport { LIB_VERSION } from './version';\n\n// Module-level guard to prevent duplicate deploy records when multiple bundler plugin\n// instances run in the same process (e.g. Next.js creates separate webpack compilers\n// for client, server, and edge). Keyed by release name.\nconst _deployedReleases = new Set<string>();\n\n/** @internal Exported for testing only. */\nexport function _resetDeployedReleasesForTesting(): void {\n _deployedReleases.clear();\n}\n\n/**\n * A temporary folder that build artifacts are written into straight from the bundler's output,\n * before the bundler writes them to disk. The upload reads from this folder, so the bundler can\n * drop the source map assets from its own output.\n */\nexport type UploadStaging = {\n readonly dir: string;\n /** Number of artifacts written so far. */\n readonly count: number;\n /**\n * Absolute paths of the chunks staged so far (`mapDir` joined with the file name). The upload\n * does not prepare these again from disk, where a stale map of an earlier build could sit\n * next to them.\n */\n readonly stagedChunkPaths: ReadonlySet<string>;\n /**\n * Stamps the debug ID into the chunk and its source map and writes both into the folder.\n *\n * `mapSource` is `undefined` when the chunk has no separate source map. `mapDir` is the directory\n * the map would be written to and is passed to the `rewriteSources` hook. `chunkPath` is where\n * the chunk is written; `sourcemaps.assets` and `sourcemaps.ignore` are matched against it.\n */\n stage(input: {\n code: string;\n mapSource: string | undefined;\n mapDir: string;\n chunkPath: string;\n }): Promise<'staged' | 'skipped' | 'excluded' | 'failed'>;\n /** Removes the folder. Call this when no upload will consume it. */\n discard(): Promise<void>;\n /**\n * Keeps the folder and logs how to upload it by hand. Call this when the bundler already\n * dropped the staged source maps from its output but the upload did not run. Removes the\n * folder instead when nothing was staged.\n */\n keep(reason: string): Promise<void>;\n};\n\nexport type SentryBuildPluginManager = {\n /**\n * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)\n */\n logger: Logger;\n\n /**\n * Options after normalization. Includes things like the inferred release name.\n */\n normalizedOptions: NormalizedOptions;\n /**\n * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes\n * into account the options passed to the build plugin manager.\n */\n bundleSizeOptimizationReplacementValues: SentrySDKBuildFlags;\n /**\n * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.\n */\n // See `generateModuleMetadataInjectorCode` for how this should be used exactly\n bundleMetadata: Record<string, unknown>;\n\n /**\n * Contains utility functions for emitting telemetry via the build plugin manager.\n */\n telemetry: {\n /**\n * Emits a `Sentry Bundler Plugin execution` signal.\n */\n emitBundlerPluginExecutionSignal(): Promise<void>;\n };\n\n /**\n * Will potentially create a release based on the build plugin manager options.\n *\n * Also\n * - finalizes the release\n * - sets commits\n * - uploads legacy sourcemaps\n * - adds deploy information\n */\n createRelease(): Promise<void>;\n\n /**\n * Injects debug IDs into the build artifacts.\n *\n * This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.\n * Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.\n * Only use this if you need to manually inject debug IDs into the build artifacts.\n */\n injectDebugIds(buildArtifactPaths: string[]): Promise<void>;\n\n /**\n * Uploads sourcemaps using the \"Debug ID\" method. This function takes a list of build artifact paths that will be uploaded\n */\n uploadSourcemaps(\n buildArtifactPaths: string[],\n opts?: { prepareArtifacts?: boolean; staging?: UploadStaging },\n ): Promise<{ uploaded: boolean }>;\n\n /**\n * Creates a staging folder that `uploadSourcemaps` uploads together with the build artifacts\n * found on disk, in both the prepared and the direct (`prepareArtifacts: false`) mode.\n */\n createUploadStaging(): Promise<UploadStaging>;\n\n sourceMaps: {\n /**\n * Whether a source map upload can run with the current options and environment.\n */\n uploadPossible: boolean;\n /**\n * Decides how the plugin treats the user's source map setting (see `decideSourceMapHandling`).\n * Logs the decision's message once per message, unless `log` is `false`.\n */\n decide(kind: SourceMapKind, options?: { log?: boolean }): SourceMapDecision;\n /** Logs the decision's message, once per message. */\n logDecision(decision: SourceMapDecision): void;\n /**\n * Whether a file of the build output is uploaded, for files that are not on disk yet. Mirrors\n * the glob of the upload from disk: it must match `sourcemaps.assets` (all files when unset)\n * and none of `sourcemaps.ignore`.\n */\n shouldUpload: UploadFilter;\n };\n\n /**\n * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.\n */\n deleteArtifacts(): Promise<void>;\n\n createDependencyOnBuildArtifacts: () => () => void;\n};\n\n/**\n * Creates a build plugin manager that exposes primitives for everything that a Sentry JavaScript SDK or build tooling may do during a build.\n *\n * The build plugin manager's behavior strongly depends on the options that are passed in.\n */\nexport function createSentryBuildPluginManager(\n userOptions: Options,\n bundlerPluginMetaContext: {\n /**\n * E.g. `webpack` or `nextjs` or `turbopack`\n */\n buildTool: string;\n /**\n * E.g. `5` for webpack v5 or `4` for Rollup v4\n */\n buildToolMajorVersion?: string;\n /**\n * E.g. `[sentry-webpack-plugin]` or `[@sentry/nextjs]`\n */\n loggerPrefix: string;\n },\n): SentryBuildPluginManager {\n const logger = createLogger({\n prefix: bundlerPluginMetaContext.loggerPrefix,\n silent: userOptions.silent ?? false,\n debug: userOptions.debug ?? false,\n });\n\n try {\n const dotenvFile = fs.readFileSync(path.join(process.cwd(), '.env.sentry-build-plugin'), 'utf-8');\n // NOTE: Do not use the dotenv.config API directly to read the dotenv file! For some ungodly reason, it falls back to reading `${process.cwd()}/.env` which is absolutely not what we want.\n const dotenvResult = dotenv.parse(dotenvFile);\n\n // Vite has a bug/behaviour where spreading into process.env will cause it to crash\n // https://github.com/vitest-dev/vitest/issues/1870#issuecomment-1501140251\n Object.assign(process.env, dotenvResult);\n\n logger.info('Using environment variables configured in \".env.sentry-build-plugin\".');\n } catch (e: unknown) {\n // Ignore \"file not found\" errors but throw all others\n if (typeof e === 'object' && e && 'code' in e && e.code !== 'ENOENT') {\n throw e;\n }\n }\n\n const options = normalizeUserOptions(userOptions);\n\n if (options.disable) {\n // Early-return a noop build plugin manager instance so that we\n // don't continue validating options, setting up Sentry, etc.\n // Otherwise we might create side-effects or log messages that\n // users don't expect from a disabled plugin.\n return {\n normalizedOptions: options,\n logger,\n bundleSizeOptimizationReplacementValues: {},\n telemetry: {\n emitBundlerPluginExecutionSignal: async () => {\n /* noop */\n },\n },\n bundleMetadata: {},\n createRelease: async () => {\n /* noop */\n },\n uploadSourcemaps: async () => ({ uploaded: false }),\n createUploadStaging: async () => ({\n dir: '',\n count: 0,\n stagedChunkPaths: new Set<string>(),\n stage: async () => 'skipped' as const,\n discard: async () => {\n /* noop */\n },\n keep: async () => {\n /* noop */\n },\n }),\n sourceMaps: {\n uploadPossible: false,\n decide: () => ({ enableHidden: false, deleteAfterUpload: false }),\n logDecision: () => undefined,\n shouldUpload: () => false,\n },\n deleteArtifacts: async () => {\n /* noop */\n },\n createDependencyOnBuildArtifacts: () => () => {\n /* noop */\n },\n injectDebugIds: async () => {\n /* noop */\n },\n };\n }\n\n const shouldSendTelemetry = allowedToSendTelemetry(options);\n const { sentryScope, sentryClient } = createSentryInstance(\n options,\n shouldSendTelemetry,\n bundlerPluginMetaContext.buildTool,\n bundlerPluginMetaContext.buildToolMajorVersion,\n );\n\n const { release, environment = DEFAULT_ENVIRONMENT } = sentryClient.getOptions();\n\n const sentrySession = makeSession({ release, environment });\n sentryScope.setSession(sentrySession);\n // Send the start of the session\n sentryClient.captureSession(sentrySession);\n\n let sessionHasEnded = false; // Just to prevent infinite loops with beforeExit, which is called whenever the event loop empties out\n\n function endSession(): void {\n if (sessionHasEnded) {\n return;\n }\n\n closeSession(sentrySession);\n sentryClient.captureSession(sentrySession);\n sessionHasEnded = true;\n }\n\n // We also need to manually end sessions on errors because beforeExit is not called on crashes\n process.on('beforeExit', () => {\n endSession();\n });\n\n // Set the User-Agent that Sentry CLI will use when interacting with Sentry\n process.env['SENTRY_PIPELINE'] = `${bundlerPluginMetaContext.buildTool}-plugin/${LIB_VERSION}`;\n\n // Propagate debug flag to Sentry CLI via environment variable\n // Only set if not already defined to respect user's explicit configuration\n if (options.debug && !process.env['SENTRY_LOG_LEVEL']) {\n process.env['SENTRY_LOG_LEVEL'] = 'debug';\n }\n\n // Not a bulletproof check but should be good enough to at least sometimes determine\n // if the plugin is called in dev/watch mode or for a prod build. The important part\n // here is to avoid a false positive. False negatives are okay.\n const isDevMode = process.env['NODE_ENV'] === 'development';\n\n /**\n * Handles errors caught and emitted in various areas of the plugin.\n *\n * Also sets the sentry session status according to the error handling.\n *\n * If users specify their custom `errorHandler` we'll leave the decision to throw\n * or continue up to them. By default, @param throwByDefault controls if the plugin\n * should throw an error (which causes a build fail in most bundlers) or continue.\n */\n function handleRecoverableError(unknownError: unknown, throwByDefault: boolean): void {\n sentrySession.status = 'abnormal';\n try {\n if (options.errorHandler) {\n try {\n if (unknownError instanceof Error) {\n options.errorHandler(unknownError);\n } else {\n options.errorHandler(new Error('An unknown error occurred'));\n }\n } catch (e) {\n sentrySession.status = 'crashed';\n throw e;\n }\n } else {\n // setting the session to \"crashed\" b/c from a plugin perspective this run failed.\n // However, we're intentionally not rethrowing the error to avoid breaking the user build.\n sentrySession.status = 'crashed';\n if (throwByDefault) {\n throw unknownError;\n }\n logger.error(\"An error occurred. Couldn't finish all operations:\", unknownError);\n }\n } finally {\n endSession();\n }\n }\n\n if (!validateOptions(options, logger)) {\n // Throwing by default to avoid a misconfigured plugin going unnoticed.\n handleRecoverableError(new Error('Options were not set correctly. See output above for more details.'), true);\n }\n\n // We have multiple plugins depending on generated source map files. (debug ID upload, legacy upload)\n // Additionally, we also want to have the functionality to delete files after uploading sourcemaps.\n // All of these plugins and the delete functionality need to run in the same hook (`writeBundle`).\n // Since the plugins among themselves are not aware of when they run and finish, we need a system to\n // track their dependencies on the generated files, so that we can initiate the file deletion only after\n // nothing depends on the files anymore.\n const dependenciesOnBuildArtifacts = new Set<symbol>();\n const buildArtifactsDependencySubscribers: (() => void)[] = [];\n\n function notifyBuildArtifactDependencySubscribers(): void {\n buildArtifactsDependencySubscribers.forEach(subscriber => {\n subscriber();\n });\n }\n\n function createDependencyOnBuildArtifacts(): () => void {\n const dependencyIdentifier = Symbol();\n dependenciesOnBuildArtifacts.add(dependencyIdentifier);\n\n return function freeDependencyOnBuildArtifacts() {\n dependenciesOnBuildArtifacts.delete(dependencyIdentifier);\n notifyBuildArtifactDependencySubscribers();\n };\n }\n\n const sourceMapUploadPossible = getSourceMapUploadBlocker(options, isDevMode) === undefined;\n const loggedSourceMapMessages = new Set<string>();\n const shouldUpload = createUploadFilter(options);\n\n function logDecision(decision: SourceMapDecision): void {\n if (decision.log && !loggedSourceMapMessages.has(decision.log.message)) {\n loggedSourceMapMessages.add(decision.log.message);\n logger[decision.log.level](decision.log.message);\n }\n }\n\n /**\n * Returns a Promise that resolves when all the currently active dependencies are freed again.\n *\n * It is very important that this function is called as late as possible before wanting to await the Promise to give\n * the dependency producers as much time as possible to register themselves.\n */\n function waitUntilBuildArtifactDependenciesAreFreed(): Promise<void> {\n return new Promise<void>(resolve => {\n buildArtifactsDependencySubscribers.push(() => {\n if (dependenciesOnBuildArtifacts.size === 0) {\n resolve();\n }\n });\n\n if (dependenciesOnBuildArtifacts.size === 0) {\n resolve();\n }\n });\n }\n\n const bundleSizeOptimizationReplacementValues: SentrySDKBuildFlags = {};\n if (options.bundleSizeOptimizations) {\n const { bundleSizeOptimizations } = options;\n\n if (bundleSizeOptimizations.excludeDebugStatements) {\n bundleSizeOptimizationReplacementValues['__SENTRY_DEBUG__'] = false;\n }\n if (bundleSizeOptimizations.excludeTracing) {\n bundleSizeOptimizationReplacementValues['__SENTRY_TRACING__'] = false;\n }\n if (bundleSizeOptimizations.excludeChannelInjection) {\n bundleSizeOptimizationReplacementValues['__SENTRY_CHANNEL_INJECTION__'] = false;\n }\n if (bundleSizeOptimizations.excludeReplayCanvas) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_CANVAS__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayIframe) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_IFRAME__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayShadowDom) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_SHADOW_DOM__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayWorker) {\n bundleSizeOptimizationReplacementValues['__SENTRY_EXCLUDE_REPLAY_WORKER__'] = true;\n }\n }\n\n let bundleMetadata: Record<string, unknown> = {};\n if (options.moduleMetadata || options.applicationKey) {\n if (options.applicationKey) {\n // We use different keys so that if user-code receives multiple bundling passes, we will store the application keys of all the passes.\n // It is a bit unfortunate that we have to inject the metadata snippet at the top, because after multiple\n // injections, the first injection will always \"win\" because it comes last in the code. We would generally be\n // fine with making the last bundling pass win. But because it cannot win, we have to use a workaround of storing\n // the app keys in different object keys.\n // We can simply use the `_sentryBundlerPluginAppKey:` to filter for app keys in the SDK.\n bundleMetadata[`_sentryBundlerPluginAppKey:${options.applicationKey}`] = true;\n }\n\n if (typeof options.moduleMetadata === 'function') {\n const args = {\n org: options.org,\n project: getProjects(options.project)?.[0],\n projects: getProjects(options.project),\n release: options.release.name,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata(args) };\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata };\n }\n }\n\n return {\n /**\n * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)\n */\n logger,\n\n /**\n * Options after normalization. Includes things like the inferred release name.\n */\n normalizedOptions: options,\n\n /**\n * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes\n * into account the options passed to the build plugin manager.\n */\n bundleSizeOptimizationReplacementValues,\n\n /**\n * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.\n */\n // See `generateModuleMetadataInjectorCode` for how this should be used exactly\n bundleMetadata,\n\n /**\n * Contains utility functions for emitting telemetry via the build plugin manager.\n */\n telemetry: {\n /**\n * Emits a `Sentry Bundler Plugin execution` signal.\n */\n async emitBundlerPluginExecutionSignal() {\n if (await shouldSendTelemetry) {\n logger.info(\n 'Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.',\n );\n startSpan({ name: 'Sentry Bundler Plugin execution', scope: sentryScope }, () => {\n //\n });\n await safeFlushTelemetry(sentryClient);\n }\n },\n },\n\n /**\n * Will potentially create a release based on the build plugin manager options.\n *\n * Also\n * - finalizes the release\n * - sets commits\n * - uploads legacy sourcemaps\n * - adds deploy information\n */\n async createRelease() {\n if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not create release. Please set the `release.name` option to identify your release.',\n );\n return;\n } else if (isDevMode) {\n logger.debug('Running in development mode. Will not create release.');\n return;\n } else if (!options.authToken) {\n logger.warn(\n `No auth token provided. Will not create release. Please set the \\`authToken\\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${getTurborepoEnvPassthroughWarning('SENTRY_AUTH_TOKEN')}`,\n );\n return;\n } else if (!options.org && !options.authToken.startsWith('sntrys_')) {\n logger.warn(\n `No organization slug provided. Will not create release. Please set the \\`org\\` option to your Sentry organization slug.${getTurborepoEnvPassthroughWarning('SENTRY_ORG')}`,\n );\n return;\n } else if (!options.project || (Array.isArray(options.project) && options.project.length === 0)) {\n logger.warn(\n `No project provided. Will not create release. Please set the \\`project\\` option to your Sentry project slug.${getTurborepoEnvPassthroughWarning('SENTRY_PROJECT')}`,\n );\n return;\n }\n\n // It is possible that this writeBundle hook is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)\n // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.\n const freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnBuildArtifacts();\n\n // Guaranteed to be set by the guard clause above.\n const releaseName = options.release.name;\n\n try {\n const cliInstance = new SentryCliAdapter(options);\n\n if (options.release.create) {\n const releaseOutput = await cliInstance.createRelease(releaseName);\n logger.debug('Release created:', releaseOutput);\n }\n\n if (options.release.uploadLegacySourcemaps) {\n const uploadTargets = arrayify(options.release.uploadLegacySourcemaps)\n .map(includeItem => (typeof includeItem === 'string' ? { paths: [includeItem] } : includeItem))\n .flatMap(includeEntry =>\n includeEntry.paths.map(directory => ({\n directory,\n dist: options.release.dist,\n ext: includeEntry.ext\n ? includeEntry.ext.map(extension => `.${extension.replace(/^\\./, '')}`)\n : ['.js', '.map', '.jsbundle', '.bundle'],\n // The old CLI only skipped `node_modules` when neither ignore source was configured.\n ignore: includeEntry.ignore\n ? arrayify(includeEntry.ignore)\n : includeEntry.ignoreFile\n ? undefined\n : ['node_modules'],\n ignoreFile: includeEntry.ignoreFile,\n urlPrefix: includeEntry.urlPrefix,\n })),\n );\n\n await cliInstance.uploadSourcemaps(releaseName, uploadTargets);\n }\n\n if (options.release.setCommits !== false) {\n try {\n await cliInstance.setCommits(\n releaseName,\n // set commits always exists due to the normalize function\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n options.release.setCommits!,\n );\n } catch (e) {\n // shouldNotThrowOnFailure being present means that the plugin defaulted to `{ auto: true }` for the setCommitsOptions, meaning that wee should not throw when CLI throws because there is no repo\n if (\n options.release.setCommits &&\n 'shouldNotThrowOnFailure' in options.release.setCommits &&\n options.release.setCommits.shouldNotThrowOnFailure\n ) {\n logger.debug(\n 'An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):',\n e,\n );\n } else {\n throw e;\n }\n }\n }\n\n if (options.release.finalize) {\n await cliInstance.finalizeRelease(releaseName);\n }\n\n if (options.release.deploy && !_deployedReleases.has(releaseName)) {\n await cliInstance.newDeploy(releaseName, options.release.deploy);\n _deployedReleases.add(releaseName);\n }\n } catch (e) {\n sentryScope.captureException('Error in \"releaseManagementPlugin\" writeBundle hook');\n await safeFlushTelemetry(sentryClient);\n handleRecoverableError(e, false);\n } finally {\n freeWriteBundleInvocationDependencyOnSourcemapFiles();\n }\n },\n\n /*\n Injects debug IDs into the build artifacts.\n\n This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.\n Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.\n Only use this if you need to manually inject debug IDs into the build artifacts.\n */\n async injectDebugIds(buildArtifactPaths: string[]) {\n // oxlint-disable-next-line typescript/no-deprecated\n await startSpan({ name: 'inject-debug-ids', scope: sentryScope, forceTransaction: true }, async () => {\n try {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.injectDebugIds(buildArtifactPaths, options.sourcemaps?.ignore);\n } catch (e) {\n sentryScope.captureException('Error in \"debugIdInjectionPlugin\" writeBundle hook');\n handleRecoverableError(e, false);\n } finally {\n await safeFlushTelemetry(sentryClient);\n }\n });\n },\n\n /**\n * Uploads sourcemaps using the \"Debug ID\" method.\n *\n * By default, this prepares bundles in a temporary folder before uploading. You can opt into an\n * in-place, direct upload path by setting `prepareArtifacts` to `false`. If `prepareArtifacts` is set to\n * `false`, no preparation (e.g. adding `//# debugId=...` and writing adjusted source maps) is performed and no temp folder is used.\n *\n * @param buildArtifactPaths - The paths of the build artifacts to upload\n * @param opts - Optional flags to control temp folder usage and preparation\n */\n async uploadSourcemaps(\n buildArtifactPaths: string[],\n opts?: { prepareArtifacts?: boolean; staging?: UploadStaging },\n ): Promise<{ uploaded: boolean }> {\n const staging = opts?.staging;\n\n if (!canUploadSourceMaps(options, logger, isDevMode)) {\n await staging?.discard();\n return { uploaded: false };\n }\n\n const assets = options.sourcemaps?.assets;\n let uploaded = false;\n\n await startSpan(\n // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.\n // oxlint-disable-next-line typescript/no-deprecated\n { name: 'debug-id-sourcemap-upload', scope: sentryScope, forceTransaction: true },\n async () => {\n // If we're not using a temp folder, we must not prepare artifacts in-place (to avoid mutating user files)\n const shouldPrepare = opts?.prepareArtifacts ?? true;\n\n let folderToCleanUp: string | undefined = staging?.dir;\n\n // It is possible that this writeBundle hook (which calls this function) is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)\n // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.\n const freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n\n try {\n if (!shouldPrepare) {\n // Direct CLI upload from existing artifact paths (no globbing, no preparation)\n let pathsToUpload: string[];\n\n if (assets) {\n pathsToUpload = Array.isArray(assets) ? assets : [assets];\n logger.debug(\n `Direct upload mode: passing user-provided assets directly to CLI: ${pathsToUpload.join(', ')}`,\n );\n } else {\n // Use original paths e.g. like ['.next/server'] directly –> preferred way when no globbing is done\n pathsToUpload = buildArtifactPaths;\n }\n\n // Staged artifacts are already prepared, so the CLI can take the folder as it is.\n if (staging && staging.count > 0) {\n pathsToUpload = [...pathsToUpload, staging.dir];\n }\n\n if (pathsToUpload.length === 0) {\n logger.warn(\n \"Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.\",\n );\n return;\n }\n\n await startSpan({ name: 'upload', scope: sentryScope }, async () => {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.uploadSourcemaps(\n options.release.name ?? 'undefined',\n pathsToUpload.map(directory => ({\n directory,\n dist: options.release.dist,\n ignore: options.sourcemaps?.ignore,\n })),\n );\n });\n\n uploaded = true;\n logger.info('Successfully uploaded source maps to Sentry');\n } else {\n // Prepare artifacts in temp folder before uploading\n let globAssets: string | string[];\n if (assets) {\n globAssets = assets;\n } else {\n logger.debug(\n 'No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.',\n );\n globAssets = buildArtifactPaths.map(asset => escapeGlob(asset.split(path.sep).join('/')));\n }\n\n const globResult = await startSpan({ name: 'glob', scope: sentryScope }, async () =>\n globFiles(globAssets, { ignore: options.sourcemaps?.ignore }),\n );\n\n const debugIdChunkFilePaths = globResult.filter(debugIdChunkFilePath => {\n const filePath = stripQueryAndHashFromPath(debugIdChunkFilePath);\n return !!filePath.match(/\\.(js|mjs|cjs)$/) && !staging?.stagedChunkPaths.has(path.resolve(filePath));\n });\n\n // The order of the files output by glob() is not deterministic\n // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent\n debugIdChunkFilePaths.sort();\n\n const stagedCount = staging?.count ?? 0;\n\n if (debugIdChunkFilePaths.length === 0 && stagedCount === 0) {\n logger.warn(\n \"Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.\",\n );\n } else {\n const tmpUploadFolder =\n staging?.dir ??\n (await startSpan({ name: 'mkdtemp', scope: sentryScope }, () => createTempUploadFolder()));\n folderToCleanUp = tmpUploadFolder;\n\n // Prepare into temp folder, then upload\n await startSpan({ name: 'prepare-bundles', scope: sentryScope }, async prepBundlesSpan => {\n // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so\n // instead we do it with a maximum of 16 concurrent workers\n const preparationTasks = debugIdChunkFilePaths.map((chunkFilePath, chunkIndex) => async () => {\n await prepareBundleForDebugIdUpload(\n chunkFilePath,\n tmpUploadFolder,\n stagedCount + chunkIndex,\n logger,\n options.sourcemaps?.rewriteSources ?? defaultRewriteSourcesHook,\n options.sourcemaps?.resolveSourceMap,\n );\n });\n const workers: Promise<void>[] = [];\n const worker = async (): Promise<void> => {\n while (preparationTasks.length > 0) {\n const task = preparationTasks.shift();\n if (task) {\n await task();\n }\n }\n };\n for (let workerIndex = 0; workerIndex < 16; workerIndex++) {\n workers.push(worker());\n }\n\n await Promise.all(workers);\n\n const files = await fs.promises.readdir(tmpUploadFolder);\n const stats = files.map(file => fs.promises.stat(path.join(tmpUploadFolder, file)));\n const uploadSize = (await Promise.all(stats)).reduce(\n (accumulator, { size }) => accumulator + size,\n 0,\n );\n\n setMeasurement('files', files.length, 'none', prepBundlesSpan);\n setMeasurement('upload_size', uploadSize, 'byte', prepBundlesSpan);\n\n // Preparation produced no artifacts, meaning none of the\n // matched bundles had an associated source map. This almost\n // always means source map generation is turned off in the\n // bundler, so warn instead of silently reporting success.\n if (files.length === 0) {\n logger.warn(\n `No source maps found for any of the ${debugIdChunkFilePaths.length + stagedCount} matched build ` +\n 'artifacts, so no source maps were uploaded to Sentry. This usually means source map ' +\n 'generation is not enabled in your bundler. Enable it so Sentry can un-minify your stack traces.',\n );\n return;\n }\n\n await startSpan({ name: 'upload', scope: sentryScope }, async () => {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.uploadSourcemaps(options.release.name ?? 'undefined', [\n {\n directory: tmpUploadFolder,\n dist: options.release.dist,\n },\n ]);\n });\n\n // this must be in the method so that the \"no sourcemaps\"\n // early return doesn't also log success.\n uploaded = true;\n logger.info('Successfully uploaded source maps to Sentry');\n });\n }\n }\n } catch (e) {\n if (staging && folderToCleanUp) {\n await staging.keep('Source map upload failed.');\n folderToCleanUp = undefined;\n }\n sentryScope.captureException('Error in \"debugIdUploadPlugin\" writeBundle hook');\n handleRecoverableError(e, false);\n } finally {\n if (folderToCleanUp && !process.env?.['SENTRY_TEST_OVERRIDE_TEMP_DIR']) {\n logger.debug('Cleaning up temporary files...');\n try {\n await startSpan({ name: 'cleanup', scope: sentryScope }, async () => {\n if (folderToCleanUp) {\n await fs.promises.rm(folderToCleanUp, { recursive: true, force: true });\n logger.debug(`Temporary folder deleted: ${folderToCleanUp}`);\n }\n });\n } catch (e) {\n // A failed cleanup must not skip the teardown steps below (freeing upload\n // dependencies, flushing telemetry), so swallow and log instead of rethrowing.\n logger.debug('Failed to clean up temporary folder:', e);\n }\n }\n logger.debug('Freeing upload dependencies...');\n freeUploadDependencyOnBuildArtifacts();\n logger.debug('Flushing telemetry data...');\n await safeFlushTelemetry(sentryClient);\n logger.debug('Telemetry flushed. Plugin upload process complete.');\n }\n },\n );\n\n return { uploaded };\n },\n\n async createUploadStaging(): Promise<UploadStaging> {\n const dir = await createTempUploadFolder();\n const rewriteSourcesHook = options.sourcemaps?.rewriteSources ?? defaultRewriteSourcesHook;\n let count = 0;\n let discarded = false;\n const stagedChunkPaths = new Set<string>();\n\n const discard = async (): Promise<void> => {\n if (discarded) {\n return;\n }\n discarded = true;\n\n if (process.env['SENTRY_TEST_OVERRIDE_TEMP_DIR']) {\n return;\n }\n\n try {\n await fs.promises.rm(dir, { recursive: true, force: true });\n } catch (e) {\n logger.debug(`Failed to remove staging folder ${dir}:`, e);\n }\n };\n\n return {\n dir,\n get count() {\n return count;\n },\n stagedChunkPaths,\n async stage(input) {\n const chunkPath = path.resolve(input.chunkPath);\n const chunkName = path.basename(chunkPath);\n if (!shouldUpload(chunkPath)) {\n logger.debug(\n `Not staging ${chunkName} for upload: excluded by \\`sourcemaps.assets\\` or \\`sourcemaps.ignore\\`.`,\n );\n return 'excluded';\n }\n\n const result = prepareArtifactForUpload({\n code: input.code,\n mapSource: input.mapSource,\n mapDir: input.mapDir,\n rewriteSourcesHook,\n });\n\n if (!result.ok) {\n logger.debug(`Not staging ${chunkName} for upload: ${result.reason}`);\n return 'skipped';\n }\n\n const index = count++;\n\n try {\n await writePreparedArtifact(dir, `${result.artifact.debugId}-${index}`, result.artifact);\n stagedChunkPaths.add(chunkPath);\n return 'staged';\n } catch (e) {\n sentryScope.captureException('Error staging build artifact for upload');\n // Throwing by default: the bundler drops the source map from its\n // output once staged, so a lost copy would leave no map at all.\n handleRecoverableError(e, true);\n return 'failed';\n }\n },\n discard,\n async keep(reason) {\n if (count === 0) {\n await discard();\n return;\n }\n if (discarded) {\n return;\n }\n discarded = true;\n\n // The bundler dropped the staged source maps from its output, so\n // this folder is the only copy left.\n logger.error(\n `${reason} The source maps were kept in ${dir}. Upload them with \\`sentry sourcemap upload ${dir}\\`.`,\n );\n },\n };\n },\n\n sourceMaps: {\n uploadPossible: sourceMapUploadPossible,\n decide(kind, { log = true } = {}) {\n const decision = decideSourceMapHandling(kind, options, sourceMapUploadPossible);\n if (log) {\n logDecision(decision);\n }\n return decision;\n },\n logDecision,\n shouldUpload,\n },\n\n /**\n * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.\n */\n async deleteArtifacts() {\n try {\n const filesToDelete = await options.sourcemaps?.filesToDeleteAfterUpload;\n if (filesToDelete !== undefined) {\n const filePathsToDelete = await globFiles(filesToDelete);\n\n logger.debug('Waiting for dependencies on generated files to be freed before deleting...');\n\n await waitUntilBuildArtifactDependenciesAreFreed();\n\n filePathsToDelete.forEach(filePathToDelete => {\n logger.debug(`Deleting asset after upload: ${filePathToDelete}`);\n });\n\n await Promise.all(\n filePathsToDelete.map(filePathToDelete =>\n fs.promises.rm(filePathToDelete, { force: true }).catch(e => {\n // This is allowed to fail - we just don't do anything\n logger.debug(`An error occurred while attempting to delete asset: ${filePathToDelete}`, e);\n }),\n ),\n );\n }\n } catch (e) {\n sentryScope.captureException('Error in \"sentry-file-deletion-plugin\" buildEnd hook');\n await safeFlushTelemetry(sentryClient);\n // We throw by default if we get here b/c not being able to delete\n // source maps could leak them to production\n handleRecoverableError(e, true);\n }\n },\n createDependencyOnBuildArtifacts,\n };\n}\n\nasync function createTempUploadFolder(): Promise<string> {\n return (\n process.env['SENTRY_TEST_OVERRIDE_TEMP_DIR'] ||\n (await fs.promises.mkdtemp(path.join(os.tmpdir(), 'sentry-bundler-plugin-upload-')))\n );\n}\n\ntype SourceMapUploadBlocker = 'disabled' | 'no-assets' | 'dev-mode' | 'no-auth-token' | 'no-org' | 'no-project';\n\nfunction getSourceMapUploadBlocker(options: NormalizedOptions, isDevMode: boolean): SourceMapUploadBlocker | undefined {\n if (options.sourcemaps?.disable) {\n return 'disabled';\n }\n if (Array.isArray(options.sourcemaps?.assets) && options.sourcemaps.assets.length === 0) {\n return 'no-assets';\n }\n if (isDevMode) {\n return 'dev-mode';\n }\n if (!options.authToken) {\n return 'no-auth-token';\n }\n if (!options.org && !options.authToken.startsWith('sntrys_')) {\n return 'no-org';\n }\n if (!getProjects(options.project)?.[0]) {\n return 'no-project';\n }\n return undefined;\n}\n\nfunction canUploadSourceMaps(options: NormalizedOptions, logger: Logger, isDevMode: boolean): boolean {\n switch (getSourceMapUploadBlocker(options, isDevMode)) {\n case 'disabled':\n logger.debug('Source map upload was disabled. Will not upload sourcemaps using debug ID process.');\n return false;\n case 'no-assets':\n logger.debug('Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.');\n return false;\n case 'dev-mode':\n logger.debug('Running in development mode. Will not upload sourcemaps.');\n return false;\n case 'no-auth-token':\n logger.warn(\n `No auth token provided. Will not upload source maps. Please set the \\`authToken\\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${getTurborepoEnvPassthroughWarning('SENTRY_AUTH_TOKEN')}`,\n );\n return false;\n case 'no-org':\n logger.warn(\n `No org provided. Will not upload source maps. Please set the \\`org\\` option to your Sentry organization slug.${getTurborepoEnvPassthroughWarning('SENTRY_ORG')}`,\n );\n return false;\n case 'no-project':\n logger.warn(\n `No project provided. Will not upload source maps. Please set the \\`project\\` option to your Sentry project slug.${getTurborepoEnvPassthroughWarning('SENTRY_PROJECT')}`,\n );\n return false;\n default:\n return true;\n }\n}\n"],"names":["logger","createLogger","fs","path","dotenv","normalizeUserOptions","allowedToSendTelemetry","createSentryInstance","DEFAULT_ENVIRONMENT","makeSession","closeSession","LIB_VERSION","validateOptions","createUploadFilter","getProjects","startSpan","safeFlushTelemetry","getTurborepoEnvPassthroughWarning","SentryCliAdapter","arrayify","escapeGlob","globFiles","stripQueryAndHashFromPath","prepareBundleForDebugIdUpload","defaultRewriteSourcesHook","setMeasurement","prepareArtifactForUpload","writePreparedArtifact","decideSourceMapHandling","os"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,iBAAA,uBAAwB,GAAA,EAAY;AA+InC,SAAS,8BAAA,CACd,aACA,wBAAA,EAc0B;AAC1B,EAAA,MAAMA,WAASC,mBAAA,CAAa;AAAA,IAC1B,QAAQ,wBAAA,CAAyB,YAAA;AAAA,IACjC,MAAA,EAAQ,YAAY,MAAA,IAAU,KAAA;AAAA,IAC9B,KAAA,EAAO,YAAY,KAAA,IAAS;AAAA,GAC7B,CAAA;AAED,EAAA,IAAI;AACF,IAAA,MAAM,UAAA,GAAaC,aAAA,CAAG,YAAA,CAAaC,eAAA,CAAK,IAAA,CAAK,QAAQ,GAAA,EAAI,EAAG,0BAA0B,CAAA,EAAG,OAAO,CAAA;AAEhG,IAAA,MA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AA,CAAO,IAAA;AAAA,QACL,CAAA,gHAAA,EAAmHA,uCAAA,CAAkC,gBAAgB,CAAC,CAAA;AAAA,OACxK;AACA,MAAA,OAAO,KAAA;AAAA,IACT;AACE,MAAA,OAAO,IAAA;AAAA;AAEb;;;;"}
1
+ {"version":3,"file":"build-plugin-manager.js","names":["createLogger","normalizeUserOptions","allowedToSendTelemetry","createSentryInstance","DEFAULT_ENVIRONMENT","makeSession","closeSession","LIB_VERSION","validateOptions","createUploadFilter","getProjects","startSpan","safeFlushTelemetry","getTurborepoEnvPassthroughWarning","SentryCliAdapter","arrayify","escapeGlob","globFiles","stripQueryAndHashFromPath","prepareBundleForDebugIdUpload","defaultRewriteSourcesHook","setMeasurement","prepareArtifactForUpload","writePreparedArtifact","decideSourceMapHandling"],"sources":["../../../src/core/build-plugin-manager.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport { closeSession, DEFAULT_ENVIRONMENT, makeSession, setMeasurement, startSpan } from '@sentry/core';\nimport * as dotenv from 'dotenv';\nimport * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { escape as escapeGlob } from 'glob';\nimport { SentryCliAdapter } from './cli';\nimport type { NormalizedOptions } from './options-mapping';\nimport { normalizeUserOptions, validateOptions } from './options-mapping';\nimport type { Logger } from './logger';\nimport { createLogger } from './logger';\nimport { allowedToSendTelemetry, createSentryInstance, safeFlushTelemetry } from './sentry/telemetry';\nimport type { InternalOptions, SentrySDKBuildFlags } from './types';\nimport { arrayify, getProjects, getTurborepoEnvPassthroughWarning, stripQueryAndHashFromPath } from './utils';\nimport {\n defaultRewriteSourcesHook,\n prepareArtifactForUpload,\n prepareBundleForDebugIdUpload,\n writePreparedArtifact,\n} from './debug-id-upload';\nimport { globFiles } from './glob';\nimport type { SourceMapDecision, SourceMapKind } from './sourcemap-settings';\nimport { decideSourceMapHandling } from './sourcemap-settings';\nimport type { UploadFilter } from './upload-filter';\nimport { createUploadFilter } from './upload-filter';\nimport { LIB_VERSION } from './version';\n\n// Module-level guard to prevent duplicate deploy records when multiple bundler plugin\n// instances run in the same process (e.g. Next.js creates separate webpack compilers\n// for client, server, and edge). Keyed by release name.\nconst _deployedReleases = new Set<string>();\n\n/** @internal Exported for testing only. */\nexport function _resetDeployedReleasesForTesting(): void {\n _deployedReleases.clear();\n}\n\n/**\n * A temporary folder that build artifacts are written into straight from the bundler's output,\n * before the bundler writes them to disk. The upload reads from this folder, so the bundler can\n * drop the source map assets from its own output.\n */\nexport type UploadResult = { uploaded: boolean; uploadedSourceMapPaths: string[] };\n\nexport type UploadStaging = {\n readonly dir: string;\n /** Number of artifacts written so far. */\n readonly count: number;\n /**\n * Absolute paths of the chunks staged so far (`mapDir` joined with the file name). The upload\n * does not prepare these again from disk, where a stale map of an earlier build could sit\n * next to them.\n */\n readonly stagedChunkPaths: ReadonlySet<string>;\n /**\n * Stamps the debug ID into the chunk and its source map and writes both into the folder.\n *\n * `mapSource` is `undefined` when the chunk has no separate source map. `mapDir` is the directory\n * the map would be written to and is passed to the `rewriteSources` hook. `chunkPath` is where\n * the chunk is written; `sourcemaps.assets` and `sourcemaps.ignore` are matched against it.\n */\n stage(input: {\n code: string;\n mapSource: string | undefined;\n mapDir: string;\n chunkPath: string;\n }): Promise<'staged' | 'skipped' | 'excluded' | 'failed'>;\n /** Removes the folder. Call this when no upload will consume it. */\n discard(): Promise<void>;\n /**\n * Keeps the folder and logs how to upload it by hand. Call this when the bundler already\n * dropped the staged source maps from its output but the upload did not run. Removes the\n * folder instead when nothing was staged.\n */\n keep(reason: string): Promise<void>;\n};\n\nexport type SentryBuildPluginManager = {\n /**\n * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)\n */\n logger: Logger;\n\n /**\n * Options after normalization. Includes things like the inferred release name.\n */\n normalizedOptions: NormalizedOptions;\n /**\n * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes\n * into account the options passed to the build plugin manager.\n */\n bundleSizeOptimizationReplacementValues: SentrySDKBuildFlags;\n /**\n * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.\n */\n // See `generateModuleMetadataInjectorCode` for how this should be used exactly\n bundleMetadata: Record<string, unknown>;\n\n /**\n * Contains utility functions for emitting telemetry via the build plugin manager.\n */\n telemetry: {\n /**\n * Emits a `Sentry Bundler Plugin execution` signal.\n */\n emitBundlerPluginExecutionSignal(): Promise<void>;\n };\n\n /**\n * Will potentially create a release based on the build plugin manager options.\n *\n * Also\n * - finalizes the release\n * - sets commits\n * - uploads legacy sourcemaps\n * - adds deploy information\n */\n createRelease(): Promise<void>;\n\n /**\n * Injects debug IDs into the build artifacts.\n *\n * This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.\n * Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.\n * Only use this if you need to manually inject debug IDs into the build artifacts.\n */\n injectDebugIds(buildArtifactPaths: string[]): Promise<void>;\n\n /**\n * Uploads sourcemaps using the \"Debug ID\" method. This function takes a list of build artifact paths that will be uploaded\n *\n * `uploadedSourceMapPaths` lists the source maps read from disk that were uploaded. It is empty\n * when nothing was uploaded, in direct mode (`prepareArtifacts: false`) and for staged artifacts.\n */\n uploadSourcemaps(\n buildArtifactPaths: string[],\n opts?: { prepareArtifacts?: boolean; staging?: UploadStaging },\n ): Promise<UploadResult>;\n\n /**\n * Creates a staging folder that `uploadSourcemaps` uploads together with the build artifacts\n * found on disk, in both the prepared and the direct (`prepareArtifacts: false`) mode.\n */\n createUploadStaging(): Promise<UploadStaging>;\n\n sourceMaps: {\n /**\n * Whether a source map upload can run with the current options and environment.\n */\n uploadPossible: boolean;\n /**\n * Decides how the plugin treats the user's source map setting (see `decideSourceMapHandling`).\n * Logs the decision's message once per message, unless `log` is `false`.\n */\n decide(kind: SourceMapKind, options?: { log?: boolean; environment?: string }): SourceMapDecision;\n /** Logs the decision's message, once per message. */\n logDecision(decision: SourceMapDecision): void;\n /**\n * Whether a file of the build output is uploaded, for files that are not on disk yet. Mirrors\n * the glob of the upload from disk: it must match `sourcemaps.assets` (all files when unset)\n * and none of `sourcemaps.ignore`.\n */\n shouldUpload: UploadFilter;\n /**\n * Deletes source maps from the build output after their upload. A map that cannot be deleted\n * goes to `errorHandler`, or fails the build when none is set.\n */\n deleteFromOutput(sourceMapPaths: string[]): Promise<void>;\n };\n\n /**\n * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.\n */\n deleteArtifacts(): Promise<void>;\n\n createDependencyOnBuildArtifacts: () => () => void;\n};\n\n/**\n * Creates a build plugin manager that exposes primitives for everything that a Sentry JavaScript SDK or build tooling may do during a build.\n *\n * The build plugin manager's behavior strongly depends on the options that are passed in.\n */\nexport function createSentryBuildPluginManager(\n userOptions: InternalOptions,\n bundlerPluginMetaContext: {\n /**\n * E.g. `webpack` or `nextjs` or `turbopack`\n */\n buildTool: string;\n /**\n * E.g. `5` for webpack v5 or `4` for Rollup v4\n */\n buildToolMajorVersion?: string;\n /**\n * E.g. `[sentry-webpack-plugin]` or `[@sentry/nextjs]`\n */\n loggerPrefix: string;\n },\n): SentryBuildPluginManager {\n const logger = createLogger({\n prefix: bundlerPluginMetaContext.loggerPrefix,\n silent: userOptions.silent ?? false,\n debug: userOptions.debug ?? false,\n });\n\n try {\n const dotenvFile = fs.readFileSync(path.join(process.cwd(), '.env.sentry-build-plugin'), 'utf-8');\n // NOTE: Do not use the dotenv.config API directly to read the dotenv file! For some ungodly reason, it falls back to reading `${process.cwd()}/.env` which is absolutely not what we want.\n const dotenvResult = dotenv.parse(dotenvFile);\n\n // Vite has a bug/behaviour where spreading into process.env will cause it to crash\n // https://github.com/vitest-dev/vitest/issues/1870#issuecomment-1501140251\n Object.assign(process.env, dotenvResult);\n\n logger.info('Using environment variables configured in \".env.sentry-build-plugin\".');\n } catch (e: unknown) {\n // Ignore \"file not found\" errors but throw all others\n if (typeof e === 'object' && e && 'code' in e && e.code !== 'ENOENT') {\n throw e;\n }\n }\n\n const options = normalizeUserOptions(userOptions);\n\n if (options.disable) {\n // Early-return a noop build plugin manager instance so that we\n // don't continue validating options, setting up Sentry, etc.\n // Otherwise we might create side-effects or log messages that\n // users don't expect from a disabled plugin.\n return {\n normalizedOptions: options,\n logger,\n bundleSizeOptimizationReplacementValues: {},\n telemetry: {\n emitBundlerPluginExecutionSignal: async () => {\n /* noop */\n },\n },\n bundleMetadata: {},\n createRelease: async () => {\n /* noop */\n },\n uploadSourcemaps: async () => ({ uploaded: false, uploadedSourceMapPaths: [] }),\n createUploadStaging: async () => ({\n dir: '',\n count: 0,\n stagedChunkPaths: new Set<string>(),\n stage: async () => 'skipped' as const,\n discard: async () => {\n /* noop */\n },\n keep: async () => {\n /* noop */\n },\n }),\n sourceMaps: {\n uploadPossible: false,\n decide: () => ({ enableHidden: false, deleteAfterUpload: false }),\n logDecision: () => undefined,\n shouldUpload: () => false,\n deleteFromOutput: async () => {\n /* noop */\n },\n },\n deleteArtifacts: async () => {\n /* noop */\n },\n createDependencyOnBuildArtifacts: () => () => {\n /* noop */\n },\n injectDebugIds: async () => {\n /* noop */\n },\n };\n }\n\n const shouldSendTelemetry = allowedToSendTelemetry(options);\n const { sentryScope, sentryClient } = createSentryInstance(\n options,\n shouldSendTelemetry,\n bundlerPluginMetaContext.buildTool,\n bundlerPluginMetaContext.buildToolMajorVersion,\n );\n\n const { release, environment = DEFAULT_ENVIRONMENT } = sentryClient.getOptions();\n\n const sentrySession = makeSession({ release, environment });\n sentryScope.setSession(sentrySession);\n // Send the start of the session\n sentryClient.captureSession(sentrySession);\n\n let sessionHasEnded = false; // Just to prevent infinite loops with beforeExit, which is called whenever the event loop empties out\n\n function endSession(): void {\n if (sessionHasEnded) {\n return;\n }\n\n closeSession(sentrySession);\n sentryClient.captureSession(sentrySession);\n sessionHasEnded = true;\n }\n\n // We also need to manually end sessions on errors because beforeExit is not called on crashes\n process.on('beforeExit', () => {\n endSession();\n });\n\n // Set the User-Agent that Sentry CLI will use when interacting with Sentry\n process.env['SENTRY_PIPELINE'] = `${bundlerPluginMetaContext.buildTool}-plugin/${LIB_VERSION}`;\n\n // Propagate debug flag to Sentry CLI via environment variable\n // Only set if not already defined to respect user's explicit configuration\n if (options.debug && !process.env['SENTRY_LOG_LEVEL']) {\n process.env['SENTRY_LOG_LEVEL'] = 'debug';\n }\n\n // Not a bulletproof check but should be good enough to at least sometimes determine\n // if the plugin is called in dev/watch mode or for a prod build. The important part\n // here is to avoid a false positive. False negatives are okay.\n const isDevMode = process.env['NODE_ENV'] === 'development';\n\n /**\n * Handles errors caught and emitted in various areas of the plugin.\n *\n * Also sets the sentry session status according to the error handling.\n *\n * If users specify their custom `errorHandler` we'll leave the decision to throw\n * or continue up to them. By default, @param throwByDefault controls if the plugin\n * should throw an error (which causes a build fail in most bundlers) or continue.\n */\n function handleRecoverableError(unknownError: unknown, throwByDefault: boolean): void {\n sentrySession.status = 'abnormal';\n try {\n if (options.errorHandler) {\n try {\n if (unknownError instanceof Error) {\n options.errorHandler(unknownError);\n } else {\n options.errorHandler(new Error('An unknown error occurred'));\n }\n } catch (e) {\n sentrySession.status = 'crashed';\n throw e;\n }\n } else {\n // setting the session to \"crashed\" b/c from a plugin perspective this run failed.\n // However, we're intentionally not rethrowing the error to avoid breaking the user build.\n sentrySession.status = 'crashed';\n if (throwByDefault) {\n throw unknownError;\n }\n logger.error(\"An error occurred. Couldn't finish all operations:\", unknownError);\n }\n } finally {\n endSession();\n }\n }\n\n if (!validateOptions(options, logger)) {\n // Throwing by default to avoid a misconfigured plugin going unnoticed.\n handleRecoverableError(new Error('Options were not set correctly. See output above for more details.'), true);\n }\n\n // We have multiple plugins depending on generated source map files. (debug ID upload, legacy upload)\n // Additionally, we also want to have the functionality to delete files after uploading sourcemaps.\n // All of these plugins and the delete functionality need to run in the same hook (`writeBundle`).\n // Since the plugins among themselves are not aware of when they run and finish, we need a system to\n // track their dependencies on the generated files, so that we can initiate the file deletion only after\n // nothing depends on the files anymore.\n const dependenciesOnBuildArtifacts = new Set<symbol>();\n const buildArtifactsDependencySubscribers: (() => void)[] = [];\n\n function notifyBuildArtifactDependencySubscribers(): void {\n buildArtifactsDependencySubscribers.forEach(subscriber => {\n subscriber();\n });\n }\n\n function createDependencyOnBuildArtifacts(): () => void {\n const dependencyIdentifier = Symbol();\n dependenciesOnBuildArtifacts.add(dependencyIdentifier);\n\n return function freeDependencyOnBuildArtifacts() {\n dependenciesOnBuildArtifacts.delete(dependencyIdentifier);\n notifyBuildArtifactDependencySubscribers();\n };\n }\n\n const sourceMapUploadPossible = getSourceMapUploadBlocker(options, isDevMode) === undefined;\n const loggedSourceMapMessages = new Set<string>();\n const shouldUpload = createUploadFilter(options);\n\n function logDecision(decision: SourceMapDecision): void {\n if (decision.log && !loggedSourceMapMessages.has(decision.log.message)) {\n loggedSourceMapMessages.add(decision.log.message);\n logger[decision.log.level](decision.log.message);\n }\n }\n\n /**\n * Returns a Promise that resolves when all the currently active dependencies are freed again.\n *\n * It is very important that this function is called as late as possible before wanting to await the Promise to give\n * the dependency producers as much time as possible to register themselves.\n */\n function waitUntilBuildArtifactDependenciesAreFreed(): Promise<void> {\n return new Promise<void>(resolve => {\n buildArtifactsDependencySubscribers.push(() => {\n if (dependenciesOnBuildArtifacts.size === 0) {\n resolve();\n }\n });\n\n if (dependenciesOnBuildArtifacts.size === 0) {\n resolve();\n }\n });\n }\n\n const bundleSizeOptimizationReplacementValues: SentrySDKBuildFlags = {};\n if (options.bundleSizeOptimizations) {\n const { bundleSizeOptimizations } = options;\n\n if (bundleSizeOptimizations.excludeDebugStatements) {\n bundleSizeOptimizationReplacementValues['__SENTRY_DEBUG__'] = false;\n }\n if (bundleSizeOptimizations.excludeTracing) {\n bundleSizeOptimizationReplacementValues['__SENTRY_TRACING__'] = false;\n }\n if (bundleSizeOptimizations.excludeChannelInjection) {\n bundleSizeOptimizationReplacementValues['__SENTRY_CHANNEL_INJECTION__'] = false;\n }\n if (bundleSizeOptimizations.excludeReplayCanvas) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_CANVAS__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayIframe) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_IFRAME__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayShadowDom) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_SHADOW_DOM__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayWorker) {\n bundleSizeOptimizationReplacementValues['__SENTRY_EXCLUDE_REPLAY_WORKER__'] = true;\n }\n }\n\n let bundleMetadata: Record<string, unknown> = {};\n if (options.moduleMetadata || options.applicationKey) {\n if (options.applicationKey) {\n // We use different keys so that if user-code receives multiple bundling passes, we will store the application keys of all the passes.\n // It is a bit unfortunate that we have to inject the metadata snippet at the top, because after multiple\n // injections, the first injection will always \"win\" because it comes last in the code. We would generally be\n // fine with making the last bundling pass win. But because it cannot win, we have to use a workaround of storing\n // the app keys in different object keys.\n // We can simply use the `_sentryBundlerPluginAppKey:` to filter for app keys in the SDK.\n bundleMetadata[`_sentryBundlerPluginAppKey:${options.applicationKey}`] = true;\n }\n\n if (typeof options.moduleMetadata === 'function') {\n const args = {\n org: options.org,\n project: getProjects(options.project)?.[0],\n projects: getProjects(options.project),\n release: options.release.name,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata(args) };\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata };\n }\n }\n\n return {\n /**\n * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)\n */\n logger,\n\n /**\n * Options after normalization. Includes things like the inferred release name.\n */\n normalizedOptions: options,\n\n /**\n * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes\n * into account the options passed to the build plugin manager.\n */\n bundleSizeOptimizationReplacementValues,\n\n /**\n * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.\n */\n // See `generateModuleMetadataInjectorCode` for how this should be used exactly\n bundleMetadata,\n\n /**\n * Contains utility functions for emitting telemetry via the build plugin manager.\n */\n telemetry: {\n /**\n * Emits a `Sentry Bundler Plugin execution` signal.\n */\n async emitBundlerPluginExecutionSignal() {\n if (await shouldSendTelemetry) {\n logger.info(\n 'Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.',\n );\n startSpan({ name: 'Sentry Bundler Plugin execution', scope: sentryScope }, () => {\n //\n });\n await safeFlushTelemetry(sentryClient);\n }\n },\n },\n\n /**\n * Will potentially create a release based on the build plugin manager options.\n *\n * Also\n * - finalizes the release\n * - sets commits\n * - uploads legacy sourcemaps\n * - adds deploy information\n */\n async createRelease() {\n if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not create release. Please set the `release.name` option to identify your release.',\n );\n return;\n } else if (isDevMode) {\n logger.debug('Running in development mode. Will not create release.');\n return;\n } else if (!options.authToken) {\n logger.warn(\n `No auth token provided. Will not create release. Please set the \\`authToken\\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${getTurborepoEnvPassthroughWarning('SENTRY_AUTH_TOKEN')}`,\n );\n return;\n } else if (!options.org && !options.authToken.startsWith('sntrys_')) {\n logger.warn(\n `No organization slug provided. Will not create release. Please set the \\`org\\` option to your Sentry organization slug.${getTurborepoEnvPassthroughWarning('SENTRY_ORG')}`,\n );\n return;\n } else if (!options.project || (Array.isArray(options.project) && options.project.length === 0)) {\n logger.warn(\n `No project provided. Will not create release. Please set the \\`project\\` option to your Sentry project slug.${getTurborepoEnvPassthroughWarning('SENTRY_PROJECT')}`,\n );\n return;\n }\n\n // It is possible that this writeBundle hook is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)\n // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.\n const freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnBuildArtifacts();\n\n // Guaranteed to be set by the guard clause above.\n const releaseName = options.release.name;\n\n try {\n const cliInstance = new SentryCliAdapter(options);\n\n if (options.release.create) {\n const releaseOutput = await cliInstance.createRelease(releaseName);\n logger.debug('Release created:', releaseOutput);\n }\n\n if (options.release.uploadLegacySourcemaps) {\n const uploadTargets = arrayify(options.release.uploadLegacySourcemaps)\n .map(includeItem => (typeof includeItem === 'string' ? { paths: [includeItem] } : includeItem))\n .flatMap(includeEntry =>\n includeEntry.paths.map(directory => ({\n directory,\n dist: options.release.dist,\n ext: includeEntry.ext\n ? includeEntry.ext.map(extension => `.${extension.replace(/^\\./, '')}`)\n : ['.js', '.map', '.jsbundle', '.bundle'],\n // The old CLI only skipped `node_modules` when neither ignore source was configured.\n ignore: includeEntry.ignore\n ? arrayify(includeEntry.ignore)\n : includeEntry.ignoreFile\n ? undefined\n : ['node_modules'],\n ignoreFile: includeEntry.ignoreFile,\n urlPrefix: includeEntry.urlPrefix,\n })),\n );\n\n warnAboutDirectoriesWithoutSourcemaps(logger, await cliInstance.uploadSourcemaps(releaseName, uploadTargets));\n }\n\n if (options.release.setCommits !== false) {\n try {\n await cliInstance.setCommits(\n releaseName,\n // set commits always exists due to the normalize function\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n options.release.setCommits!,\n );\n } catch (e) {\n // shouldNotThrowOnFailure being present means that the plugin defaulted to `{ auto: true }` for the setCommitsOptions, meaning that wee should not throw when CLI throws because there is no repo\n if (\n options.release.setCommits &&\n 'shouldNotThrowOnFailure' in options.release.setCommits &&\n options.release.setCommits.shouldNotThrowOnFailure\n ) {\n logger.debug(\n 'An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):',\n e,\n );\n } else {\n throw e;\n }\n }\n }\n\n if (options.release.finalize) {\n await cliInstance.finalizeRelease(releaseName);\n }\n\n if (options.release.deploy && !_deployedReleases.has(releaseName)) {\n await cliInstance.newDeploy(releaseName, options.release.deploy);\n _deployedReleases.add(releaseName);\n }\n } catch (e) {\n sentryScope.captureException('Error in \"releaseManagementPlugin\" writeBundle hook');\n await safeFlushTelemetry(sentryClient);\n handleRecoverableError(e, false);\n } finally {\n freeWriteBundleInvocationDependencyOnSourcemapFiles();\n }\n },\n\n /*\n Injects debug IDs into the build artifacts.\n\n This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.\n Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.\n Only use this if you need to manually inject debug IDs into the build artifacts.\n */\n async injectDebugIds(buildArtifactPaths: string[]) {\n // oxlint-disable-next-line typescript/no-deprecated\n await startSpan({ name: 'inject-debug-ids', scope: sentryScope, forceTransaction: true }, async () => {\n try {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.injectDebugIds(buildArtifactPaths, options.sourcemaps?.ignore);\n } catch (e) {\n sentryScope.captureException('Error in \"debugIdInjectionPlugin\" writeBundle hook');\n handleRecoverableError(e, false);\n } finally {\n await safeFlushTelemetry(sentryClient);\n }\n });\n },\n\n /**\n * Uploads sourcemaps using the \"Debug ID\" method.\n *\n * By default, this prepares bundles in a temporary folder before uploading. You can opt into an\n * in-place, direct upload path by setting `prepareArtifacts` to `false`. If `prepareArtifacts` is set to\n * `false`, no preparation (e.g. adding `//# debugId=...` and writing adjusted source maps) is performed and no temp folder is used.\n *\n * @param buildArtifactPaths - The paths of the build artifacts to upload\n * @param opts - Optional flags to control temp folder usage and preparation\n */\n async uploadSourcemaps(\n buildArtifactPaths: string[],\n opts?: { prepareArtifacts?: boolean; staging?: UploadStaging },\n ): Promise<UploadResult> {\n const staging = opts?.staging;\n\n if (!canUploadSourceMaps(options, logger, isDevMode)) {\n await staging?.discard();\n return { uploaded: false, uploadedSourceMapPaths: [] };\n }\n\n const assets = options.sourcemaps?.assets;\n let uploaded = false;\n const preparedSourceMapPaths: string[] = [];\n\n await startSpan(\n // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.\n // oxlint-disable-next-line typescript/no-deprecated\n { name: 'debug-id-sourcemap-upload', scope: sentryScope, forceTransaction: true },\n async () => {\n // If we're not using a temp folder, we must not prepare artifacts in-place (to avoid mutating user files)\n const shouldPrepare = opts?.prepareArtifacts ?? true;\n\n let folderToCleanUp: string | undefined = staging?.dir;\n\n // It is possible that this writeBundle hook (which calls this function) is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)\n // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.\n const freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n\n try {\n if (!shouldPrepare) {\n // Direct CLI upload from existing artifact paths (no globbing, no preparation)\n let pathsToUpload: string[];\n\n if (assets) {\n pathsToUpload = Array.isArray(assets) ? assets : [assets];\n logger.debug(\n `Direct upload mode: passing user-provided assets directly to CLI: ${pathsToUpload.join(', ')}`,\n );\n } else {\n // Use original paths e.g. like ['.next/server'] directly –> preferred way when no globbing is done\n pathsToUpload = buildArtifactPaths;\n }\n\n // Staged artifacts are already prepared, so the CLI can take the folder as it is.\n if (staging && staging.count > 0) {\n pathsToUpload = [...pathsToUpload, staging.dir];\n }\n\n if (pathsToUpload.length === 0) {\n logger.warn(\n \"Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.\",\n );\n return;\n }\n\n const emptyDirectories = await startSpan({ name: 'upload', scope: sentryScope }, async () => {\n const cliInstance = new SentryCliAdapter(options);\n return cliInstance.uploadSourcemaps(\n options.release.name ?? 'undefined',\n pathsToUpload.map(directory => ({\n directory,\n dist: options.release.dist,\n ignore: options.sourcemaps?.ignore,\n })),\n );\n });\n\n warnAboutDirectoriesWithoutSourcemaps(logger, emptyDirectories);\n if (emptyDirectories.length < pathsToUpload.length) {\n uploaded = true;\n logger.info('Successfully uploaded source maps to Sentry');\n }\n } else {\n // Prepare artifacts in temp folder before uploading\n let globAssets: string | string[];\n if (assets) {\n globAssets = assets;\n } else {\n logger.debug(\n 'No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.',\n );\n globAssets = buildArtifactPaths.map(asset => escapeGlob(asset.split(path.sep).join('/')));\n }\n\n const globResult = await startSpan({ name: 'glob', scope: sentryScope }, async () =>\n globFiles(globAssets, { ignore: options.sourcemaps?.ignore }),\n );\n\n const debugIdChunkFilePaths = globResult.filter(debugIdChunkFilePath => {\n const filePath = stripQueryAndHashFromPath(debugIdChunkFilePath);\n return !!filePath.match(/\\.(js|mjs|cjs)$/) && !staging?.stagedChunkPaths.has(path.resolve(filePath));\n });\n\n // The order of the files output by glob() is not deterministic\n // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent\n debugIdChunkFilePaths.sort();\n\n const stagedCount = staging?.count ?? 0;\n\n if (debugIdChunkFilePaths.length === 0 && stagedCount === 0) {\n logger.warn(\n \"Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.\",\n );\n } else {\n const tmpUploadFolder =\n staging?.dir ??\n (await startSpan({ name: 'mkdtemp', scope: sentryScope }, () => createTempUploadFolder()));\n folderToCleanUp = tmpUploadFolder;\n\n // Prepare into temp folder, then upload\n await startSpan({ name: 'prepare-bundles', scope: sentryScope }, async prepBundlesSpan => {\n // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so\n // instead we do it with a maximum of 16 concurrent workers\n const preparationTasks = debugIdChunkFilePaths.map((chunkFilePath, chunkIndex) => async () => {\n const prepared = await prepareBundleForDebugIdUpload(\n chunkFilePath,\n tmpUploadFolder,\n stagedCount + chunkIndex,\n logger,\n options.sourcemaps?.rewriteSources ?? defaultRewriteSourcesHook,\n options.sourcemaps?.resolveSourceMap,\n );\n if (prepared?.sourceMapPath !== undefined) {\n preparedSourceMapPaths.push(prepared.sourceMapPath);\n }\n });\n const workers: Promise<void>[] = [];\n const worker = async (): Promise<void> => {\n while (preparationTasks.length > 0) {\n const task = preparationTasks.shift();\n if (task) {\n await task();\n }\n }\n };\n for (let workerIndex = 0; workerIndex < 16; workerIndex++) {\n workers.push(worker());\n }\n\n await Promise.all(workers);\n\n const files = await fs.promises.readdir(tmpUploadFolder);\n const stats = files.map(file => fs.promises.stat(path.join(tmpUploadFolder, file)));\n const uploadSize = (await Promise.all(stats)).reduce(\n (accumulator, { size }) => accumulator + size,\n 0,\n );\n\n setMeasurement('files', files.length, 'none', prepBundlesSpan);\n setMeasurement('upload_size', uploadSize, 'byte', prepBundlesSpan);\n\n // Preparation produced no artifacts, meaning none of the\n // matched bundles had an associated source map. This almost\n // always means source map generation is turned off in the\n // bundler, so warn instead of silently reporting success.\n if (files.length === 0) {\n logger.warn(\n `No source maps found for any of the ${debugIdChunkFilePaths.length + stagedCount} matched build ` +\n 'artifacts, so no source maps were uploaded to Sentry. This usually means source map ' +\n 'generation is not enabled in your bundler. Enable it so Sentry can un-minify your stack traces.',\n );\n return;\n }\n\n await startSpan({ name: 'upload', scope: sentryScope }, async () => {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.uploadSourcemaps(options.release.name ?? 'undefined', [\n {\n directory: tmpUploadFolder,\n dist: options.release.dist,\n },\n ]);\n });\n\n // this must be in the method so that the \"no sourcemaps\"\n // early return doesn't also log success.\n uploaded = true;\n logger.info('Successfully uploaded source maps to Sentry');\n });\n }\n }\n } catch (e) {\n if (staging && folderToCleanUp) {\n await staging.keep('Source map upload failed.');\n folderToCleanUp = undefined;\n }\n sentryScope.captureException('Error in \"debugIdUploadPlugin\" writeBundle hook');\n handleRecoverableError(e, false);\n } finally {\n if (folderToCleanUp && !process.env?.['SENTRY_TEST_OVERRIDE_TEMP_DIR']) {\n logger.debug('Cleaning up temporary files...');\n try {\n await startSpan({ name: 'cleanup', scope: sentryScope }, async () => {\n if (folderToCleanUp) {\n await fs.promises.rm(folderToCleanUp, { recursive: true, force: true });\n logger.debug(`Temporary folder deleted: ${folderToCleanUp}`);\n }\n });\n } catch (e) {\n // A failed cleanup must not skip the teardown steps below (freeing upload\n // dependencies, flushing telemetry), so swallow and log instead of rethrowing.\n logger.debug('Failed to clean up temporary folder:', e);\n }\n }\n logger.debug('Freeing upload dependencies...');\n freeUploadDependencyOnBuildArtifacts();\n logger.debug('Flushing telemetry data...');\n await safeFlushTelemetry(sentryClient);\n logger.debug('Telemetry flushed. Plugin upload process complete.');\n }\n },\n );\n\n return { uploaded, uploadedSourceMapPaths: uploaded ? preparedSourceMapPaths.sort() : [] };\n },\n\n async createUploadStaging(): Promise<UploadStaging> {\n const dir = await createTempUploadFolder();\n const rewriteSourcesHook = options.sourcemaps?.rewriteSources ?? defaultRewriteSourcesHook;\n let count = 0;\n let discarded = false;\n const stagedChunkPaths = new Set<string>();\n\n const discard = async (): Promise<void> => {\n if (discarded) {\n return;\n }\n discarded = true;\n\n if (process.env['SENTRY_TEST_OVERRIDE_TEMP_DIR']) {\n return;\n }\n\n try {\n await fs.promises.rm(dir, { recursive: true, force: true });\n } catch (e) {\n logger.debug(`Failed to remove staging folder ${dir}:`, e);\n }\n };\n\n return {\n dir,\n get count() {\n return count;\n },\n stagedChunkPaths,\n async stage(input) {\n const chunkPath = path.resolve(input.chunkPath);\n const chunkName = path.basename(chunkPath);\n if (!shouldUpload(chunkPath)) {\n logger.debug(\n `Not staging ${chunkName} for upload: excluded by \\`sourcemaps.assets\\` or \\`sourcemaps.ignore\\`.`,\n );\n return 'excluded';\n }\n\n const result = prepareArtifactForUpload({\n code: input.code,\n mapSource: input.mapSource,\n mapDir: input.mapDir,\n rewriteSourcesHook,\n });\n\n if (!result.ok) {\n logger.debug(`Not staging ${chunkName} for upload: ${result.reason}`);\n return 'skipped';\n }\n\n const index = count++;\n\n try {\n await writePreparedArtifact(dir, `${result.artifact.debugId}-${index}`, result.artifact);\n stagedChunkPaths.add(chunkPath);\n return 'staged';\n } catch (e) {\n sentryScope.captureException('Error staging build artifact for upload');\n // Throwing by default: the bundler drops the source map from its\n // output once staged, so a lost copy would leave no map at all.\n handleRecoverableError(e, true);\n return 'failed';\n }\n },\n discard,\n async keep(reason) {\n if (count === 0) {\n await discard();\n return;\n }\n if (discarded) {\n return;\n }\n discarded = true;\n\n // The bundler dropped the staged source maps from its output, so\n // this folder is the only copy left.\n logger.error(\n `${reason} The source maps were kept in ${dir}. Upload them with \\`sentry sourcemap upload ${dir}\\`.`,\n );\n },\n };\n },\n\n sourceMaps: {\n uploadPossible: sourceMapUploadPossible,\n decide(kind, { log = true, environment } = {}) {\n // Watch builds in development keep their source maps.\n const decision = isDevMode\n ? { enableHidden: false, deleteAfterUpload: false }\n : decideSourceMapHandling(kind, options, sourceMapUploadPossible, environment);\n if (log) {\n logDecision(decision);\n }\n return decision;\n },\n logDecision,\n shouldUpload,\n async deleteFromOutput(sourceMapPaths) {\n try {\n await Promise.all(\n sourceMapPaths.map(async sourceMapPath => {\n try {\n await fs.promises.rm(sourceMapPath, { force: true });\n } catch (e) {\n logger.error(`Could not delete source map ${sourceMapPath} from the build output.`);\n throw e;\n }\n }),\n );\n } catch (e) {\n sentryScope.captureException('Error deleting source maps after upload');\n await safeFlushTelemetry(sentryClient);\n // Throwing by default: a map left in the output could leak to production.\n handleRecoverableError(e, true);\n }\n },\n },\n\n /**\n * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.\n */\n async deleteArtifacts() {\n try {\n const filesToDelete = await options.sourcemaps?.filesToDeleteAfterUpload;\n if (filesToDelete !== undefined) {\n const filePathsToDelete = await globFiles(filesToDelete);\n\n logger.debug('Waiting for dependencies on generated files to be freed before deleting...');\n\n await waitUntilBuildArtifactDependenciesAreFreed();\n\n filePathsToDelete.forEach(filePathToDelete => {\n logger.debug(`Deleting asset after upload: ${filePathToDelete}`);\n });\n\n await Promise.all(\n filePathsToDelete.map(filePathToDelete =>\n fs.promises.rm(filePathToDelete, { force: true }).catch(e => {\n // This is allowed to fail - we just don't do anything\n logger.debug(`An error occurred while attempting to delete asset: ${filePathToDelete}`, e);\n }),\n ),\n );\n }\n } catch (e) {\n sentryScope.captureException('Error in \"sentry-file-deletion-plugin\" buildEnd hook');\n await safeFlushTelemetry(sentryClient);\n // We throw by default if we get here b/c not being able to delete\n // source maps could leak them to production\n handleRecoverableError(e, true);\n }\n },\n createDependencyOnBuildArtifacts,\n };\n}\n\nasync function createTempUploadFolder(): Promise<string> {\n return (\n process.env['SENTRY_TEST_OVERRIDE_TEMP_DIR'] ||\n (await fs.promises.mkdtemp(path.join(os.tmpdir(), 'sentry-bundler-plugin-upload-')))\n );\n}\n\ntype SourceMapUploadBlocker = 'disabled' | 'no-assets' | 'dev-mode' | 'no-auth-token' | 'no-org' | 'no-project';\n\nfunction getSourceMapUploadBlocker(options: NormalizedOptions, isDevMode: boolean): SourceMapUploadBlocker | undefined {\n if (options.sourcemaps?.disable) {\n return 'disabled';\n }\n if (Array.isArray(options.sourcemaps?.assets) && options.sourcemaps.assets.length === 0) {\n return 'no-assets';\n }\n if (isDevMode) {\n return 'dev-mode';\n }\n if (!options.authToken) {\n return 'no-auth-token';\n }\n if (!options.org && !options.authToken.startsWith('sntrys_')) {\n return 'no-org';\n }\n if (!getProjects(options.project)?.[0]) {\n return 'no-project';\n }\n return undefined;\n}\n\nfunction canUploadSourceMaps(options: NormalizedOptions, logger: Logger, isDevMode: boolean): boolean {\n switch (getSourceMapUploadBlocker(options, isDevMode)) {\n case 'disabled':\n logger.debug('Source map upload was disabled. Will not upload sourcemaps using debug ID process.');\n return false;\n case 'no-assets':\n logger.debug('Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.');\n return false;\n case 'dev-mode':\n logger.debug('Running in development mode. Will not upload sourcemaps.');\n return false;\n case 'no-auth-token':\n logger.warn(\n `No auth token provided. Will not upload source maps. Please set the \\`authToken\\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${getTurborepoEnvPassthroughWarning('SENTRY_AUTH_TOKEN')}`,\n );\n return false;\n case 'no-org':\n logger.warn(\n `No org provided. Will not upload source maps. Please set the \\`org\\` option to your Sentry organization slug.${getTurborepoEnvPassthroughWarning('SENTRY_ORG')}`,\n );\n return false;\n case 'no-project':\n logger.warn(\n `No project provided. Will not upload source maps. Please set the \\`project\\` option to your Sentry project slug.${getTurborepoEnvPassthroughWarning('SENTRY_PROJECT')}`,\n );\n return false;\n default:\n return true;\n }\n}\n\nfunction warnAboutDirectoriesWithoutSourcemaps(logger: Logger, directories: string[]): void {\n if (directories.length === 0) {\n return;\n }\n const list = directories.map(directory => ` - ${directory}`).join('\\n');\n logger.warn(\n `No source maps found in the following directories, so nothing was uploaded from them:\\n${list}\\n` +\n 'This usually means source map generation is not enabled for these build outputs. ' +\n 'Enable it so Sentry can un-minify stack traces from these files.',\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,oCAAoB,IAAI,IAAY;;;;;;AAyJ1C,SAAgB,+BACd,aACA,0BAc0B;CAC1B,MAAM,SAASA,eAAAA,aAAa;EAC1B,QAAQ,yBAAyB;EACjC,QAAQ,YAAY,UAAU;EAC9B,OAAO,YAAY,SAAS;CAC9B,CAAC;CAED,IAAI;EACF,MAAM,aAAa,GAAG,aAAa,KAAK,KAAK,QAAQ,IAAI,GAAG,0BAA0B,GAAG,OAAO;EAEhG,MAAM,eAAe,OAAO,MAAM,UAAU;EAI5C,OAAO,OAAO,QAAQ,KAAK,YAAY;EAEvC,OAAO,KAAK,yEAAuE;CACrF,SAAS,GAAY;EAEnB,IAAI,OAAO,MAAM,YAAY,KAAK,UAAU,KAAK,EAAE,SAAS,UAC1D,MAAM;CAEV;CAEA,MAAM,UAAUC,wBAAAA,qBAAqB,WAAW;CAEhD,IAAI,QAAQ,SAKV,OAAO;EACL,mBAAmB;EACnB;EACA,yCAAyC,CAAC;EAC1C,WAAW,EACT,kCAAkC,YAAY,CAE9C,EACF;EACA,gBAAgB,CAAC;EACjB,eAAe,YAAY,CAE3B;EACA,kBAAkB,aAAa;GAAE,UAAU;GAAO,wBAAwB,CAAC;EAAE;EAC7E,qBAAqB,aAAa;GAChC,KAAK;GACL,OAAO;GACP,kCAAkB,IAAI,IAAY;GAClC,OAAO,YAAY;GACnB,SAAS,YAAY,CAErB;GACA,MAAM,YAAY,CAElB;EACF;EACA,YAAY;GACV,gBAAgB;GAChB,eAAe;IAAE,cAAc;IAAO,mBAAmB;GAAM;GAC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ringTag, { value: 'Module' });
2
-
3
- const sentry = require('sentry');
4
- const utils = require('./utils.js');
5
-
6
- var __typeError = (msg) => {
7
- throw TypeError(msg);
8
- };
9
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
10
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
11
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
12
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
13
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
14
- var _options, _sdk, _SentryCliAdapter_instances, createClient_fn;
1
+ const require_utils = require("./utils.js");
2
+ const require_classPrivateMethodInitSpec = require("../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js");
3
+ const require_classPrivateFieldInitSpec = require("../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js");
4
+ const require_classPrivateFieldSet2 = require("../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js");
5
+ const require_assertClassBrand = require("../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js");
6
+ const require_classPrivateFieldGet2 = require("../_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js");
7
+ let sentry = require("sentry");
8
+ // src/core/cli.ts
9
+ /** Comma-joined list of ignore globs, or `undefined` when nothing should be ignored. */
15
10
  function serializeIgnore(ignore) {
16
- if (!ignore) {
17
- return void 0;
18
- }
19
- const patterns = utils.arrayify(ignore);
20
- return patterns.length > 0 ? patterns.join(",") : void 0;
21
- }
22
- class SentryCliAdapter {
23
- constructor(options) {
24
- __privateAdd(this, _SentryCliAdapter_instances);
25
- __privateAdd(this, _options);
26
- /** Client for every command that is not scoped to a specific project. */
27
- __privateAdd(this, _sdk);
28
- __privateSet(this, _options, options);
29
- __privateSet(this, _sdk, __privateMethod(this, _SentryCliAdapter_instances, createClient_fn).call(this));
30
- }
31
- /** Create a release and associate it with the configured project(s). */
32
- async createRelease(name) {
33
- return __privateGet(this, _sdk).release.create({ orgVersion: name, project: utils.getProjects(__privateGet(this, _options).project)?.join(",") });
34
- }
35
- /** Finalize a release by stamping an end timestamp. */
36
- async finalizeRelease(name) {
37
- await __privateGet(this, _sdk).release.finalize({ orgVersion: name });
38
- }
39
- /**
40
- * Associate commits with a release. Translates the plugin's {@link SetCommitsOptions} `auto` /
41
- * `repo`+`commit` union into the flags accepted by `sentry release set-commits`. The old CLI's
42
- * `ignoreMissing`/`ignoreEmpty` toggles have no equivalent flag on the new CLI; the caller's
43
- * `shouldNotThrowOnFailure` handling still swallows the "no repository" failure case.
44
- */
45
- async setCommits(name, setCommitsOptions) {
46
- const { auto, repo, commit, previousCommit } = setCommitsOptions;
47
- const commitSpec = repo && commit ? `${repo}@${previousCommit ? `${previousCommit}..${commit}` : commit}` : void 0;
48
- await __privateGet(this, _sdk).release["set-commits"]({
49
- orgVersion: name,
50
- auto: auto === true,
51
- commit: commitSpec
52
- });
53
- }
54
- /** Create a deploy for a release. */
55
- async newDeploy(name, deploy) {
56
- if (deploy === false) {
57
- return;
58
- }
59
- await __privateGet(this, _sdk).release.deploy({
60
- orgVersion: name,
61
- environment: deploy.env,
62
- name: deploy.name,
63
- url: deploy.url,
64
- started: deploy.started !== void 0 ? String(deploy.started) : void 0,
65
- finished: deploy.finished !== void 0 ? String(deploy.finished) : void 0,
66
- time: deploy.time !== void 0 ? String(deploy.time) : void 0
67
- });
68
- }
69
- /**
70
- * Upload sourcemaps for one or more directories. The old CLI accepted a structured `include`
71
- * array; the new `sourcemap upload` command takes a single directory, so we upload each target
72
- * separately. A client is created per project because project selection is bound at client
73
- * creation time.
74
- */
75
- async uploadSourcemaps(name, targets) {
76
- const projects = utils.getProjects(__privateGet(this, _options).project) ?? [void 0];
77
- for (const project of projects) {
78
- const sdk = __privateMethod(this, _SentryCliAdapter_instances, createClient_fn).call(this, project);
79
- for (const target of targets) {
80
- await sdk.sourcemap.upload({
81
- directory: target.directory,
82
- release: name,
83
- dist: target.dist ?? __privateGet(this, _options).release.dist,
84
- ext: target.ext?.join(","),
85
- ignore: serializeIgnore(target.ignore),
86
- ignoreFile: target.ignoreFile,
87
- urlPrefix: target.urlPrefix
88
- });
89
- }
90
- }
91
- }
92
- /** Inject debug IDs into the given build artifacts. */
93
- async injectDebugIds(directories, ignore) {
94
- const serializedIgnore = serializeIgnore(ignore) ?? "node_modules";
95
- for (const directory of directories) {
96
- await __privateGet(this, _sdk).sourcemap.inject({ directory, ignore: serializedIgnore });
97
- }
98
- }
99
- /**
100
- * Resolve the Sentry server URL the CLI is configured to talk to. Used by the telemetry guard
101
- * to decide whether the current build targets Sentry SaaS. Returns `undefined` on error.
102
- */
103
- async getServerUrl() {
104
- try {
105
- const info = await __privateGet(this, _sdk).run("info");
106
- return info.config?.url;
107
- } catch {
108
- return void 0;
109
- }
110
- }
11
+ if (!ignore) return;
12
+ const patterns = require_utils.arrayify(ignore);
13
+ return patterns.length > 0 ? patterns.join(",") : void 0;
111
14
  }
112
- _options = new WeakMap();
113
- _sdk = new WeakMap();
114
- _SentryCliAdapter_instances = new WeakSet();
15
+ var _options = /* @__PURE__ */ new WeakMap();
16
+ var _sdk = /* @__PURE__ */ new WeakMap();
17
+ var _SentryCliAdapter_brand = /* @__PURE__ */ new WeakSet();
115
18
  /**
116
- * The CLI binds `org`/`project`/`url` when the client is created rather than per call, so a
117
- * client scoped to a different project needs to be a different client.
118
- *
119
- * Creating one is free: it reads no config and opens no connection, it only closes over these
120
- * options. Everything happens when a command is actually invoked.
121
- */
122
- createClient_fn = function(project) {
123
- const options = {
124
- token: __privateGet(this, _options).authToken,
125
- org: __privateGet(this, _options).org,
126
- project,
127
- url: __privateGet(this, _options).url,
128
- headers: __privateGet(this, _options).headers
129
- };
130
- return sentry.createSentrySDK(options);
19
+ * Thin wrapper around the Sentry CLI's programmatic SDK. The bundler plugin used to drive the
20
+ * old `@sentry/cli` binary through a `SentryCli` class; the new CLI exposes typed methods via
21
+ * `createSentrySDK()` instead. This adapter maps the plugin's structured option shapes onto
22
+ * those methods and keeps all translation logic in one place.
23
+ */
24
+ var SentryCliAdapter = class {
25
+ constructor(options) {
26
+ require_classPrivateMethodInitSpec.default(this, _SentryCliAdapter_brand);
27
+ require_classPrivateFieldInitSpec.default(this, _options, void 0);
28
+ require_classPrivateFieldInitSpec.default(this, _sdk, void 0);
29
+ require_classPrivateFieldSet2.default(_options, this, options);
30
+ require_classPrivateFieldSet2.default(_sdk, this, require_assertClassBrand.default(_SentryCliAdapter_brand, this, _createClient).call(this));
31
+ }
32
+ /** Create a release and associate it with the configured project(s). */
33
+ async createRelease(name) {
34
+ return require_classPrivateFieldGet2.default(_sdk, this).release.create({
35
+ orgVersion: name,
36
+ project: require_utils.getProjects(require_classPrivateFieldGet2.default(_options, this).project)?.join(",")
37
+ });
38
+ }
39
+ /** Finalize a release by stamping an end timestamp. */
40
+ async finalizeRelease(name) {
41
+ await require_classPrivateFieldGet2.default(_sdk, this).release.finalize({ orgVersion: name });
42
+ }
43
+ /**
44
+ * Associate commits with a release. Translates the plugin's {@link SetCommitsOptions} `auto` /
45
+ * `repo`+`commit` union into the flags accepted by `sentry release set-commits`. The old CLI's
46
+ * `ignoreMissing`/`ignoreEmpty` toggles have no equivalent flag on the new CLI; the caller's
47
+ * `shouldNotThrowOnFailure` handling still swallows the "no repository" failure case.
48
+ */
49
+ async setCommits(name, setCommitsOptions) {
50
+ const { auto, repo, commit, previousCommit } = setCommitsOptions;
51
+ const commitSpec = repo && commit ? `${repo}@${previousCommit ? `${previousCommit}..${commit}` : commit}` : void 0;
52
+ await require_classPrivateFieldGet2.default(_sdk, this).release["set-commits"]({
53
+ orgVersion: name,
54
+ auto: auto === true,
55
+ commit: commitSpec
56
+ });
57
+ }
58
+ /** Create a deploy for a release. */
59
+ async newDeploy(name, deploy) {
60
+ if (deploy === false) return;
61
+ await require_classPrivateFieldGet2.default(_sdk, this).release.deploy({
62
+ orgVersion: name,
63
+ environment: deploy.env,
64
+ name: deploy.name,
65
+ url: deploy.url,
66
+ started: deploy.started !== void 0 ? String(deploy.started) : void 0,
67
+ finished: deploy.finished !== void 0 ? String(deploy.finished) : void 0,
68
+ time: deploy.time !== void 0 ? String(deploy.time) : void 0
69
+ });
70
+ }
71
+ /**
72
+ * Upload sourcemaps for one or more directories. The old CLI accepted a structured `include`
73
+ * array; the new `sourcemap upload` command takes a single directory, so we upload each target
74
+ * separately. A client is created per project because project selection is bound at client
75
+ * creation time.
76
+ *
77
+ * Empty directories must not abort the loop: `@sentry/nextjs` uploads `.next/server` first, and
78
+ * a server build without source maps would otherwise skip every client directory after it.
79
+ *
80
+ * @returns The directories that had no source maps to upload.
81
+ */
82
+ async uploadSourcemaps(name, targets) {
83
+ const projects = require_utils.getProjects(require_classPrivateFieldGet2.default(_options, this).project) ?? [void 0];
84
+ const emptyDirectories = /* @__PURE__ */ new Set();
85
+ for (const project of projects) {
86
+ const sdk = require_assertClassBrand.default(_SentryCliAdapter_brand, this, _createClient).call(this, project);
87
+ for (const target of targets) if ((await sdk.sourcemap.upload({
88
+ directory: target.directory,
89
+ release: name,
90
+ dist: target.dist ?? require_classPrivateFieldGet2.default(_options, this).release.dist,
91
+ ext: target.ext?.join(","),
92
+ ignore: serializeIgnore(target.ignore),
93
+ ignoreFile: target.ignoreFile,
94
+ urlPrefix: target.urlPrefix,
95
+ allowEmpty: true
96
+ }))?.filesUploaded === 0) emptyDirectories.add(target.directory);
97
+ }
98
+ return [...emptyDirectories];
99
+ }
100
+ /** Inject debug IDs into the given build artifacts. */
101
+ async injectDebugIds(directories, ignore) {
102
+ const serializedIgnore = serializeIgnore(ignore) ?? "node_modules";
103
+ for (const directory of directories) await require_classPrivateFieldGet2.default(_sdk, this).sourcemap.inject({
104
+ directory,
105
+ ignore: serializedIgnore
106
+ });
107
+ }
108
+ /**
109
+ * Resolve the Sentry server URL the CLI is configured to talk to. Used by the telemetry guard
110
+ * to decide whether the current build targets Sentry SaaS. Returns `undefined` on error.
111
+ */
112
+ async getServerUrl() {
113
+ try {
114
+ return (await require_classPrivateFieldGet2.default(_sdk, this).run("info")).config?.url;
115
+ } catch {
116
+ return;
117
+ }
118
+ }
131
119
  };
132
-
120
+ /**
121
+ * The CLI binds `org`/`project`/`url` when the client is created rather than per call, so a
122
+ * client scoped to a different project needs to be a different client.
123
+ *
124
+ * Creating one is free: it reads no config and opens no connection, it only closes over these
125
+ * options. Everything happens when a command is actually invoked.
126
+ */
127
+ function _createClient(project) {
128
+ const options = {
129
+ token: require_classPrivateFieldGet2.default(_options, this).authToken,
130
+ org: require_classPrivateFieldGet2.default(_options, this).org,
131
+ project,
132
+ url: require_classPrivateFieldGet2.default(_options, this).url,
133
+ headers: require_classPrivateFieldGet2.default(_options, this).headers
134
+ };
135
+ return (0, sentry.createSentrySDK)(options);
136
+ }
133
137
  exports.SentryCliAdapter = SentryCliAdapter;
134
- //# sourceMappingURL=cli.js.map
138
+
139
+ //# sourceMappingURL=cli.js.map