@sentry/bundler-plugins 11.14.0 → 11.15.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 (87) hide show
  1. package/build/cjs/bun/index.js +6 -2
  2. package/build/cjs/bun/index.js.map +1 -1
  3. package/build/cjs/core/build-plugin-manager.js +5 -1
  4. package/build/cjs/core/build-plugin-manager.js.map +1 -1
  5. package/build/cjs/core/debug-id-upload.js +1 -1
  6. package/build/cjs/core/debug-id-upload.js.map +1 -1
  7. package/build/cjs/core/index.js +3 -0
  8. package/build/cjs/core/index.js.map +1 -1
  9. package/build/cjs/core/options-mapping.js +6 -1
  10. package/build/cjs/core/options-mapping.js.map +1 -1
  11. package/build/cjs/core/sentry/telemetry.js +3 -0
  12. package/build/cjs/core/sentry/telemetry.js.map +1 -1
  13. package/build/cjs/core/sourcemap-settings.js +85 -5
  14. package/build/cjs/core/sourcemap-settings.js.map +1 -1
  15. package/build/cjs/core/utils.js +10 -0
  16. package/build/cjs/core/utils.js.map +1 -1
  17. package/build/cjs/core/version.js +1 -1
  18. package/build/cjs/core/version.js.map +1 -1
  19. package/build/cjs/esbuild/index.js +14 -9
  20. package/build/cjs/esbuild/index.js.map +1 -1
  21. package/build/cjs/rollup/index.js +20 -12
  22. package/build/cjs/rollup/index.js.map +1 -1
  23. package/build/cjs/rollup/source-map-handling.js +19 -1
  24. package/build/cjs/rollup/source-map-handling.js.map +1 -1
  25. package/build/cjs/vite/release-html-injection.js +33 -0
  26. package/build/cjs/vite/release-html-injection.js.map +1 -0
  27. package/build/cjs/vite/source-map-hooks.js +8 -6
  28. package/build/cjs/vite/source-map-hooks.js.map +1 -1
  29. package/build/cjs/webpack/index.js +40 -8
  30. package/build/cjs/webpack/index.js.map +1 -1
  31. package/build/esm/bun/index.js +6 -2
  32. package/build/esm/bun/index.js.map +1 -1
  33. package/build/esm/core/build-plugin-manager.js +6 -2
  34. package/build/esm/core/build-plugin-manager.js.map +1 -1
  35. package/build/esm/core/debug-id-upload.js +1 -1
  36. package/build/esm/core/debug-id-upload.js.map +1 -1
  37. package/build/esm/core/index.js +3 -3
  38. package/build/esm/core/index.js.map +1 -1
  39. package/build/esm/core/options-mapping.js +7 -2
  40. package/build/esm/core/options-mapping.js.map +1 -1
  41. package/build/esm/core/sentry/telemetry.js +3 -0
  42. package/build/esm/core/sentry/telemetry.js.map +1 -1
  43. package/build/esm/core/sourcemap-settings.js +84 -6
  44. package/build/esm/core/sourcemap-settings.js.map +1 -1
  45. package/build/esm/core/utils.js +10 -1
  46. package/build/esm/core/utils.js.map +1 -1
  47. package/build/esm/core/version.js +1 -1
  48. package/build/esm/core/version.js.map +1 -1
  49. package/build/esm/esbuild/index.js +14 -9
  50. package/build/esm/esbuild/index.js.map +1 -1
  51. package/build/esm/package.json +1 -1
  52. package/build/esm/rollup/index.js +20 -12
  53. package/build/esm/rollup/index.js.map +1 -1
  54. package/build/esm/rollup/source-map-handling.js +19 -1
  55. package/build/esm/rollup/source-map-handling.js.map +1 -1
  56. package/build/esm/vite/release-html-injection.js +33 -0
  57. package/build/esm/vite/release-html-injection.js.map +1 -0
  58. package/build/esm/vite/source-map-hooks.js +9 -7
  59. package/build/esm/vite/source-map-hooks.js.map +1 -1
  60. package/build/esm/webpack/index.js +40 -8
  61. package/build/esm/webpack/index.js.map +1 -1
  62. package/build/types/bun/index.d.ts.map +1 -1
  63. package/build/types/core/build-plugin-manager.d.ts.map +1 -1
  64. package/build/types/core/debug-id-upload.d.ts +1 -1
  65. package/build/types/core/index.d.ts +2 -2
  66. package/build/types/core/index.d.ts.map +1 -1
  67. package/build/types/core/options-mapping.d.ts +4 -1
  68. package/build/types/core/options-mapping.d.ts.map +1 -1
  69. package/build/types/core/sentry/telemetry.d.ts.map +1 -1
  70. package/build/types/core/sourcemap-settings.d.ts +19 -0
  71. package/build/types/core/sourcemap-settings.d.ts.map +1 -1
  72. package/build/types/core/types.d.ts +54 -1
  73. package/build/types/core/types.d.ts.map +1 -1
  74. package/build/types/core/utils.d.ts +7 -0
  75. package/build/types/core/utils.d.ts.map +1 -1
  76. package/build/types/core/version.d.ts +1 -1
  77. package/build/types/esbuild/index.d.ts.map +1 -1
  78. package/build/types/rollup/index.d.ts +36 -5
  79. package/build/types/rollup/index.d.ts.map +1 -1
  80. package/build/types/rollup/source-map-handling.d.ts +5 -0
  81. package/build/types/rollup/source-map-handling.d.ts.map +1 -1
  82. package/build/types/vite/release-html-injection.d.ts +31 -0
  83. package/build/types/vite/release-html-injection.d.ts.map +1 -0
  84. package/build/types/vite/source-map-hooks.d.ts +1 -0
  85. package/build/types/vite/source-map-hooks.d.ts.map +1 -1
  86. package/build/types/webpack/index.d.ts.map +1 -1
  87. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createRequire","createSentryBuildPluginManager","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","path","stringifyForCodeInjection","randomUUID","getDebugIdSnippet","createDebugIdUploadFunction","isJsFile","addDebugIdToEmittedArtifacts"],"sources":["../../../src/esbuild/index.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport type { InternalOptions, SourceMapDecision, SourceMapKind } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n CodeInjection,\n addDebugIdToEmittedArtifacts,\n isJsFile,\n} from '../core';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport { randomUUID } from 'node:crypto';\nimport { stringifyForCodeInjection } from '@sentry/core';\n\ninterface EsbuildOnResolveArgs {\n path: string;\n kind: string;\n importer?: string;\n resolveDir: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnResolveResult {\n path: string;\n sideEffects?: boolean;\n pluginName?: string;\n namespace?: string;\n suffix?: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnLoadArgs {\n path: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnLoadResult {\n loader: string;\n pluginName: string;\n contents: string;\n resolveDir?: string;\n}\n\ninterface EsbuildOnEndArgs {\n metafile?: {\n outputs: Record<string, unknown>;\n };\n}\n\ntype EsbuildSourceMapSetting = boolean | 'inline' | 'external' | 'linked' | 'both' | undefined;\n\ninterface EsbuildInitialOptions {\n bundle?: boolean;\n inject?: string[];\n metafile?: boolean;\n define?: Record<string, string>;\n write?: boolean;\n absWorkingDir?: string;\n logOverride?: Record<string, string>;\n sourcemap?: EsbuildSourceMapSetting;\n}\n\n/** Maps esbuild's `sourcemap` setting onto the plugin's source map kinds. */\nfunction sourceMapKindFromEsbuildSetting(setting: EsbuildSourceMapSetting): SourceMapKind {\n switch (setting) {\n case undefined:\n return 'unset';\n case false:\n return 'off';\n case 'external':\n return 'hidden';\n case 'inline':\n case 'both':\n return 'inline';\n default:\n return 'visible';\n }\n}\n\ninterface EsbuildPluginBuild {\n initialOptions: EsbuildInitialOptions;\n onLoad: (\n options: { filter: RegExp; namespace?: string },\n callback: (args: EsbuildOnLoadArgs) => EsbuildOnLoadResult | null,\n ) => void;\n onResolve: (\n options: { filter: RegExp },\n callback: (args: EsbuildOnResolveArgs) => EsbuildOnResolveResult | undefined,\n ) => void;\n onStart: (callback: () => void) => void;\n onEnd: (callback: (result: EsbuildOnEndArgs) => void | Promise<void>) => void;\n}\n\nfunction getEsbuildMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - esbuild transpiles this for us\n const req = createRequire(import.meta.url);\n const esbuild = req('esbuild') as { version?: string };\n // esbuild hasn't released a v1 yet, so we'll return the minor version as the major version\n return esbuild.version?.split('.')[1];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nconst pluginName = 'sentry-esbuild-plugin';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function sentryEsbuildPlugin(userOptions: InternalOptions = {}): any {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[${pluginName}]`,\n buildTool: 'esbuild',\n buildToolMajorVersion: getEsbuildMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n name: 'sentry-esbuild-noop-plugin',\n setup() {\n // noop plugin\n },\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n // Component annotation warning\n if (options.reactComponentAnnotation?.enabled) {\n logger.warn(\n 'Component name annotation is not supported in esbuild. Please use a separate transform step or consider using a different bundler.',\n );\n }\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n // Track entry points wrapped for debug ID injection\n const debugIdWrappedPaths = new Set<string>();\n\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n return {\n name: pluginName,\n setup({ initialOptions, onLoad, onResolve, onStart, onEnd }: EsbuildPluginBuild) {\n // Release and/or metadata injection\n if (!staticInjectionCode.isEmpty()) {\n const virtualInjectionFilePath = path.resolve('_sentry-injection-stub');\n initialOptions.inject = initialOptions.inject || [];\n // esbuild emits injected files after an entry's directive prologue. A banner would precede\n // \"use strict\" and turn it into an ordinary string expression.\n initialOptions.inject.push(virtualInjectionFilePath);\n\n onResolve({ filter: /_sentry-injection-stub/ }, args => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n };\n });\n\n onLoad({ filter: /_sentry-injection-stub/ }, () => {\n return {\n loader: 'js',\n pluginName,\n contents: staticInjectionCode.code(),\n };\n });\n }\n\n // Bundle size optimizations\n if (transformReplace) {\n const replacementStringValues: Record<string, string> = {};\n Object.entries(replacementValues).forEach(([key, value]) => {\n replacementStringValues[key] = JSON.stringify(value);\n });\n\n initialOptions.define = { ...initialOptions.define, ...replacementStringValues };\n }\n\n // Debug ID injection - requires per-entry-point unique IDs\n if (sourcemapsEnabled) {\n // `setup` runs once per context, `onStart` once per build, so a\n // rebuild wraps the entry points again.\n onStart(() => debugIdWrappedPaths.clear());\n\n // The proxy module re-exports `OriginalModule.default` statically so downstream bundlers can tree-shake it,\n // but esbuild warns about that access when the entry point has no default export.\n initialOptions.logOverride = { 'import-is-undefined': 'silent', ...initialOptions.logOverride };\n\n if (!initialOptions.bundle) {\n logger.warn(\n 'The Sentry esbuild plugin only supports esbuild with `bundle: true` being set in the esbuild build options. Esbuild will probably crash now. Sorry about that. If you need to upload sourcemaps without `bundle: true`, it is recommended to use Sentry CLI instead: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/',\n );\n }\n\n // Wrap entry points to inject debug IDs\n onResolve({ filter: /.*/ }, args => {\n if (args.kind !== 'entry-point') {\n return;\n }\n\n // Skip injecting debug IDs into modules specified in the esbuild `inject` option\n // since they're already part of the entry points\n if (initialOptions.inject?.includes(args.path)) {\n return;\n }\n\n const resolvedPath = path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path);\n\n // Skip injecting debug IDs into paths that have already been wrapped\n if (debugIdWrappedPaths.has(resolvedPath)) {\n return;\n }\n debugIdWrappedPaths.add(resolvedPath);\n\n return {\n pluginName,\n path: resolvedPath,\n pluginData: {\n isDebugIdProxy: true,\n originalPath: args.path,\n originalResolveDir: args.resolveDir,\n },\n // We need to add a suffix here, otherwise esbuild will mark the entrypoint as resolved and won't traverse\n // the module tree any further down past the proxy module because we're essentially creating a dependency\n // loop back to the proxy module.\n // By setting a suffix we're telling esbuild that the entrypoint and proxy module are two different things,\n // making it re-resolve the entrypoint when it is imported from the proxy module.\n // Super confusing? Yes. Works? Apparently... Let's see.\n suffix: '?sentryDebugIdProxy=true',\n };\n });\n\n onLoad({ filter: /.*/ }, args => {\n if (!(args.pluginData as { isDebugIdProxy?: boolean })?.isDebugIdProxy) {\n return null;\n }\n\n const originalPath = (args.pluginData as { originalPath: string }).originalPath;\n const originalResolveDir = (args.pluginData as { originalResolveDir: string }).originalResolveDir;\n\n return {\n loader: 'js',\n pluginName,\n contents: `\n import \"_sentry-debug-id-injection-stub\";\n import * as OriginalModule from ${stringifyForCodeInjection(originalPath)};\n export default OriginalModule.default;\n export * from ${stringifyForCodeInjection(originalPath)};`,\n resolveDir: originalResolveDir,\n };\n });\n\n onResolve({ filter: /_sentry-debug-id-injection-stub/ }, args => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n namespace: 'sentry-debug-id-stub',\n suffix: `?sentry-module-id=${randomUUID()}`,\n };\n });\n\n onLoad({ filter: /_sentry-debug-id-injection-stub/, namespace: 'sentry-debug-id-stub' }, () => {\n return {\n loader: 'js',\n pluginName,\n contents: getDebugIdSnippet(randomUUID()).code(),\n };\n });\n }\n\n // With `write: false` nothing reaches the disk, so nothing can be uploaded or deleted.\n const sourceMapKind = sourceMapKindFromEsbuildSetting(initialOptions.sourcemap);\n const sourceMapDecision: SourceMapDecision =\n initialOptions.write === false\n ? { enableHidden: false, deleteAfterUpload: false }\n : sentryBuildPluginManager.sourceMaps.decide(sourceMapKind);\n if (sourceMapDecision.enableHidden) {\n initialOptions.sourcemap = 'external';\n }\n\n // Create release and optionally upload\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n initialOptions.metafile = true;\n onEnd(async result => {\n try {\n await sentryBuildPluginManager.createRelease();\n\n // The metafile lists outputs relative to `absWorkingDir`, not to the process.\n const outputDir = initialOptions.absWorkingDir ?? process.cwd();\n const buildArtifacts = result.metafile\n ? Object.keys(result.metafile.outputs).map(output => path.resolve(outputDir, output))\n : [];\n\n const { sourceMaps } = sentryBuildPluginManager;\n const allMaps = buildArtifacts.filter(artifact => artifact.endsWith('.map'));\n const deleteWithoutUpload = sourceMapDecision.deleteAfterUpload && !sourceMaps.uploadPossible;\n if (sourcemapsEnabled && options.sourcemaps?.disable === 'disable-upload') {\n if (initialOptions.write === false) {\n logger.debug('Build output is not written to disk. Skipping debug ID injection into build artifacts.');\n } else {\n // The upload routine (which stamps debug IDs into temp copies of the artifacts) is\n // skipped with `disable-upload`. esbuild has no hook to modify outputs before they are\n // written, so the emitted artifacts get stamped on disk instead.\n await Promise.all(\n buildArtifacts\n .filter(isJsFile)\n .map(bundle => addDebugIdToEmittedArtifacts(bundle, logger, options.sourcemaps?.resolveSourceMap)),\n );\n }\n } else if (sourcemapsEnabled) {\n // The upload globs the paths, and glob reads backslashes as escapes.\n // When no upload can run, this logs why.\n const { uploaded, uploadedSourceMapPaths } = await upload(\n buildArtifacts.map(artifact => artifact.split(path.sep).join('/')),\n );\n\n // esbuild writes before `onEnd` runs, so the maps are deleted from disk\n // afterwards instead of being dropped from the output like in other bundlers.\n // A map the plugin turned on never stays in the output. A map the user\n // enabled is only deleted once it was uploaded.\n if (sourceMapDecision.deleteAfterUpload && !deleteWithoutUpload) {\n const mapsToDelete = sourceMapDecision.removeAllSourceMaps ? allMaps : uploadedSourceMapPaths;\n\n if (uploaded) {\n await sourceMaps.deleteFromOutput(mapsToDelete);\n } else if (mapsToDelete.length > 0) {\n logger.error('The source maps were not uploaded, so they stay in the build output.');\n }\n }\n }\n\n if (deleteWithoutUpload) {\n const bundleOf = (map: string): string => map.slice(0, -'.map'.length);\n const isUploaded = (map: string): boolean =>\n isJsFile(bundleOf(map)) && sourceMaps.shouldUpload(bundleOf(map));\n await sourceMaps.deleteFromOutput(\n sourceMapDecision.removeAllSourceMaps ? allMaps : allMaps.filter(isUploaded),\n );\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n });\n },\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport default sentryEsbuildPlugin;\nexport type { Options as SentryEsbuildPluginOptions } from '../core';\n"],"mappings":";;;;;;;;;;;;;;;;AAkEA,SAAS,gCAAgC,SAAiD;CACxF,QAAQ,SAAR;EACE,KAAK,KAAA,GACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK;EACL,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAgBA,SAAS,yBAA6C;CACpD,IAAI;EAMF,QAAA,GAHYA,YAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IACM,CAAC,CAAC,SAEP,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC;CACrC,QAAQ,CAER;AAGF;AAEA,MAAM,aAAa;AAGnB,SAAgB,oBAAoB,cAA+B,CAAC,GAAQ;CAC1E,MAAM,2BAA2BC,6BAAAA,+BAA+B,aAAa;EAC3E,cAAc,YAAY,cAAc,wBAAwB,IAAI,WAAW;EAC/E,WAAW;EACX,uBAAuB,uBAAuB;CAChD,CAAC;CAED,MAAM,EACJ,QACA,mBAAmB,SACnB,yCAAyC,mBACzC,gBACA,qCACE;CAEJ,IAAI,QAAQ,SACV,OAAO;EACL,MAAM;EACN,QAAQ,CAER;CACF;CAGF,IAAI,QAAQ,IAAI,CAAC,CAAC,MAAM,mCAAmC,GACzD,OAAO,KAAK,wFAAwF;CAGtG,MAAM,oBAAoB,QAAQ,YAAY,YAAY;CAC1D,MAAM,sBAAsB,IAAIC,cAAAA,cAAc;C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B,OAAO,MAAM,sEAAsE;MAEvF;KACF;KAEA,IAAI,qBAAqB;MACvB,MAAM,YAAY,QAAwB,IAAI,MAAM,GAAG,EAAc;MACrE,MAAM,cAAc,QAClBK,cAAAA,SAAS,SAAS,GAAG,CAAC,KAAK,WAAW,aAAa,SAAS,GAAG,CAAC;MAClE,MAAM,WAAW,iBACf,kBAAkB,sBAAsB,UAAU,QAAQ,OAAO,UAAU,CAC7E;KACF;IACF,UAAU;KACR,qCAAqC;KACrC,MAAM,yBAAyB,gBAAgB;IACjD;GACF,CAAC;EACH;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":["createRequire","createSentryBuildPluginManager","getSourceMapFeatures","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","path","stringifyForCodeInjection","randomUUID","getDebugIdSnippet","createDebugIdUploadFunction","isJsFile","addDebugIdToEmittedArtifacts"],"sources":["../../../src/esbuild/index.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport type { InternalOptions, SourceMapDecision, SourceMapKind } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n CodeInjection,\n addDebugIdToEmittedArtifacts,\n isJsFile,\n getSourceMapFeatures,\n} from '../core';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport { randomUUID } from 'node:crypto';\nimport { stringifyForCodeInjection } from '@sentry/core';\n\ninterface EsbuildOnResolveArgs {\n path: string;\n kind: string;\n importer?: string;\n resolveDir: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnResolveResult {\n path: string;\n sideEffects?: boolean;\n pluginName?: string;\n namespace?: string;\n suffix?: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnLoadArgs {\n path: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnLoadResult {\n loader: string;\n pluginName: string;\n contents: string;\n resolveDir?: string;\n}\n\ninterface EsbuildOnEndArgs {\n metafile?: {\n outputs: Record<string, unknown>;\n };\n}\n\ntype EsbuildSourceMapSetting = boolean | 'inline' | 'external' | 'linked' | 'both' | undefined;\n\ninterface EsbuildInitialOptions {\n bundle?: boolean;\n inject?: string[];\n metafile?: boolean;\n define?: Record<string, string>;\n write?: boolean;\n absWorkingDir?: string;\n logOverride?: Record<string, string>;\n sourcemap?: EsbuildSourceMapSetting;\n}\n\n/** Maps esbuild's `sourcemap` setting onto the plugin's source map kinds. */\nfunction sourceMapKindFromEsbuildSetting(setting: EsbuildSourceMapSetting): SourceMapKind {\n switch (setting) {\n case undefined:\n return 'unset';\n case false:\n return 'off';\n case 'external':\n return 'hidden';\n case 'inline':\n case 'both':\n return 'inline';\n default:\n return 'visible';\n }\n}\n\ninterface EsbuildPluginBuild {\n initialOptions: EsbuildInitialOptions;\n onLoad: (\n options: { filter: RegExp; namespace?: string },\n callback: (args: EsbuildOnLoadArgs) => EsbuildOnLoadResult | null,\n ) => void;\n onResolve: (\n options: { filter: RegExp },\n callback: (args: EsbuildOnResolveArgs) => EsbuildOnResolveResult | undefined,\n ) => void;\n onStart: (callback: () => void) => void;\n onEnd: (callback: (result: EsbuildOnEndArgs) => void | Promise<void>) => void;\n}\n\nfunction getEsbuildMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - esbuild transpiles this for us\n const req = createRequire(import.meta.url);\n const esbuild = req('esbuild') as { version?: string };\n // esbuild hasn't released a v1 yet, so we'll return the minor version as the major version\n return esbuild.version?.split('.')[1];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nconst pluginName = 'sentry-esbuild-plugin';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function sentryEsbuildPlugin(userOptions: InternalOptions = {}): any {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[${pluginName}]`,\n buildTool: 'esbuild',\n buildToolMajorVersion: getEsbuildMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n name: 'sentry-esbuild-noop-plugin',\n setup() {\n // noop plugin\n },\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const { injectDebugIds, upload: uploadEnabled, stampEmittedFiles } = getSourceMapFeatures(options);\n const staticInjectionCode = new CodeInjection();\n\n if (options.release.inject === 'html') {\n logger.warn(\n \"`release.inject: 'html'` is not supported by the esbuild plugin. Injecting the release into the startup chunks instead.\",\n );\n }\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n // Component annotation warning\n if (options.reactComponentAnnotation?.enabled) {\n logger.warn(\n 'Component name annotation is not supported in esbuild. Please use a separate transform step or consider using a different bundler.',\n );\n }\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n // Track entry points wrapped for debug ID injection\n const debugIdWrappedPaths = new Set<string>();\n\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n return {\n name: pluginName,\n setup({ initialOptions, onLoad, onResolve, onStart, onEnd }: EsbuildPluginBuild) {\n // Release and/or metadata injection\n if (!staticInjectionCode.isEmpty()) {\n const virtualInjectionFilePath = path.resolve('_sentry-injection-stub');\n initialOptions.inject = initialOptions.inject || [];\n // esbuild emits injected files after an entry's directive prologue. A banner would precede\n // \"use strict\" and turn it into an ordinary string expression.\n initialOptions.inject.push(virtualInjectionFilePath);\n\n onResolve({ filter: /_sentry-injection-stub/ }, args => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n };\n });\n\n onLoad({ filter: /_sentry-injection-stub/ }, () => {\n return {\n loader: 'js',\n pluginName,\n contents: staticInjectionCode.code(),\n };\n });\n }\n\n // Bundle size optimizations\n if (transformReplace) {\n const replacementStringValues: Record<string, string> = {};\n Object.entries(replacementValues).forEach(([key, value]) => {\n replacementStringValues[key] = JSON.stringify(value);\n });\n\n initialOptions.define = { ...initialOptions.define, ...replacementStringValues };\n }\n\n // Debug ID injection - requires per-entry-point unique IDs\n if (injectDebugIds) {\n // `setup` runs once per context, `onStart` once per build, so a\n // rebuild wraps the entry points again.\n onStart(() => debugIdWrappedPaths.clear());\n\n // The proxy module re-exports `OriginalModule.default` statically so downstream bundlers can tree-shake it,\n // but esbuild warns about that access when the entry point has no default export.\n initialOptions.logOverride = { 'import-is-undefined': 'silent', ...initialOptions.logOverride };\n\n if (!initialOptions.bundle) {\n logger.warn(\n 'The Sentry esbuild plugin only supports esbuild with `bundle: true` being set in the esbuild build options. Esbuild will probably crash now. Sorry about that. If you need to upload sourcemaps without `bundle: true`, it is recommended to use Sentry CLI instead: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/',\n );\n }\n\n // Wrap entry points to inject debug IDs\n onResolve({ filter: /.*/ }, args => {\n if (args.kind !== 'entry-point') {\n return;\n }\n\n // Skip injecting debug IDs into modules specified in the esbuild `inject` option\n // since they're already part of the entry points\n if (initialOptions.inject?.includes(args.path)) {\n return;\n }\n\n const resolvedPath = path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path);\n\n // Skip injecting debug IDs into paths that have already been wrapped\n if (debugIdWrappedPaths.has(resolvedPath)) {\n return;\n }\n debugIdWrappedPaths.add(resolvedPath);\n\n return {\n pluginName,\n path: resolvedPath,\n pluginData: {\n isDebugIdProxy: true,\n originalPath: args.path,\n originalResolveDir: args.resolveDir,\n },\n // We need to add a suffix here, otherwise esbuild will mark the entrypoint as resolved and won't traverse\n // the module tree any further down past the proxy module because we're essentially creating a dependency\n // loop back to the proxy module.\n // By setting a suffix we're telling esbuild that the entrypoint and proxy module are two different things,\n // making it re-resolve the entrypoint when it is imported from the proxy module.\n // Super confusing? Yes. Works? Apparently... Let's see.\n suffix: '?sentryDebugIdProxy=true',\n };\n });\n\n onLoad({ filter: /.*/ }, args => {\n if (!(args.pluginData as { isDebugIdProxy?: boolean })?.isDebugIdProxy) {\n return null;\n }\n\n const originalPath = (args.pluginData as { originalPath: string }).originalPath;\n const originalResolveDir = (args.pluginData as { originalResolveDir: string }).originalResolveDir;\n\n return {\n loader: 'js',\n pluginName,\n contents: `\n import \"_sentry-debug-id-injection-stub\";\n import * as OriginalModule from ${stringifyForCodeInjection(originalPath)};\n export default OriginalModule.default;\n export * from ${stringifyForCodeInjection(originalPath)};`,\n resolveDir: originalResolveDir,\n };\n });\n\n onResolve({ filter: /_sentry-debug-id-injection-stub/ }, args => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n namespace: 'sentry-debug-id-stub',\n suffix: `?sentry-module-id=${randomUUID()}`,\n };\n });\n\n onLoad({ filter: /_sentry-debug-id-injection-stub/, namespace: 'sentry-debug-id-stub' }, () => {\n return {\n loader: 'js',\n pluginName,\n contents: getDebugIdSnippet(randomUUID()).code(),\n };\n });\n }\n\n // With `write: false` nothing reaches the disk, so nothing can be uploaded or deleted.\n const sourceMapKind = sourceMapKindFromEsbuildSetting(initialOptions.sourcemap);\n const sourceMapDecision: SourceMapDecision =\n initialOptions.write === false\n ? { enableHidden: false, deleteAfterUpload: false }\n : sentryBuildPluginManager.sourceMaps.decide(sourceMapKind);\n if (sourceMapDecision.enableHidden) {\n initialOptions.sourcemap = 'external';\n }\n\n // Create release and optionally upload\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n initialOptions.metafile = true;\n onEnd(async result => {\n // The metafile lists outputs relative to `absWorkingDir`, not to the process.\n const outputDir = initialOptions.absWorkingDir ?? process.cwd();\n const buildArtifacts = result.metafile\n ? Object.keys(result.metafile.outputs).map(output => path.resolve(outputDir, output))\n : [];\n const { sourceMaps } = sentryBuildPluginManager;\n const allMaps = buildArtifacts.filter(artifact => artifact.endsWith('.map'));\n\n try {\n await sentryBuildPluginManager.createRelease();\n\n const deleteWithoutUpload = sourceMapDecision.deleteAfterUpload && !sourceMaps.uploadPossible;\n if (stampEmittedFiles) {\n if (initialOptions.write === false) {\n logger.debug('Build output is not written to disk. Skipping debug ID injection into build artifacts.');\n } else {\n // esbuild has no hook to modify outputs before they are written, so the emitted\n // artifacts get stamped on disk.\n await Promise.all(\n buildArtifacts\n .filter(isJsFile)\n .map(bundle => addDebugIdToEmittedArtifacts(bundle, logger, options.sourcemaps?.resolveSourceMap)),\n );\n }\n } else if (uploadEnabled) {\n // The upload globs the paths, and glob reads backslashes as escapes.\n // When no upload can run, this logs why.\n const { uploaded, uploadedSourceMapPaths } = await upload(\n buildArtifacts.map(artifact => artifact.split(path.sep).join('/')),\n );\n\n // esbuild writes before `onEnd` runs, so the maps are deleted from disk\n // afterwards instead of being dropped from the output like in other bundlers.\n // A map the plugin turned on never stays in the output. A map the user\n // enabled is only deleted once it was uploaded, unless `sourcemaps.delete`\n // asks for it, which does not depend on the upload.\n if (sourceMapDecision.deleteAfterUpload && !deleteWithoutUpload) {\n const mapsToDelete = sourceMapDecision.removeAllSourceMaps ? allMaps : uploadedSourceMapPaths;\n\n if (uploaded || options.sourcemaps?.delete === true) {\n await sourceMaps.deleteFromOutput(mapsToDelete);\n } else if (mapsToDelete.length > 0) {\n logger.error('The source maps were not uploaded, so they stay in the build output.');\n }\n }\n }\n\n if (deleteWithoutUpload) {\n const bundleOf = (map: string): string => map.slice(0, -'.map'.length);\n const isUploaded = (map: string): boolean =>\n isJsFile(bundleOf(map)) && sourceMaps.shouldUpload(bundleOf(map));\n await sourceMaps.deleteFromOutput(\n sourceMapDecision.removeAllSourceMaps ? allMaps : allMaps.filter(isUploaded),\n );\n }\n } catch (error) {\n // esbuild already wrote the maps, and `sourcemaps.delete: true` also\n // applies when the release or upload step fails.\n if (options.sourcemaps?.delete === true && sourceMapDecision.deleteAfterUpload) {\n await sourceMaps.deleteFromOutput(allMaps);\n }\n throw error;\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n });\n },\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport default sentryEsbuildPlugin;\nexport type { Options as SentryEsbuildPluginOptions } from '../core';\n"],"mappings":";;;;;;;;;;;;;;;;;AAmEA,SAAS,gCAAgC,SAAiD;CACxF,QAAQ,SAAR;EACE,KAAK,KAAA,GACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK;EACL,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAgBA,SAAS,yBAA6C;CACpD,IAAI;EAMF,QAAA,GAHYA,YAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IACM,CAAC,CAAC,SAEP,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC;CACrC,QAAQ,CAER;AAGF;AAEA,MAAM,aAAa;AAGnB,SAAgB,oBAAoB,cAA+B,CAAC,GAAQ;CAC1E,MAAM,2BAA2BC,6BAAAA,+BAA+B,aAAa;EAC3E,cAAc,YAAY,cAAc,wBAAwB,IAAI,WAAW;EAC/E,WAAW;EACX,uBAAuB,uBAAuB;CAChD,CAAC;CAED,MAAM,EACJ,QACA,mBAAmB,SACnB,yCAAyC,mBACzC,gBACA,qCACE;CAEJ,IAAI,QAAQ,SACV,OAAO;EACL,MAAM;EACN,QAAQ,CAER;CACF;CAGF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,MAAMN,UAAK,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CACnE;MAOA,IAAI,kBAAkB,qBAAqB,CAAC,qBAAqB;OAC/D,MAAM,eAAe,kBAAkB,sBAAsB,UAAU;OAEvE,IAAI,YAAY,QAAQ,YAAY,WAAW,MAC7C,MAAM,WAAW,iBAAiB,YAAY;YACzC,IAAI,aAAa,SAAS,GAC/B,OAAO,MAAM,sEAAsE;MAEvF;KACF;KAEA,IAAI,qBAAqB;MACvB,MAAM,YAAY,QAAwB,IAAI,MAAM,GAAG,EAAc;MACrE,MAAM,cAAc,QAClBK,cAAAA,SAAS,SAAS,GAAG,CAAC,KAAK,WAAW,aAAa,SAAS,GAAG,CAAC;MAClE,MAAM,WAAW,iBACf,kBAAkB,sBAAsB,UAAU,QAAQ,OAAO,UAAU,CAC7E;KACF;IACF,SAAS,OAAO;KAGd,IAAI,QAAQ,YAAY,WAAW,QAAQ,kBAAkB,mBAC3D,MAAM,WAAW,iBAAiB,OAAO;KAE3C,MAAM;IACR,UAAU;KACR,qCAAqC;KACrC,MAAM,yBAAyB,gBAAgB;IACjD;GACF,CAAC;EACH;CACF;AACF"}
@@ -5,12 +5,14 @@ const require_glob = require("../core/glob.js");
5
5
  const require_get_code_injection_position = require("../core/get-code-injection-position.js");
6
6
  const require_component_annotate_hooks = require("../core/component-annotate-hooks.js");
7
7
  const require_debug_id_upload = require("../core/debug-id-upload.js");
8
+ const require_sourcemap_settings = require("../core/sourcemap-settings.js");
8
9
  const require_build_plugin_manager = require("../core/build-plugin-manager.js");
9
10
  const require_index = require("../core/index.js");
10
11
  const require_debug_id_injection = require("./debug-id-injection.js");
11
12
  const require_debug_id_stamping = require("./debug-id-stamping.js");
12
13
  const require_source_map_handling = require("./source-map-handling.js");
13
14
  const require_source_map_hooks = require("../vite/source-map-hooks.js");
15
+ const require_release_html_injection = require("../vite/release-html-injection.js");
14
16
  let magic_string = require("magic-string");
15
17
  magic_string = require_runtime.__toESM(magic_string);
16
18
  let node_path = require("node:path");
@@ -58,7 +60,7 @@ function _createRollupPluginInternals(userOptions = {}, buildTool, buildToolMajo
58
60
  if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
59
61
  const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
60
62
  const upload = require_debug_id_upload.createDebugIdUploadFunction({ sentryBuildPluginManager });
61
- const sourcemapsEnabled = options.sourcemaps?.disable !== true;
63
+ const { injectDebugIds, upload: uploadEnabled, stampEmittedFiles } = require_sourcemap_settings.getSourceMapFeatures(options);
62
64
  const sourceMapHandling = require_source_map_handling.createSourceMapHandling(sentryBuildPluginManager);
63
65
  const releaseInjectionCode = new require_utils.CodeInjection();
64
66
  const chunkInjectionCode = new require_utils.CodeInjection();
@@ -69,13 +71,16 @@ function _createRollupPluginInternals(userOptions = {}, buildTool, buildToolMajo
69
71
  injectBuildInformation: options._experiments.injectBuildInformation || false
70
72
  }));
71
73
  if (Object.keys(bundleMetadata).length > 0) chunkInjectionCode.append(require_utils.generateModuleMetadataInjectorCode(bundleMetadata));
74
+ const releaseHtmlInjection = options.release.inject === "html" && buildTool === "vite" && !releaseInjectionCode.isEmpty() ? require_release_html_injection.createViteReleaseHtmlInjection(releaseInjectionCode, logger) : void 0;
75
+ if (options.release.inject === "html" && buildTool === "rollup") logger.warn("`release.inject: 'html'` is not supported by the Rollup plugin, because Rollup does not emit HTML. Injecting the release into the startup chunks instead.");
72
76
  const transformAnnotations = options.reactComponentAnnotation?.enabled ? require_component_annotate_hooks.createComponentNameAnnotateHooks(options.reactComponentAnnotation?.ignoredComponents || [], !!options.reactComponentAnnotation?._experimentalInjectIntoHtml, {
73
77
  getParseAstAsync: buildTool === "vite" && buildToolMajorVersion === "8" ? getViteParseAstAsync : void 0,
74
78
  logger
75
79
  }) : void 0;
76
80
  const transformReplace = Object.keys(replacementValues).length > 0;
77
81
  const shouldTransform = transformAnnotations || transformReplace;
78
- function buildStart() {
82
+ function buildStart(inputOptions) {
83
+ releaseHtmlInjection?.buildStart(this, inputOptions);
79
84
  sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {});
80
85
  }
81
86
  async function transform(code, id, meta) {
@@ -90,9 +95,9 @@ function _createRollupPluginInternals(userOptions = {}, buildTool, buildToolMajo
90
95
  if (!require_index.isJsFile(chunk.fileName)) return null;
91
96
  if (require_index.shouldSkipCodeInjection(code, chunk.facadeModuleId)) return null;
92
97
  const injectCode = new require_utils.CodeInjection();
93
- if (require_index.isInitialChunk(chunk, meta?.chunks)) injectCode.append(releaseInjectionCode);
98
+ if (!releaseHtmlInjection?.inHtml(this) && require_index.isInitialChunk(chunk, meta?.chunks)) injectCode.append(releaseInjectionCode);
94
99
  injectCode.append(chunkInjectionCode);
95
- if (sourcemapsEnabled && !require_debug_id_injection.hasExistingDebugID(code)) {
100
+ if (injectDebugIds && !require_debug_id_injection.hasExistingDebugID(code)) {
96
101
  const debugId = require_debug_id_injection.getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);
97
102
  injectCode.append(require_index.getDebugIdSnippet(debugId));
98
103
  }
@@ -114,14 +119,13 @@ function _createRollupPluginInternals(userOptions = {}, buildTool, buildToolMajo
114
119
  * Resolves Rolldown's placeholder debug IDs, then stamps debug IDs into the emitted chunks and
115
120
  * source maps.
116
121
  *
117
- * `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted
118
- * artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the
119
- * comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final
120
- * assets afterwards (e.g. subresource integrity) see the stamped content.
122
+ * Without an upload the emitted artifacts get stamped here. Not in `renderChunk`: minifiers running
123
+ * after it would strip the comment. Rollup computes `[hash]` file names before this hook, so only
124
+ * plugins that hash the final assets afterwards (e.g. subresource integrity) see the stamped content.
121
125
  */
122
126
  function generateBundle(_outputOptions, bundle) {
123
127
  if (this?.meta?.rolldownVersion) require_debug_id_injection.finalizeRolldownDebugIds(bundle);
124
- if (options.sourcemaps?.disable !== "disable-upload") return;
128
+ if (!stampEmittedFiles) return;
125
129
  require_debug_id_stamping.stampDebugIds(bundle, true);
126
130
  }
127
131
  async function writeBundle(outputOptions, bundle) {
@@ -129,7 +133,7 @@ function _createRollupPluginInternals(userOptions = {}, buildTool, buildToolMajo
129
133
  let stagingHandedOver = false;
130
134
  try {
131
135
  await sentryBuildPluginManager.createRelease();
132
- if (sourcemapsEnabled && options.sourcemaps?.disable !== "disable-upload") {
136
+ if (uploadEnabled) {
133
137
  let buildArtifacts;
134
138
  if (outputOptions.dir) {
135
139
  const outputDir = outputOptions.dir;
@@ -169,7 +173,11 @@ function _createRollupPluginInternals(userOptions = {}, buildTool, buildToolMajo
169
173
  name,
170
174
  buildStart,
171
175
  ...shouldTransform ? { transform: transformHook } : {},
172
- ...viteSourceMapHooks ? { configResolved: viteSourceMapHooks.configResolved } : { outputOptions: sourceMapHandling.outputOptions },
176
+ ...viteSourceMapHooks ? {
177
+ configResolved: viteSourceMapHooks.configResolved,
178
+ outputOptions: viteSourceMapHooks.outputOptions
179
+ } : { outputOptions: sourceMapHandling.outputOptions },
180
+ ...releaseHtmlInjection ? { transformIndexHtml: releaseHtmlInjection.transformIndexHtml } : {},
173
181
  renderChunk,
174
182
  generateBundle: {
175
183
  order: "pre",
@@ -183,7 +191,7 @@ function _createRollupPluginInternals(userOptions = {}, buildTool, buildToolMajo
183
191
  generateBundle: {
184
192
  order: "post",
185
193
  async handler(outputOptions, bundle, isWrite) {
186
- if (buildTool === "vite" && options.sourcemaps?.disable === "disable-upload") require_debug_id_stamping.stampDebugIds(bundle, false);
194
+ if (buildTool === "vite" && stampEmittedFiles) require_debug_id_stamping.stampDebugIds(bundle, false);
187
195
  await sourceMapHandling.stageSourceMaps(outputOptions, bundle, isWrite);
188
196
  }
189
197
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createRequire","createSentryBuildPluginManager","createDebugIdUploadFunction","createSourceMapHandling","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","createComponentNameAnnotateHooks","replaceBooleanFlagsInCode","isJsFile","shouldSkipCodeInjection","isInitialChunk","hasExistingDebugID","getDebugIdForChunk","getDebugIdSnippet","MagicString","getCodeInjectionPosition","finalizeRolldownDebugIds","stampDebugIds","globFiles","path","createViteSourceMapHooks"],"sources":["../../../src/rollup/index.ts"],"sourcesContent":["import type { ChunkGraphNode, InternalOptions, Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n isInitialChunk,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\n getCodeInjectionPosition,\n} from '../core';\nimport type { ComponentAnnotationTransformMeta } from '../core/component-annotation-oxc';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport { finalizeRolldownDebugIds, getDebugIdForChunk, hasExistingDebugID } from './debug-id-injection';\nimport { stampDebugIds, type OutputBundle } from './debug-id-stamping';\nimport { createSourceMapHandling, type OutputDestinationOptions } from './source-map-handling';\nimport { createViteSourceMapHooks } from '../vite/source-map-hooks';\n\n// The subset of Rollup's `TransformResult` that this plugin's `transform`\n// hook actually returns. Defined locally instead of imported from `rollup`\n// because `rollup` is an optional dependency.\ntype TransformResult = { code: string; map?: SourceMap | string | { mappings: string } | null } | null | undefined;\n\ntype ViteModule = {\n parseAstAsync?: (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n};\n\ntype ViteParseAstAsync = NonNullable<ViteModule['parseAstAsync']>;\n\nlet viteParseAstAsyncPromise: Promise<ViteParseAstAsync | null> | undefined;\n\n// Rolldown sets `meta.rolldownVersion` on the plugin context.\ntype PluginContext = { meta?: { rolldownVersion?: string } };\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\n\nfunction getRollupMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const rollup = req('rollup') as { VERSION?: string };\n return rollup.VERSION?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nfunction getViteParseAstAsync(): Promise<ViteParseAstAsync | null> {\n if (!viteParseAstAsyncPromise) {\n viteParseAstAsyncPromise = Promise.resolve()\n .then(async () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Vite is an optional runtime peer for this package\n const viteModule = createRequire(import.meta.url)('vite') as ViteModule;\n\n if (typeof viteModule.parseAstAsync !== 'function') {\n return null;\n }\n\n try {\n await viteModule.parseAstAsync('const x = <div />;', { lang: 'tsx' });\n } catch {\n return null;\n }\n\n return viteModule.parseAstAsync;\n })\n .catch(() => null);\n }\n\n return viteParseAstAsyncPromise;\n}\n\n/**\n * @ignore - internal plugin factory shared by the Rollup and Vite plugins.\n *\n * `main` carries injection, release creation and the upload. `post` runs last in `generateBundle`,\n * copies chunks and their source maps into the upload staging folder and drops the map assets\n * from the bundle, so the bundler never writes them.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _createRollupPluginInternals(\n userOptions: InternalOptions = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,\n buildTool,\n buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n main: {\n name: 'sentry-noop-plugin',\n },\n post: undefined,\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const sourceMapHandling = createSourceMapHandling(sentryBuildPluginManager);\n const releaseInjectionCode = new CodeInjection();\n const chunkInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n releaseInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n chunkInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n {\n // Vite 8 already loads an oxc-based parser, so reuse it.\n getParseAstAsync: buildTool === 'vite' && buildToolMajorVersion === '8' ? getViteParseAstAsync : undefined,\n logger,\n },\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n const shouldTransform = transformAnnotations || transformReplace;\n\n function buildStart(): void {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n }\n\n async function transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<TransformResult> {\n // Component annotations are only in user code and boolean flag replacements are\n // only in Sentry code. If we successfully add annotations, we can return early.\n if (transformAnnotations) {\n const result = await transformAnnotations.transform(code, id, meta);\n if (result) {\n return result;\n }\n }\n\n if (transformReplace) {\n return replaceBooleanFlagsInCode(code, replacementValues);\n }\n\n return null;\n }\n\n function renderChunk(\n this: PluginContext | undefined,\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null; isEntry?: boolean },\n _?: unknown,\n meta?: { magicString?: MagicString; chunks?: Record<string, ChunkGraphNode> },\n ): {\n code: string;\n map?: SourceMap;\n } | null {\n if (!isJsFile(chunk.fileName)) {\n return null; // returning null means not modifying the chunk at all\n }\n\n // Skip empty chunks and HTML facade chunks (Vite MPA)\n if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {\n return null;\n }\n\n const injectCode = new CodeInjection();\n\n if (isInitialChunk(chunk, meta?.chunks)) {\n injectCode.append(releaseInjectionCode);\n }\n\n injectCode.append(chunkInjectionCode);\n\n if (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);\n injectCode.append(getDebugIdSnippet(debugId));\n }\n\n if (injectCode.isEmpty()) {\n return null;\n }\n\n const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName });\n const injectionPosition = getCodeInjectionPosition(code);\n const codeToInject = injectionPosition === code.length ? `\\n${injectCode.code()}` : injectCode.code();\n ms.appendLeft(injectionPosition, codeToInject);\n\n // Rolldown can pass a native MagicString instance in meta.magicString\n // https://rolldown.rs/in-depth/native-magic-string#usage-examples\n if (ms?.constructor?.name === 'BindingMagicString') {\n // Rolldown docs say to return the magic string instance directly in this case\n return { code: ms as unknown as string };\n }\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' }),\n };\n }\n\n /**\n * Resolves Rolldown's placeholder debug IDs, then stamps debug IDs into the emitted chunks and\n * source maps.\n *\n * `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted\n * artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the\n * comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final\n * assets afterwards (e.g. subresource integrity) see the stamped content.\n */\n function generateBundle(this: PluginContext | undefined, _outputOptions: unknown, bundle: OutputBundle): void {\n if (this?.meta?.rolldownVersion) {\n finalizeRolldownDebugIds(bundle);\n }\n\n if (options.sourcemaps?.disable !== 'disable-upload') {\n return;\n }\n\n stampDebugIds(bundle, true);\n }\n\n async function writeBundle(outputOptions: OutputDestinationOptions, bundle: OutputBundle | undefined): Promise<void> {\n const staging = await sourceMapHandling.takeStaging(outputOptions, bundle);\n let stagingHandedOver = false;\n\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n let buildArtifacts: string[];\n if (outputOptions.dir) {\n const outputDir = outputOptions.dir;\n const JS_AND_MAP_PATTERNS = [\n '/**/*.js',\n '/**/*.mjs',\n '/**/*.cjs',\n '/**/*.js.map',\n '/**/*.mjs.map',\n '/**/*.cjs.map',\n ].map(q => `${q}?(\\\\?*)?(#*)`); // We want to allow query and hash strings at the end of files\n buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });\n } else if (outputOptions.file) {\n buildArtifacts = [outputOptions.file];\n } else {\n buildArtifacts = Object.keys(bundle ?? {}).map(asset => path.join(path.resolve(), asset));\n }\n stagingHandedOver = true;\n await upload(buildArtifacts, { staging });\n } else {\n stagingHandedOver = true;\n await staging?.discard();\n }\n } catch (e) {\n if (!stagingHandedOver) {\n await staging?.keep('The source map upload did not run.');\n }\n throw e;\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n }\n\n const name = `sentry-${buildTool}-plugin`;\n const transformHook =\n buildTool === 'vite'\n ? {\n filter: { id: JS_MODULE_ID_FILTER },\n handler: transform,\n }\n : transform;\n\n // Vite warns about `rollupOptions.output.sourcemap`, so the Vite plugin\n // decides in a `config` hook instead.\n const viteSourceMapHooks =\n buildTool === 'vite' ? createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) : undefined;\n\n const main = {\n name,\n buildStart,\n ...(shouldTransform ? { transform: transformHook } : {}),\n ...(viteSourceMapHooks\n ? { configResolved: viteSourceMapHooks.configResolved }\n : { outputOptions: sourceMapHandling.outputOptions }),\n renderChunk,\n generateBundle: { order: 'pre' as const, handler: generateBundle },\n writeBundle,\n };\n\n const post = {\n name: buildTool === 'vite' ? 'sentry-vite-upload-staging' : 'sentry-rollup-upload-staging',\n // On the post plugin, so framework plugins that set `build.sourcemap`\n // themselves run first and the decision sees the merged setting.\n ...(viteSourceMapHooks ? { config: viteSourceMapHooks.config } : {}),\n generateBundle: {\n order: 'post' as const,\n async handler(outputOptions: OutputDestinationOptions, bundle: OutputBundle, isWrite?: boolean): Promise<void> {\n if (buildTool === 'vite' && options.sourcemaps?.disable === 'disable-upload') {\n // Vite's module preload rewrite in `generateBundle` regenerates the source map of every\n // chunk with a dynamic import, which drops the debug ID the main plugin stamped in its\n // `pre` hook. Restore it without touching the chunk code, so file hashes stay valid.\n stampDebugIds(bundle, false);\n }\n\n await sourceMapHandling.stageSourceMaps(outputOptions, bundle, isWrite);\n },\n },\n };\n\n return { main, post };\n}\n\n/**\n * @ignore - this is the internal plugin factory function only used for the Vite plugin!\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _rollupPluginInternal(\n userOptions: Options = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n return _createRollupPluginInternals(userOptions, buildTool, buildToolMajorVersion).main;\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-explicit-any\nexport function sentryRollupPlugin(userOptions: Options = {}): any {\n const { main, post } = _createRollupPluginInternals(userOptions, 'rollup');\n // We return an array here so we don't break backwards compatibility with what\n // unplugin used to return\n return post ? [main, post] : [main];\n}\n\nexport type { Options as SentryRollupPluginOptions } from '../core';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,IAAI;AAKJ,MAAM,sBAAsB;AAE5B,SAAS,wBAA4C;CAC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O;IACxE;GACF;EAGgB;CAAE;AACtB;;;;AAMA,SAAgB,sBACd,cAAuB,CAAC,GACxB,WACA,uBACA;CACA,OAAO,6BAA6B,aAAa,WAAW,qBAAqB,CAAC,CAAC;AACrF;AAGA,SAAgB,mBAAmB,cAAuB,CAAC,GAAQ;CACjE,MAAM,EAAE,MAAM,SAAS,6BAA6B,aAAa,QAAQ;CAGzE,OAAO,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI;AACpC"}
1
+ {"version":3,"file":"index.js","names":["createRequire","createSentryBuildPluginManager","createDebugIdUploadFunction","getSourceMapFeatures","createSourceMapHandling","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","createViteReleaseHtmlInjection","createComponentNameAnnotateHooks","replaceBooleanFlagsInCode","isJsFile","shouldSkipCodeInjection","isInitialChunk","hasExistingDebugID","getDebugIdForChunk","getDebugIdSnippet","MagicString","getCodeInjectionPosition","finalizeRolldownDebugIds","stampDebugIds","globFiles","path","createViteSourceMapHooks"],"sources":["../../../src/rollup/index.ts"],"sourcesContent":["import type { ChunkGraphNode, InternalOptions, Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n isInitialChunk,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\n getCodeInjectionPosition,\n getSourceMapFeatures,\n} from '../core';\nimport type { ComponentAnnotationTransformMeta } from '../core/component-annotation-oxc';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport { finalizeRolldownDebugIds, getDebugIdForChunk, hasExistingDebugID } from './debug-id-injection';\nimport { stampDebugIds, type OutputBundle } from './debug-id-stamping';\nimport { createSourceMapHandling, type OutputDestinationOptions } from './source-map-handling';\nimport { createViteSourceMapHooks } from '../vite/source-map-hooks';\nimport {\n createViteReleaseHtmlInjection,\n type BuildInputOptions,\n type ViteHookContext,\n} from '../vite/release-html-injection';\n\n// The subset of Rollup's `TransformResult` that this plugin's `transform`\n// hook actually returns. Defined locally instead of imported from `rollup`\n// because `rollup` is an optional dependency.\ntype TransformResult = { code: string; map?: SourceMap | string | { mappings: string } | null } | null | undefined;\n\ntype ViteModule = {\n parseAstAsync?: (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n};\n\ntype ViteParseAstAsync = NonNullable<ViteModule['parseAstAsync']>;\n\nlet viteParseAstAsyncPromise: Promise<ViteParseAstAsync | null> | undefined;\n\n// Rolldown sets `meta.rolldownVersion` on the plugin context.\ntype PluginContext = ViteHookContext & { meta?: { rolldownVersion?: string } };\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\n\nfunction getRollupMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const rollup = req('rollup') as { VERSION?: string };\n return rollup.VERSION?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nfunction getViteParseAstAsync(): Promise<ViteParseAstAsync | null> {\n if (!viteParseAstAsyncPromise) {\n viteParseAstAsyncPromise = Promise.resolve()\n .then(async () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Vite is an optional runtime peer for this package\n const viteModule = createRequire(import.meta.url)('vite') as ViteModule;\n\n if (typeof viteModule.parseAstAsync !== 'function') {\n return null;\n }\n\n try {\n await viteModule.parseAstAsync('const x = <div />;', { lang: 'tsx' });\n } catch {\n return null;\n }\n\n return viteModule.parseAstAsync;\n })\n .catch(() => null);\n }\n\n return viteParseAstAsyncPromise;\n}\n\n/**\n * @ignore - internal plugin factory shared by the Rollup and Vite plugins.\n *\n * `main` carries injection, release creation and the upload. `post` runs last in `generateBundle`,\n * copies chunks and their source maps into the upload staging folder and drops the map assets\n * from the bundle, so the bundler never writes them.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _createRollupPluginInternals(\n userOptions: InternalOptions = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,\n buildTool,\n buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n main: {\n name: 'sentry-noop-plugin',\n },\n post: undefined,\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n const { injectDebugIds, upload: uploadEnabled, stampEmittedFiles } = getSourceMapFeatures(options);\n const sourceMapHandling = createSourceMapHandling(sentryBuildPluginManager);\n const releaseInjectionCode = new CodeInjection();\n const chunkInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n releaseInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n chunkInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const releaseHtmlInjection =\n options.release.inject === 'html' && buildTool === 'vite' && !releaseInjectionCode.isEmpty()\n ? createViteReleaseHtmlInjection(releaseInjectionCode, logger)\n : undefined;\n\n if (options.release.inject === 'html' && buildTool === 'rollup') {\n logger.warn(\n \"`release.inject: 'html'` is not supported by the Rollup plugin, because Rollup does not emit HTML. Injecting the release into the startup chunks instead.\",\n );\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n {\n // Vite 8 already loads an oxc-based parser, so reuse it.\n getParseAstAsync: buildTool === 'vite' && buildToolMajorVersion === '8' ? getViteParseAstAsync : undefined,\n logger,\n },\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n const shouldTransform = transformAnnotations || transformReplace;\n\n function buildStart(this: ViteHookContext | undefined, inputOptions?: BuildInputOptions): void {\n releaseHtmlInjection?.buildStart(this, inputOptions);\n\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n }\n\n async function transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<TransformResult> {\n // Component annotations are only in user code and boolean flag replacements are\n // only in Sentry code. If we successfully add annotations, we can return early.\n if (transformAnnotations) {\n const result = await transformAnnotations.transform(code, id, meta);\n if (result) {\n return result;\n }\n }\n\n if (transformReplace) {\n return replaceBooleanFlagsInCode(code, replacementValues);\n }\n\n return null;\n }\n\n function renderChunk(\n this: PluginContext | undefined,\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null; isEntry?: boolean },\n _?: unknown,\n meta?: { magicString?: MagicString; chunks?: Record<string, ChunkGraphNode> },\n ): {\n code: string;\n map?: SourceMap;\n } | null {\n if (!isJsFile(chunk.fileName)) {\n return null; // returning null means not modifying the chunk at all\n }\n\n // Skip empty chunks and HTML facade chunks (Vite MPA)\n if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {\n return null;\n }\n\n const injectCode = new CodeInjection();\n\n if (!releaseHtmlInjection?.inHtml(this) && isInitialChunk(chunk, meta?.chunks)) {\n injectCode.append(releaseInjectionCode);\n }\n\n injectCode.append(chunkInjectionCode);\n\n if (injectDebugIds && !hasExistingDebugID(code)) {\n const debugId = getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);\n injectCode.append(getDebugIdSnippet(debugId));\n }\n\n if (injectCode.isEmpty()) {\n return null;\n }\n\n const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName });\n const injectionPosition = getCodeInjectionPosition(code);\n const codeToInject = injectionPosition === code.length ? `\\n${injectCode.code()}` : injectCode.code();\n ms.appendLeft(injectionPosition, codeToInject);\n\n // Rolldown can pass a native MagicString instance in meta.magicString\n // https://rolldown.rs/in-depth/native-magic-string#usage-examples\n if (ms?.constructor?.name === 'BindingMagicString') {\n // Rolldown docs say to return the magic string instance directly in this case\n return { code: ms as unknown as string };\n }\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' }),\n };\n }\n\n /**\n * Resolves Rolldown's placeholder debug IDs, then stamps debug IDs into the emitted chunks and\n * source maps.\n *\n * Without an upload the emitted artifacts get stamped here. Not in `renderChunk`: minifiers running\n * after it would strip the comment. Rollup computes `[hash]` file names before this hook, so only\n * plugins that hash the final assets afterwards (e.g. subresource integrity) see the stamped content.\n */\n function generateBundle(this: PluginContext | undefined, _outputOptions: unknown, bundle: OutputBundle): void {\n if (this?.meta?.rolldownVersion) {\n finalizeRolldownDebugIds(bundle);\n }\n\n if (!stampEmittedFiles) {\n return;\n }\n\n stampDebugIds(bundle, true);\n }\n\n async function writeBundle(outputOptions: OutputDestinationOptions, bundle: OutputBundle | undefined): Promise<void> {\n const staging = await sourceMapHandling.takeStaging(outputOptions, bundle);\n let stagingHandedOver = false;\n\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (uploadEnabled) {\n let buildArtifacts: string[];\n if (outputOptions.dir) {\n const outputDir = outputOptions.dir;\n const JS_AND_MAP_PATTERNS = [\n '/**/*.js',\n '/**/*.mjs',\n '/**/*.cjs',\n '/**/*.js.map',\n '/**/*.mjs.map',\n '/**/*.cjs.map',\n ].map(q => `${q}?(\\\\?*)?(#*)`); // We want to allow query and hash strings at the end of files\n buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });\n } else if (outputOptions.file) {\n buildArtifacts = [outputOptions.file];\n } else {\n buildArtifacts = Object.keys(bundle ?? {}).map(asset => path.join(path.resolve(), asset));\n }\n stagingHandedOver = true;\n await upload(buildArtifacts, { staging });\n } else {\n stagingHandedOver = true;\n await staging?.discard();\n }\n } catch (e) {\n if (!stagingHandedOver) {\n await staging?.keep('The source map upload did not run.');\n }\n throw e;\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n }\n\n const name = `sentry-${buildTool}-plugin`;\n const transformHook =\n buildTool === 'vite'\n ? {\n filter: { id: JS_MODULE_ID_FILTER },\n handler: transform,\n }\n : transform;\n\n // Vite warns about `rollupOptions.output.sourcemap`, so the Vite plugin\n // decides in a `config` hook instead.\n const viteSourceMapHooks =\n buildTool === 'vite' ? createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) : undefined;\n\n const main = {\n name,\n buildStart,\n ...(shouldTransform ? { transform: transformHook } : {}),\n ...(viteSourceMapHooks\n ? { configResolved: viteSourceMapHooks.configResolved, outputOptions: viteSourceMapHooks.outputOptions }\n : { outputOptions: sourceMapHandling.outputOptions }),\n ...(releaseHtmlInjection ? { transformIndexHtml: releaseHtmlInjection.transformIndexHtml } : {}),\n renderChunk,\n generateBundle: { order: 'pre' as const, handler: generateBundle },\n writeBundle,\n };\n\n const post = {\n name: buildTool === 'vite' ? 'sentry-vite-upload-staging' : 'sentry-rollup-upload-staging',\n // On the post plugin, so framework plugins that set `build.sourcemap`\n // themselves run first and the decision sees the merged setting.\n ...(viteSourceMapHooks ? { config: viteSourceMapHooks.config } : {}),\n generateBundle: {\n order: 'post' as const,\n async handler(outputOptions: OutputDestinationOptions, bundle: OutputBundle, isWrite?: boolean): Promise<void> {\n if (buildTool === 'vite' && stampEmittedFiles) {\n // Vite's module preload rewrite in `generateBundle` regenerates the source map of every\n // chunk with a dynamic import, which drops the debug ID the main plugin stamped in its\n // `pre` hook. Restore it without touching the chunk code, so file hashes stay valid.\n stampDebugIds(bundle, false);\n }\n\n await sourceMapHandling.stageSourceMaps(outputOptions, bundle, isWrite);\n },\n },\n };\n\n return { main, post };\n}\n\n/**\n * @ignore - this is the internal plugin factory function only used for the Vite plugin!\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _rollupPluginInternal(\n userOptions: Options = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n return _createRollupPluginInternals(userOptions, buildTool, buildToolMajorVersion).main;\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-explicit-any\nexport function sentryRollupPlugin(userOptions: Options = {}): any {\n const { main, post } = _createRollupPluginInternals(userOptions, 'rollup');\n // We return an array here so we don't break backwards compatibility with what\n // unplugin used to return\n return post ? [main, post] : [main];\n}\n\nexport type { Options as SentryRollupPluginOptions } from '../core';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2CA,IAAI;AAKJ,MAAM,sBAAsB;AAE5B,SAAS,wBAA4C;CACnD,IAAI;EAKF,QAAA,GAFYA,YAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IACK,CAAC,CAAC,QACP,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC;CACpC,QAAQ,CAER;AAGF;AAEA,SAAS,uBAA0D;CACjE,IAAI,CAAC,0BACH,2BAA2B,QAAQ,QAAQ,CAAC,CACzC,KAAK,YAAY;EAGhB,MAAM,cAAA,GAAaA,YAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,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AAuB,CAAC,GACxB,WACA,uBACA;CACA,OAAO,6BAA6B,aAAa,WAAW,qBAAqB,CAAC,CAAC;AACrF;AAGA,SAAgB,mBAAmB,cAAuB,CAAC,GAAQ;CACjE,MAAM,EAAE,MAAM,SAAS,6BAA6B,aAAa,QAAQ;CAGzE,OAAO,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI;AACpC"}
@@ -110,6 +110,23 @@ function createSourceMapHandling(sentryBuildPluginManager) {
110
110
  return decision.enableHidden ? outputOptions : null;
111
111
  },
112
112
  setDecision,
113
+ applyHiddenDecision: (rawOutputOptions) => {
114
+ if (rawOutputOptions.sourcemap !== true) return null;
115
+ const destination = getOutputDestination(rawOutputOptions);
116
+ const record = findDecision(destination, rawOutputOptions);
117
+ if (!record?.decision.enableHidden) return null;
118
+ setDecision(destination, {
119
+ ...record,
120
+ match: {
121
+ ...record.match,
122
+ sourcemap: "hidden"
123
+ }
124
+ });
125
+ return {
126
+ ...rawOutputOptions,
127
+ sourcemap: "hidden"
128
+ };
129
+ },
113
130
  stageSourceMaps: async (outputOptions, bundle, isWrite) => {
114
131
  const destination = getOutputDestination(outputOptions);
115
132
  const record = findDecision(destination, outputOptions);
@@ -121,7 +138,8 @@ function createSourceMapHandling(sentryBuildPluginManager) {
121
138
  sentryBuildPluginManager.sourceMaps.logDecision(record.decision);
122
139
  if (!record.decision.deleteAfterUpload) return;
123
140
  const removeAll = record.decision.removeAllSourceMaps === true;
124
- if (removeAll && record.kind !== "unset") dropAssetSourceMaps(bundle);
141
+ const deleteAll = sentryBuildPluginManager.normalizedOptions.sourcemaps?.delete === true;
142
+ if (removeAll && (record.kind !== "unset" || deleteAll)) dropAssetSourceMaps(bundle);
125
143
  if (!sentryBuildPluginManager.sourceMaps.uploadPossible) {
126
144
  dropSourceMaps(bundle, removeAll ? void 0 : (fileName) => sentryBuildPluginManager.sourceMaps.shouldUpload(node_path.join(destination, fileName)));
127
145
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"source-map-handling.js","names":["path","isJsFile"],"sources":["../../../src/rollup/source-map-handling.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { SentryBuildPluginManager, SourceMapDecision, SourceMapKind, UploadStaging } from '../core';\nimport { isJsFile } from '../core';\nimport type { OutputBundle } from './debug-id-stamping';\n\nexport type RollupSourceMapSetting = boolean | 'inline' | 'hidden' | undefined;\n\nexport type OutputDestinationOptions = { dir?: string; file?: string };\n\n/**\n * The output options that tell outputs of one directory apart. Several outputs can write into the\n * same directory at once, for example an ES and a CJS build, each with its own `sourcemap` setting.\n * `sourcemap` holds the setting as the plugin left it, so an output it switched to hidden maps\n * differs from one the user set.\n */\nexport type OutputMatch = {\n dir?: unknown;\n file?: unknown;\n format?: unknown;\n entryFileNames?: unknown;\n chunkFileNames?: unknown;\n preserveModules?: unknown;\n sourcemap?: unknown;\n};\n\nexport type OutputOptions = OutputDestinationOptions & OutputMatch & { sourcemap?: RollupSourceMapSetting };\n\n/** Maps Rollup's (and Vite's) `sourcemap` setting onto the plugin's source map kinds. */\nexport function sourceMapKindFromRollupSetting(setting: RollupSourceMapSetting): SourceMapKind {\n switch (setting) {\n case undefined:\n return 'unset';\n case false:\n return 'off';\n case true:\n return 'visible';\n default:\n return setting;\n }\n}\n\n/** The directory an output writes to. Decisions and stagings are keyed by it. */\nexport function getOutputDestination(outputOptions: OutputDestinationOptions): string {\n return path.resolve(outputOptions.dir ?? path.dirname(outputOptions.file ?? '.'));\n}\n\nconst MATCH_KEYS = [\n 'dir',\n 'file',\n 'format',\n 'entryFileNames',\n 'chunkFileNames',\n 'preserveModules',\n 'sourcemap',\n] as const;\n\n/** The raw options accept aliases that the normalized options do not carry. */\nfunction normalizeFormat(format: unknown): unknown {\n switch (format) {\n case 'esm':\n case 'module':\n return 'es';\n case 'commonjs':\n return 'cjs';\n case 'systemjs':\n return 'system';\n default:\n return format;\n }\n}\n\n/** The fields of `OutputMatch` an output sets, in the form the normalized options carry them. */\nexport function getOutputMatch(outputOptions: OutputMatch): OutputMatch {\n const match: OutputMatch = {};\n for (const key of MATCH_KEYS) {\n const value = outputOptions[key];\n if (value === undefined) {\n continue;\n }\n match[key] =\n key === 'format' ? normalizeFormat(value) : key === 'dir' || key === 'file' ? path.resolve(String(value)) : value;\n }\n return match;\n}\n\nfunction matchesOutput(match: OutputMatch, outputOptions: OutputMatch): boolean {\n const actual = getOutputMatch(outputOptions);\n return MATCH_KEYS.every(key => match[key] === undefined || match[key] === actual[key]);\n}\n\nfunction isSameMatch(a: OutputMatch, b: OutputMatch): boolean {\n return MATCH_KEYS.every(key => a[key] === b[key]);\n}\n\nfunction countMatchFields(match: OutputMatch): number {\n return MATCH_KEYS.filter(key => match[key] !== undefined).length;\n}\n\nconst DEBUG_ID_PATTERN = /sentry-dbid-([0-9a-f-]{36})|\\/\\/# debugId=([0-9a-f-]{36})/i;\n\n/** Identifies the chunks of a bundle by name and debug ID, so a staging can be matched to its write. */\nfunction getBundleSignature(bundle: OutputBundle): string {\n const entries: string[] = [];\n for (const output of Object.values(bundle)) {\n if (output.type === 'chunk' && isJsFile(output.fileName)) {\n const match = output.code.match(DEBUG_ID_PATTERN);\n entries.push(`${output.fileName}:${match?.[1] ?? match?.[2] ?? ''}`);\n }\n }\n return entries.sort().join('\\n');\n}\n\nfunction getSourceMapFileName(output: { fileName: string; sourcemapFileName?: string | null }): string {\n return output.sourcemapFileName ?? `${output.fileName}.map`;\n}\n\ntype PendingStaging = { staging: UploadStaging; signature: string; match: OutputMatch };\n\nexport type DecisionRecord = { match: OutputMatch; kind: SourceMapKind; decision: SourceMapDecision };\n\nexport type SourceMapHandling = {\n /** Rollup's `outputOptions` hook: decides for the output and switches it to hidden source maps when needed. */\n outputOptions: (rawOutputOptions: OutputOptions) => OutputOptions | null;\n /** Records the decision for an output, for bundlers that decide outside `outputOptions`. */\n setDecision: (destination: string, record: DecisionRecord) => void;\n /**\n * `generateBundle` with `order: 'post'`: copies each chunk and its source map into a staging folder\n * and drops the map asset from the bundle, so the bundler never writes it.\n */\n stageSourceMaps: (outputOptions: OutputOptions, bundle: OutputBundle, isWrite?: boolean) => Promise<void>;\n /**\n * Hands the staging of this bundle to `writeBundle`. Without a bundle (SvelteKit calls the hook\n * with output options only) the oldest staging is taken.\n */\n takeStaging: (\n outputOptions: OutputDestinationOptions,\n bundle: OutputBundle | undefined,\n ) => Promise<UploadStaging | undefined>;\n};\n\n/**\n * Source map decisions and upload stagings of one plugin instance. Keyed by output destination\n * because one instance can serve several outputs, and watch mode or several `write()` calls\n * rebuild the same one. Outputs that share a directory are told apart by `OutputMatch`.\n */\nexport function createSourceMapHandling(sentryBuildPluginManager: SentryBuildPluginManager): SourceMapHandling {\n const decisions = new Map<string, DecisionRecord[]>();\n const pendingStagings = new Map<string, PendingStaging[]>();\n\n function setDecision(destination: string, record: DecisionRecord): void {\n const records = decisions.get(destination) ?? [];\n const index = records.findIndex(existing => isSameMatch(existing.match, record.match));\n if (index === -1) {\n records.push(record);\n } else {\n records[index] = record;\n }\n decisions.set(destination, records);\n }\n\n function findDecision(destination: string, outputOptions: OutputOptions): DecisionRecord | undefined {\n const candidates = (decisions.get(destination) ?? []).filter(record => matchesOutput(record.match, outputOptions));\n // The record that sets the most fields describes this output best. Equal\n // candidates keep their order, so the first one recorded wins.\n return candidates.sort((a, b) => countMatchFields(b.match) - countMatchFields(a.match))[0];\n }\n\n function dropSourceMaps(bundle: OutputBundle, shouldDrop: (fileName: string) => boolean = () => true): void {\n for (const output of Object.values(bundle)) {\n if (output.type === 'chunk' && isJsFile(output.fileName) && shouldDrop(output.fileName)) {\n // oxlint-disable-next-line typescript/no-dynamic-delete -- Rollup drops an asset when its key is deleted from the bundle\n delete bundle[getSourceMapFileName(output)];\n }\n }\n }\n\n // Other plugins emit maps as assets, e.g. for CSS or for Vite worker\n // bundles. Chunk maps stay here, because staging still needs them.\n function dropAssetSourceMaps(bundle: OutputBundle): void {\n const chunkMaps = new Set<string>();\n for (const output of Object.values(bundle)) {\n if (output.type === 'chunk') {\n chunkMaps.add(getSourceMapFileName(output));\n }\n }\n for (const [fileName, output] of Object.entries(bundle)) {\n if (output.type === 'asset' && fileName.endsWith('.map') && !chunkMaps.has(fileName)) {\n // oxlint-disable-next-line typescript/no-dynamic-delete -- Rollup drops an asset when its key is deleted from the bundle\n delete bundle[fileName];\n }\n }\n }\n\n return {\n outputOptions: rawOutputOptions => {\n const kind = sourceMapKindFromRollupSetting(rawOutputOptions.sourcemap);\n // Logged in `generateBundle`, which knows whether the output is written.\n const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });\n const outputOptions = decision.enableHidden\n ? { ...rawOutputOptions, sourcemap: 'hidden' as const }\n : rawOutputOptions;\n setDecision(getOutputDestination(rawOutputOptions), { match: getOutputMatch(outputOptions), kind, decision });\n\n return decision.enableHidden ? outputOptions : null;\n },\n\n setDecision,\n\n stageSourceMaps: async (outputOptions, bundle, isWrite) => {\n const destination = getOutputDestination(outputOptions);\n const record = findDecision(destination, outputOptions);\n if (!record) {\n return;\n }\n\n // `generate()` never reaches `writeBundle`, so nothing would upload a staging. Maps the\n // plugin turned on are dropped, so the result holds what the user configured.\n if (isWrite === false) {\n if (record.kind === 'unset' && record.decision.enableHidden) {\n dropSourceMaps(bundle);\n }\n return;\n }\n\n sentryBuildPluginManager.sourceMaps.logDecision(record.decision);\n if (!record.decision.deleteAfterUpload) {\n return;\n }\n\n const removeAll = record.decision.removeAllSourceMaps === true;\n // With `unset` the plugin only turned on the chunk maps. Asset maps\n // come from other plugins' own settings.\n if (removeAll && record.kind !== 'unset') {\n dropAssetSourceMaps(bundle);\n }\n\n if (!sentryBuildPluginManager.sourceMaps.uploadPossible) {\n dropSourceMaps(\n bundle,\n removeAll\n ? undefined\n : fileName => sentryBuildPluginManager.sourceMaps.shouldUpload(path.join(destination, fileName)),\n );\n return;\n }\n\n const staging = await sentryBuildPluginManager.createUploadStaging();\n\n try {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const mapFileName = getSourceMapFileName(output);\n const mapAsset = bundle[mapFileName];\n if (mapAsset?.type !== 'asset' || typeof mapAsset.source !== 'string') {\n continue;\n }\n\n const result = await staging.stage({\n code: output.code,\n mapSource: mapAsset.source,\n mapDir: path.join(destination, path.dirname(mapFileName)),\n chunkPath: path.join(destination, output.fileName),\n });\n\n // A map the plugin or the SDK turned on never reaches the output,\n // whether or not the chunk is uploaded. A map the user enabled\n // stays unless it was staged.\n if (result === 'staged' || removeAll) {\n // oxlint-disable-next-line typescript/no-dynamic-delete -- Rollup drops an asset when its key is deleted from the bundle\n delete bundle[mapFileName];\n }\n if (result === 'skipped' || result === 'failed') {\n sentryBuildPluginManager.logger.warn(\n removeAll\n ? `Could not prepare ${output.fileName} for upload, so it is not uploaded and its source map ${mapFileName} was removed from the build output.`\n : `Could not prepare ${output.fileName} for upload, so its source map ${mapFileName} stays in the build output.`,\n );\n }\n }\n } catch (e) {\n // The error fails the build before anything is written.\n await staging.discard();\n throw e;\n }\n\n // A staging of the same output that no `writeBundle` took belongs to a\n // write that never finished. Stagings of other outputs to this directory\n // may still be in flight, so the shared list changes in place and without\n // an await in between.\n const stagings = pendingStagings.get(destination) ?? [];\n pendingStagings.set(destination, stagings);\n const superseded = stagings.filter(pending => isSameMatch(pending.match, record.match));\n for (const pending of superseded) {\n stagings.splice(stagings.indexOf(pending), 1);\n }\n stagings.push({ staging, signature: getBundleSignature(bundle), match: record.match });\n\n for (const pending of superseded) {\n sentryBuildPluginManager.logger.debug(\n `Discarding staged source maps of an earlier build of ${destination} that was never written.`,\n );\n await pending.staging.discard();\n }\n },\n\n takeStaging: async (outputOptions, bundle) => {\n const destination = getOutputDestination(outputOptions);\n const stagings = pendingStagings.get(destination) ?? [];\n\n if (!bundle) {\n return stagings.shift()?.staging;\n }\n\n const signature = getBundleSignature(bundle);\n const index = stagings.findIndex(pending => pending.signature === signature);\n return index === -1 ? undefined : stagings.splice(index, 1)[0]?.staging;\n },\n };\n}\n"],"mapp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AM;GAC3C,MAAM,QAAQ,SAAS,WAAU,YAAW,QAAQ,cAAc,SAAS;GAC3E,OAAO,UAAU,KAAK,KAAA,IAAY,SAAS,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;EAClE;CACF;AACF"}
1
+ {"version":3,"file":"source-map-handling.js","names":["path","isJsFile"],"sources":["../../../src/rollup/source-map-handling.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { SentryBuildPluginManager, SourceMapDecision, SourceMapKind, UploadStaging } from '../core';\nimport { isJsFile } from '../core';\nimport type { OutputBundle } from './debug-id-stamping';\n\nexport type RollupSourceMapSetting = boolean | 'inline' | 'hidden' | undefined;\n\nexport type OutputDestinationOptions = { dir?: string; file?: string };\n\n/**\n * The output options that tell outputs of one directory apart. Several outputs can write into the\n * same directory at once, for example an ES and a CJS build, each with its own `sourcemap` setting.\n * `sourcemap` holds the setting as the plugin left it, so an output it switched to hidden maps\n * differs from one the user set.\n */\nexport type OutputMatch = {\n dir?: unknown;\n file?: unknown;\n format?: unknown;\n entryFileNames?: unknown;\n chunkFileNames?: unknown;\n preserveModules?: unknown;\n sourcemap?: unknown;\n};\n\nexport type OutputOptions = OutputDestinationOptions & OutputMatch & { sourcemap?: RollupSourceMapSetting };\n\n/** Maps Rollup's (and Vite's) `sourcemap` setting onto the plugin's source map kinds. */\nexport function sourceMapKindFromRollupSetting(setting: RollupSourceMapSetting): SourceMapKind {\n switch (setting) {\n case undefined:\n return 'unset';\n case false:\n return 'off';\n case true:\n return 'visible';\n default:\n return setting;\n }\n}\n\n/** The directory an output writes to. Decisions and stagings are keyed by it. */\nexport function getOutputDestination(outputOptions: OutputDestinationOptions): string {\n return path.resolve(outputOptions.dir ?? path.dirname(outputOptions.file ?? '.'));\n}\n\nconst MATCH_KEYS = [\n 'dir',\n 'file',\n 'format',\n 'entryFileNames',\n 'chunkFileNames',\n 'preserveModules',\n 'sourcemap',\n] as const;\n\n/** The raw options accept aliases that the normalized options do not carry. */\nfunction normalizeFormat(format: unknown): unknown {\n switch (format) {\n case 'esm':\n case 'module':\n return 'es';\n case 'commonjs':\n return 'cjs';\n case 'systemjs':\n return 'system';\n default:\n return format;\n }\n}\n\n/** The fields of `OutputMatch` an output sets, in the form the normalized options carry them. */\nexport function getOutputMatch(outputOptions: OutputMatch): OutputMatch {\n const match: OutputMatch = {};\n for (const key of MATCH_KEYS) {\n const value = outputOptions[key];\n if (value === undefined) {\n continue;\n }\n match[key] =\n key === 'format' ? normalizeFormat(value) : key === 'dir' || key === 'file' ? path.resolve(String(value)) : value;\n }\n return match;\n}\n\nfunction matchesOutput(match: OutputMatch, outputOptions: OutputMatch): boolean {\n const actual = getOutputMatch(outputOptions);\n return MATCH_KEYS.every(key => match[key] === undefined || match[key] === actual[key]);\n}\n\nfunction isSameMatch(a: OutputMatch, b: OutputMatch): boolean {\n return MATCH_KEYS.every(key => a[key] === b[key]);\n}\n\nfunction countMatchFields(match: OutputMatch): number {\n return MATCH_KEYS.filter(key => match[key] !== undefined).length;\n}\n\nconst DEBUG_ID_PATTERN = /sentry-dbid-([0-9a-f-]{36})|\\/\\/# debugId=([0-9a-f-]{36})/i;\n\n/** Identifies the chunks of a bundle by name and debug ID, so a staging can be matched to its write. */\nfunction getBundleSignature(bundle: OutputBundle): string {\n const entries: string[] = [];\n for (const output of Object.values(bundle)) {\n if (output.type === 'chunk' && isJsFile(output.fileName)) {\n const match = output.code.match(DEBUG_ID_PATTERN);\n entries.push(`${output.fileName}:${match?.[1] ?? match?.[2] ?? ''}`);\n }\n }\n return entries.sort().join('\\n');\n}\n\nfunction getSourceMapFileName(output: { fileName: string; sourcemapFileName?: string | null }): string {\n return output.sourcemapFileName ?? `${output.fileName}.map`;\n}\n\ntype PendingStaging = { staging: UploadStaging; signature: string; match: OutputMatch };\n\nexport type DecisionRecord = { match: OutputMatch; kind: SourceMapKind; decision: SourceMapDecision };\n\nexport type SourceMapHandling = {\n /** Rollup's `outputOptions` hook: decides for the output and switches it to hidden source maps when needed. */\n outputOptions: (rawOutputOptions: OutputOptions) => OutputOptions | null;\n /** Records the decision for an output, for bundlers that decide outside `outputOptions`. */\n setDecision: (destination: string, record: DecisionRecord) => void;\n /**\n * Vite's `outputOptions` hook: switches an output with its own visible setting to hidden source\n * maps when its recorded decision removes them.\n */\n applyHiddenDecision: (rawOutputOptions: OutputOptions) => OutputOptions | null;\n /**\n * `generateBundle` with `order: 'post'`: copies each chunk and its source map into a staging folder\n * and drops the map asset from the bundle, so the bundler never writes it.\n */\n stageSourceMaps: (outputOptions: OutputOptions, bundle: OutputBundle, isWrite?: boolean) => Promise<void>;\n /**\n * Hands the staging of this bundle to `writeBundle`. Without a bundle (SvelteKit calls the hook\n * with output options only) the oldest staging is taken.\n */\n takeStaging: (\n outputOptions: OutputDestinationOptions,\n bundle: OutputBundle | undefined,\n ) => Promise<UploadStaging | undefined>;\n};\n\n/**\n * Source map decisions and upload stagings of one plugin instance. Keyed by output destination\n * because one instance can serve several outputs, and watch mode or several `write()` calls\n * rebuild the same one. Outputs that share a directory are told apart by `OutputMatch`.\n */\nexport function createSourceMapHandling(sentryBuildPluginManager: SentryBuildPluginManager): SourceMapHandling {\n const decisions = new Map<string, DecisionRecord[]>();\n const pendingStagings = new Map<string, PendingStaging[]>();\n\n function setDecision(destination: string, record: DecisionRecord): void {\n const records = decisions.get(destination) ?? [];\n const index = records.findIndex(existing => isSameMatch(existing.match, record.match));\n if (index === -1) {\n records.push(record);\n } else {\n records[index] = record;\n }\n decisions.set(destination, records);\n }\n\n function findDecision(destination: string, outputOptions: OutputOptions): DecisionRecord | undefined {\n const candidates = (decisions.get(destination) ?? []).filter(record => matchesOutput(record.match, outputOptions));\n // The record that sets the most fields describes this output best. Equal\n // candidates keep their order, so the first one recorded wins.\n return candidates.sort((a, b) => countMatchFields(b.match) - countMatchFields(a.match))[0];\n }\n\n function dropSourceMaps(bundle: OutputBundle, shouldDrop: (fileName: string) => boolean = () => true): void {\n for (const output of Object.values(bundle)) {\n if (output.type === 'chunk' && isJsFile(output.fileName) && shouldDrop(output.fileName)) {\n // oxlint-disable-next-line typescript/no-dynamic-delete -- Rollup drops an asset when its key is deleted from the bundle\n delete bundle[getSourceMapFileName(output)];\n }\n }\n }\n\n // Other plugins emit maps as assets, e.g. for CSS or for Vite worker\n // bundles. Chunk maps stay here, because staging still needs them.\n function dropAssetSourceMaps(bundle: OutputBundle): void {\n const chunkMaps = new Set<string>();\n for (const output of Object.values(bundle)) {\n if (output.type === 'chunk') {\n chunkMaps.add(getSourceMapFileName(output));\n }\n }\n for (const [fileName, output] of Object.entries(bundle)) {\n if (output.type === 'asset' && fileName.endsWith('.map') && !chunkMaps.has(fileName)) {\n // oxlint-disable-next-line typescript/no-dynamic-delete -- Rollup drops an asset when its key is deleted from the bundle\n delete bundle[fileName];\n }\n }\n }\n\n return {\n outputOptions: rawOutputOptions => {\n const kind = sourceMapKindFromRollupSetting(rawOutputOptions.sourcemap);\n // Logged in `generateBundle`, which knows whether the output is written.\n const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });\n const outputOptions = decision.enableHidden\n ? { ...rawOutputOptions, sourcemap: 'hidden' as const }\n : rawOutputOptions;\n setDecision(getOutputDestination(rawOutputOptions), { match: getOutputMatch(outputOptions), kind, decision });\n\n return decision.enableHidden ? outputOptions : null;\n },\n\n setDecision,\n\n applyHiddenDecision: rawOutputOptions => {\n if (rawOutputOptions.sourcemap !== true) {\n return null;\n }\n const destination = getOutputDestination(rawOutputOptions);\n const record = findDecision(destination, rawOutputOptions);\n if (!record?.decision.enableHidden) {\n return null;\n }\n // Later hooks see the hidden setting, so the record has to match it.\n setDecision(destination, { ...record, match: { ...record.match, sourcemap: 'hidden' } });\n return { ...rawOutputOptions, sourcemap: 'hidden' };\n },\n\n stageSourceMaps: async (outputOptions, bundle, isWrite) => {\n const destination = getOutputDestination(outputOptions);\n const record = findDecision(destination, outputOptions);\n if (!record) {\n return;\n }\n\n // `generate()` never reaches `writeBundle`, so nothing would upload a staging. Maps the\n // plugin turned on are dropped, so the result holds what the user configured.\n if (isWrite === false) {\n if (record.kind === 'unset' && record.decision.enableHidden) {\n dropSourceMaps(bundle);\n }\n return;\n }\n\n sentryBuildPluginManager.sourceMaps.logDecision(record.decision);\n if (!record.decision.deleteAfterUpload) {\n return;\n }\n\n const removeAll = record.decision.removeAllSourceMaps === true;\n // With `unset` the plugin only turned on the chunk maps. Asset maps\n // come from other plugins' own settings. `sourcemaps.delete: true`\n // removes them too, because it applies to every map of the build.\n const deleteAll = sentryBuildPluginManager.normalizedOptions.sourcemaps?.delete === true;\n if (removeAll && (record.kind !== 'unset' || deleteAll)) {\n dropAssetSourceMaps(bundle);\n }\n\n if (!sentryBuildPluginManager.sourceMaps.uploadPossible) {\n dropSourceMaps(\n bundle,\n removeAll\n ? undefined\n : fileName => sentryBuildPluginManager.sourceMaps.shouldUpload(path.join(destination, fileName)),\n );\n return;\n }\n\n const staging = await sentryBuildPluginManager.createUploadStaging();\n\n try {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const mapFileName = getSourceMapFileName(output);\n const mapAsset = bundle[mapFileName];\n if (mapAsset?.type !== 'asset' || typeof mapAsset.source !== 'string') {\n continue;\n }\n\n const result = await staging.stage({\n code: output.code,\n mapSource: mapAsset.source,\n mapDir: path.join(destination, path.dirname(mapFileName)),\n chunkPath: path.join(destination, output.fileName),\n });\n\n // A map the plugin or the SDK turned on never reaches the output,\n // whether or not the chunk is uploaded. A map the user enabled\n // stays unless it was staged.\n if (result === 'staged' || removeAll) {\n // oxlint-disable-next-line typescript/no-dynamic-delete -- Rollup drops an asset when its key is deleted from the bundle\n delete bundle[mapFileName];\n }\n if (result === 'skipped' || result === 'failed') {\n sentryBuildPluginManager.logger.warn(\n removeAll\n ? `Could not prepare ${output.fileName} for upload, so it is not uploaded and its source map ${mapFileName} was removed from the build output.`\n : `Could not prepare ${output.fileName} for upload, so its source map ${mapFileName} stays in the build output.`,\n );\n }\n }\n } catch (e) {\n // The error fails the build before anything is written.\n await staging.discard();\n throw e;\n }\n\n // A staging of the same output that no `writeBundle` took belongs to a\n // write that never finished. Stagings of other outputs to this directory\n // may still be in flight, so the shared list changes in place and without\n // an await in between.\n const stagings = pendingStagings.get(destination) ?? [];\n pendingStagings.set(destination, stagings);\n const superseded = stagings.filter(pending => isSameMatch(pending.match, record.match));\n for (const pending of superseded) {\n stagings.splice(stagings.indexOf(pending), 1);\n }\n stagings.push({ staging, signature: getBundleSignature(bundle), match: record.match });\n\n for (const pending of superseded) {\n sentryBuildPluginManager.logger.debug(\n `Discarding staged source maps of an earlier build of ${destination} that was never written.`,\n );\n await pending.staging.discard();\n }\n },\n\n takeStaging: async (outputOptions, bundle) => {\n const destination = getOutputDestination(outputOptions);\n const stagings = pendingStagings.get(destination) ?? [];\n\n if (!bundle) {\n return stagings.shift()?.staging;\n }\n\n const signature = getBundleSignature(bundle);\n const index = stagings.findIndex(pending => pending.signature === signature);\n return index === -1 ? undefined : stagings.splice(index, 1)[0]?.staging;\n },\n };\n}\n"],"mappings":";;;;;;AA4BA,SAAgB,+BAA+B,SAAgD;CAC7F,QAAQ,SAAR;EACE,KAAK,KAAA,GACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,MACH,OAAO;EACT,SACE,OAAO;CACX;AACF;;AAGA,SAAgB,qBAAqB,eAAiD;CACpF,OAAOA,UAAK,QAAQ,cAAc,OAAOA,UAAK,QAAQ,cAAc,QAAQ,GAAG,CAAC;AAClF;AAEA,MAAM,aAAa;CACjB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAS,gBAAgB,QAA0B;CACjD,QAAQ,QAAR;EACE,KAAK;EACL,KAAK,UACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,SACE,OAAO;CACX;AACF;;AAGA,SAAgB,eAAe,eAAyC;CACtE,MAAM,QAAqB,CAAC;CAC5B,KAAK,MAAM,OAAO,YAAY;EAC5B,MAA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ection.ts
2
+ /**
3
+ * Puts the release snippet into the HTML pages of a Vite build (`release.inject: 'html'`), so the
4
+ * content hashes of the chunks do not change when only the release changes.
5
+ */
6
+ function createViteReleaseHtmlInjection(releaseInjectionCode, logger) {
7
+ const inHtmlByEnvironment = /* @__PURE__ */ new WeakMap();
8
+ let inHtmlWithoutEnvironment = false;
9
+ let warned = false;
10
+ return {
11
+ inHtml: (context) => context?.environment ? inHtmlByEnvironment.get(context.environment) ?? false : inHtmlWithoutEnvironment,
12
+ buildStart(context, inputOptions) {
13
+ const inHtml = Object.values(inputOptions?.input ?? {}).some((input) => /\.html$/.test(input));
14
+ if (context?.environment) inHtmlByEnvironment.set(context.environment, inHtml);
15
+ else inHtmlWithoutEnvironment = inHtml;
16
+ if (!inHtml && !warned && context?.environment?.config?.consumer !== "server") {
17
+ warned = true;
18
+ logger.warn("`release.inject: 'html'` needs a build with HTML entry points, and this build has none. Injecting the release into the startup chunks instead.");
19
+ }
20
+ },
21
+ transformIndexHtml(_html, ctx) {
22
+ if (ctx.server) return;
23
+ return [{
24
+ tag: "script",
25
+ children: releaseInjectionCode.code(),
26
+ injectTo: "head"
27
+ }];
28
+ }
29
+ };
30
+ }
31
+ exports.createViteReleaseHtmlInjection = createViteReleaseHtmlInjection;
32
+
33
+ //# sourceMappingURL=release-html-injection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-html-injection.js","names":[],"sources":["../../../src/vite/release-html-injection.ts"],"sourcesContent":["import type { CodeInjection, Logger } from '../core';\n\n// Vite 6+ sets `environment` on the plugin context.\nexport type ViteHookContext = { environment?: { config?: { consumer?: string } } };\n\nexport type BuildInputOptions = { input?: string[] | Record<string, string> };\n\ntype HtmlTagDescriptor = { tag: string; children: string; injectTo: 'head' };\n\nexport type ViteReleaseHtmlInjection = {\n /** Whether the build of the hook's environment puts the release into its HTML pages instead of its chunks. */\n inHtml: (context: ViteHookContext | undefined) => boolean;\n buildStart: (context: ViteHookContext | undefined, inputOptions: BuildInputOptions | undefined) => void;\n transformIndexHtml: (html: string, ctx: { server?: unknown }) => HtmlTagDescriptor[] | undefined;\n};\n\n/**\n * Puts the release snippet into the HTML pages of a Vite build (`release.inject: 'html'`), so the\n * content hashes of the chunks do not change when only the release changes.\n */\nexport function createViteReleaseHtmlInjection(\n releaseInjectionCode: CodeInjection,\n logger: Logger,\n): ViteReleaseHtmlInjection {\n // Only a build with HTML entry points runs `transformIndexHtml`. Without one, the release goes\n // into the chunks so it is not lost.\n // In Vite 6+, one plugin instance serves every environment, and environments can build in parallel.\n const inHtmlByEnvironment = new WeakMap<object, boolean>();\n let inHtmlWithoutEnvironment = false;\n let warned = false;\n\n return {\n inHtml: context =>\n context?.environment ? (inHtmlByEnvironment.get(context.environment) ?? false) : inHtmlWithoutEnvironment,\n\n buildStart(context, inputOptions) {\n const inHtml = Object.values(inputOptions?.input ?? {}).some(input => /\\.html$/.test(input));\n if (context?.environment) {\n inHtmlByEnvironment.set(context.environment, inHtml);\n } else {\n inHtmlWithoutEnvironment = inHtml;\n }\n\n // The server build of an SSR app has no HTML, and browsers do not cache its chunks.\n if (!inHtml && !warned && context?.environment?.config?.consumer !== 'server') {\n warned = true;\n logger.warn(\n \"`release.inject: 'html'` needs a build with HTML entry points, and this build has none. Injecting the release into the startup chunks instead.\",\n );\n }\n },\n\n transformIndexHtml(_html, ctx) {\n // The dev server does not inject the release into chunks either.\n if (ctx.server) {\n return undefined;\n }\n // Vite emits its entry scripts as deferred module scripts, so this runs before them.\n return [{ tag: 'script', children: releaseInjectionCode.code(), injectTo: 'head' }];\n },\n };\n}\n"],"mappings":";;;;;AAoBA,SAAgB,+BACd,sBACA,QAC0B;CAI1B,MAAM,sCAAsB,IAAI,QAAyB;CACzD,IAAI,2BAA2B;CAC/B,IAAI,SAAS;CAEb,OAAO;EACL,SAAQ,YACN,SAAS,cAAe,oBAAoB,IAAI,QAAQ,WAAW,KAAK,QAAS;EAEnF,WAAW,SAAS,cAAc;GAChC,MAAM,SAAS,OAAO,OAAO,cAAc,SAAS,CAAC,CAAC,CAAC,CAAC,MAAK,UAAS,UAAU,KAAK,KAAK,CAAC;GAC3F,IAAI,SAAS,aACX,oBAAoB,IAAI,QAAQ,aAAa,MAAM;QAEnD,2BAA2B;GAI7B,IAAI,CAAC,UAAU,CAAC,UAAU,SAAS,aAAa,QAAQ,aAAa,UAAU;IAC7E,SAAS;IACT,OAAO,KACL,gJACF;GACF;EACF;EAEA,mBAAmB,OAAO,KAAK;GAE7B,IAAI,IAAI,QACN;GAGF,OAAO,CAAC;IAAE,KAAK;IAAU,UAAU,qBAAqB,KAAK;IAAG,UAAU;GAAO,CAAC;EACpF;CACF;AACF"}
@@ -77,18 +77,19 @@ function createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) {
77
77
  };
78
78
  const environmentName = decisions.has(name) ? name : void 0;
79
79
  const { normalizedOptions } = sentryBuildPluginManager;
80
- const deleteOption = require_sourcemap_settings.getDeleteSourcemapsAfterUpload(normalizedOptions, environmentName);
81
- const sdkEnabledSourceMaps = require_sourcemap_settings.getSdkEnabledSourceMaps(normalizedOptions, environmentName);
80
+ const deleteOption = require_sourcemap_settings.getDeleteOption(normalizedOptions, environmentName);
81
+ const removeAll = normalizedOptions.sourcemaps?.delete === true || require_sourcemap_settings.getSdkEnabledSourceMaps(normalizedOptions, environmentName);
82
82
  for (const output of getOutputs(config.root, environment.build)) {
83
83
  if (output.ownSetting) {
84
84
  const outputKind = require_source_map_handling.sourceMapKindFromRollupSetting(output.sourcemap);
85
- const removeAllSourceMaps = sdkEnabledSourceMaps && (outputKind === "hidden" || outputKind === "visible");
85
+ const removeAllSourceMaps = removeAll && (outputKind === "hidden" || outputKind === "visible");
86
+ const deleteAfterUpload = deleteOption === true && (outputKind === "hidden" || removeAllSourceMaps);
86
87
  sourceMapHandling.setDecision(output.destination, {
87
88
  match: output.match,
88
89
  kind: outputKind,
89
90
  decision: {
90
- enableHidden: false,
91
- deleteAfterUpload: deleteOption === true && (outputKind === "hidden" || removeAllSourceMaps),
91
+ enableHidden: outputKind === "visible" && deleteAfterUpload,
92
+ deleteAfterUpload,
92
93
  removeAllSourceMaps
93
94
  }
94
95
  });
@@ -108,7 +109,8 @@ function createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) {
108
109
  });
109
110
  }
110
111
  }
111
- }
112
+ },
113
+ outputOptions: sourceMapHandling.applyHiddenDecision
112
114
  };
113
115
  }
114
116
  exports.createViteSourceMapHooks = createViteSourceMapHooks;
@@ -1 +1 @@
1
- {"version":3,"file":"source-map-hooks.js","names":["path","getOutputMatch","sourceMapKindFromRollupSetting","getDeleteSourcemapsAfterUpload","getSdkEnabledSourceMaps"],"sources":["../../../src/vite/source-map-hooks.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { SentryBuildPluginManager, SourceMapDecision, SourceMapKind } from '../core';\nimport { getDeleteSourcemapsAfterUpload, getSdkEnabledSourceMaps } from '../core';\nimport type { OutputMatch, RollupSourceMapSetting, SourceMapHandling } from '../rollup/source-map-handling';\nimport { getOutputMatch, sourceMapKindFromRollupSetting } from '../rollup/source-map-handling';\n\ntype BundlerOutput = OutputMatch & { dir?: string; sourcemap?: RollupSourceMapSetting };\ntype BundlerOutputOptions = BundlerOutput | BundlerOutput[] | undefined;\n\ntype ViteBuildOptions = {\n sourcemap?: RollupSourceMapSetting;\n outDir?: string;\n rollupOptions?: { output?: BundlerOutputOptions };\n rolldownOptions?: { output?: BundlerOutputOptions };\n};\n\nexport type ViteUserConfig = {\n build?: ViteBuildOptions;\n environments?: Record<string, { build?: ViteBuildOptions } | undefined>;\n};\n\nexport type ViteResolvedConfig = {\n root: string;\n build: ViteBuildOptions;\n environments?: Record<string, { build: ViteBuildOptions }>;\n};\n\nexport type ViteSourceMapHooks = {\n config: (userConfig: ViteUserConfig, env: { command: string }) => ViteUserConfig | null;\n configResolved: (config: ViteResolvedConfig) => void;\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\ntype EnvironmentOutput = {\n destination: string;\n match: OutputMatch;\n sourcemap: RollupSourceMapSetting;\n /** The output sets `sourcemap` itself, which overrides `build.sourcemap`. */\n ownSetting: boolean;\n};\n\n/**\n * The outputs an environment writes: one per entry of `rollupOptions.output` or\n * `rolldownOptions.output`. An output writes to `build.outDir` (relative to the root) unless it\n * sets its own `dir`, which the bundler resolves from the working directory. An output's own\n * `sourcemap` overrides `build.sourcemap`.\n */\nfunction getOutputs(root: string, build: ViteBuildOptions): EnvironmentOutput[] {\n const configured = build.rolldownOptions?.output ?? build.rollupOptions?.output;\n const outputs = Array.isArray(configured) ? configured : [configured ?? {}];\n\n return outputs.map(output => {\n const sourcemap = output.sourcemap ?? build.sourcemap;\n return {\n destination: output.dir === undefined ? path.resolve(root, build.outDir ?? 'dist') : path.resolve(output.dir),\n match: getOutputMatch({ ...output, sourcemap }),\n sourcemap,\n ownSetting: output.sourcemap !== undefined,\n };\n });\n}\n\n/**\n * Vite warns about `rollupOptions.output.sourcemap`, so the Vite plugin decides on `build.sourcemap`\n * in a `config` hook. The hook belongs on the post plugin: framework plugins that set\n * `build.sourcemap` themselves run first, and the decision sees the merged setting. The output\n * directories are only known in `configResolved`, which then records the decision for each of them.\n */\nexport function createViteSourceMapHooks(\n sentryBuildPluginManager: SentryBuildPluginManager,\n sourceMapHandling: SourceMapHandling,\n): ViteSourceMapHooks {\n // `'*'` for the top-level setting, otherwise the name of an environment with its own.\n const decisions = new Map<string, { kind: SourceMapKind; decision: SourceMapDecision }>();\n\n return {\n config: (userConfig, env) => {\n if (env.command !== 'build') {\n return null;\n }\n\n // The same plugin instances can serve several builds in a row.\n decisions.clear();\n\n const kind = sourceMapKindFromRollupSetting(userConfig.build?.sourcemap);\n // Logged in `generateBundle`, which knows whether the output is written.\n const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });\n decisions.set('*', { kind, decision });\n\n const result: ViteUserConfig = decision.enableHidden ? { build: { sourcemap: 'hidden' } } : {};\n\n for (const [name, environment] of Object.entries(userConfig.environments ?? {})) {\n const setting = environment?.build?.sourcemap;\n if (setting === undefined) {\n continue;\n }\n\n const environmentKind = sourceMapKindFromRollupSetting(setting);\n const environmentDecision = sentryBuildPluginManager.sourceMaps.decide(environmentKind, {\n log: false,\n environment: name,\n });\n decisions.set(name, { kind: environmentKind, decision: environmentDecision });\n\n if (environmentDecision.enableHidden) {\n result.environments = { ...result.environments, [name]: { build: { sourcemap: 'hidden' } } };\n }\n }\n\n return result;\n },\n\n configResolved: config => {\n const environments = config.environments ?? { client: { build: config.build } };\n\n for (const [name, environment] of Object.entries(environments)) {\n const { kind, decision } = decisions.get(name) ?? decisions.get('*') ?? { kind: 'unset', decision: NO_CHANGE };\n const environmentName = decisions.has(name) ? name : undefined;\n const { normalizedOptions } = sentryBuildPluginManager;\n const deleteOption = getDeleteSourcemapsAfterUpload(normalizedOptions, environmentName);\n const sdkEnabledSourceMaps = getSdkEnabledSourceMaps(normalizedOptions, environmentName);\n\n for (const output of getOutputs(config.root, environment.build)) {\n // The plugin never changes an output's own setting. Hidden maps are\n // removed when the user asks for it, visible ones only when the SDK\n // turned source maps on.\n if (output.ownSetting) {\n const outputKind = sourceMapKindFromRollupSetting(output.sourcemap);\n const removeAllSourceMaps = sdkEnabledSourceMaps && (outputKind === 'hidden' || outputKind === 'visible');\n sourceMapHandling.setDecision(output.destination, {\n match: output.match,\n kind: outputKind,\n decision: {\n enableHidden: false,\n deleteAfterUpload: deleteOption === true && (outputKind === 'hidden' || removeAllSourceMaps),\n removeAllSourceMaps,\n },\n });\n continue;\n }\n\n // A plugin that ran after ours may have changed the setting again.\n if (decision.deleteAfterUpload && output.sourcemap !== 'hidden') {\n sentryBuildPluginManager.logger.debug(\n `Source maps of the \"${name}\" environment are set to ${JSON.stringify(output.sourcemap)}. Not removing them after upload.`,\n );\n sourceMapHandling.setDecision(output.destination, { match: output.match, kind, decision: NO_CHANGE });\n } else {\n sourceMapHandling.setDecision(output.destination, { match: output.match, kind, decision });\n }\n }\n }\n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AAY,OAAO,aAAa;MAAE,OAAO,OAAO;MAAO;MAAM;KAAS,CAAC;IAE7F;GACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"source-map-hooks.js","names":["path","getOutputMatch","sourceMapKindFromRollupSetting","getDeleteOption","getSdkEnabledSourceMaps"],"sources":["../../../src/vite/source-map-hooks.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { SentryBuildPluginManager, SourceMapDecision, SourceMapKind } from '../core';\nimport { getDeleteOption, getSdkEnabledSourceMaps } from '../core';\nimport type { OutputMatch, RollupSourceMapSetting, SourceMapHandling } from '../rollup/source-map-handling';\nimport { getOutputMatch, sourceMapKindFromRollupSetting } from '../rollup/source-map-handling';\n\ntype BundlerOutput = OutputMatch & { dir?: string; sourcemap?: RollupSourceMapSetting };\ntype BundlerOutputOptions = BundlerOutput | BundlerOutput[] | undefined;\n\ntype ViteBuildOptions = {\n sourcemap?: RollupSourceMapSetting;\n outDir?: string;\n rollupOptions?: { output?: BundlerOutputOptions };\n rolldownOptions?: { output?: BundlerOutputOptions };\n};\n\nexport type ViteUserConfig = {\n build?: ViteBuildOptions;\n environments?: Record<string, { build?: ViteBuildOptions } | undefined>;\n};\n\nexport type ViteResolvedConfig = {\n root: string;\n build: ViteBuildOptions;\n environments?: Record<string, { build: ViteBuildOptions }>;\n};\n\nexport type ViteSourceMapHooks = {\n config: (userConfig: ViteUserConfig, env: { command: string }) => ViteUserConfig | null;\n configResolved: (config: ViteResolvedConfig) => void;\n outputOptions: SourceMapHandling['applyHiddenDecision'];\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\ntype EnvironmentOutput = {\n destination: string;\n match: OutputMatch;\n sourcemap: RollupSourceMapSetting;\n /** The output sets `sourcemap` itself, which overrides `build.sourcemap`. */\n ownSetting: boolean;\n};\n\n/**\n * The outputs an environment writes: one per entry of `rollupOptions.output` or\n * `rolldownOptions.output`. An output writes to `build.outDir` (relative to the root) unless it\n * sets its own `dir`, which the bundler resolves from the working directory. An output's own\n * `sourcemap` overrides `build.sourcemap`.\n */\nfunction getOutputs(root: string, build: ViteBuildOptions): EnvironmentOutput[] {\n const configured = build.rolldownOptions?.output ?? build.rollupOptions?.output;\n const outputs = Array.isArray(configured) ? configured : [configured ?? {}];\n\n return outputs.map(output => {\n const sourcemap = output.sourcemap ?? build.sourcemap;\n return {\n destination: output.dir === undefined ? path.resolve(root, build.outDir ?? 'dist') : path.resolve(output.dir),\n match: getOutputMatch({ ...output, sourcemap }),\n sourcemap,\n ownSetting: output.sourcemap !== undefined,\n };\n });\n}\n\n/**\n * Vite warns about `rollupOptions.output.sourcemap`, so the Vite plugin decides on `build.sourcemap`\n * in a `config` hook. The hook belongs on the post plugin: framework plugins that set\n * `build.sourcemap` themselves run first, and the decision sees the merged setting. The output\n * directories are only known in `configResolved`, which then records the decision for each of them.\n */\nexport function createViteSourceMapHooks(\n sentryBuildPluginManager: SentryBuildPluginManager,\n sourceMapHandling: SourceMapHandling,\n): ViteSourceMapHooks {\n // `'*'` for the top-level setting, otherwise the name of an environment with its own.\n const decisions = new Map<string, { kind: SourceMapKind; decision: SourceMapDecision }>();\n\n return {\n config: (userConfig, env) => {\n if (env.command !== 'build') {\n return null;\n }\n\n // The same plugin instances can serve several builds in a row.\n decisions.clear();\n\n const kind = sourceMapKindFromRollupSetting(userConfig.build?.sourcemap);\n // Logged in `generateBundle`, which knows whether the output is written.\n const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });\n decisions.set('*', { kind, decision });\n\n const result: ViteUserConfig = decision.enableHidden ? { build: { sourcemap: 'hidden' } } : {};\n\n for (const [name, environment] of Object.entries(userConfig.environments ?? {})) {\n const setting = environment?.build?.sourcemap;\n if (setting === undefined) {\n continue;\n }\n\n const environmentKind = sourceMapKindFromRollupSetting(setting);\n const environmentDecision = sentryBuildPluginManager.sourceMaps.decide(environmentKind, {\n log: false,\n environment: name,\n });\n decisions.set(name, { kind: environmentKind, decision: environmentDecision });\n\n if (environmentDecision.enableHidden) {\n result.environments = { ...result.environments, [name]: { build: { sourcemap: 'hidden' } } };\n }\n }\n\n return result;\n },\n\n configResolved: config => {\n const environments = config.environments ?? { client: { build: config.build } };\n\n for (const [name, environment] of Object.entries(environments)) {\n const { kind, decision } = decisions.get(name) ?? decisions.get('*') ?? { kind: 'unset', decision: NO_CHANGE };\n const environmentName = decisions.has(name) ? name : undefined;\n const { normalizedOptions } = sentryBuildPluginManager;\n const deleteOption = getDeleteOption(normalizedOptions, environmentName);\n // `sourcemaps.delete: true` removes every source map, like for maps the SDK turned on.\n const removeAll =\n normalizedOptions.sourcemaps?.delete === true || getSdkEnabledSourceMaps(normalizedOptions, environmentName);\n\n for (const output of getOutputs(config.root, environment.build)) {\n // Hidden maps of an output's own setting are removed when the user\n // asks for it, visible ones only when every source map is removed.\n // Removed visible maps switch to hidden in `outputOptions`, so no\n // `sourceMappingURL` comment points at a removed file.\n if (output.ownSetting) {\n const outputKind = sourceMapKindFromRollupSetting(output.sourcemap);\n const removeAllSourceMaps = removeAll && (outputKind === 'hidden' || outputKind === 'visible');\n const deleteAfterUpload = deleteOption === true && (outputKind === 'hidden' || removeAllSourceMaps);\n sourceMapHandling.setDecision(output.destination, {\n match: output.match,\n kind: outputKind,\n decision: {\n enableHidden: outputKind === 'visible' && deleteAfterUpload,\n deleteAfterUpload,\n removeAllSourceMaps,\n },\n });\n continue;\n }\n\n // A plugin that ran after ours may have changed the setting again.\n if (decision.deleteAfterUpload && output.sourcemap !== 'hidden') {\n sentryBuildPluginManager.logger.debug(\n `Source maps of the \"${name}\" environment are set to ${JSON.stringify(output.sourcemap)}. Not removing them after upload.`,\n );\n sourceMapHandling.setDecision(output.destination, { match: output.match, kind, decision: NO_CHANGE });\n } else {\n sourceMapHandling.setDecision(output.destination, { match: output.match, kind, decision });\n }\n }\n }\n },\n\n outputOptions: sourceMapHandling.applyHiddenDecision,\n };\n}\n"],"mappings":";;;;;;;AAiCA,MAAM,YAA+B;CAAE,cAAc;C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