@sentry/bundler-plugins 11.18.0 → 11.20.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 (93) hide show
  1. package/build/cjs/core/index.js +1 -2
  2. package/build/cjs/core/index.js.map +1 -1
  3. package/build/cjs/core/options-mapping.js.map +1 -1
  4. package/build/cjs/core/sentry/telemetry.js +1 -1
  5. package/build/cjs/core/sentry/telemetry.js.map +1 -1
  6. package/build/cjs/core/sourcemap-settings.js +26 -22
  7. package/build/cjs/core/sourcemap-settings.js.map +1 -1
  8. package/build/cjs/core/version.js +1 -1
  9. package/build/cjs/core/version.js.map +1 -1
  10. package/build/cjs/rewriter/arrays.js +25 -0
  11. package/build/cjs/rewriter/arrays.js.map +1 -0
  12. package/build/cjs/rewriter/ast.js +102 -0
  13. package/build/cjs/rewriter/ast.js.map +1 -0
  14. package/build/cjs/rewriter/class-extends.js +67 -0
  15. package/build/cjs/rewriter/class-extends.js.map +1 -0
  16. package/build/cjs/rewriter/exports.js +241 -0
  17. package/build/cjs/rewriter/exports.js.map +1 -0
  18. package/build/cjs/rewriter/imports.js +22 -0
  19. package/build/cjs/rewriter/imports.js.map +1 -0
  20. package/build/cjs/rewriter/index.js +45 -0
  21. package/build/cjs/rewriter/module-shape.js +120 -0
  22. package/build/cjs/rewriter/module-shape.js.map +1 -0
  23. package/build/cjs/rewriter/parse.js +64 -0
  24. package/build/cjs/rewriter/parse.js.map +1 -0
  25. package/build/cjs/rewriter/report.js +17 -0
  26. package/build/cjs/rewriter/report.js.map +1 -0
  27. package/build/cjs/rewriter/rewriter.js +68 -0
  28. package/build/cjs/rewriter/rewriter.js.map +1 -0
  29. package/build/cjs/vite/source-map-hooks.js +1 -1
  30. package/build/cjs/vite/source-map-hooks.js.map +1 -1
  31. package/build/esm/core/index.js +2 -2
  32. package/build/esm/core/index.js.map +1 -1
  33. package/build/esm/core/options-mapping.js.map +1 -1
  34. package/build/esm/core/sentry/telemetry.js +1 -1
  35. package/build/esm/core/sentry/telemetry.js.map +1 -1
  36. package/build/esm/core/sourcemap-settings.js +26 -21
  37. package/build/esm/core/sourcemap-settings.js.map +1 -1
  38. package/build/esm/core/version.js +1 -1
  39. package/build/esm/core/version.js.map +1 -1
  40. package/build/esm/package.json +1 -1
  41. package/build/esm/rewriter/arrays.js +25 -0
  42. package/build/esm/rewriter/arrays.js.map +1 -0
  43. package/build/esm/rewriter/ast.js +95 -0
  44. package/build/esm/rewriter/ast.js.map +1 -0
  45. package/build/esm/rewriter/class-extends.js +67 -0
  46. package/build/esm/rewriter/class-extends.js.map +1 -0
  47. package/build/esm/rewriter/exports.js +231 -0
  48. package/build/esm/rewriter/exports.js.map +1 -0
  49. package/build/esm/rewriter/imports.js +21 -0
  50. package/build/esm/rewriter/imports.js.map +1 -0
  51. package/build/esm/rewriter/index.js +11 -0
  52. package/build/esm/rewriter/module-shape.js +118 -0
  53. package/build/esm/rewriter/module-shape.js.map +1 -0
  54. package/build/esm/rewriter/parse.js +60 -0
  55. package/build/esm/rewriter/parse.js.map +1 -0
  56. package/build/esm/rewriter/report.js +16 -0
  57. package/build/esm/rewriter/report.js.map +1 -0
  58. package/build/esm/rewriter/rewriter.js +65 -0
  59. package/build/esm/rewriter/rewriter.js.map +1 -0
  60. package/build/esm/vite/source-map-hooks.js +2 -2
  61. package/build/esm/vite/source-map-hooks.js.map +1 -1
  62. package/build/types/core/index.d.ts +1 -1
  63. package/build/types/core/index.d.ts.map +1 -1
  64. package/build/types/core/options-mapping.d.ts +2 -2
  65. package/build/types/core/options-mapping.d.ts.map +1 -1
  66. package/build/types/core/sentry/telemetry.d.ts.map +1 -1
  67. package/build/types/core/sourcemap-settings.d.ts +8 -6
  68. package/build/types/core/sourcemap-settings.d.ts.map +1 -1
  69. package/build/types/core/types.d.ts +14 -11
  70. package/build/types/core/types.d.ts.map +1 -1
  71. package/build/types/core/version.d.ts +1 -1
  72. package/build/types/rewriter/arrays.d.ts +12 -0
  73. package/build/types/rewriter/arrays.d.ts.map +1 -0
  74. package/build/types/rewriter/ast.d.ts +120 -0
  75. package/build/types/rewriter/ast.d.ts.map +1 -0
  76. package/build/types/rewriter/class-extends.d.ts +16 -0
  77. package/build/types/rewriter/class-extends.d.ts.map +1 -0
  78. package/build/types/rewriter/exports.d.ts +88 -0
  79. package/build/types/rewriter/exports.d.ts.map +1 -0
  80. package/build/types/rewriter/imports.d.ts +7 -0
  81. package/build/types/rewriter/imports.d.ts.map +1 -0
  82. package/build/types/rewriter/index.d.ts +10 -0
  83. package/build/types/rewriter/index.d.ts.map +1 -0
  84. package/build/types/rewriter/module-shape.d.ts +47 -0
  85. package/build/types/rewriter/module-shape.d.ts.map +1 -0
  86. package/build/types/rewriter/parse.d.ts +27 -0
  87. package/build/types/rewriter/parse.d.ts.map +1 -0
  88. package/build/types/rewriter/report.d.ts +12 -0
  89. package/build/types/rewriter/report.d.ts.map +1 -0
  90. package/build/types/rewriter/rewriter.d.ts +64 -0
  91. package/build/types/rewriter/rewriter.d.ts.map +1 -0
  92. package/build/types/vite/source-map-hooks.d.ts.map +1 -1
  93. package/package.json +9 -4
@@ -0,0 +1,68 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
2
+ const require_parse = require("./parse.js");
3
+ const require_report = require("./report.js");
4
+ let magic_string = require("magic-string");
5
+ magic_string = require_runtime.__toESM(magic_string);
6
+ let node_path = require("node:path");
7
+ // src/rewriter/rewriter.ts
8
+ function createRewriteState(code) {
9
+ return {
10
+ ms: new magic_string.default(code),
11
+ needsImport: false,
12
+ wrappedLocals: /* @__PURE__ */ new Map(),
13
+ imports: /* @__PURE__ */ new Set(),
14
+ report: require_report.createReport()
15
+ };
16
+ }
17
+ function createCallSiteRewriter(rules, options = {}) {
18
+ const rewrite = (matching, code, id, parse) => {
19
+ let ast;
20
+ try {
21
+ ast = parse(code, id);
22
+ } catch {
23
+ return null;
24
+ }
25
+ const state = createRewriteState(code);
26
+ const ctx = {
27
+ ast,
28
+ code,
29
+ id,
30
+ state
31
+ };
32
+ const finish = () => {
33
+ const warning = require_report.formatReport(state.report, id);
34
+ if (warning) options.logger?.warn(warning);
35
+ if (!state.ms.hasChanged()) return null;
36
+ return {
37
+ code: state.ms.toString(),
38
+ map: state.ms.generateMap({ hires: true })
39
+ };
40
+ };
41
+ const pending = applyRules(matching, ctx, 0);
42
+ return pending ? pending.then(finish) : finish();
43
+ };
44
+ return { transform(code, id, context) {
45
+ const matching = rules.filter((rule) => matches(rule.include, code, id));
46
+ if (matching.length === 0) return null;
47
+ const parse = options.parse ?? require_parse.bundlerParser(context) ?? require_parse.parseModule;
48
+ if (require_parse.isParserLoading()) return require_parse.loadParser().then(() => rewrite(matching, code, id, parse));
49
+ return rewrite(matching, code, id, parse);
50
+ } };
51
+ }
52
+ function matches(include, code, id) {
53
+ if (include.id && !include.id.test(id)) return false;
54
+ if (include.basename && !include.basename.test((0, node_path.basename)(id))) return false;
55
+ if (include.contains && !include.contains.every((substring) => code.includes(substring))) return false;
56
+ return true;
57
+ }
58
+ /** Applies the rules in order, staying synchronous until a rule returns a promise. */
59
+ function applyRules(rules, ctx, from) {
60
+ for (let index = from; index < rules.length; index++) {
61
+ const pending = rules[index]?.apply(ctx);
62
+ if (pending instanceof Promise) return pending.then(() => applyRules(rules, ctx, index + 1));
63
+ }
64
+ }
65
+ exports.createCallSiteRewriter = createCallSiteRewriter;
66
+ exports.createRewriteState = createRewriteState;
67
+
68
+ //# sourceMappingURL=rewriter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rewriter.js","names":["MagicString","createReport","formatReport","bundlerParser","parseModule","isParserLoading","loadParser","basename"],"sources":["../../../src/rewriter/rewriter.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport MagicString, { type SourceMap } from 'magic-string';\nimport type { ProgramBody } from './ast';\nimport {\n bundlerParser,\n isParserLoading,\n loadParser,\n type ModuleParser,\n parseModule,\n type ParserContext,\n} from './parse';\nimport { createReport, formatReport, type RewriteReport } from './report';\n\n/** The edits a rewrite makes to one module, shared by every rule that runs on it. */\nexport interface RewriteState {\n /** Positions are always relative to the original source. */\n ms: MagicString;\n /** Set once the rewritten code references a binding the caller must import. */\n needsImport: boolean;\n /** Local binding name → the binding that holds its wrapper. */\n wrappedLocals: Map<string, string>;\n /** Import statements already added to this module. */\n imports: Set<string>;\n report: RewriteReport;\n}\n\nexport function createRewriteState(code: string): RewriteState {\n return {\n ms: new MagicString(code),\n needsImport: false,\n wrappedLocals: new Map(),\n imports: new Set(),\n report: createReport(),\n };\n}\n\n/** Which modules a rule runs on. Every given condition must hold. */\nexport interface RuleInclude {\n /** Tested against the full module id. */\n id?: RegExp;\n /** Tested against the last path segment of the module id. */\n basename?: RegExp;\n /** Substrings the source must contain, checked before parsing. */\n contains?: string[];\n}\n\nexport interface RuleContext {\n ast: ProgramBody;\n code: string;\n id: string;\n state: RewriteState;\n}\n\nexport interface RewriteRule {\n name: string;\n include: RuleInclude;\n apply(ctx: RuleContext): void | Promise<void>;\n}\n\nexport interface RewriterOptions {\n /**\n * Defaults to Rolldown's `this.parse` when the transform gets a Rolldown\n * plugin context, and to {@link parseModule} otherwise.\n */\n parse?: ModuleParser;\n /** Receives the warning for sites a rule could not wrap. */\n logger?: { warn(message: string): void };\n}\n\nexport interface RewriteOutput {\n code: string;\n map: SourceMap;\n}\n\nexport interface CallSiteRewriter {\n /**\n * Runs every matching rule on one module. Returns `null` when nothing\n * changed. The result is a promise only while `oxc-parser` is still\n * loading, or when a rule's `apply` returns one.\n *\n * @param context the bundler's plugin context, for its parser\n */\n transform(code: string, id: string, context?: ParserContext): RewriteOutput | null | Promise<RewriteOutput | null>;\n}\n\nexport function createCallSiteRewriter(rules: RewriteRule[], options: RewriterOptions = {}): CallSiteRewriter {\n const rewrite = (\n matching: RewriteRule[],\n code: string,\n id: string,\n parse: ModuleParser,\n ): RewriteOutput | null | Promise<RewriteOutput | null> => {\n let ast: ProgramBody;\n try {\n ast = parse(code, id);\n } catch {\n return null;\n }\n\n const state = createRewriteState(code);\n const ctx: RuleContext = { ast, code, id, state };\n const finish = (): RewriteOutput | null => {\n const warning = formatReport(state.report, id);\n if (warning) options.logger?.warn(warning);\n if (!state.ms.hasChanged()) return null;\n return { code: state.ms.toString(), map: state.ms.generateMap({ hires: true }) };\n };\n\n const pending = applyRules(matching, ctx, 0);\n return pending ? pending.then(finish) : finish();\n };\n\n return {\n transform(code, id, context) {\n const matching = rules.filter(rule => matches(rule.include, code, id));\n if (matching.length === 0) return null;\n\n const parse = options.parse ?? bundlerParser(context) ?? parseModule;\n // Rules may parse other modules with `parseModule`, so it has to be ready\n // whichever parser reads this one.\n if (isParserLoading()) {\n return loadParser().then(() => rewrite(matching, code, id, parse));\n }\n return rewrite(matching, code, id, parse);\n },\n };\n}\n\nfunction matches(include: RuleInclude, code: string, id: string): boolean {\n if (include.id && !include.id.test(id)) return false;\n if (include.basename && !include.basename.test(basename(id))) return false;\n if (include.contains && !include.contains.every(substring => code.includes(substring))) return false;\n return true;\n}\n\n/** Applies the rules in order, staying synchronous until a rule returns a promise. */\nfunction applyRules(rules: RewriteRule[], ctx: RuleContext, from: number): Promise<void> | undefined {\n for (let index = from; index < rules.length; index++) {\n const pending = rules[index]?.apply(ctx);\n if (pending instanceof Promise) {\n return pending.then(() => applyRules(rules, ctx, index + 1));\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;;AA0BA,SAAgB,mBAAmB,MAA4B;CAC7D,OAAO;EACL,IAAI,IAAIA,aAAAA,QAAY,IAAI;EACxB,aAAa;EACb,+BAAe,IAAI,IAAI;EACvB,yBAAS,IAAI,IAAI;EACjB,QAAQC,eAAAA,aAAa;CACvB;AACF;AAmDA,SAAgB,uBAAuB,OAAsB,UAA2B,CAAC,GAAqB;CAC5G,MAAM,WACJ,UACA,MACA,IACA,UACyD;EACzD,IAAI;EACJ,IAAI;GACF,MAAM,MAAM,MAAM,EAAE;EACtB,QAAQ;GACN,OAAO;EACT;EAEA,MAAM,QAAQ,mBAAmB,IAAI;E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;EACpD,MAAM,UAAU,MAAM,MAAM,EAAE,MAAM,GAAG;EACvC,IAAI,mBAAmB,SACrB,OAAO,QAAQ,WAAW,WAAW,OAAO,KAAK,QAAQ,CAAC,CAAC;CAE/D;AAEF"}
@@ -78,7 +78,7 @@ function createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) {
78
78
  const environmentName = decisions.has(name) ? name : void 0;
79
79
  const { normalizedOptions } = sentryBuildPluginManager;
80
80
  const deleteOption = require_sourcemap_settings.getDeleteOption(normalizedOptions, environmentName);
81
- const removeAll = normalizedOptions.sourcemaps?.delete === true || require_sourcemap_settings.getSdkEnabledSourceMaps(normalizedOptions, environmentName);
81
+ const removeAll = normalizedOptions.sourcemaps?.delete === true || require_sourcemap_settings.getSdkDeleteSourceMaps(normalizedOptions, environmentName) === true;
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);
@@ -1 +1 @@
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;CAAO,mBAAmB;AAAM;;;;;;;AAgBrF,SAAS,WAAW,MAAc,OAA8C;CAC9E,MAAM,aAAa,MAAM,iBAAiB,UAAU,MAAM,eAAe;CAGzE,QAFgB,MAAM,QAAQ,UAAU,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC,EAAA,CAE3D,KAAI,WAAU;EAC3B,MAAM,YAAY,OAAO,aAAa,MAAM;EAC5C,OAAO;GACL,aAAa,OAAO,QAAQ,KAAA,IAAYA,UAAK,QAAQ,MAAM,MAAM,UAAU,MAAM,IAAIA,UAAK,QAAQ,OAAO,GAAG;GAC5G,OAAOC,4BAAAA,eAAe;IAAE,GAAG;IAAQ;GAAU,CAAC;GAC9C;GACA,YAAY,OAAO,cAAc,KAAA;EACnC;CACF,CAAC;AACH;;;;;;;AAQA,SAAgB,yBACd,0BACA,mBACoB;CAEpB,MAAM,4BAAY,IAAI,IAAkE;CAExF,OAAO;EACL,SAAS,YAAY,QAAQ;GAC3B,IAAI,IAAI,YAAY,SAClB,OAAO;GAIT,UAAU,MAAM;GAEhB,MAAM,OAAOC,4BAAAA,+BAA+B,WAAW,O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,IAAI,OAAO,YAAY;MACrB,MAAM,aAAaF,4BAAAA,+BAA+B,OAAO,SAAS;MAClE,MAAM,sBAAsB,cAAc,eAAe,YAAY,eAAe;MACpF,MAAM,oBAAoB,iBAAiB,SAAS,eAAe,YAAY;MAC/E,kBAAkB,YAAY,OAAO,aAAa;OAChD,OAAO,OAAO;OACd,MAAM;OACN,UAAU;QACR,cAAc,eAAe,aAAa;QAC1C;QACA;OACF;MACF,CAAC;MACD;KACF;KAGA,IAAI,SAAS,qBAAqB,OAAO,cAAc,UAAU;MAC/D,yBAAyB,OAAO,MAC9B,uBAAuB,KAAK,2BAA2B,KAAK,UAAU,OAAO,SAAS,EAAE,kCAC1F;MACA,kBAAkB,YAAY,OAAO,aAAa;OAAE,OAAO,OAAO;OAAO;OAAM,UAAU;MAAU,CAAC;KACtG,OACE,kBAAkB,YAAY,OAAO,aAAa;MAAE,OAAO,OAAO;MAAO;MAAM;KAAS,CAAC;IAE7F;GACF;EACF;EAEA,eAAe,kBAAkB;CACnC;AACF"}
1
+ {"version":3,"file":"source-map-hooks.js","names":["path","getOutputMatch","sourceMapKindFromRollupSetting","getDeleteOption","getSdkDeleteSourceMaps"],"sources":["../../../src/vite/source-map-hooks.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { SentryBuildPluginManager, SourceMapDecision, SourceMapKind } from '../core';\nimport { getDeleteOption, getSdkDeleteSourceMaps } 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 ||\n getSdkDeleteSourceMaps(normalizedOptions, environmentName) === true;\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;CAAO,mBAAmB;AAAM;;;;;;;AAgBrF,SAAS,WAAW,MAAc,OAA8C;CAC9E,MAAM,aAAa,MAAM,iBAAiB,UAAU,MAAM,eAAe;CAGzE,QAFgB,MAAM,QAAQ,UAAU,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC,EAAA,CAE3D,KAAI,WAAU;EAC3B,MAAM,YAAY,OAAO,aAAa,MAAM;EAC5C,OAAO;GACL,aAAa,OAAO,QAAQ,KAAA,IAAYA,UAAK,QAAQ,MAAM,MAAM,UAAU,MAAM,IAAIA,UAAK,QAAQ,OAAO,GAAG;GAC5G,OAAOC,4BAAAA,eAAe;IAAE,GAAG;IAAQ;GAAU,CAAC;GAC9C;GACA,YAAY,OAAO,cAAc,KAAA;EACnC;CACF,CAAC;AACH;;;;;;;AAQA,SAAgB,yBACd,0BACA,mBACoB;CAEpB,MAAM,4BAAY,IAAI,IAAkE;CAExF,OAAO;EACL,SAAS,YAAY,QAAQ;GAC3B,IAAI,IAAI,YAAY,SAClB,OAAO;GAIT,UAAU,MAAM;GAEhB,MAAM,OAAOC,4BAAAA,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AY,KAAK,GAAG;KAK/D,IAAI,OAAO,YAAY;MACrB,MAAM,aAAaF,4BAAAA,+BAA+B,OAAO,SAAS;MAClE,MAAM,sBAAsB,cAAc,eAAe,YAAY,eAAe;MACpF,MAAM,oBAAoB,iBAAiB,SAAS,eAAe,YAAY;MAC/E,kBAAkB,YAAY,OAAO,aAAa;OAChD,OAAO,OAAO;OACd,MAAM;OACN,UAAU;QACR,cAAc,eAAe,aAAa;QAC1C;QACA;OACF;MACF,CAAC;MACD;KACF;KAGA,IAAI,SAAS,qBAAqB,OAAO,cAAc,UAAU;MAC/D,yBAAyB,OAAO,MAC9B,uBAAuB,KAAK,2BAA2B,KAAK,UAAU,OAAO,SAAS,EAAE,kCAC1F;MACA,kBAAkB,YAAY,OAAO,aAAa;OAAE,OAAO,OAAO;OAAO;OAAM,UAAU;MAAU,CAAC;KACtG,OACE,kBAAkB,YAAY,OAAO,aAAa;MAAE,OAAO,OAAO;MAAO;MAAM;KAAS,CAAC;IAE7F;GACF;EACF;EAEA,eAAe,kBAAkB;CACnC;AACF"}
@@ -5,7 +5,7 @@ import { getCodeInjectionPosition } from "./get-code-injection-position.js";
5
5
  import { createComponentNameAnnotateHooks } from "./component-annotate-hooks.js";
6
6
  import { createSentryBuildPluginManager } from "./build-plugin-manager.js";
7
7
  import { addDebugIdToEmittedArtifacts, createDebugIdUploadFunction, stampDebugId } from "./debug-id-upload.js";
8
- import { decideSourceMapHandling, getDeleteOption, getDeleteSourcemapsAfterUpload, getSdkEnabledSourceMaps, getSourceMapFeatures } from "./sourcemap-settings.js";
8
+ import { decideSourceMapHandling, getDeleteOption, getSdkDeleteSourceMaps, getSourceMapFeatures } from "./sourcemap-settings.js";
9
9
  import { hasSourceMapUploadCredentials } from "./upload-credentials.js";
10
10
  // src/core/index.ts
11
11
  /**
@@ -70,6 +70,6 @@ function isInitialChunk(chunk, chunks) {
70
70
  function getDebugIdSnippet(debugId) {
71
71
  return new CodeInjection(`var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="${debugId}",e._sentryDebugIdIdentifier="sentry-dbid-${debugId}");`);
72
72
  }
73
- export { CodeInjection, addDebugIdToEmittedArtifacts, createComponentNameAnnotateHooks, createDebugIdUploadFunction, createSentryBuildPluginManager, decideSourceMapHandling, generateModuleMetadataInjectorCode, generateReleaseInjectorCode, getCodeInjectionPosition, getDebugIdSnippet, getDeleteOption, getDeleteSourcemapsAfterUpload, getSdkEnabledSourceMaps, getSourceMapFeatures, globFiles, hasSourceMapUploadCredentials, isInitialChunk, isJsFile, replaceBooleanFlagsInCode, resolveReleaseName, shouldSkipCodeInjection, stampDebugId, stringToUUID };
73
+ export { CodeInjection, addDebugIdToEmittedArtifacts, createComponentNameAnnotateHooks, createDebugIdUploadFunction, createSentryBuildPluginManager, decideSourceMapHandling, generateModuleMetadataInjectorCode, generateReleaseInjectorCode, getCodeInjectionPosition, getDebugIdSnippet, getDeleteOption, getSdkDeleteSourceMaps, getSourceMapFeatures, globFiles, hasSourceMapUploadCredentials, isInitialChunk, isJsFile, replaceBooleanFlagsInCode, resolveReleaseName, shouldSkipCodeInjection, stampDebugId, stringToUUID };
74
74
 
75
75
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/core/index.ts"],"sourcesContent":["import { CodeInjection, containsOnlyImports, stripQueryAndHashFromPath } from './utils';\n\n/**\n * Checks if a file is a JavaScript file based on its extension.\n * Handles query strings and hashes in the filename.\n */\nexport function isJsFile(fileName: string): boolean {\n const cleanFileName = stripQueryAndHashFromPath(fileName);\n return ['.js', '.mjs', '.cjs'].some(ext => cleanFileName.endsWith(ext));\n}\n\n/**\n * Checks if a chunk should be skipped for code injection\n *\n * This is necessary to handle Vite's MPA (multi-page application) mode where\n * HTML entry points create \"facade\" chunks that should not contain injected code.\n * See: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829\n *\n * However, in SPA mode, the main bundle also has an HTML facade but contains\n * substantial application code. We should NOT skip injection for these bundles.\n *\n * @param code - The chunk's code content\n * @param facadeModuleId - The facade module ID (if any) - HTML files create facade chunks\n * @returns true if the chunk should be skipped\n */\nexport function shouldSkipCodeInjection(code: string, facadeModuleId: string | null | undefined): boolean {\n // Skip empty chunks - these are placeholder chunks that should be optimized away\n if (code.trim().length === 0) {\n return true;\n }\n\n // For HTML facade chunks, only skip if they contain only import statements\n if (facadeModuleId && stripQueryAndHashFromPath(facadeModuleId).endsWith('.html')) {\n return containsOnlyImports(code);\n }\n\n return false;\n}\n\nexport interface ChunkGraphNode {\n fileName: string;\n isEntry?: boolean;\n imports?: string[];\n}\n\nconst initialChunksCache = new WeakMap<Record<string, ChunkGraphNode>, Set<string>>();\n\nfunction getInitialChunks(chunks: Record<string, ChunkGraphNode>): Set<string> {\n const cached = initialChunksCache.get(chunks);\n if (cached) {\n return cached;\n }\n\n const initial = new Set<string>();\n const queue = Object.values(chunks).filter(chunk => chunk.isEntry);\n\n for (let chunk = queue.shift(); chunk; chunk = queue.shift()) {\n if (initial.has(chunk.fileName)) {\n continue;\n }\n initial.add(chunk.fileName);\n for (const imported of chunk.imports ?? []) {\n const importedChunk = chunks[imported];\n if (importedChunk) {\n queue.push(importedChunk);\n }\n }\n }\n\n initialChunksCache.set(chunks, initial);\n return initial;\n}\n\n/**\n * Whether a chunk loads at startup: it is an entry chunk, or an entry chunk\n * reaches it through static imports. Chunks that only dynamic imports reach\n * load later, after startup code already ran.\n *\n * Without the chunk graph every chunk counts as initial.\n */\nexport function isInitialChunk(\n chunk: Pick<ChunkGraphNode, 'fileName' | 'isEntry'>,\n chunks: Record<string, ChunkGraphNode> | undefined,\n): boolean {\n if (chunk.isEntry || !chunks) {\n return true;\n }\n\n return getInitialChunks(chunks).has(chunk.fileName);\n}\n\nexport { globFiles } from './glob';\nexport { getCodeInjectionPosition } from './get-code-injection-position';\n\nexport { createComponentNameAnnotateHooks } from './component-annotate-hooks';\n\nexport function getDebugIdSnippet(debugId: string): CodeInjection {\n return new CodeInjection(\n `var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"${debugId}\",e._sentryDebugIdIdentifier=\"sentry-dbid-${debugId}\");`,\n );\n}\n\nexport type { Logger } from './logger';\nexport type { InternalOptions, Options, SentrySDKBuildFlags } from './types';\nexport {\n CodeInjection,\n replaceBooleanFlagsInCode,\n stringToUUID,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n resolveReleaseName,\n} from './utils';\nexport { createSentryBuildPluginManager } from './build-plugin-manager';\nexport type { SentryBuildPluginManager, UploadResult, UploadStaging } from './build-plugin-manager';\nexport { createDebugIdUploadFunction, addDebugIdToEmittedArtifacts, stampDebugId } from './debug-id-upload';\nexport {\n decideSourceMapHandling,\n getDeleteOption,\n getDeleteSourcemapsAfterUpload,\n getSdkEnabledSourceMaps,\n getSourceMapFeatures,\n} from './sourcemap-settings';\nexport type { SourceMapDecision, SourceMapKind } from './sourcemap-settings';\nexport { hasSourceMapUploadCredentials } from './upload-credentials';\nexport type { UploadFilter } from './upload-filter';\n"],"mappings":";;;;;;;;;;;;;;AAMA,SAAgB,SAAS,UAA2B;CAClD,MAAM,gBAAgB,0BAA0B,QAAQ;CACxD,OAAO;EAAC;EAAO;EAAQ;CAAM,CAAC,CAAC,MAAK,QAAO,cAAc,SAAS,GAAG,CAAC;AACxE;;;;;;;;;;;;;;;AAgBA,SAAgB,wBAAwB,MAAc,gBAAoD;CAExG,IAAI,KAAK,KAAK,CAAC,CAAC,WAAW,GACzB,OAAO;CAIT,IAAI,kBAAkB,0BAA0B,cAAc,CAAC,CAAC,SAAS,OAAO,GAC9E,OAAO,oBAAoB,IAAI;CAGjC,OAAO;AACT;AAQA,MAAM,qCAAqB,IAAI,QAAqD;AAEpF,SAAS,iBAAiB,QAAqD;CAC7E,MAAM,SAAS,mBAAmB,IAAI,MAAM;CAC5C,IAAI,QACF,OAAO;CAGT,MAAM,0BAAU,IAAI,IAAY;CAChC,MAAM,QAAQ,OAAO,OAAO,MAAM,CAAC,CAAC,QAAO,UAAS,MAAM,OAAO;CAEjE,KAAK,IAAI,QAAQ,MAAM,MAAM,GAAG,OAAO,QAAQ,MAAM,MAAM,GAAG;EAC5D,IAAI,QAAQ,IAAI,MAAM,QAAQ,GAC5B;EAEF,QAAQ,IAAI,MAAM,QAAQ;EAC1B,KAAK,MAAM,YAAY,MAAM,WAAW,CAAC,GAAG;GAC1C,MAAM,gBAAgB,OAAO;GAC7B,IAAI,eACF,MAAM,KAAK,aAAa;EAE5B;CACF;CAEA,mBAAmB,IAAI,QAAQ,OAAO;CACtC,OAAO;AACT;;;;;;;;AASA,SAAgB,eACd,OACA,QACS;CACT,IAAI,MAAM,WAAW,CAAC,QACpB,OAAO;CAGT,OAAO,iBAAiB,MAAM,CAAC,CAAC,IAAI,MAAM,QAAQ;AACpD;AAOA,SAAgB,kBAAkB,SAAgC;CAChE,OAAO,IAAI,cACT,+FAA+F,QAAQ,4CAA4C,QAAQ,IAC7J;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/core/index.ts"],"sourcesContent":["import { CodeInjection, containsOnlyImports, stripQueryAndHashFromPath } from './utils';\n\n/**\n * Checks if a file is a JavaScript file based on its extension.\n * Handles query strings and hashes in the filename.\n */\nexport function isJsFile(fileName: string): boolean {\n const cleanFileName = stripQueryAndHashFromPath(fileName);\n return ['.js', '.mjs', '.cjs'].some(ext => cleanFileName.endsWith(ext));\n}\n\n/**\n * Checks if a chunk should be skipped for code injection\n *\n * This is necessary to handle Vite's MPA (multi-page application) mode where\n * HTML entry points create \"facade\" chunks that should not contain injected code.\n * See: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829\n *\n * However, in SPA mode, the main bundle also has an HTML facade but contains\n * substantial application code. We should NOT skip injection for these bundles.\n *\n * @param code - The chunk's code content\n * @param facadeModuleId - The facade module ID (if any) - HTML files create facade chunks\n * @returns true if the chunk should be skipped\n */\nexport function shouldSkipCodeInjection(code: string, facadeModuleId: string | null | undefined): boolean {\n // Skip empty chunks - these are placeholder chunks that should be optimized away\n if (code.trim().length === 0) {\n return true;\n }\n\n // For HTML facade chunks, only skip if they contain only import statements\n if (facadeModuleId && stripQueryAndHashFromPath(facadeModuleId).endsWith('.html')) {\n return containsOnlyImports(code);\n }\n\n return false;\n}\n\nexport interface ChunkGraphNode {\n fileName: string;\n isEntry?: boolean;\n imports?: string[];\n}\n\nconst initialChunksCache = new WeakMap<Record<string, ChunkGraphNode>, Set<string>>();\n\nfunction getInitialChunks(chunks: Record<string, ChunkGraphNode>): Set<string> {\n const cached = initialChunksCache.get(chunks);\n if (cached) {\n return cached;\n }\n\n const initial = new Set<string>();\n const queue = Object.values(chunks).filter(chunk => chunk.isEntry);\n\n for (let chunk = queue.shift(); chunk; chunk = queue.shift()) {\n if (initial.has(chunk.fileName)) {\n continue;\n }\n initial.add(chunk.fileName);\n for (const imported of chunk.imports ?? []) {\n const importedChunk = chunks[imported];\n if (importedChunk) {\n queue.push(importedChunk);\n }\n }\n }\n\n initialChunksCache.set(chunks, initial);\n return initial;\n}\n\n/**\n * Whether a chunk loads at startup: it is an entry chunk, or an entry chunk\n * reaches it through static imports. Chunks that only dynamic imports reach\n * load later, after startup code already ran.\n *\n * Without the chunk graph every chunk counts as initial.\n */\nexport function isInitialChunk(\n chunk: Pick<ChunkGraphNode, 'fileName' | 'isEntry'>,\n chunks: Record<string, ChunkGraphNode> | undefined,\n): boolean {\n if (chunk.isEntry || !chunks) {\n return true;\n }\n\n return getInitialChunks(chunks).has(chunk.fileName);\n}\n\nexport { globFiles } from './glob';\nexport { getCodeInjectionPosition } from './get-code-injection-position';\n\nexport { createComponentNameAnnotateHooks } from './component-annotate-hooks';\n\nexport function getDebugIdSnippet(debugId: string): CodeInjection {\n return new CodeInjection(\n `var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"${debugId}\",e._sentryDebugIdIdentifier=\"sentry-dbid-${debugId}\");`,\n );\n}\n\nexport type { Logger } from './logger';\nexport type { InternalOptions, Options, SentrySDKBuildFlags } from './types';\nexport {\n CodeInjection,\n replaceBooleanFlagsInCode,\n stringToUUID,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n resolveReleaseName,\n} from './utils';\nexport { createSentryBuildPluginManager } from './build-plugin-manager';\nexport type { SentryBuildPluginManager, UploadResult, UploadStaging } from './build-plugin-manager';\nexport { createDebugIdUploadFunction, addDebugIdToEmittedArtifacts, stampDebugId } from './debug-id-upload';\nexport {\n decideSourceMapHandling,\n getDeleteOption,\n getSdkDeleteSourceMaps,\n getSourceMapFeatures,\n} from './sourcemap-settings';\nexport type { SourceMapDecision, SourceMapKind } from './sourcemap-settings';\nexport { hasSourceMapUploadCredentials } from './upload-credentials';\nexport type { UploadFilter } from './upload-filter';\n"],"mappings":";;;;;;;;;;;;;;AAMA,SAAgB,SAAS,UAA2B;CAClD,MAAM,gBAAgB,0BAA0B,QAAQ;CACxD,OAAO;EAAC;EAAO;EAAQ;CAAM,CAAC,CAAC,MAAK,QAAO,cAAc,SAAS,GAAG,CAAC;AACxE;;;;;;;;;;;;;;;AAgBA,SAAgB,wBAAwB,MAAc,gBAAoD;CAExG,IAAI,KAAK,KAAK,CAAC,CAAC,WAAW,GACzB,OAAO;CAIT,IAAI,kBAAkB,0BAA0B,cAAc,CAAC,CAAC,SAAS,OAAO,GAC9E,OAAO,oBAAoB,IAAI;CAGjC,OAAO;AACT;AAQA,MAAM,qCAAqB,IAAI,QAAqD;AAEpF,SAAS,iBAAiB,QAAqD;CAC7E,MAAM,SAAS,mBAAmB,IAAI,MAAM;CAC5C,IAAI,QACF,OAAO;CAGT,MAAM,0BAAU,IAAI,IAAY;CAChC,MAAM,QAAQ,OAAO,OAAO,MAAM,CAAC,CAAC,QAAO,UAAS,MAAM,OAAO;CAEjE,KAAK,IAAI,QAAQ,MAAM,MAAM,GAAG,OAAO,QAAQ,MAAM,MAAM,GAAG;EAC5D,IAAI,QAAQ,IAAI,MAAM,QAAQ,GAC5B;EAEF,QAAQ,IAAI,MAAM,QAAQ;EAC1B,KAAK,MAAM,YAAY,MAAM,WAAW,CAAC,GAAG;GAC1C,MAAM,gBAAgB,OAAO;GAC7B,IAAI,eACF,MAAM,KAAK,aAAa;EAE5B;CACF;CAEA,mBAAmB,IAAI,QAAQ,OAAO;CACtC,OAAO;AACT;;;;;;;;AASA,SAAgB,eACd,OACA,QACS;CACT,IAAI,MAAM,WAAW,CAAC,QACpB,OAAO;CAGT,OAAO,iBAAiB,MAAM,CAAC,CAAC,IAAI,MAAM,QAAQ;AACpD;AAOA,SAAgB,kBAAkB,SAAgC;CAChE,OAAO,IAAI,cACT,+FAA+F,QAAQ,4CAA4C,QAAQ,IAC7J;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"options-mapping.js","names":[],"sources":["../../../src/core/options-mapping.ts"],"sourcesContent":["import { getVercelEnv, warnOnConflictingSourceMapOptions } from '@sentry/core';\nimport type { Logger } from './logger';\nimport type {\n InternalOptions as UserOptions,\n SetCommitsOptions,\n RewriteSourcesHook,\n ResolveSourceMapHook,\n IncludeEntry,\n ModuleMetadata,\n ModuleMetadataCallback,\n} from './types';\nimport { parseProjectEnvVar } from './upload-credentials';\nimport { canAutoDetectRepository, readCommitEnvVar, resolveReleaseName } from './utils';\n\nexport type NormalizedOptions = {\n org: string | undefined;\n project: string | string[] | undefined;\n authToken: string | undefined;\n url: string | undefined;\n headers: Record<string, string> | undefined;\n debug: boolean;\n silent: boolean;\n errorHandler: ((err: Error) => void) | undefined;\n telemetry: boolean;\n disable: boolean;\n sourcemaps:\n | {\n disable?: boolean | 'disable-upload';\n upload?: boolean;\n injectDebugIds?: boolean;\n delete?: boolean;\n assets?: string | string[];\n ignore?: string | string[];\n rewriteSources?: RewriteSourcesHook;\n resolveSourceMap?: ResolveSourceMapHook;\n filesToDeleteAfterUpload?: string | string[] | Promise<string | string[] | undefined>;\n deleteSourcemapsAfterUpload?: boolean | ((environment?: string) => boolean | undefined);\n sdkEnabledSourceMaps?: boolean | ((environment?: string) => boolean | undefined);\n }\n | undefined;\n release: {\n name: string | undefined;\n inject: boolean | 'html';\n create: boolean;\n finalize: boolean;\n vcsRemote: string;\n setCommits:\n | (SetCommitsOptions & {\n shouldNotThrowOnFailure?: boolean;\n })\n | false\n | undefined;\n dist?: string;\n deploy?:\n | {\n env: string;\n started?: number | string;\n finished?: number | string;\n time?: number;\n name?: string;\n url?: string;\n }\n | false;\n uploadLegacySourcemaps?: string | IncludeEntry | Array<string | IncludeEntry>;\n };\n bundleSizeOptimizations:\n | {\n excludeDebugStatements?: boolean;\n excludeTracing?: boolean;\n excludeChannelInjection?: boolean;\n excludeReplayCanvas?: boolean;\n excludeReplayShadowDom?: boolean;\n excludeReplayIframe?: boolean;\n excludeReplayWorker?: boolean;\n }\n | undefined;\n reactComponentAnnotation:\n | {\n enabled?: boolean;\n ignoredComponents?: string[];\n _experimentalInjectIntoHtml?: boolean;\n }\n | undefined;\n _metaOptions: {\n telemetry: {\n metaFramework: string | undefined;\n bundlerMajorVersion: string | undefined;\n };\n };\n applicationKey: string | undefined;\n moduleMetadata: ModuleMetadata | ModuleMetadataCallback | undefined;\n _experiments: {\n injectBuildInformation?: boolean;\n } & Record<string, unknown>;\n};\n\nexport const SENTRY_SAAS_URL = 'https://sentry.io';\n\n// oxlint-disable-next-line complexity\nexport function normalizeUserOptions(userOptions: UserOptions): NormalizedOptions {\n const options = {\n org: userOptions.org ?? process.env['SENTRY_ORG'],\n project: userOptions.project ?? parseProjectEnvVar(process.env['SENTRY_PROJECT']),\n authToken: userOptions.authToken ?? process.env['SENTRY_AUTH_TOKEN'],\n // No sentry.io default: the CLI then uses the server an `sntrys_` org token was issued for, and\n // sentry.io otherwise. A default here would send self-hosted tokens to sentry.io.\n url: userOptions.url ?? process.env['SENTRY_URL'],\n headers: userOptions.headers,\n debug: userOptions.debug ?? false,\n silent: userOptions.silent ?? false,\n errorHandler: userOptions.errorHandler,\n telemetry: userOptions.telemetry ?? true,\n disable: userOptions.disable ?? false,\n sourcemaps: userOptions.sourcemaps,\n release: {\n ...userOptions.release,\n name: resolveReleaseName(userOptions.release?.name),\n inject: userOptions.release?.inject ?? true,\n create: userOptions.release?.create ?? true,\n finalize: userOptions.release?.finalize ?? true,\n vcsRemote: userOptions.release?.vcsRemote ?? process.env['SENTRY_VSC_REMOTE'] ?? 'origin',\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion -- rule false positive: the cast carries the internal `shouldNotThrowOnFailure` field; tsc errors without it\n setCommits: userOptions.release?.setCommits as\n | (SetCommitsOptions & { shouldNotThrowOnFailure?: boolean })\n | false\n | undefined,\n },\n bundleSizeOptimizations: userOptions.bundleSizeOptimizations,\n reactComponentAnnotation: userOptions.reactComponentAnnotation,\n _metaOptions: {\n telemetry: {\n metaFramework: userOptions._metaOptions?.telemetry?.metaFramework,\n bundlerMajorVersion: userOptions._metaOptions?.telemetry?.bundlerMajorVersion,\n },\n },\n applicationKey: userOptions.applicationKey,\n moduleMetadata: userOptions.moduleMetadata,\n _experiments: userOptions._experiments ?? {},\n };\n\n const vercelEnv = getVercelEnv();\n\n if (options.release.setCommits === undefined) {\n const vercelCommitSha = readCommitEnvVar('VERCEL_GIT_COMMIT_SHA');\n if (\n process.env['VERCEL'] &&\n vercelCommitSha &&\n process.env['VERCEL_GIT_REPO_SLUG'] &&\n process.env['VERCEL_GIT_REPO_OWNER'] &&\n // We only want to set commits for the production env because Sentry becomes extremely noisy (eg on slack) for\n // preview environments because the previous commit is always the \"stem\" commit of the preview/PR causing Sentry\n // to notify you for other people creating PRs.\n vercelEnv === 'production'\n ) {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n commit: vercelCommitSha,\n previousCommit: readCommitEnvVar('VERCEL_GIT_PREVIOUS_SHA'),\n repo: `${process.env['VERCEL_GIT_REPO_OWNER']}/${process.env['VERCEL_GIT_REPO_SLUG']}`,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n } else if (\n process.env['VERCEL'] &&\n vercelEnv !== 'production' &&\n !canAutoDetectRepository(options.release.vcsRemote)\n ) {\n // Vercel's own builders have no git remote and no other CI variables, so commit association can only fail there.\n // Builds that have either, such as `vercel build` in GitHub Actions, keep `auto: true` below.\n options.release.setCommits = false;\n } else {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n auto: true,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n }\n }\n\n if (options.release.deploy === undefined && process.env['VERCEL'] && vercelEnv) {\n options.release.deploy = {\n env: vercelEnv,\n url: process.env['VERCEL_URL'] ? `https://${process.env['VERCEL_URL']}` : undefined,\n };\n }\n\n return options;\n}\n\n/**\n * Validates a few combinations of options that are not checked by Sentry CLI.\n *\n * For all other options, we can rely on Sentry CLI to validate them. In fact,\n * we can't validate them in the plugin because Sentry CLI might pick up options from\n * its config file.\n *\n * @param options the internal options\n * @param logger the logger\n *\n * @returns `true` if the options are valid, `false` otherwise\n */\nexport function validateOptions(options: NormalizedOptions, logger: Logger): boolean {\n const setCommits = options.release?.setCommits;\n if (setCommits) {\n if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {\n logger.error(\n 'The `setCommits` option was specified but is missing required properties.',\n 'Please set either `auto` or both, `repo` and `commit`.',\n );\n return false;\n }\n if (setCommits.auto && setCommits.repo && setCommits) {\n logger.warn(\n 'The `setCommits` options includes `auto` but also `repo` and `commit`.',\n 'Ignoring `repo` and `commit`.',\n 'Please only set either `auto` or both, `repo` and `commit`.',\n );\n }\n }\n\n warnOnConflictingSourceMapOptions(options.sourcemaps, message => logger.warn(message));\n\n if (options.release?.deploy && typeof options.release.deploy === 'object' && !options.release.deploy.env) {\n logger.error(\n 'The `deploy` option was specified but is missing the required `env` property.',\n 'Please set the `env` property.',\n );\n return false;\n }\n\n if (options.project && Array.isArray(options.project)) {\n if (options.project.length === 0) {\n logger.error(\n 'The `project` option was specified as an array but is empty.',\n 'Please provide at least one project slug.',\n );\n return false;\n }\n // Check each project is a non-empty string\n const invalidProjects = options.project.filter(p => typeof p !== 'string' || p.trim() === '');\n if (invalidProjects.length > 0) {\n logger.error('The `project` option contains invalid project slugs.', 'All projects must be non-empty strings.');\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":";;;;AAgGA,MAAa,kBAAkB;AAG/B,SAAgB,qBAAqB,aAA6C;CAChF,MAAM,UAAU;EACd,KAAK,YAAY,OAAO,QAAQ,IAAI;EACpC,SAAS,YAAY,WAAW,mBAAmB,QAAQ,IAAI,iBAAiB;EAChF,WAAW,YAAY,aAAa,QAAQ,IAAI;EAGhD,KAAK,YAAY,OAAO,QAAQ,IAAI;EACpC,SAAS,YAAY;EACrB,OAAO,YAAY,SAAS;EAC5B,QAAQ,YAAY,UAAU;EAC9B,cAAc,YAAY;EAC1B,WAAW,YAAY,aAAa;EACpC,SAAS,YAAY,WAAW;EAChC,YAAY,YAAY;EACxB,SAAS;GACP,GAAG,YAAY;GACf,MAAM,mBAAmB,YAAY,SAAS,IAAI;GAClD,QAAQ,YAAY,SAAS,UAAU;GACvC,QAAQ,YAAY,SAAS,UAAU;GACvC,UAAU,YAAY,SAAS,YAAY;GAC3C,WAAW,YAAY,SAAS,aAAa,QAAQ,IAAI,wBAAwB;GAEjF,YAAY,YAAY,SAAS;EAInC;EACA,yBAAyB,YAAY;EACrC,0BAA0B,YAAY;EACtC,cAAc,EACZ,WAAW;GACT,eAAe,YAAY,cAAc,WAAW;GACpD,qBAAqB,YAAY,cAAc,WAAW;EAC5D,EACF;EACA,gBAAgB,YAAY;EAC5B,gBAAgB,YAAY;EAC5B,cAAc,YAAY,gBAAgB,CAAC;CAC7C;CAEA,MAAM,YAAY,aAAa;CAE/B,IAAI,QAAQ,QAAQ,eAAe,KAAA,GAAW;EAC5C,MAAM,kBAAkB,iBAAiB,uBAAuB;EAChE,IACE,QAAQ,IAAI,aACZ,mBACA,QAAQ,IAAI,2BACZ,QAAQ,IAAI,4BAIZ,cAAc,cAEd,QAAQ,QAAQ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AAK,MAAM,EACxE,CAAC,CAAC,SAAS,GAAG;GAC9B,OAAO,MAAM,wDAAwD,yCAAyC;GAC9G,OAAO;EACT;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"options-mapping.js","names":[],"sources":["../../../src/core/options-mapping.ts"],"sourcesContent":["import { getVercelEnv, warnOnConflictingSourceMapOptions } from '@sentry/core';\nimport type { Logger } from './logger';\nimport type {\n InternalOptions as UserOptions,\n SetCommitsOptions,\n RewriteSourcesHook,\n ResolveSourceMapHook,\n IncludeEntry,\n ModuleMetadata,\n ModuleMetadataCallback,\n} from './types';\nimport { parseProjectEnvVar } from './upload-credentials';\nimport { canAutoDetectRepository, readCommitEnvVar, resolveReleaseName } from './utils';\n\nexport type NormalizedOptions = {\n org: string | undefined;\n project: string | string[] | undefined;\n authToken: string | undefined;\n url: string | undefined;\n headers: Record<string, string> | undefined;\n debug: boolean;\n silent: boolean;\n errorHandler: ((err: Error) => void) | undefined;\n telemetry: boolean;\n disable: boolean;\n sourcemaps:\n | {\n disable?: boolean | 'disable-upload';\n upload?: boolean;\n injectDebugIds?: boolean;\n delete?: boolean;\n assets?: string | string[];\n ignore?: string | string[];\n rewriteSources?: RewriteSourcesHook;\n resolveSourceMap?: ResolveSourceMapHook;\n filesToDeleteAfterUpload?: string | string[] | Promise<string | string[] | undefined>;\n deleteSourcemapsAfterUpload?: boolean;\n sdkDeleteSourceMaps?: boolean | ((environment?: string) => boolean | undefined);\n }\n | undefined;\n release: {\n name: string | undefined;\n inject: boolean | 'html';\n create: boolean;\n finalize: boolean;\n vcsRemote: string;\n setCommits:\n | (SetCommitsOptions & {\n shouldNotThrowOnFailure?: boolean;\n })\n | false\n | undefined;\n dist?: string;\n deploy?:\n | {\n env: string;\n started?: number | string;\n finished?: number | string;\n time?: number;\n name?: string;\n url?: string;\n }\n | false;\n uploadLegacySourcemaps?: string | IncludeEntry | Array<string | IncludeEntry>;\n };\n bundleSizeOptimizations:\n | {\n excludeDebugStatements?: boolean;\n excludeTracing?: boolean;\n excludeChannelInjection?: boolean;\n excludeReplayCanvas?: boolean;\n excludeReplayShadowDom?: boolean;\n excludeReplayIframe?: boolean;\n excludeReplayWorker?: boolean;\n }\n | undefined;\n reactComponentAnnotation:\n | {\n enabled?: boolean;\n ignoredComponents?: string[];\n _experimentalInjectIntoHtml?: boolean;\n }\n | undefined;\n _metaOptions: {\n telemetry: {\n metaFramework: string | undefined;\n bundlerMajorVersion: string | undefined;\n };\n };\n applicationKey: string | undefined;\n moduleMetadata: ModuleMetadata | ModuleMetadataCallback | undefined;\n _experiments: {\n injectBuildInformation?: boolean;\n } & Record<string, unknown>;\n};\n\nexport const SENTRY_SAAS_URL = 'https://sentry.io';\n\n// oxlint-disable-next-line complexity\nexport function normalizeUserOptions(userOptions: UserOptions): NormalizedOptions {\n const options = {\n org: userOptions.org ?? process.env['SENTRY_ORG'],\n project: userOptions.project ?? parseProjectEnvVar(process.env['SENTRY_PROJECT']),\n authToken: userOptions.authToken ?? process.env['SENTRY_AUTH_TOKEN'],\n // No sentry.io default: the CLI then uses the server an `sntrys_` org token was issued for, and\n // sentry.io otherwise. A default here would send self-hosted tokens to sentry.io.\n url: userOptions.url ?? process.env['SENTRY_URL'],\n headers: userOptions.headers,\n debug: userOptions.debug ?? false,\n silent: userOptions.silent ?? false,\n errorHandler: userOptions.errorHandler,\n telemetry: userOptions.telemetry ?? true,\n disable: userOptions.disable ?? false,\n sourcemaps: userOptions.sourcemaps,\n release: {\n ...userOptions.release,\n name: resolveReleaseName(userOptions.release?.name),\n inject: userOptions.release?.inject ?? true,\n create: userOptions.release?.create ?? true,\n finalize: userOptions.release?.finalize ?? true,\n vcsRemote: userOptions.release?.vcsRemote ?? process.env['SENTRY_VSC_REMOTE'] ?? 'origin',\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion -- rule false positive: the cast carries the internal `shouldNotThrowOnFailure` field; tsc errors without it\n setCommits: userOptions.release?.setCommits as\n | (SetCommitsOptions & { shouldNotThrowOnFailure?: boolean })\n | false\n | undefined,\n },\n bundleSizeOptimizations: userOptions.bundleSizeOptimizations,\n reactComponentAnnotation: userOptions.reactComponentAnnotation,\n _metaOptions: {\n telemetry: {\n metaFramework: userOptions._metaOptions?.telemetry?.metaFramework,\n bundlerMajorVersion: userOptions._metaOptions?.telemetry?.bundlerMajorVersion,\n },\n },\n applicationKey: userOptions.applicationKey,\n moduleMetadata: userOptions.moduleMetadata,\n _experiments: userOptions._experiments ?? {},\n };\n\n const vercelEnv = getVercelEnv();\n\n if (options.release.setCommits === undefined) {\n const vercelCommitSha = readCommitEnvVar('VERCEL_GIT_COMMIT_SHA');\n if (\n process.env['VERCEL'] &&\n vercelCommitSha &&\n process.env['VERCEL_GIT_REPO_SLUG'] &&\n process.env['VERCEL_GIT_REPO_OWNER'] &&\n // We only want to set commits for the production env because Sentry becomes extremely noisy (eg on slack) for\n // preview environments because the previous commit is always the \"stem\" commit of the preview/PR causing Sentry\n // to notify you for other people creating PRs.\n vercelEnv === 'production'\n ) {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n commit: vercelCommitSha,\n previousCommit: readCommitEnvVar('VERCEL_GIT_PREVIOUS_SHA'),\n repo: `${process.env['VERCEL_GIT_REPO_OWNER']}/${process.env['VERCEL_GIT_REPO_SLUG']}`,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n } else if (\n process.env['VERCEL'] &&\n vercelEnv !== 'production' &&\n !canAutoDetectRepository(options.release.vcsRemote)\n ) {\n // Vercel's own builders have no git remote and no other CI variables, so commit association can only fail there.\n // Builds that have either, such as `vercel build` in GitHub Actions, keep `auto: true` below.\n options.release.setCommits = false;\n } else {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n auto: true,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n }\n }\n\n if (options.release.deploy === undefined && process.env['VERCEL'] && vercelEnv) {\n options.release.deploy = {\n env: vercelEnv,\n url: process.env['VERCEL_URL'] ? `https://${process.env['VERCEL_URL']}` : undefined,\n };\n }\n\n return options;\n}\n\n/**\n * Validates a few combinations of options that are not checked by Sentry CLI.\n *\n * For all other options, we can rely on Sentry CLI to validate them. In fact,\n * we can't validate them in the plugin because Sentry CLI might pick up options from\n * its config file.\n *\n * @param options the internal options\n * @param logger the logger\n *\n * @returns `true` if the options are valid, `false` otherwise\n */\nexport function validateOptions(options: NormalizedOptions, logger: Logger): boolean {\n const setCommits = options.release?.setCommits;\n if (setCommits) {\n if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {\n logger.error(\n 'The `setCommits` option was specified but is missing required properties.',\n 'Please set either `auto` or both, `repo` and `commit`.',\n );\n return false;\n }\n if (setCommits.auto && setCommits.repo && setCommits) {\n logger.warn(\n 'The `setCommits` options includes `auto` but also `repo` and `commit`.',\n 'Ignoring `repo` and `commit`.',\n 'Please only set either `auto` or both, `repo` and `commit`.',\n );\n }\n }\n\n warnOnConflictingSourceMapOptions(options.sourcemaps, message => logger.warn(message));\n\n if (options.release?.deploy && typeof options.release.deploy === 'object' && !options.release.deploy.env) {\n logger.error(\n 'The `deploy` option was specified but is missing the required `env` property.',\n 'Please set the `env` property.',\n );\n return false;\n }\n\n if (options.project && Array.isArray(options.project)) {\n if (options.project.length === 0) {\n logger.error(\n 'The `project` option was specified as an array but is empty.',\n 'Please provide at least one project slug.',\n );\n return false;\n }\n // Check each project is a non-empty string\n const invalidProjects = options.project.filter(p => typeof p !== 'string' || p.trim() === '');\n if (invalidProjects.length > 0) {\n logger.error('The `project` option contains invalid project slugs.', 'All projects must be non-empty strings.');\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":";;;;AAgGA,MAAa,kBAAkB;AAG/B,SAAgB,qBAAqB,aAA6C;CAChF,MAAM,UAAU;EACd,KAAK,YAAY,OAAO,QAAQ,IAAI;EACpC,SAAS,YAAY,WAAW,mBAAmB,QAAQ,IAAI,iBAAiB;EAChF,WAAW,YAAY,aAAa,QAAQ,IAAI;EAGhD,KAAK,YAAY,OAAO,QAAQ,IAAI;EACpC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aAAa,WACnE,QAAQ,QAAQ,SAAS;EACvB,KAAK;EACL,KAAK,QAAQ,IAAI,gBAAgB,WAAW,QAAQ,IAAI,kBAAkB,KAAA;CAC5E;CAGF,OAAO;AACT;;;;;;;;;;;;;AAcA,SAAgB,gBAAgB,SAA4B,QAAyB;CACnF,MAAM,aAAa,QAAQ,SAAS;CACpC,IAAI,YAAY;EACd,IAAI,CAAC,WAAW,QAAQ,EAAE,WAAW,QAAQ,WAAW,SAAS;GAC/D,OAAO,MACL,6EACA,wDACF;GACA,OAAO;EACT;EACA,IAAI,WAAW,QAAQ,WAAW,QAAQ,YACxC,OAAO,KACL,0EACA,iCACA,6DACF;CAEJ;CAEA,kCAAkC,QAAQ,aAAY,YAAW,OAAO,KAAK,OAAO,CAAC;CAErF,IAAI,QAAQ,SAAS,UAAU,OAAO,QAAQ,QAAQ,WAAW,YAAY,CAAC,QAAQ,QAAQ,OAAO,KAAK;EACxG,OAAO,MACL,iFACA,gCACF;EACA,OAAO;CACT;CAEA,IAAI,QAAQ,WAAW,MAAM,QAAQ,QAAQ,OAAO,GAAG;EACrD,IAAI,QAAQ,QAAQ,WAAW,GAAG;GAChC,OAAO,MACL,gEACA,2CACF;GACA,OAAO;EACT;EAGA,IADwB,QAAQ,QAAQ,QAAO,MAAK,OAAO,MAAM,YAAY,EAAE,KAAK,MAAM,EACxE,CAAC,CAAC,SAAS,GAAG;GAC9B,OAAO,MAAM,wDAAwD,yCAAyC;GAC9G,OAAO;EACT;CACF;CAEA,OAAO;AACT"}
@@ -62,7 +62,7 @@ function setTelemetryDataOnScope(options, scope, buildTool, buildToolMajorVersio
62
62
  scope.setTag("custom-error-handler", !!errorHandler);
63
63
  scope.setTag("sourcemaps-assets", !!sourcemaps?.assets);
64
64
  scope.setTag("delete-after-upload", !!sourcemaps?.filesToDeleteAfterUpload);
65
- scope.setTag("delete-sourcemaps-after-upload", typeof sourcemaps?.deleteSourcemapsAfterUpload === "function" ? "function" : sourcemaps?.deleteSourcemapsAfterUpload === void 0 ? "auto" : String(sourcemaps.deleteSourcemapsAfterUpload));
65
+ scope.setTag("delete-sourcemaps-after-upload", sourcemaps?.deleteSourcemapsAfterUpload === void 0 ? "auto" : String(sourcemaps.deleteSourcemapsAfterUpload));
66
66
  scope.setTag("sourcemaps-disabled", !!sourcemaps?.disable);
67
67
  scope.setTag("sourcemaps-upload", sourcemaps?.upload === void 0 ? "auto" : String(sourcemaps.upload));
68
68
  scope.setTag("sourcemaps-inject-debug-ids", sourcemaps?.injectDebugIds === void 0 ? "auto" : String(sourcemaps.injectDebugIds));
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.js","names":[],"sources":["../../../../src/core/sentry/telemetry.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport type { ServerRuntimeClientOptions } from '@sentry/core/server';\nimport { applySdkMetadata } from '@sentry/core';\nimport { ServerRuntimeClient } from '@sentry/core/server';\nimport type { NormalizedOptions } from '../options-mapping';\nimport { SENTRY_SAAS_URL } from '../options-mapping';\nimport { Scope } from '@sentry/core';\nimport { createStackParser } from '@sentry/core';\nimport { nodeStackLineParser } from '@sentry/core/server';\nimport { makeOptionallyEnabledNodeTransport } from './transports';\nimport { SentryCliAdapter } from '../cli';\nimport { LIB_VERSION } from '../version';\n\nconst SENTRY_SAAS_HOSTNAME = 'sentry.io';\n\nconst stackParser = createStackParser(nodeStackLineParser());\n\nexport function createSentryInstance(\n options: NormalizedOptions,\n shouldSendTelemetry: Promise<boolean>,\n buildTool: string,\n buildToolMajorVersion: string | undefined,\n): { sentryScope: Scope; sentryClient: Client } {\n const clientOptions: ServerRuntimeClientOptions = {\n platform: 'node',\n runtime: { name: 'node', version: global.process.version },\n\n dsn: 'https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737',\n\n tracesSampleRate: 0.3,\n traceLifecycle: 'static',\n sampleRate: 1,\n\n release: LIB_VERSION,\n integrations: [],\n tracePropagationTargets: ['sentry.io/api'],\n\n stackParser,\n\n beforeSend: event => {\n event.exception?.values?.forEach(exception => {\n delete exception.stacktrace;\n });\n\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n // Deprecated, but still applied because this client runs on the static trace lifecycle.\n // oxlint-disable-next-line typescript/no-deprecated\n beforeSendTransaction: event => {\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n // We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told\n // us that the upload URL is the Sentry SaaS URL)\n transport: makeOptionallyEnabledNodeTransport(shouldSendTelemetry),\n };\n\n applySdkMetadata(clientOptions, 'node');\n\n const client = new ServerRuntimeClient(clientOptions);\n const scope = new Scope();\n scope.setClient(client);\n\n // Integration tests snapshot the emitted transaction, so the sampling decision must not depend on chance.\n if (process.env['SENTRY_TEST_OUT_DIR']) {\n scope.setPropagationContext({ ...scope.getPropagationContext(), sampleRand: 0 });\n }\n\n setTelemetryDataOnScope(options, scope, buildTool, buildToolMajorVersion);\n\n return { sentryScope: scope, sentryClient: client };\n}\n\nexport function setTelemetryDataOnScope(\n options: NormalizedOptions,\n scope: Scope,\n buildTool: string,\n buildToolMajorVersion?: string,\n): void {\n const { org, project, release, errorHandler, sourcemaps, reactComponentAnnotation } = options;\n\n scope.setTag('upload-legacy-sourcemaps', !!release.uploadLegacySourcemaps);\n if (release.uploadLegacySourcemaps) {\n scope.setTag(\n 'uploadLegacySourcemapsEntries',\n Array.isArray(release.uploadLegacySourcemaps) ? release.uploadLegacySourcemaps.length : 1,\n );\n }\n\n scope.setTag('module-metadata', !!options.moduleMetadata);\n scope.setTag('inject-build-information', !!options._experiments.injectBuildInformation);\n\n // Optional release pipeline steps\n if (release.setCommits) {\n scope.setTag('set-commits', release.setCommits.auto === true ? 'auto' : 'manual');\n } else {\n scope.setTag('set-commits', 'undefined');\n }\n scope.setTag('finalize-release', release.finalize);\n scope.setTag('deploy-options', !!release.deploy);\n\n // Miscellaneous options\n scope.setTag('custom-error-handler', !!errorHandler);\n scope.setTag('sourcemaps-assets', !!sourcemaps?.assets);\n scope.setTag('delete-after-upload', !!sourcemaps?.filesToDeleteAfterUpload);\n scope.setTag(\n 'delete-sourcemaps-after-upload',\n typeof sourcemaps?.deleteSourcemapsAfterUpload === 'function'\n ? 'function'\n : sourcemaps?.deleteSourcemapsAfterUpload === undefined\n ? 'auto'\n : String(sourcemaps.deleteSourcemapsAfterUpload),\n );\n scope.setTag('sourcemaps-disabled', !!sourcemaps?.disable);\n scope.setTag('sourcemaps-upload', sourcemaps?.upload === undefined ? 'auto' : String(sourcemaps.upload));\n scope.setTag(\n 'sourcemaps-inject-debug-ids',\n sourcemaps?.injectDebugIds === undefined ? 'auto' : String(sourcemaps.injectDebugIds),\n );\n scope.setTag('sourcemaps-delete', sourcemaps?.delete === undefined ? 'auto' : String(sourcemaps.delete));\n\n scope.setTag('react-annotate', !!reactComponentAnnotation?.enabled);\n\n scope.setTag('node', process.version);\n scope.setTag('platform', process.platform);\n\n scope.setTag('meta-framework', options._metaOptions.telemetry.metaFramework ?? 'none');\n\n scope.setTag('application-key-set', options.applicationKey !== undefined);\n\n scope.setTag('ci', !!process.env['CI']);\n\n scope.setTags({\n organization: org,\n project: Array.isArray(project) ? project.join(', ') : (project ?? 'undefined'),\n bundler: buildTool,\n });\n\n if (buildToolMajorVersion) {\n scope.setTag('bundler-major-version', buildToolMajorVersion);\n }\n\n scope.setUser({ id: org });\n}\n\nexport async function allowedToSendTelemetry(options: NormalizedOptions): Promise<boolean> {\n const { telemetry } = options;\n const url = options.url ?? SENTRY_SAAS_URL;\n\n // `options.telemetry` defaults to true\n if (telemetry === false) {\n return false;\n }\n\n if (url === SENTRY_SAAS_URL) {\n return true;\n }\n\n // Ask the CLI which Sentry server URL it resolves to. This can differ from the default (or the\n // configured `url`) because the CLI also honors a possibly existing `.sentryclirc` file.\n const cliInfoUrl = await new SentryCliAdapter(options).getServerUrl();\n\n if (cliInfoUrl === undefined) {\n return false;\n }\n\n return new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME;\n}\n\n/**\n * Flushing the SDK client can fail. We never want to crash the plugin because of telemetry.\n */\nexport async function safeFlushTelemetry(sentryClient: Client): Promise<void> {\n try {\n await sentryClient.flush(2000);\n } catch {\n // Noop when flushing fails.\n // We don't even need to log anything because there's likely nothing the user can do and they likely will not care.\n }\n}\n"],"mappings":";;;;;;;AAaA,MAAM,uBAAuB;AAE7B,MAAM,cAAc,kBAAkB,oBAAoB,CAAC;AAE3D,SAAgB,qBACd,SACA,qBACA,WACA,uBAC8C;CAC9C,MAAM,gBAA4C;EAChD,UAAU;EACV,SAAS;GAAE,MAAM;GAAQ,SAAS,OAAO,QAAQ;EAAQ;EAEzD,KAAK;EAEL,kBAAkB;EAClB,gBAAgB;EAChB,YAAY;EAEZ,SAAS;EACT,cAAc,CAAC;EACf,yBAAyB,CAAC,eAAe;EAEzC;EAEA,aAAY,UAAS;GACnB,MAAM,WAAW,QAAQ,SAAQ,cAAa;IAC5C,OAAO,UAAU;GACnB,CAAC;GAED,OAAO,MAAM;GACb,OAAO;EACT;EAIA,wBAAuB,UAAS;GAC9B,OAAO,MAAM;GACb,OAAO;EACT;EAIA,WAAW,mCAAmC,mBAAmB;CACnE;CAEA,iBAAiB,eAAe,MAAM;CAEtC,MAAM,SAAS,IAAI,oBAAoB,aAAa;CACpD,MAAM,QAAQ,IAAI,MAAM;CACxB,MAAM,UAAU,MAAM;CAGtB,IAAI,QAAQ,IAAI,wBACd,MAAM,sBAAsB;EAAE,GAAG,MAAM,sBAAsB;EAAG,YAAY;CAAE,CAAC;CAGjF,wBAAwB,SAAS,OAAO,WAAW,qBAAqB;CAExE,OAAO;EAAE,aAAa;EAAO,cAAc;CAAO;AACpD;AAEA,SAAgB,wBACd,SACA,OACA,WACA,uBACM;CACN,MAAM,EAAE,KAAK,SAAS,SAAS,cAAc,YAAY,6BAA6B;CAEtF,MAAM,OAAO,4BAA4B,CAAC,CAAC,QAAQ,sBAAsB;CACzE,IAAI,QAAQ,wBACV,MAAM,OACJ,iCACA,MAAM,Q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;CAEtC,MAAM,QAAQ;EACZ,cAAc;EACd,SAAS,MAAM,QAAQ,OAAO,IAAI,QAAQ,KAAK,IAAI,IAAK,WAAW;EACnE,SAAS;CACX,CAAC;CAED,IAAI,uBACF,MAAM,OAAO,yBAAyB,qBAAqB;CAG7D,MAAM,QAAQ,EAAE,IAAI,IAAI,CAAC;AAC3B;AAEA,eAAsB,uBAAuB,SAA8C;CACzF,MAAM,EAAE,cAAc;CACtB,MAAM,MAAM,QAAQ,OAAA;CAGpB,IAAI,cAAc,OAChB,OAAO;CAGT,IAAI,QAAA,qBACF,OAAO;CAKT,MAAM,aAAa,MAAM,IAAI,iBAAiB,OAAO,CAAC,CAAC,aAAa;CAEpE,IAAI,eAAe,KAAA,GACjB,OAAO;CAGT,OAAO,IAAI,IAAI,UAAU,CAAC,CAAC,aAAa;AAC1C;;;;AAKA,eAAsB,mBAAmB,cAAqC;CAC5E,IAAI;EACF,MAAM,aAAa,MAAM,GAAI;CAC/B,QAAQ,CAGR;AACF"}
1
+ {"version":3,"file":"telemetry.js","names":[],"sources":["../../../../src/core/sentry/telemetry.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport type { ServerRuntimeClientOptions } from '@sentry/core/server';\nimport { applySdkMetadata } from '@sentry/core';\nimport { ServerRuntimeClient } from '@sentry/core/server';\nimport type { NormalizedOptions } from '../options-mapping';\nimport { SENTRY_SAAS_URL } from '../options-mapping';\nimport { Scope } from '@sentry/core';\nimport { createStackParser } from '@sentry/core';\nimport { nodeStackLineParser } from '@sentry/core/server';\nimport { makeOptionallyEnabledNodeTransport } from './transports';\nimport { SentryCliAdapter } from '../cli';\nimport { LIB_VERSION } from '../version';\n\nconst SENTRY_SAAS_HOSTNAME = 'sentry.io';\n\nconst stackParser = createStackParser(nodeStackLineParser());\n\nexport function createSentryInstance(\n options: NormalizedOptions,\n shouldSendTelemetry: Promise<boolean>,\n buildTool: string,\n buildToolMajorVersion: string | undefined,\n): { sentryScope: Scope; sentryClient: Client } {\n const clientOptions: ServerRuntimeClientOptions = {\n platform: 'node',\n runtime: { name: 'node', version: global.process.version },\n\n dsn: 'https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737',\n\n tracesSampleRate: 0.3,\n traceLifecycle: 'static',\n sampleRate: 1,\n\n release: LIB_VERSION,\n integrations: [],\n tracePropagationTargets: ['sentry.io/api'],\n\n stackParser,\n\n beforeSend: event => {\n event.exception?.values?.forEach(exception => {\n delete exception.stacktrace;\n });\n\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n // Deprecated, but still applied because this client runs on the static trace lifecycle.\n // oxlint-disable-next-line typescript/no-deprecated\n beforeSendTransaction: event => {\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n // We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told\n // us that the upload URL is the Sentry SaaS URL)\n transport: makeOptionallyEnabledNodeTransport(shouldSendTelemetry),\n };\n\n applySdkMetadata(clientOptions, 'node');\n\n const client = new ServerRuntimeClient(clientOptions);\n const scope = new Scope();\n scope.setClient(client);\n\n // Integration tests snapshot the emitted transaction, so the sampling decision must not depend on chance.\n if (process.env['SENTRY_TEST_OUT_DIR']) {\n scope.setPropagationContext({ ...scope.getPropagationContext(), sampleRand: 0 });\n }\n\n setTelemetryDataOnScope(options, scope, buildTool, buildToolMajorVersion);\n\n return { sentryScope: scope, sentryClient: client };\n}\n\nexport function setTelemetryDataOnScope(\n options: NormalizedOptions,\n scope: Scope,\n buildTool: string,\n buildToolMajorVersion?: string,\n): void {\n const { org, project, release, errorHandler, sourcemaps, reactComponentAnnotation } = options;\n\n scope.setTag('upload-legacy-sourcemaps', !!release.uploadLegacySourcemaps);\n if (release.uploadLegacySourcemaps) {\n scope.setTag(\n 'uploadLegacySourcemapsEntries',\n Array.isArray(release.uploadLegacySourcemaps) ? release.uploadLegacySourcemaps.length : 1,\n );\n }\n\n scope.setTag('module-metadata', !!options.moduleMetadata);\n scope.setTag('inject-build-information', !!options._experiments.injectBuildInformation);\n\n // Optional release pipeline steps\n if (release.setCommits) {\n scope.setTag('set-commits', release.setCommits.auto === true ? 'auto' : 'manual');\n } else {\n scope.setTag('set-commits', 'undefined');\n }\n scope.setTag('finalize-release', release.finalize);\n scope.setTag('deploy-options', !!release.deploy);\n\n // Miscellaneous options\n scope.setTag('custom-error-handler', !!errorHandler);\n scope.setTag('sourcemaps-assets', !!sourcemaps?.assets);\n scope.setTag('delete-after-upload', !!sourcemaps?.filesToDeleteAfterUpload);\n scope.setTag(\n 'delete-sourcemaps-after-upload',\n sourcemaps?.deleteSourcemapsAfterUpload === undefined ? 'auto' : String(sourcemaps.deleteSourcemapsAfterUpload),\n );\n scope.setTag('sourcemaps-disabled', !!sourcemaps?.disable);\n scope.setTag('sourcemaps-upload', sourcemaps?.upload === undefined ? 'auto' : String(sourcemaps.upload));\n scope.setTag(\n 'sourcemaps-inject-debug-ids',\n sourcemaps?.injectDebugIds === undefined ? 'auto' : String(sourcemaps.injectDebugIds),\n );\n scope.setTag('sourcemaps-delete', sourcemaps?.delete === undefined ? 'auto' : String(sourcemaps.delete));\n\n scope.setTag('react-annotate', !!reactComponentAnnotation?.enabled);\n\n scope.setTag('node', process.version);\n scope.setTag('platform', process.platform);\n\n scope.setTag('meta-framework', options._metaOptions.telemetry.metaFramework ?? 'none');\n\n scope.setTag('application-key-set', options.applicationKey !== undefined);\n\n scope.setTag('ci', !!process.env['CI']);\n\n scope.setTags({\n organization: org,\n project: Array.isArray(project) ? project.join(', ') : (project ?? 'undefined'),\n bundler: buildTool,\n });\n\n if (buildToolMajorVersion) {\n scope.setTag('bundler-major-version', buildToolMajorVersion);\n }\n\n scope.setUser({ id: org });\n}\n\nexport async function allowedToSendTelemetry(options: NormalizedOptions): Promise<boolean> {\n const { telemetry } = options;\n const url = options.url ?? SENTRY_SAAS_URL;\n\n // `options.telemetry` defaults to true\n if (telemetry === false) {\n return false;\n }\n\n if (url === SENTRY_SAAS_URL) {\n return true;\n }\n\n // Ask the CLI which Sentry server URL it resolves to. This can differ from the default (or the\n // configured `url`) because the CLI also honors a possibly existing `.sentryclirc` file.\n const cliInfoUrl = await new SentryCliAdapter(options).getServerUrl();\n\n if (cliInfoUrl === undefined) {\n return false;\n }\n\n return new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME;\n}\n\n/**\n * Flushing the SDK client can fail. We never want to crash the plugin because of telemetry.\n */\nexport async function safeFlushTelemetry(sentryClient: Client): Promise<void> {\n try {\n await sentryClient.flush(2000);\n } catch {\n // Noop when flushing fails.\n // We don't even need to log anything because there's likely nothing the user can do and they likely will not care.\n }\n}\n"],"mappings":";;;;;;;AAaA,MAAM,uBAAuB;AAE7B,MAAM,cAAc,kBAAkB,oBAAoB,CAAC;AAE3D,SAAgB,qBACd,SACA,qBACA,WACA,uBAC8C;CAC9C,MAAM,gBAA4C;EAChD,UAAU;EACV,SAAS;GAAE,MAAM;GAAQ,SAAS,OAAO,QAAQ;EAAQ;EAEzD,KAAK;EAEL,kBAAkB;EAClB,gBAAgB;EAChB,YAAY;EAEZ,SAAS;EACT,cAAc,CAAC;EACf,yBAAyB,CAAC,eAAe;EAEzC;EAEA,aAAY,UAAS;GACnB,MAAM,WAAW,QAAQ,SAAQ,cAAa;IAC5C,OAAO,UAAU;GACnB,CAAC;GAED,OAAO,MAAM;GACb,OAAO;EACT;EAIA,wBAAuB,UAAS;GAC9B,OAAO,MAAM;GACb,OAAO;EACT;EAIA,WAAW,mCAAmC,mBAAmB;CACnE;CAEA,iBAAiB,eAAe,MAAM;CAEtC,MAAM,SAAS,IAAI,oBAAoB,aAAa;CACpD,MAAM,QAAQ,IAAI,MAAM;CACxB,MAAM,UAAU,MAAM;CAGtB,IAAI,QAAQ,IAAI,wBACd,MAAM,sBAAsB;EAAE,GAAG,MAAM,sBAAsB;EAAG,YAAY;CAAE,CAAC;CAGjF,wBAAwB,SAAS,OAAO,WAAW,qBAAqB;CAExE,OAAO;EAAE,aAAa;EAAO,cAAc;CAAO;AACpD;AA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zC,MAAM,OAAO,kBAAkB,QAAQ,aAAa,UAAU,iBAAiB,MAAM;CAErF,MAAM,OAAO,uBAAuB,QAAQ,mBAAmB,KAAA,CAAS;CAExE,MAAM,OAAO,MAAM,CAAC,CAAC,QAAQ,IAAI,KAAK;CAEtC,MAAM,QAAQ;EACZ,cAAc;EACd,SAAS,MAAM,QAAQ,OAAO,IAAI,QAAQ,KAAK,IAAI,IAAK,WAAW;EACnE,SAAS;CACX,CAAC;CAED,IAAI,uBACF,MAAM,OAAO,yBAAyB,qBAAqB;CAG7D,MAAM,QAAQ,EAAE,IAAI,IAAI,CAAC;AAC3B;AAEA,eAAsB,uBAAuB,SAA8C;CACzF,MAAM,EAAE,cAAc;CACtB,MAAM,MAAM,QAAQ,OAAA;CAGpB,IAAI,cAAc,OAChB,OAAO;CAGT,IAAI,QAAA,qBACF,OAAO;CAKT,MAAM,aAAa,MAAM,IAAI,iBAAiB,OAAO,CAAC,CAAC,aAAa;CAEpE,IAAI,eAAe,KAAA,GACjB,OAAO;CAGT,OAAO,IAAI,IAAI,UAAU,CAAC,CAAC,aAAa;AAC1C;;;;AAKA,eAAsB,mBAAmB,cAAqC;CAC5E,IAAI;EACF,MAAM,aAAa,MAAM,GAAI;CAC/B,QAAQ,CAGR;AACF"}
@@ -18,33 +18,35 @@ function getSourceMapFeatures(options) {
18
18
  stampEmittedFiles: injectDebugIds && !upload
19
19
  };
20
20
  }
21
- /** Reads `sourcemaps.deleteSourcemapsAfterUpload`, calling the internal function form if given. */
22
- function getDeleteSourcemapsAfterUpload(options, environment) {
23
- const value = options.sourcemaps?.deleteSourcemapsAfterUpload;
21
+ /** Reads the internal `sourcemaps.sdkDeleteSourceMaps` option, calling its function form if given. */
22
+ function getSdkDeleteSourceMaps(options, environment) {
23
+ const value = options.sourcemaps?.sdkDeleteSourceMaps;
24
24
  return typeof value === "function" ? value(environment) : value;
25
25
  }
26
- /** Reads `sourcemaps.delete`. When it is unset, `sourcemaps.deleteSourcemapsAfterUpload` decides. */
26
+ /**
27
+ * Reads `sourcemaps.delete`. When it is unset, `sourcemaps.deleteSourcemapsAfterUpload` decides, and
28
+ * then the SDK.
29
+ */
27
30
  function getDeleteOption(options, environment) {
28
- return options.sourcemaps?.delete ?? getDeleteSourcemapsAfterUpload(options, environment);
29
- }
30
- /** Reads the internal `sourcemaps.sdkEnabledSourceMaps` option, calling its function form if given. */
31
- function getSdkEnabledSourceMaps(options, environment) {
32
- const value = options.sourcemaps?.sdkEnabledSourceMaps;
33
- return (typeof value === "function" ? value(environment) : value) === true;
31
+ return options.sourcemaps?.delete ?? options.sourcemaps?.deleteSourcemapsAfterUpload ?? getSdkDeleteSourceMaps(options, environment);
34
32
  }
35
33
  /**
36
34
  * Decides whether the plugin turns hidden source maps on and whether it removes the maps from the
37
35
  * build output after the upload. The plugin only turns maps on when an upload can run, and only
38
- * removes maps it turned on itself unless `deleteSourcemapsAfterUpload` says otherwise.
36
+ * removes maps it turned on itself unless `deleteSourcemapsAfterUpload` or the SDK's
37
+ * `sdkDeleteSourceMaps` says otherwise. The user's `deleteSourcemapsAfterUpload` wins over the SDK.
39
38
  */
40
39
  function decideSourceMapHandling(kind, options, uploadPossible, environment) {
41
40
  const features = getSourceMapFeatures(options);
42
41
  if (options.sourcemaps?.delete !== void 0) return decideWithDeleteOption(kind, options.sourcemaps.delete, features, uploadPossible);
43
- const deleteOption = getDeleteSourcemapsAfterUpload(options, environment);
44
- const sdkEnabledSourceMaps = getSdkEnabledSourceMaps(options, environment);
42
+ const userDeleteOption = options.sourcemaps?.deleteSourcemapsAfterUpload;
43
+ const sdkDeleteOption = getSdkDeleteSourceMaps(options, environment);
44
+ const deleteOption = userDeleteOption ?? sdkDeleteOption;
45
+ const sdkRemovesAll = sdkDeleteOption === true;
46
+ const fromUser = userDeleteOption !== void 0;
45
47
  if (!uploadPossible || !features.upload) {
46
48
  if (deleteOption !== true || kind !== "hidden" && kind !== "visible") return NO_CHANGE;
47
- if (!features.upload && !sdkEnabledSourceMaps) return {
49
+ if (!features.upload && !sdkRemovesAll) return {
48
50
  ...NO_CHANGE,
49
51
  log: {
50
52
  level: "warn",
@@ -54,10 +56,13 @@ function decideSourceMapHandling(kind, options, uploadPossible, environment) {
54
56
  return {
55
57
  enableHidden: kind === "visible",
56
58
  deleteAfterUpload: true,
57
- removeAllSourceMaps: sdkEnabledSourceMaps,
58
- log: {
59
+ removeAllSourceMaps: sdkRemovesAll,
60
+ log: fromUser ? {
59
61
  level: "warn",
60
62
  message: "Source maps are not uploaded, but they are removed from the build output because `sourcemaps.deleteSourcemapsAfterUpload` is set."
63
+ } : {
64
+ level: "info",
65
+ message: "Source maps are not uploaded, but the Sentry SDK removes them from the build output."
61
66
  }
62
67
  };
63
68
  }
@@ -91,7 +96,7 @@ function decideSourceMapHandling(kind, options, uploadPossible, environment) {
91
96
  removeAllSourceMaps: true,
92
97
  log: {
93
98
  level: "info",
94
- message: "Enabling hidden source maps. They are uploaded to Sentry and removed from the build output. Set `sourcemaps.deleteSourcemapsAfterUpload: false` to keep them."
99
+ message: "Enabling hidden source maps. They are uploaded to Sentry and removed from the build output. Set `sourcemaps.delete: false` to keep them."
95
100
  }
96
101
  };
97
102
  case "hidden":
@@ -99,17 +104,17 @@ function decideSourceMapHandling(kind, options, uploadPossible, environment) {
99
104
  return {
100
105
  enableHidden: false,
101
106
  deleteAfterUpload: true,
102
- removeAllSourceMaps: sdkEnabledSourceMaps
107
+ removeAllSourceMaps: sdkRemovesAll
103
108
  };
104
109
  case "visible":
105
110
  if (deleteOption !== true) return NO_CHANGE;
106
111
  return {
107
112
  enableHidden: true,
108
113
  deleteAfterUpload: true,
109
- removeAllSourceMaps: sdkEnabledSourceMaps,
114
+ removeAllSourceMaps: sdkRemovesAll,
110
115
  log: {
111
116
  level: "info",
112
- message: "Switching to hidden source maps because `sourcemaps.deleteSourcemapsAfterUpload` is set. Without the `sourceMappingURL` comment browsers do not request the removed map files."
117
+ message: fromUser ? "Switching to hidden source maps because `sourcemaps.deleteSourcemapsAfterUpload` is set. Without the `sourceMappingURL` comment browsers do not request the removed map files." : "Switching to hidden source maps, because the Sentry SDK removes them from the build output. Without the `sourceMappingURL` comment browsers do not request the removed map files."
113
118
  }
114
119
  };
115
120
  }
@@ -171,6 +176,6 @@ function decideWithDeleteOption(kind, deleteSourceMaps, features, uploadPossible
171
176
  };
172
177
  }
173
178
  }
174
- export { decideSourceMapHandling, getDeleteOption, getDeleteSourcemapsAfterUpload, getSdkEnabledSourceMaps, getSourceMapFeatures };
179
+ export { decideSourceMapHandling, getDeleteOption, getSdkDeleteSourceMaps, getSourceMapFeatures };
175
180
 
176
181
  //# sourceMappingURL=sourcemap-settings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sourcemap-settings.js","names":[],"sources":["../../../src/core/sourcemap-settings.ts"],"sourcesContent":["import { resolveSourceMapsFeatures } from '@sentry/core';\nimport type { NormalizedOptions } from './options-mapping';\n\n/**\n * The user's source map setting in the bundler, reduced to what matters for upload and deletion.\n *\n * - `unset`: the user did not configure source maps\n * - `off`: source map generation is turned off\n * - `visible`: separate map files with a `sourceMappingURL` comment\n * - `hidden`: separate map files without the comment\n * - `inline`: the map is embedded into the bundle\n */\nexport type SourceMapKind = 'unset' | 'off' | 'visible' | 'hidden' | 'inline';\n\nexport type SourceMapDecision = {\n /** Switch the bundler to hidden source maps. */\n enableHidden: boolean;\n /** Remove the source maps from the build output once they are uploaded. */\n deleteAfterUpload: boolean;\n /**\n * With `deleteAfterUpload`, remove every source map of the build, also those of CSS and of chunks\n * the upload leaves out. Set when the plugin or the SDK turned the source maps on.\n */\n removeAllSourceMaps?: boolean;\n log?: { level: 'info' | 'warn'; message: string };\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\nconst SOURCE_MAPS_OFF_MESSAGE =\n 'Source map generation is turned off in your bundler, so Sentry cannot un-minify your stack traces. ' +\n 'Remove the setting to let the plugin generate hidden source maps, upload them to Sentry and remove them from the build output.';\n\nconst INLINE_SOURCE_MAPS_MESSAGE =\n 'Source maps are inlined into your bundles. They are uploaded to Sentry, but inline source maps ship your source code to users and cannot be removed after the upload. ' +\n 'Remove the setting to let the plugin generate hidden source maps instead.';\n\nexport type SourceMapFeatures = {\n /** The plugin adds debug IDs to the bundles and their source maps. */\n injectDebugIds: boolean;\n /** The plugin uploads the source maps. Never `true` without `injectDebugIds`. */\n upload: boolean;\n /**\n * The plugin writes the debug IDs into the emitted files and source maps. The upload only stamps\n * temp copies, so without an upload the emitted files get them and a later manual upload needs\n * no inject step.\n */\n stampEmittedFiles: boolean;\n};\n\n/**\n * Reads `sourcemaps.upload` and `sourcemaps.injectDebugIds`. When neither is set,\n * `sourcemaps.disable` decides.\n */\nexport function getSourceMapFeatures(options: NormalizedOptions): SourceMapFeatures {\n const { injectDebugIds, upload } = resolveSourceMapsFeatures(options.sourcemaps);\n\n return { injectDebugIds, upload, stampEmittedFiles: injectDebugIds && !upload };\n}\n\n/** Reads `sourcemaps.deleteSourcemapsAfterUpload`, calling the internal function form if given. */\nexport function getDeleteSourcemapsAfterUpload(options: NormalizedOptions, environment?: string): boolean | undefined {\n const value = options.sourcemaps?.deleteSourcemapsAfterUpload;\n return typeof value === 'function' ? value(environment) : value;\n}\n\n/** Reads `sourcemaps.delete`. When it is unset, `sourcemaps.deleteSourcemapsAfterUpload` decides. */\nexport function getDeleteOption(options: NormalizedOptions, environment?: string): boolean | undefined {\n return options.sourcemaps?.delete ?? getDeleteSourcemapsAfterUpload(options, environment);\n}\n\n/** Reads the internal `sourcemaps.sdkEnabledSourceMaps` option, calling its function form if given. */\nexport function getSdkEnabledSourceMaps(options: NormalizedOptions, environment?: string): boolean {\n const value = options.sourcemaps?.sdkEnabledSourceMaps;\n return (typeof value === 'function' ? value(environment) : value) === true;\n}\n\n/**\n * Decides whether the plugin turns hidden source maps on and whether it removes the maps from the\n * build output after the upload. The plugin only turns maps on when an upload can run, and only\n * removes maps it turned on itself unless `deleteSourcemapsAfterUpload` says otherwise.\n */\nexport function decideSourceMapHandling(\n kind: SourceMapKind,\n options: NormalizedOptions,\n uploadPossible: boolean,\n environment?: string,\n): SourceMapDecision {\n const features = getSourceMapFeatures(options);\n\n if (options.sourcemaps?.delete !== undefined) {\n return decideWithDeleteOption(kind, options.sourcemaps.delete, features, uploadPossible);\n }\n\n const deleteOption = getDeleteSourcemapsAfterUpload(options, environment);\n const sdkEnabledSourceMaps = getSdkEnabledSourceMaps(options, environment);\n\n if (!uploadPossible || !features.upload) {\n if (deleteOption !== true || (kind !== 'hidden' && kind !== 'visible')) {\n return NO_CHANGE;\n }\n // Users switch the upload off to upload the maps themselves. Maps the\n // SDK turned on are still removed, as the SDKs' own globs did.\n if (!features.upload && !sdkEnabledSourceMaps) {\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message: `\\`sourcemaps.deleteSourcemapsAfterUpload\\` is set, but source map upload is disabled with ${\n resolveSourceMapsFeatures(options.sourcemaps).legacyDisable\n ? '`sourcemaps.disable`'\n : '`sourcemaps.upload` or `sourcemaps.injectDebugIds`'\n }, so the source maps are not removed.`,\n },\n };\n }\n return {\n enableHidden: kind === 'visible',\n deleteAfterUpload: true,\n removeAllSourceMaps: sdkEnabledSourceMaps,\n log: {\n level: 'warn',\n message:\n 'Source maps are not uploaded, but they are removed from the build output because `sourcemaps.deleteSourcemapsAfterUpload` is set.',\n },\n };\n }\n\n switch (kind) {\n case 'off':\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message: SOURCE_MAPS_OFF_MESSAGE,\n },\n };\n\n case 'inline':\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message: INLINE_SOURCE_MAPS_MESSAGE,\n },\n };\n\n case 'unset':\n if (deleteOption === false) {\n return {\n enableHidden: true,\n deleteAfterUpload: false,\n log: {\n level: 'info',\n message: 'Enabling hidden source maps. They are uploaded to Sentry and kept in the build output.',\n },\n };\n }\n return {\n enableHidden: true,\n deleteAfterUpload: true,\n removeAllSourceMaps: true,\n log: {\n level: 'info',\n message:\n 'Enabling hidden source maps. They are uploaded to Sentry and removed from the build output. ' +\n 'Set `sourcemaps.deleteSourcemapsAfterUpload: false` to keep them.',\n },\n };\n\n case 'hidden':\n if (deleteOption !== true) {\n return NO_CHANGE;\n }\n return { enableHidden: false, deleteAfterUpload: true, removeAllSourceMaps: sdkEnabledSourceMaps };\n\n case 'visible':\n if (deleteOption !== true) {\n return NO_CHANGE;\n }\n return {\n enableHidden: true,\n deleteAfterUpload: true,\n removeAllSourceMaps: sdkEnabledSourceMaps,\n log: {\n level: 'info',\n message:\n 'Switching to hidden source maps because `sourcemaps.deleteSourcemapsAfterUpload` is set. ' +\n 'Without the `sourceMappingURL` comment browsers do not request the removed map files.',\n },\n };\n }\n}\n\n/**\n * The decision when `sourcemaps.delete` is set. Unlike `deleteSourcemapsAfterUpload`, it does not\n * depend on an upload: `true` removes every source map of the build, and `false` keeps the hidden\n * source maps the plugin turns on, also when nothing is uploaded.\n */\nfunction decideWithDeleteOption(\n kind: SourceMapKind,\n deleteSourceMaps: boolean,\n features: SourceMapFeatures,\n uploadPossible: boolean,\n): SourceMapDecision {\n switch (kind) {\n case 'off':\n return uploadPossible ? { ...NO_CHANGE, log: { level: 'warn', message: SOURCE_MAPS_OFF_MESSAGE } } : NO_CHANGE;\n\n case 'inline':\n return uploadPossible ? { ...NO_CHANGE, log: { level: 'warn', message: INLINE_SOURCE_MAPS_MESSAGE } } : NO_CHANGE;\n\n case 'unset':\n if (deleteSourceMaps) {\n // Maps that are only turned on to be removed again are not turned on.\n return uploadPossible\n ? {\n enableHidden: true,\n deleteAfterUpload: true,\n removeAllSourceMaps: true,\n log: {\n level: 'info',\n message: 'Enabling hidden source maps. They are uploaded to Sentry and removed from the build output.',\n },\n }\n : NO_CHANGE;\n }\n // Without debug IDs the maps are of no use to Sentry.\n if (!features.injectDebugIds) {\n return NO_CHANGE;\n }\n return {\n enableHidden: true,\n deleteAfterUpload: false,\n log: {\n level: 'info',\n message: uploadPossible\n ? 'Enabling hidden source maps. They are uploaded to Sentry and kept in the build output.'\n : 'Enabling hidden source maps. They are not uploaded to Sentry and are kept in the build output, because `sourcemaps.delete` is `false`.',\n },\n };\n\n case 'hidden':\n case 'visible':\n if (!deleteSourceMaps) {\n return NO_CHANGE;\n }\n return {\n enableHidden: kind === 'visible',\n deleteAfterUpload: true,\n removeAllSourceMaps: true,\n log: uploadPossible\n ? kind === 'visible'\n ? {\n level: 'info',\n message:\n 'Switching to hidden source maps because `sourcemaps.delete` is set. ' +\n 'Without the `sourceMappingURL` comment browsers do not request the removed map files.',\n }\n : undefined\n : {\n level: 'warn',\n message:\n 'Source maps are not uploaded, but they are removed from the build output because `sourcemaps.delete` is set.',\n },\n };\n }\n}\n"],"mappings":";;AA2BA,MAAM,YAA+B;CAAE,cAAc;CAAO,mBAAmB;AAAM;AAErF,MAAM,0BACJ;AAGF,MAAM,6BACJ;;;;;AAoBF,SAAgB,qBAAqB,SAA+C;CAClF,MAAM,EAAE,gBAAgB,WAAW,0BAA0B,QAAQ,UAAU;CAE/E,OAAO;EAAE;EAAgB;EAAQ,mBAAmB,kBAAkB,CAAC;CAAO;AAChF;;AAGA,SAAgB,+BAA+B,SAA4B,aAA2C;CACpH,MAAM,QAAQ,QAAQ,YAAY;CAClC,OAAO,OAAO,UAAU,aAAa,MAAM,WAAW,IAAI;AAC5D;;AAGA,SAAgB,gBAAgB,SAA4B,aAA2C;CACrG,OAAO,QAAQ,YAAY,UAAU,+BAA+B,SAAS,WAAW;AAC1F;;AAGA,SAAgB,wBAAwB,SAA4B,aAA+B;CACjG,MAAM,QAAQ,QAAQ,YAAY;CAClC,QAAQ,OAAO,UAAU,aAAa,MAAM,WAAW,IAAI,WAAW;AACxE;;;;;;AAOA,SAAgB,wBACd,MACA,SACA,gBACA,aACmB;CACnB,MAAM,WAAW,qBAAqB,OAAO;CAE7C,IAAI,QAAQ,YAAY,WAAW,KAAA,GACjC,OAAO,uBAAuB,MAAM,QAAQ,WAAW,QAAQ,UAAU,cAA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wB;EAAE,IAAI;EAEvG,KAAK,UACH,OAAO,iBAAiB;GAAE,GAAG;GAAW,KAAK;IAAE,OAAO;IAAQ,SAAS;GAA2B;EAAE,IAAI;EAE1G,KAAK;GACH,IAAI,kBAEF,OAAO,iBACH;IACE,cAAc;IACd,mBAAmB;IACnB,qBAAqB;IACrB,KAAK;KACH,OAAO;KACP,SAAS;IACX;GACF,IACA;GAGN,IAAI,CAAC,SAAS,gBACZ,OAAO;GAET,OAAO;IACL,cAAc;IACd,mBAAmB;IACnB,KAAK;KACH,OAAO;KACP,SAAS,iBACL,2FACA;IACN;GACF;EAEF,KAAK;EACL,KAAK;GACH,IAAI,CAAC,kBACH,OAAO;GAET,OAAO;IACL,cAAc,SAAS;IACvB,mBAAmB;IACnB,qBAAqB;IACrB,KAAK,iBACD,SAAS,YACP;KACE,OAAO;KACP,SACE;IAEJ,IACA,KAAA,IACF;KACE,OAAO;KACP,SACE;IACJ;GACN;CACJ;AACF"}
1
+ {"version":3,"file":"sourcemap-settings.js","names":[],"sources":["../../../src/core/sourcemap-settings.ts"],"sourcesContent":["import { resolveSourceMapsFeatures } from '@sentry/core';\nimport type { NormalizedOptions } from './options-mapping';\n\n/**\n * The user's source map setting in the bundler, reduced to what matters for upload and deletion.\n *\n * - `unset`: the user did not configure source maps\n * - `off`: source map generation is turned off\n * - `visible`: separate map files with a `sourceMappingURL` comment\n * - `hidden`: separate map files without the comment\n * - `inline`: the map is embedded into the bundle\n */\nexport type SourceMapKind = 'unset' | 'off' | 'visible' | 'hidden' | 'inline';\n\nexport type SourceMapDecision = {\n /** Switch the bundler to hidden source maps. */\n enableHidden: boolean;\n /** Remove the source maps from the build output once they are uploaded. */\n deleteAfterUpload: boolean;\n /**\n * With `deleteAfterUpload`, remove every source map of the build, also those of CSS and of chunks\n * the upload leaves out. Set when the plugin or the SDK turned the source maps on.\n */\n removeAllSourceMaps?: boolean;\n log?: { level: 'info' | 'warn'; message: string };\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\nconst SOURCE_MAPS_OFF_MESSAGE =\n 'Source map generation is turned off in your bundler, so Sentry cannot un-minify your stack traces. ' +\n 'Remove the setting to let the plugin generate hidden source maps, upload them to Sentry and remove them from the build output.';\n\nconst INLINE_SOURCE_MAPS_MESSAGE =\n 'Source maps are inlined into your bundles. They are uploaded to Sentry, but inline source maps ship your source code to users and cannot be removed after the upload. ' +\n 'Remove the setting to let the plugin generate hidden source maps instead.';\n\nexport type SourceMapFeatures = {\n /** The plugin adds debug IDs to the bundles and their source maps. */\n injectDebugIds: boolean;\n /** The plugin uploads the source maps. Never `true` without `injectDebugIds`. */\n upload: boolean;\n /**\n * The plugin writes the debug IDs into the emitted files and source maps. The upload only stamps\n * temp copies, so without an upload the emitted files get them and a later manual upload needs\n * no inject step.\n */\n stampEmittedFiles: boolean;\n};\n\n/**\n * Reads `sourcemaps.upload` and `sourcemaps.injectDebugIds`. When neither is set,\n * `sourcemaps.disable` decides.\n */\nexport function getSourceMapFeatures(options: NormalizedOptions): SourceMapFeatures {\n const { injectDebugIds, upload } = resolveSourceMapsFeatures(options.sourcemaps);\n\n return { injectDebugIds, upload, stampEmittedFiles: injectDebugIds && !upload };\n}\n\n/** Reads the internal `sourcemaps.sdkDeleteSourceMaps` option, calling its function form if given. */\nexport function getSdkDeleteSourceMaps(options: NormalizedOptions, environment?: string): boolean | undefined {\n const value = options.sourcemaps?.sdkDeleteSourceMaps;\n return typeof value === 'function' ? value(environment) : value;\n}\n\n/**\n * Reads `sourcemaps.delete`. When it is unset, `sourcemaps.deleteSourcemapsAfterUpload` decides, and\n * then the SDK.\n */\nexport function getDeleteOption(options: NormalizedOptions, environment?: string): boolean | undefined {\n return (\n options.sourcemaps?.delete ??\n options.sourcemaps?.deleteSourcemapsAfterUpload ??\n getSdkDeleteSourceMaps(options, environment)\n );\n}\n\n/**\n * Decides whether the plugin turns hidden source maps on and whether it removes the maps from the\n * build output after the upload. The plugin only turns maps on when an upload can run, and only\n * removes maps it turned on itself unless `deleteSourcemapsAfterUpload` or the SDK's\n * `sdkDeleteSourceMaps` says otherwise. The user's `deleteSourcemapsAfterUpload` wins over the SDK.\n */\nexport function decideSourceMapHandling(\n kind: SourceMapKind,\n options: NormalizedOptions,\n uploadPossible: boolean,\n environment?: string,\n): SourceMapDecision {\n const features = getSourceMapFeatures(options);\n\n if (options.sourcemaps?.delete !== undefined) {\n return decideWithDeleteOption(kind, options.sourcemaps.delete, features, uploadPossible);\n }\n\n const userDeleteOption = options.sourcemaps?.deleteSourcemapsAfterUpload;\n const sdkDeleteOption = getSdkDeleteSourceMaps(options, environment);\n const deleteOption = userDeleteOption ?? sdkDeleteOption;\n const sdkRemovesAll = sdkDeleteOption === true;\n const fromUser = userDeleteOption !== undefined;\n\n if (!uploadPossible || !features.upload) {\n if (deleteOption !== true || (kind !== 'hidden' && kind !== 'visible')) {\n return NO_CHANGE;\n }\n // Users switch the upload off to upload the maps themselves. The SDK's\n // deletion still runs, as the SDKs' own globs did.\n if (!features.upload && !sdkRemovesAll) {\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message: `\\`sourcemaps.deleteSourcemapsAfterUpload\\` is set, but source map upload is disabled with ${\n resolveSourceMapsFeatures(options.sourcemaps).legacyDisable\n ? '`sourcemaps.disable`'\n : '`sourcemaps.upload` or `sourcemaps.injectDebugIds`'\n }, so the source maps are not removed.`,\n },\n };\n }\n return {\n enableHidden: kind === 'visible',\n deleteAfterUpload: true,\n removeAllSourceMaps: sdkRemovesAll,\n log: fromUser\n ? {\n level: 'warn',\n message:\n 'Source maps are not uploaded, but they are removed from the build output because `sourcemaps.deleteSourcemapsAfterUpload` is set.',\n }\n : {\n level: 'info',\n message: 'Source maps are not uploaded, but the Sentry SDK removes them from the build output.',\n },\n };\n }\n\n switch (kind) {\n case 'off':\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message: SOURCE_MAPS_OFF_MESSAGE,\n },\n };\n\n case 'inline':\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message: INLINE_SOURCE_MAPS_MESSAGE,\n },\n };\n\n case 'unset':\n if (deleteOption === false) {\n return {\n enableHidden: true,\n deleteAfterUpload: false,\n log: {\n level: 'info',\n message: 'Enabling hidden source maps. They are uploaded to Sentry and kept in the build output.',\n },\n };\n }\n return {\n enableHidden: true,\n deleteAfterUpload: true,\n removeAllSourceMaps: true,\n log: {\n level: 'info',\n message:\n 'Enabling hidden source maps. They are uploaded to Sentry and removed from the build output. ' +\n 'Set `sourcemaps.delete: false` to keep them.',\n },\n };\n\n case 'hidden':\n if (deleteOption !== true) {\n return NO_CHANGE;\n }\n return { enableHidden: false, deleteAfterUpload: true, removeAllSourceMaps: sdkRemovesAll };\n\n case 'visible':\n if (deleteOption !== true) {\n return NO_CHANGE;\n }\n return {\n enableHidden: true,\n deleteAfterUpload: true,\n removeAllSourceMaps: sdkRemovesAll,\n log: {\n level: 'info',\n message: fromUser\n ? 'Switching to hidden source maps because `sourcemaps.deleteSourcemapsAfterUpload` is set. ' +\n 'Without the `sourceMappingURL` comment browsers do not request the removed map files.'\n : 'Switching to hidden source maps, because the Sentry SDK removes them from the build output. ' +\n 'Without the `sourceMappingURL` comment browsers do not request the removed map files.',\n },\n };\n }\n}\n\n/**\n * The decision when `sourcemaps.delete` is set. Unlike `deleteSourcemapsAfterUpload`, it does not\n * depend on an upload: `true` removes every source map of the build, and `false` keeps the hidden\n * source maps the plugin turns on, also when nothing is uploaded.\n */\nfunction decideWithDeleteOption(\n kind: SourceMapKind,\n deleteSourceMaps: boolean,\n features: SourceMapFeatures,\n uploadPossible: boolean,\n): SourceMapDecision {\n switch (kind) {\n case 'off':\n return uploadPossible ? { ...NO_CHANGE, log: { level: 'warn', message: SOURCE_MAPS_OFF_MESSAGE } } : NO_CHANGE;\n\n case 'inline':\n return uploadPossible ? { ...NO_CHANGE, log: { level: 'warn', message: INLINE_SOURCE_MAPS_MESSAGE } } : NO_CHANGE;\n\n case 'unset':\n if (deleteSourceMaps) {\n // Maps that are only turned on to be removed again are not turned on.\n return uploadPossible\n ? {\n enableHidden: true,\n deleteAfterUpload: true,\n removeAllSourceMaps: true,\n log: {\n level: 'info',\n message: 'Enabling hidden source maps. They are uploaded to Sentry and removed from the build output.',\n },\n }\n : NO_CHANGE;\n }\n // Without debug IDs the maps are of no use to Sentry.\n if (!features.injectDebugIds) {\n return NO_CHANGE;\n }\n return {\n enableHidden: true,\n deleteAfterUpload: false,\n log: {\n level: 'info',\n message: uploadPossible\n ? 'Enabling hidden source maps. They are uploaded to Sentry and kept in the build output.'\n : 'Enabling hidden source maps. They are not uploaded to Sentry and are kept in the build output, because `sourcemaps.delete` is `false`.',\n },\n };\n\n case 'hidden':\n case 'visible':\n if (!deleteSourceMaps) {\n return NO_CHANGE;\n }\n return {\n enableHidden: kind === 'visible',\n deleteAfterUpload: true,\n removeAllSourceMaps: true,\n log: uploadPossible\n ? kind === 'visible'\n ? {\n level: 'info',\n message:\n 'Switching to hidden source maps because `sourcemaps.delete` is set. ' +\n 'Without the `sourceMappingURL` comment browsers do not request the removed map files.',\n }\n : undefined\n : {\n level: 'warn',\n message:\n 'Source maps are not uploaded, but they are removed from the build output because `sourcemaps.delete` is set.',\n },\n };\n }\n}\n"],"mappings":";;AA2BA,MAAM,YAA+B;CAAE,cAAc;CAAO,mBAAmB;AAAM;AAErF,MAAM,0BACJ;AAGF,MAAM,6BACJ;;;;;AAoBF,SAAgB,qBAAqB,SAA+C;CAClF,MAAM,EAAE,gBAAgB,WAAW,0BAA0B,QAAQ,UAAU;CAE/E,OAAO;EAAE;EAAgB;EAAQ,mBAAmB,kBAAkB,CAAC;CAAO;AAChF;;AAGA,SAAgB,uBAAuB,SAA4B,aAA2C;CAC5G,MAAM,QAAQ,QAAQ,YAAY;CAClC,OAAO,OAAO,UAAU,aAAa,MAAM,WAAW,IAAI;AAC5D;;;;;AAMA,SAAgB,gBAAgB,SAA4B,aAA2C;CACrG,OACE,QAAQ,YAAY,UACpB,QAAQ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Ac;IAAO,mBAAmB;IAAM,qBAAqB;GAAc;EAE5F,KAAK;GACH,IAAI,iBAAiB,MACnB,OAAO;GAET,OAAO;IACL,cAAc;IACd,mBAAmB;IACnB,qBAAqB;IACrB,KAAK;KACH,OAAO;KACP,SAAS,WACL,mLAEA;IAEN;GACF;CACJ;AACF;;;;;;AAOA,SAAS,uBACP,MACA,kBACA,UACA,gBACmB;CACnB,QAAQ,MAAR;EACE,KAAK,OACH,OAAO,iBAAiB;GAAE,GAAG;GAAW,KAAK;IAAE,OAAO;IAAQ,SAAS;GAAwB;EAAE,IAAI;EAEvG,KAAK,UACH,OAAO,iBAAiB;GAAE,GAAG;GAAW,KAAK;IAAE,OAAO;IAAQ,SAAS;GAA2B;EAAE,IAAI;EAE1G,KAAK;GACH,IAAI,kBAEF,OAAO,iBACH;IACE,cAAc;IACd,mBAAmB;IACnB,qBAAqB;IACrB,KAAK;KACH,OAAO;KACP,SAAS;IACX;GACF,IACA;GAGN,IAAI,CAAC,SAAS,gBACZ,OAAO;GAET,OAAO;IACL,cAAc;IACd,mBAAmB;IACnB,KAAK;KACH,OAAO;KACP,SAAS,iBACL,2FACA;IACN;GACF;EAEF,KAAK;EACL,KAAK;GACH,IAAI,CAAC,kBACH,OAAO;GAET,OAAO;IACL,cAAc,SAAS;IACvB,mBAAmB;IACnB,qBAAqB;IACrB,KAAK,iBACD,SAAS,YACP;KACE,OAAO;KACP,SACE;IAEJ,IACA,KAAA,IACF;KACE,OAAO;KACP,SACE;IACJ;GACN;CACJ;AACF"}
@@ -1,5 +1,5 @@
1
1
  // src/core/version.ts
2
- const LIB_VERSION = "11.18.0";
2
+ const LIB_VERSION = "11.20.0";
3
3
  export { LIB_VERSION };
4
4
 
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.18.0\";\n"],"mappings":";AAAA,MAAa,cAAc"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.20.0\";\n"],"mappings":";AAAA,MAAa,cAAc"}
@@ -1 +1 @@
1
- {"type":"module","version":"11.18.0","sideEffects":["./sentry-release-injection-file.js","./sentry-esbuild-debugid-injection-file.js"]}
1
+ {"type":"module","version":"11.20.0","sideEffects":["./sentry-release-injection-file.js","./sentry-esbuild-debugid-injection-file.js"]}
@@ -0,0 +1,25 @@
1
+ // src/rewriter/arrays.ts
2
+ /**
3
+ * Replace an array literal of identifiers with `build(names)`, where `names`
4
+ * holds each identifier once, in source order. An empty array is left alone.
5
+ * An array holding anything other than plain identifiers is left alone and
6
+ * recorded as skipped under `label`.
7
+ *
8
+ * @returns whether the array was replaced
9
+ */
10
+ function wrapArrayLiteral(state, arrayNode, label, build) {
11
+ const elements = arrayNode.elements ?? [];
12
+ if (elements.length === 0) return false;
13
+ if (!elements.every((element) => element?.type === "Identifier")) {
14
+ state.report.skipped.push(label);
15
+ return false;
16
+ }
17
+ const names = [...new Set(elements.map((element) => element.name))];
18
+ state.ms.overwrite(arrayNode.start, arrayNode.end, build(names));
19
+ state.needsImport = true;
20
+ state.report.wrapped.push(label);
21
+ return true;
22
+ }
23
+ export { wrapArrayLiteral };
24
+
25
+ //# sourceMappingURL=arrays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrays.js","names":[],"sources":["../../../src/rewriter/arrays.ts"],"sourcesContent":["import type { ArrayExpressionNode, BaseNode, IdentifierNode } from './ast';\nimport type { RewriteState } from './rewriter';\n\n/**\n * Replace an array literal of identifiers with `build(names)`, where `names`\n * holds each identifier once, in source order. An empty array is left alone.\n * An array holding anything other than plain identifiers is left alone and\n * recorded as skipped under `label`.\n *\n * @returns whether the array was replaced\n */\nexport function wrapArrayLiteral(\n state: RewriteState,\n arrayNode: BaseNode,\n label: string,\n build: (names: string[]) => string,\n): boolean {\n const elements = (arrayNode as ArrayExpressionNode).elements ?? [];\n if (elements.length === 0) return false;\n\n if (!elements.every(element => element?.type === 'Identifier')) {\n state.report.skipped.push(label);\n return false;\n }\n\n const names = [...new Set(elements.map(element => (element as IdentifierNode).name))];\n state.ms.overwrite(arrayNode.start, arrayNode.end, build(names));\n state.needsImport = true;\n state.report.wrapped.push(label);\n return true;\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,iBACd,OACA,WACA,OACA,OACS;CACT,MAAM,WAAY,UAAkC,YAAY,CAAC;CACjE,IAAI,SAAS,WAAW,GAAG,OAAO;CAElC,IAAI,CAAC,SAAS,OAAM,YAAW,SAAS,SAAS,YAAY,GAAG;EAC9D,MAAM,OAAO,QAAQ,KAAK,KAAK;EAC/B,OAAO;CACT;CAEA,MAAM,QAAQ,CAAC,GAAG,IAAI,IAAI,SAAS,KAAI,YAAY,QAA2B,IAAI,CAAC,CAAC;CACpF,MAAM,GAAG,UAAU,UAAU,OAAO,UAAU,KAAK,MAAM,KAAK,CAAC;CAC/D,MAAM,cAAc;CACpB,MAAM,OAAO,QAAQ,KAAK,KAAK;CAC/B,OAAO;AACT"}