@sentry/bundler-plugins 11.10.0 → 11.12.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 (84) hide show
  1. package/build/cjs/core/build-plugin-manager.js +184 -33
  2. package/build/cjs/core/build-plugin-manager.js.map +1 -1
  3. package/build/cjs/core/debug-id-upload.js +63 -54
  4. package/build/cjs/core/debug-id-upload.js.map +1 -1
  5. package/build/cjs/core/index.js +2 -0
  6. package/build/cjs/core/index.js.map +1 -1
  7. package/build/cjs/core/options-mapping.js +6 -0
  8. package/build/cjs/core/options-mapping.js.map +1 -1
  9. package/build/cjs/core/sentry/telemetry.js +4 -0
  10. package/build/cjs/core/sentry/telemetry.js.map +1 -1
  11. package/build/cjs/core/sourcemap-settings.js +63 -0
  12. package/build/cjs/core/sourcemap-settings.js.map +1 -0
  13. package/build/cjs/core/upload-filter.js +57 -0
  14. package/build/cjs/core/upload-filter.js.map +1 -0
  15. package/build/cjs/core/version.js +1 -1
  16. package/build/cjs/core/version.js.map +1 -1
  17. package/build/cjs/esbuild/index.js +3 -2
  18. package/build/cjs/esbuild/index.js.map +1 -1
  19. package/build/cjs/rollup/index.js +49 -9
  20. package/build/cjs/rollup/index.js.map +1 -1
  21. package/build/cjs/rollup/source-map-handling.js +202 -0
  22. package/build/cjs/rollup/source-map-handling.js.map +1 -0
  23. package/build/cjs/vite/index.js +4 -18
  24. package/build/cjs/vite/index.js.map +1 -1
  25. package/build/cjs/vite/source-map-hooks.js +93 -0
  26. package/build/cjs/vite/source-map-hooks.js.map +1 -0
  27. package/build/cjs/webpack/index.js +113 -1
  28. package/build/cjs/webpack/index.js.map +1 -1
  29. package/build/esm/core/build-plugin-manager.js +185 -34
  30. package/build/esm/core/build-plugin-manager.js.map +1 -1
  31. package/build/esm/core/debug-id-upload.js +62 -56
  32. package/build/esm/core/debug-id-upload.js.map +1 -1
  33. package/build/esm/core/index.js +1 -0
  34. package/build/esm/core/index.js.map +1 -1
  35. package/build/esm/core/options-mapping.js +6 -0
  36. package/build/esm/core/options-mapping.js.map +1 -1
  37. package/build/esm/core/sentry/telemetry.js +4 -0
  38. package/build/esm/core/sentry/telemetry.js.map +1 -1
  39. package/build/esm/core/sourcemap-settings.js +61 -0
  40. package/build/esm/core/sourcemap-settings.js.map +1 -0
  41. package/build/esm/core/upload-filter.js +41 -0
  42. package/build/esm/core/upload-filter.js.map +1 -0
  43. package/build/esm/core/version.js +1 -1
  44. package/build/esm/core/version.js.map +1 -1
  45. package/build/esm/esbuild/index.js +3 -2
  46. package/build/esm/esbuild/index.js.map +1 -1
  47. package/build/esm/package.json +1 -1
  48. package/build/esm/rollup/index.js +49 -10
  49. package/build/esm/rollup/index.js.map +1 -1
  50. package/build/esm/rollup/source-map-handling.js +183 -0
  51. package/build/esm/rollup/source-map-handling.js.map +1 -0
  52. package/build/esm/vite/index.js +5 -19
  53. package/build/esm/vite/index.js.map +1 -1
  54. package/build/esm/vite/source-map-hooks.js +77 -0
  55. package/build/esm/vite/source-map-hooks.js.map +1 -0
  56. package/build/esm/webpack/index.js +114 -2
  57. package/build/esm/webpack/index.js.map +1 -1
  58. package/build/types/core/build-plugin-manager.d.ts +69 -1
  59. package/build/types/core/build-plugin-manager.d.ts.map +1 -1
  60. package/build/types/core/debug-id-upload.d.ts +38 -2
  61. package/build/types/core/debug-id-upload.d.ts.map +1 -1
  62. package/build/types/core/index.d.ts +4 -0
  63. package/build/types/core/index.d.ts.map +1 -1
  64. package/build/types/core/options-mapping.d.ts +1 -0
  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 +28 -0
  68. package/build/types/core/sourcemap-settings.d.ts.map +1 -0
  69. package/build/types/core/types.d.ts +18 -0
  70. package/build/types/core/types.d.ts.map +1 -1
  71. package/build/types/core/upload-filter.d.ts +9 -0
  72. package/build/types/core/upload-filter.d.ts.map +1 -0
  73. package/build/types/core/version.d.ts +1 -1
  74. package/build/types/esbuild/index.d.ts.map +1 -1
  75. package/build/types/rollup/index.d.ts +106 -6
  76. package/build/types/rollup/index.d.ts.map +1 -1
  77. package/build/types/rollup/source-map-handling.d.ts +59 -0
  78. package/build/types/rollup/source-map-handling.d.ts.map +1 -0
  79. package/build/types/vite/index.d.ts +1 -5
  80. package/build/types/vite/index.d.ts.map +1 -1
  81. package/build/types/vite/source-map-hooks.d.ts +45 -0
  82. package/build/types/vite/source-map-hooks.d.ts.map +1 -0
  83. package/build/types/webpack/index.d.ts.map +1 -1
  84. package/package.json +43 -41
@@ -0,0 +1,93 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const path = require('node:path');
4
+ const sourceMapHandling = require('../rollup/source-map-handling.js');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
9
+ if (e) {
10
+ for (const k in e) {
11
+ n[k] = e[k];
12
+ }
13
+ }
14
+ n.default = e;
15
+ return n;
16
+ }
17
+
18
+ const path__namespace = /*#__PURE__*/_interopNamespace(path);
19
+
20
+ const NO_CHANGE = { enableHidden: false, deleteAfterUpload: false };
21
+ function getOutputs(root, build) {
22
+ const configured = build.rolldownOptions?.output ?? build.rollupOptions?.output;
23
+ const outputs = Array.isArray(configured) ? configured : [configured ?? {}];
24
+ return outputs.map((output) => {
25
+ const sourcemap = output.sourcemap ?? build.sourcemap;
26
+ return {
27
+ destination: output.dir === void 0 ? path__namespace.resolve(root, build.outDir ?? "dist") : path__namespace.resolve(output.dir),
28
+ match: sourceMapHandling.getOutputMatch({ ...output, sourcemap }),
29
+ sourcemap,
30
+ ownSetting: output.sourcemap !== void 0
31
+ };
32
+ });
33
+ }
34
+ function createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling$1) {
35
+ const decisions = /* @__PURE__ */ new Map();
36
+ return {
37
+ config: (userConfig, env) => {
38
+ if (env.command !== "build") {
39
+ return null;
40
+ }
41
+ decisions.clear();
42
+ const kind = sourceMapHandling.sourceMapKindFromRollupSetting(userConfig.build?.sourcemap);
43
+ const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });
44
+ decisions.set("*", { kind, decision });
45
+ const result = decision.enableHidden ? { build: { sourcemap: "hidden" } } : {};
46
+ for (const [name, environment] of Object.entries(userConfig.environments ?? {})) {
47
+ const setting = environment?.build?.sourcemap;
48
+ if (setting === void 0) {
49
+ continue;
50
+ }
51
+ const environmentKind = sourceMapHandling.sourceMapKindFromRollupSetting(setting);
52
+ const environmentDecision = sentryBuildPluginManager.sourceMaps.decide(environmentKind, { log: false });
53
+ decisions.set(name, { kind: environmentKind, decision: environmentDecision });
54
+ if (environmentDecision.enableHidden) {
55
+ result.environments = { ...result.environments, [name]: { build: { sourcemap: "hidden" } } };
56
+ }
57
+ }
58
+ return result;
59
+ },
60
+ configResolved: (config) => {
61
+ const environments = config.environments ?? { client: { build: config.build } };
62
+ const { uploadPossible } = sentryBuildPluginManager.sourceMaps;
63
+ const deleteOption = sentryBuildPluginManager.normalizedOptions.sourcemaps?.deleteSourcemapsAfterUpload;
64
+ for (const [name, environment] of Object.entries(environments)) {
65
+ const { kind, decision } = decisions.get(name) ?? decisions.get("*") ?? { kind: "unset", decision: NO_CHANGE };
66
+ for (const output of getOutputs(config.root, environment.build)) {
67
+ if (output.ownSetting) {
68
+ sourceMapHandling$1.setDecision(output.destination, {
69
+ match: output.match,
70
+ kind: sourceMapHandling.sourceMapKindFromRollupSetting(output.sourcemap),
71
+ decision: {
72
+ enableHidden: false,
73
+ deleteAfterUpload: uploadPossible && deleteOption === true && output.sourcemap === "hidden"
74
+ }
75
+ });
76
+ continue;
77
+ }
78
+ if (decision.deleteAfterUpload && output.sourcemap !== "hidden") {
79
+ sentryBuildPluginManager.logger.debug(
80
+ `Source maps of the "${name}" environment are set to ${JSON.stringify(output.sourcemap)}. Not removing them after upload.`
81
+ );
82
+ sourceMapHandling$1.setDecision(output.destination, { match: output.match, kind, decision: NO_CHANGE });
83
+ } else {
84
+ sourceMapHandling$1.setDecision(output.destination, { match: output.match, kind, decision });
85
+ }
86
+ }
87
+ }
88
+ }
89
+ };
90
+ }
91
+
92
+ exports.createViteSourceMapHooks = createViteSourceMapHooks;
93
+ //# sourceMappingURL=source-map-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-map-hooks.js","sources":["../../../src/vite/source-map-hooks.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { SentryBuildPluginManager, SourceMapDecision, SourceMapKind } from '../core';\nimport type { OutputMatch, RollupSourceMapSetting, SourceMapHandling } from '../rollup/source-map-handling';\nimport { getOutputMatch, sourceMapKindFromRollupSetting } from '../rollup/source-map-handling';\n\ntype BundlerOutput = OutputMatch & { dir?: string; sourcemap?: RollupSourceMapSetting };\ntype BundlerOutputOptions = BundlerOutput | BundlerOutput[] | undefined;\n\ntype ViteBuildOptions = {\n sourcemap?: RollupSourceMapSetting;\n outDir?: string;\n rollupOptions?: { output?: BundlerOutputOptions };\n rolldownOptions?: { output?: BundlerOutputOptions };\n};\n\nexport type ViteUserConfig = {\n build?: ViteBuildOptions;\n environments?: Record<string, { build?: ViteBuildOptions } | undefined>;\n};\n\nexport type ViteResolvedConfig = {\n root: string;\n build: ViteBuildOptions;\n environments?: Record<string, { build: ViteBuildOptions }>;\n};\n\nexport type ViteSourceMapHooks = {\n config: (userConfig: ViteUserConfig, env: { command: string }) => ViteUserConfig | null;\n configResolved: (config: ViteResolvedConfig) => void;\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\ntype EnvironmentOutput = {\n destination: string;\n match: OutputMatch;\n sourcemap: RollupSourceMapSetting;\n /** The output sets `sourcemap` itself, which overrides `build.sourcemap`. */\n ownSetting: boolean;\n};\n\n/**\n * The outputs an environment writes: one per entry of `rollupOptions.output` or\n * `rolldownOptions.output`. An output writes to `build.outDir` (relative to the root) unless it\n * sets its own `dir`, which the bundler resolves from the working directory. An output's own\n * `sourcemap` overrides `build.sourcemap`.\n */\nfunction getOutputs(root: string, build: ViteBuildOptions): EnvironmentOutput[] {\n const configured = build.rolldownOptions?.output ?? build.rollupOptions?.output;\n const outputs = Array.isArray(configured) ? configured : [configured ?? {}];\n\n return outputs.map(output => {\n const sourcemap = output.sourcemap ?? build.sourcemap;\n return {\n destination: output.dir === undefined ? path.resolve(root, build.outDir ?? 'dist') : path.resolve(output.dir),\n match: getOutputMatch({ ...output, sourcemap }),\n sourcemap,\n ownSetting: output.sourcemap !== undefined,\n };\n });\n}\n\n/**\n * Vite warns about `rollupOptions.output.sourcemap`, so the Vite plugin decides on `build.sourcemap`\n * in a `config` hook. The hook belongs on the post plugin: framework plugins that set\n * `build.sourcemap` themselves run first, and the decision sees the merged setting. The output\n * directories are only known in `configResolved`, which then records the decision for each of them.\n */\nexport function createViteSourceMapHooks(\n sentryBuildPluginManager: SentryBuildPluginManager,\n sourceMapHandling: SourceMapHandling,\n): ViteSourceMapHooks {\n // `'*'` for the top-level setting, otherwise the name of an environment with its own.\n const decisions = new Map<string, { kind: SourceMapKind; decision: SourceMapDecision }>();\n\n return {\n config: (userConfig, env) => {\n if (env.command !== 'build') {\n return null;\n }\n\n // The same plugin instances can serve several builds in a row.\n decisions.clear();\n\n const kind = sourceMapKindFromRollupSetting(userConfig.build?.sourcemap);\n // Logged in `generateBundle`, which knows whether the output is written.\n const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });\n decisions.set('*', { kind, decision });\n\n const result: ViteUserConfig = decision.enableHidden ? { build: { sourcemap: 'hidden' } } : {};\n\n for (const [name, environment] of Object.entries(userConfig.environments ?? {})) {\n const setting = environment?.build?.sourcemap;\n if (setting === undefined) {\n continue;\n }\n\n const environmentKind = sourceMapKindFromRollupSetting(setting);\n const environmentDecision = sentryBuildPluginManager.sourceMaps.decide(environmentKind, { log: false });\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 const { uploadPossible } = sentryBuildPluginManager.sourceMaps;\n const deleteOption = sentryBuildPluginManager.normalizedOptions.sourcemaps?.deleteSourcemapsAfterUpload;\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\n for (const output of getOutputs(config.root, environment.build)) {\n // The plugin never changes an output's own setting, so the user enabled\n // these maps: only hidden ones the user asked to delete are removed.\n if (output.ownSetting) {\n sourceMapHandling.setDecision(output.destination, {\n match: output.match,\n kind: sourceMapKindFromRollupSetting(output.sourcemap),\n decision: {\n enableHidden: false,\n deleteAfterUpload: uploadPossible && deleteOption === true && output.sourcemap === 'hidden',\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}\n"],"names":["path","getOutputMatch","sourceMapHandling","sourceMapKindFromRollupSetting"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,MAAM,SAAA,GAA+B,EAAE,YAAA,EAAc,KAAA,EAAO,mBAAmB,KAAA,EAAM;AAgBrF,SAAS,UAAA,CAAW,MAAc,KAAA,EAA8C;AAC9E,EAAA,MAAM,UAAA,GAAa,KAAA,CAAM,eAAA,EAAiB,MAAA,IAAU,MAAM,aAAA,EAAe,MAAA;AACzE,EAAA,MAAM,OAAA,GAAU,MAAM,OAAA,CAAQ,UAAU,IAAI,UAAA,GAAa,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_ASSET_REGEX = /\.(?:js|ts|jsx|tsx|mjs|cjs|mts|cts)(?:\?[^?]*)?(?:#[^#]*)?$/;
38
+ function sourceMapKindFromDevtool(compiler) {
39
+ const devtool = compiler.options.devtool;
40
+ if (devtool === void 0) {
41
+ return "unset";
42
+ }
43
+ if (devtool === false) {
44
+ const hasSourceMapPlugin = compiler.options.plugins?.some(
45
+ (plugin) => plugin?.constructor?.name === "SourceMapDevToolPlugin"
46
+ );
47
+ return hasSourceMapPlugin ? void 0 : "off";
48
+ }
49
+ if (!devtool.includes("source-map")) {
50
+ return "off";
51
+ }
52
+ if (devtool.includes("inline") || devtool.includes("eval")) {
53
+ return "inline";
54
+ }
55
+ if (devtool.includes("hidden")) {
56
+ return "hidden";
57
+ }
58
+ return "visible";
59
+ }
38
60
  function getWebpackMajorVersion() {
39
61
  try {
40
62
  const webpack = _req("webpack");
@@ -63,6 +85,44 @@ function addDebugIdsToAssets(compilation, RawSource) {
63
85
  }
64
86
  }
65
87
  }
88
+ function deleteSourceMapAssets(compilation, sourceMapName) {
89
+ for (const candidate of compilation.getAssets()) {
90
+ if (candidate.name === sourceMapName || candidate.name.startsWith(`${sourceMapName}.`)) {
91
+ compilation.deleteAsset(candidate.name);
92
+ }
93
+ }
94
+ }
95
+ async function stageSourceMaps(compilation, staging, logger, pluginEnabledMaps) {
96
+ const outputPath = compilation.outputOptions.path ?? path__namespace.resolve();
97
+ for (const asset of compilation.getAssets()) {
98
+ const relatedSourceMap = asset.info.related?.sourceMap;
99
+ const sourceMapName = typeof relatedSourceMap === "string" ? relatedSourceMap : `${asset.name}.map`;
100
+ const sourceMapAsset = compilation.getAsset(sourceMapName);
101
+ if (!sourceMapAsset) {
102
+ continue;
103
+ }
104
+ if (!index.isJsFile(asset.name)) {
105
+ if (pluginEnabledMaps) {
106
+ deleteSourceMapAssets(compilation, sourceMapName);
107
+ }
108
+ continue;
109
+ }
110
+ const result = await staging.stage({
111
+ code: asset.source.source().toString(),
112
+ mapSource: sourceMapAsset.source.source().toString(),
113
+ mapDir: path__namespace.join(outputPath, path__namespace.dirname(sourceMapName)),
114
+ chunkPath: path__namespace.join(outputPath, asset.name)
115
+ });
116
+ if (result === "skipped" || result === "failed") {
117
+ logger.warn(
118
+ pluginEnabledMaps ? `Could not prepare ${asset.name} for upload, so it is not uploaded and its source map ${sourceMapName} was removed from the build output.` : `Could not prepare ${asset.name} for upload, so its source map ${sourceMapName} stays in the build output.`
119
+ );
120
+ }
121
+ if (result === "staged" || pluginEnabledMaps) {
122
+ deleteSourceMapAssets(compilation, sourceMapName);
123
+ }
124
+ }
125
+ }
66
126
  function createSentryWebpackPlugin(userOptions = {}) {
67
127
  const sentryBuildPluginManager = buildPluginManager.createSentryBuildPluginManager(userOptions, {
68
128
  loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? "[sentry-webpack-plugin]",
@@ -111,6 +171,17 @@ function createSentryWebpackPlugin(userOptions = {}) {
111
171
  { logger }
112
172
  ) : void 0;
113
173
  const transformReplace = Object.keys(replacementValues).length > 0;
174
+ function decideSourceMaps(compiler) {
175
+ const kind = compiler.options.mode === "development" ? void 0 : sourceMapKindFromDevtool(compiler);
176
+ if (kind === void 0) {
177
+ return { decision: { enableHidden: false, deleteAfterUpload: false } };
178
+ }
179
+ const decision = sentryBuildPluginManager.sourceMaps.decide(kind);
180
+ if (decision.enableHidden) {
181
+ compiler.options.devtool = kind === "visible" ? `hidden-${compiler.options.devtool}` : "hidden-source-map";
182
+ }
183
+ return { kind, decision };
184
+ }
114
185
  function addCodeInjection(compiler) {
115
186
  if (releaseInjectionCode.isEmpty() && chunkInjectionCode.isEmpty() && !sourcemapsEnabled) {
116
187
  return;
@@ -169,6 +240,35 @@ ${codeToInject.code()}` : codeToInject.code();
169
240
  void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {
170
241
  });
171
242
  const { DefinePlugin } = compiler.webpack ?? {};
243
+ const { kind: sourceMapKind, decision: sourceMapDecision } = decideSourceMaps(compiler);
244
+ const pendingStagings = /* @__PURE__ */ new Map();
245
+ if (sourceMapDecision.deleteAfterUpload) {
246
+ const stage = (compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_REPORT ?? 5e3) + 1;
247
+ compiler.hooks.thisCompilation.tap("sentry-webpack-plugin", (compilation) => {
248
+ compilation.hooks.processAssets.tapPromise({ name: "sentry-webpack-plugin", stage }, async () => {
249
+ const staging = await sentryBuildPluginManager.createUploadStaging();
250
+ pendingStagings.set(compilation, staging);
251
+ await stageSourceMaps(compilation, staging, logger, sourceMapKind === "unset");
252
+ });
253
+ });
254
+ const emittedCompilations = /* @__PURE__ */ new Set();
255
+ compiler.hooks.emit.tap("sentry-webpack-plugin", (compilation) => {
256
+ emittedCompilations.add(compilation);
257
+ });
258
+ const settlePendingStagings = () => {
259
+ for (const [compilation, staging] of pendingStagings) {
260
+ if (emittedCompilations.has(compilation)) {
261
+ void staging.keep("The source map upload did not run.");
262
+ } else {
263
+ void staging.discard();
264
+ }
265
+ }
266
+ pendingStagings.clear();
267
+ emittedCompilations.clear();
268
+ };
269
+ compiler.hooks.done.tap("sentry-webpack-plugin", settlePendingStagings);
270
+ compiler.hooks.failed?.tap("sentry-webpack-plugin", settlePendingStagings);
271
+ }
172
272
  addCodeInjection(compiler);
173
273
  if (sourcemapsEnabled && options.sourcemaps?.disable === "disable-upload") {
174
274
  const RawSource = compiler.webpack?.sources?.RawSource;
@@ -211,14 +311,26 @@ ${codeToInject.code()}` : codeToInject.code();
211
311
  (compilation, callback) => {
212
312
  const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
213
313
  const upload = debugIdUpload.createDebugIdUploadFunction({ sentryBuildPluginManager });
314
+ const staging = pendingStagings.get(compilation);
315
+ pendingStagings.delete(compilation);
316
+ let stagingHandedOver = false;
214
317
  const run = async () => {
215
318
  try {
216
319
  await sentryBuildPluginManager.createRelease();
217
320
  if (sourcemapsEnabled && options.sourcemaps?.disable !== "disable-upload") {
218
321
  const outputPath = compilation.outputOptions.path ?? path__namespace.resolve();
219
322
  const buildArtifacts = Object.keys(compilation.assets).map((asset) => path__namespace.join(outputPath, asset));
220
- await upload(buildArtifacts);
323
+ stagingHandedOver = true;
324
+ await upload(buildArtifacts, { staging });
325
+ } else {
326
+ stagingHandedOver = true;
327
+ await staging?.discard();
328
+ }
329
+ } catch (e) {
330
+ if (!stagingHandedOver) {
331
+ await staging?.keep("The source map upload did not run.");
221
332
  }
333
+ throw e;
222
334
  } finally {
223
335
  freeGlobalDependencyOnBuildArtifacts();
224
336
  await sentryBuildPluginManager.deleteArtifacts();
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/webpack/index.ts"],"sourcesContent":["/* oxlint-disable max-lines */\n\nimport type { Options } from '../core/index';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n stringToUUID,\n createComponentNameAnnotateHooks,\n CodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n getCodeInjectionPosition,\n isJsFile,\n stampDebugId,\n} from '../core/index';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { createRequire } from 'node:module';\nimport { randomUUID } from 'node:crypto';\n\nconst _req = createRequire(import.meta.url);\n\n// Resolve the loader path via the package's own exports.\n// This module may end up in a shared chunk (_chunks/) whose import.meta.url\n// does not point to the webpack/ directory where the transform file lives, so\n// a path-relative lookup would fail. Using require.resolve on the package export\n// always finds the correct installed file regardless of chunk placement.\nlet COMPONENT_ANNOTATION_LOADER: string;\ntry {\n COMPONENT_ANNOTATION_LOADER = _req.resolve('@sentry/bundler-plugins/webpack-loader');\n} catch {\n // Fallback for non-packaged environments (e.g., monorepo source runs without dist)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore Rollup transpiles import.meta for us for CJS\n const dirname = path.dirname(fileURLToPath(import.meta.url));\n // The Rollup build emits `.js` for both CJS and ESM, so the extension is the same in both.\n COMPONENT_ANNOTATION_LOADER = path.resolve(dirname, 'component-annotation-transform.js');\n}\n\ntype PluginClass = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype WebpackSource = {\n source: () => string | Buffer;\n};\n\ntype WebpackRawSource = {\n new (source: string): WebpackSource;\n};\n\ntype WebpackReplaceSource = WebpackSource & {\n insert: (position: number, value: string) => void;\n};\n\nconst WEBPACK_JAVASCRIPT_ASSET_REGEX = /\\.(?:js|ts|jsx|tsx|mjs|cjs|mts|cts)(?:\\?[^?]*)?(?:#[^#]*)?$/;\n\ntype WebpackAsset = {\n name: string;\n source: WebpackSource;\n info: {\n related?: {\n sourceMap?: string | string[];\n };\n };\n};\n\ntype WebpackCompiler = {\n options: {\n plugins?: unknown[];\n mode?: string;\n module?: {\n rules?: unknown[];\n };\n };\n hooks: {\n compilation: {\n tap: (name: string, callback: (compilation: WebpackCompilation) => void) => void;\n };\n thisCompilation: {\n tap: (name: string, callback: (compilation: WebpackCompilation) => void) => void;\n };\n afterEmit: {\n tapAsync: (name: string, callback: (compilation: WebpackCompilation, cb: () => void) => void) => void;\n };\n done: {\n tap: (name: string, callback: () => void) => void;\n };\n };\n webpack?: {\n DefinePlugin?: PluginClass;\n Compilation?: {\n PROCESS_ASSETS_STAGE_ADDITIONS?: number;\n PROCESS_ASSETS_STAGE_DEV_TOOLING?: number;\n };\n sources?: {\n RawSource?: WebpackRawSource;\n ReplaceSource?: new (source: WebpackSource) => WebpackReplaceSource;\n };\n };\n};\n\ntype WebpackCompilation = {\n chunks: Iterable<{\n files: Iterable<string>;\n hash?: string;\n contentHash?: { javascript?: string };\n canBeInitial?: () => boolean;\n }>;\n outputOptions: {\n path?: string;\n };\n assets: Record<string, unknown>;\n getAssets: () => WebpackAsset[];\n getAsset: (name: string) => WebpackAsset | undefined;\n updateAsset: (name: string, source: WebpackSource) => void;\n hooks: {\n processAssets: {\n tap: (\n options: { name: string; stage: number },\n callback: (assets: Record<string, WebpackSource>) => void,\n ) => void;\n };\n };\n};\n\ntype WebpackModule = {\n version?: string;\n default?: { version?: string };\n};\n\n// Only used for telemetry; `webpack` is an optional peer dependency and may be absent (e.g. rspack).\nfunction getWebpackMajorVersion(): string | undefined {\n try {\n const webpack = _req('webpack') as WebpackModule;\n const version = webpack.version ?? webpack.default?.version;\n return version?.split('.')[0];\n } catch {\n return undefined;\n }\n}\n\n/**\n * Stamps each JS asset's debug ID into the asset itself and its source map asset.\n *\n * Runs after source maps have been generated, so the JS asset no longer needs to carry\n * source map information and can be replaced with a plain `RawSource`.\n */\nfunction addDebugIdsToAssets(compilation: WebpackCompilation, RawSource: WebpackRawSource): void {\n for (const asset of compilation.getAssets()) {\n if (!isJsFile(asset.name)) {\n continue;\n }\n\n const bundleSource = asset.source.source().toString();\n const relatedSourceMap = asset.info.related?.sourceMap;\n const sourceMapName = typeof relatedSourceMap === 'string' ? relatedSourceMap : `${asset.name}.map`;\n const sourceMapAsset = compilation.getAsset(sourceMapName);\n\n const stamped = stampDebugId(bundleSource, sourceMapAsset?.source.source().toString());\n if (!stamped) {\n continue;\n }\n\n compilation.updateAsset(asset.name, new RawSource(stamped.bundleSource));\n if (stamped.sourceMapSource !== undefined) {\n compilation.updateAsset(sourceMapName, new RawSource(stamped.sourceMapSource));\n }\n }\n}\n\nfunction createSentryWebpackPlugin(userOptions: SentryWebpackPluginOptions = {}) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? '[sentry-webpack-plugin]',\n buildTool: 'webpack',\n buildToolMajorVersion: getWebpackMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n apply() {\n // noop plugin\n },\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const releaseInjectionCode = new CodeInjection();\n const chunkInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n releaseInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n chunkInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n { logger },\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n function addCodeInjection(compiler: WebpackCompiler): void {\n if (releaseInjectionCode.isEmpty() && chunkInjectionCode.isEmpty() && !sourcemapsEnabled) {\n return;\n }\n\n const ReplaceSource = compiler.webpack?.sources?.ReplaceSource;\n const processAssetsStage = compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS;\n\n if (!ReplaceSource || processAssetsStage === undefined) {\n logger.warn(\n 'Webpack sources are not available. Skipping code injection. This usually means webpack is not properly configured.',\n );\n return;\n }\n\n compiler.hooks.compilation.tap('sentry-webpack-plugin-injection', compilation => {\n compilation.hooks.processAssets.tap(\n {\n name: 'sentry-webpack-plugin-injection',\n stage: processAssetsStage,\n },\n assets => {\n const injectedAssets = new Set<string>();\n\n for (const chunk of compilation.chunks) {\n for (const assetName of chunk.files) {\n if (injectedAssets.has(assetName) || !WEBPACK_JAVASCRIPT_ASSET_REGEX.test(assetName)) {\n continue;\n }\n\n const source = assets[assetName];\n if (!source) {\n continue;\n }\n injectedAssets.add(assetName);\n\n const sourceContents = source.source();\n const code = typeof sourceContents === 'string' ? sourceContents : Buffer.from(sourceContents).toString();\n const codeToInject = new CodeInjection();\n if (chunk.canBeInitial?.() ?? true) {\n codeToInject.append(releaseInjectionCode);\n }\n codeToInject.append(chunkInjectionCode);\n if (sourcemapsEnabled) {\n const hash = chunk.contentHash?.javascript ?? chunk.hash;\n codeToInject.append(getDebugIdSnippet(hash ? stringToUUID(hash) : randomUUID()));\n }\n\n const injectionPosition = getCodeInjectionPosition(code);\n const injection = injectionPosition === code.length ? `\\n${codeToInject.code()}` : codeToInject.code();\n const updatedSource = new ReplaceSource(source);\n updatedSource.insert(injectionPosition, injection);\n compilation.updateAsset(assetName, updatedSource);\n }\n }\n },\n );\n });\n }\n\n return {\n apply(compiler: WebpackCompiler) {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n const { DefinePlugin } = compiler.webpack ?? {};\n\n // BannerPlugin prepends executable code before directive prologues.\n addCodeInjection(compiler);\n\n // The upload routine (which stamps debug IDs into temp copies of the artifacts) is skipped\n // with `disable-upload`, so the emitted artifacts get stamped in the asset pipeline instead.\n if (sourcemapsEnabled && options.sourcemaps?.disable === 'disable-upload') {\n const RawSource = compiler.webpack?.sources?.RawSource;\n // Right after source map generation (and thus after minification, which would strip the comment),\n // so later stages (real content hashing, subresource integrity) see the final assets.\n const stage = (compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_DEV_TOOLING ?? 500) + 1;\n\n if (!RawSource) {\n logger.warn(\n 'Webpack sources are not available. Skipping debug ID injection into emitted source maps. This usually means webpack is not properly configured.',\n );\n } else {\n compiler.hooks.thisCompilation.tap('sentry-webpack-plugin', compilation => {\n compilation.hooks.processAssets.tap({ name: 'sentry-webpack-plugin', stage }, () => {\n addDebugIdsToAssets(compilation, RawSource);\n });\n });\n }\n }\n\n // Add DefinePlugin for bundle size optimizations\n if (transformReplace && DefinePlugin) {\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(new DefinePlugin(replacementValues));\n }\n\n // Add component name annotation transform\n if (transformAnnotations?.transform) {\n compiler.options.module = compiler.options.module || {};\n compiler.options.module.rules = compiler.options.module.rules || [];\n compiler.options.module.rules.unshift({\n test: /\\.[jt]sx$/,\n exclude: /node_modules/,\n enforce: 'pre',\n use: [\n {\n loader: COMPONENT_ANNOTATION_LOADER,\n options: {\n transform: transformAnnotations.transform,\n },\n },\n ],\n });\n }\n\n compiler.hooks.afterEmit.tapAsync(\n 'sentry-webpack-plugin',\n (compilation: WebpackCompilation, callback: (err?: Error) => void) => {\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n const run = async (): Promise<void> => {\n try {\n await sentryBuildPluginManager.createRelease();\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n const outputPath = compilation.outputOptions.path ?? path.resolve();\n const buildArtifacts = Object.keys(compilation.assets).map(asset => path.join(outputPath, asset));\n await upload(buildArtifacts);\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n };\n\n run().then(\n () => callback(),\n (err: Error) => callback(err),\n );\n },\n );\n\n if (userOptions._experiments?.forceExitOnBuildCompletion && compiler.options.mode === 'production') {\n compiler.hooks.done.tap('sentry-webpack-plugin', () => {\n setTimeout(() => {\n logger.debug('Exiting process after debug file upload');\n process.exit(0);\n });\n });\n }\n },\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any = createSentryWebpackPlugin;\n\nexport type SentryWebpackPluginOptions = Options & {\n _experiments?: Options['_experiments'] & {\n /**\n * If enabled, the webpack plugin will exit the build process after the build completes.\n * Use this with caution, as it will terminate the process.\n *\n * More information: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/345\n *\n * @default false\n */\n forceExitOnBuildCompletion?: boolean;\n };\n};\n"],"names":["createRequire","path","fileURLToPath","isJsFile","stampDebugId","createSentryBuildPluginManager","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","createComponentNameAnnotateHooks","getDebugIdSnippet","stringToUUID","randomUUID","getCodeInjectionPosition","createDebugIdUploadFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,IAAA,GAAOA,yBAAA,CAAc,kQAAe,CAAA;AAO1C,IAAI,2BAAA;AACJ,IAAI;AACF,EAAA,2BAAA,GAA8B,IAAA,CAAK,QAAQ,wCAAwC,CAAA;AACrF,CAAA,CAAA,MAAQ;AAIN,EAAA,MAAM,UAAUC,eAAA,CAAK,OAAA,CAAQC,sBAAA,CAAc,kQAAe,CAAC,CAAA;AAE3D,EAAA,2BAAA,GAA8BD,eAAA,CAAK,OAAA,CAAQ,OAAA,EAAS,mCAAmC,CAAA;AACzF;AAmBA,MAAM,8BAAA,GAAiC,6DAAA;AA6EvC,SAAS,sBAAA,GAA6C;AACpD,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,KAAK,SAAS,CAAA;AAC9B,IAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,OAAA,IAAW,OAAA,CAAQ,OAAA,EAAS,OAAA;AACpD,IAAA,OAAO,OAAA,EAAS,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA;AAAA,EAC9B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAQA,SAAS,mBAAA,CAAoB,aAAiC,SAAA,EAAmC;AAC/F,EAAA,KAAA,MAAW,KAAA,IAAS,WAAA,CAAY,SAAA,EAAU,EAAG;AAC3C,IAAA,IAAI,CAACE,cAAA,CAAS,KAAA,CAAM,IAAI,CAAA,EAAG;AACzB,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,YAAA,GAAe,KAAA,CAAM,MAAA,CAAO,MAAA,GAAS,QAAA,EAAS;AACpD,IAAA,MAAM,gBAAA,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YAAA,EAAc,0BAAA,IAA8B,QAAA,CAAS,OAAA,CAAQ,SAAS,YAAA,EAAc;AAClG,QAAA,QAAA,CAAS,KAAA,CAAM,IAAA,CAAK,GAAA,CAAI,uBAAA,EAAyB,MAAM;AACrD,UAAA,UAAA,CAAW,MAAM;AACf,YAAA,MAAA,CAAO,MAAM,yCAAyC,CAAA;AACtD,YAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,UAChB,CAAC,CAAA;AAAA,QACH,CAAC,CAAA;AAAA,MACH;AAAA,IACF;AAAA,GACF;AACF;AAGO,MAAM,mBAAA,GAAqE;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/webpack/index.ts"],"sourcesContent":["/* oxlint-disable max-lines */\n\nimport type { Options, SourceMapDecision, SourceMapKind, UploadStaging } from '../core/index';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n stringToUUID,\n createComponentNameAnnotateHooks,\n CodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n getCodeInjectionPosition,\n isJsFile,\n stampDebugId,\n} from '../core/index';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { createRequire } from 'node:module';\nimport { randomUUID } from 'node:crypto';\n\nconst _req = createRequire(import.meta.url);\n\n// Resolve the loader path via the package's own exports.\n// This module may end up in a shared chunk (_chunks/) whose import.meta.url\n// does not point to the webpack/ directory where the transform file lives, so\n// a path-relative lookup would fail. Using require.resolve on the package export\n// always finds the correct installed file regardless of chunk placement.\nlet COMPONENT_ANNOTATION_LOADER: string;\ntry {\n COMPONENT_ANNOTATION_LOADER = _req.resolve('@sentry/bundler-plugins/webpack-loader');\n} catch {\n // Fallback for non-packaged environments (e.g., monorepo source runs without dist)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore Rollup transpiles import.meta for us for CJS\n const dirname = path.dirname(fileURLToPath(import.meta.url));\n // The Rollup build emits `.js` for both CJS and ESM, so the extension is the same in both.\n COMPONENT_ANNOTATION_LOADER = path.resolve(dirname, 'component-annotation-transform.js');\n}\n\ntype PluginClass = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype WebpackSource = {\n source: () => string | Buffer;\n};\n\ntype WebpackRawSource = {\n new (source: string): WebpackSource;\n};\n\ntype WebpackReplaceSource = WebpackSource & {\n insert: (position: number, value: string) => void;\n};\n\nconst WEBPACK_JAVASCRIPT_ASSET_REGEX = /\\.(?:js|ts|jsx|tsx|mjs|cjs|mts|cts)(?:\\?[^?]*)?(?:#[^#]*)?$/;\n\ntype WebpackAsset = {\n name: string;\n source: WebpackSource;\n info: {\n related?: {\n sourceMap?: string | string[];\n };\n };\n};\n\ntype WebpackCompiler = {\n options: {\n plugins?: unknown[];\n mode?: string;\n devtool?: string | false;\n module?: {\n rules?: unknown[];\n };\n };\n hooks: {\n compilation: {\n tap: (name: string, callback: (compilation: WebpackCompilation) => void) => void;\n };\n thisCompilation: {\n tap: (name: string, callback: (compilation: WebpackCompilation) => void) => void;\n };\n emit: {\n tap: (name: string, callback: (compilation: WebpackCompilation) => void) => void;\n };\n afterEmit: {\n tapAsync: (name: string, callback: (compilation: WebpackCompilation, cb: () => void) => void) => void;\n };\n done: {\n tap: (name: string, callback: () => void) => void;\n };\n failed?: {\n tap: (name: string, callback: () => void) => void;\n };\n };\n webpack?: {\n DefinePlugin?: PluginClass;\n Compilation?: {\n PROCESS_ASSETS_STAGE_ADDITIONS?: number;\n PROCESS_ASSETS_STAGE_DEV_TOOLING?: number;\n PROCESS_ASSETS_STAGE_REPORT?: number;\n };\n sources?: {\n RawSource?: WebpackRawSource;\n ReplaceSource?: new (source: WebpackSource) => WebpackReplaceSource;\n };\n };\n};\n\ntype WebpackCompilation = {\n chunks: Iterable<{\n files: Iterable<string>;\n hash?: string;\n contentHash?: { javascript?: string };\n canBeInitial?: () => boolean;\n }>;\n outputOptions: {\n path?: string;\n };\n assets: Record<string, unknown>;\n getAssets: () => WebpackAsset[];\n getAsset: (name: string) => WebpackAsset | undefined;\n updateAsset: (name: string, source: WebpackSource) => void;\n deleteAsset: (name: string) => void;\n hooks: {\n processAssets: {\n tap: (\n options: { name: string; stage: number },\n callback: (assets: Record<string, WebpackSource>) => void,\n ) => void;\n tapPromise: (options: { name: string; stage: number }, callback: () => Promise<void>) => void;\n };\n };\n};\n\n/**\n * Maps webpack's `devtool` onto the plugin's source map kinds. A user who sets `devtool: false`\n * and adds a `SourceMapDevToolPlugin` manages source maps themselves.\n */\nfunction sourceMapKindFromDevtool(compiler: WebpackCompiler): SourceMapKind | undefined {\n const devtool = compiler.options.devtool;\n\n if (devtool === undefined) {\n return 'unset';\n }\n if (devtool === false) {\n const hasSourceMapPlugin = compiler.options.plugins?.some(\n plugin =>\n (plugin as { constructor?: { name?: string } } | undefined)?.constructor?.name === 'SourceMapDevToolPlugin',\n );\n return hasSourceMapPlugin ? undefined : 'off';\n }\n // Plain `eval` has no source maps at all.\n if (!devtool.includes('source-map')) {\n return 'off';\n }\n if (devtool.includes('inline') || devtool.includes('eval')) {\n return 'inline';\n }\n if (devtool.includes('hidden')) {\n return 'hidden';\n }\n return 'visible';\n}\n\ntype WebpackModule = {\n version?: string;\n default?: { version?: string };\n};\n\n// Only used for telemetry; `webpack` is an optional peer dependency and may be absent (e.g. rspack).\nfunction getWebpackMajorVersion(): string | undefined {\n try {\n const webpack = _req('webpack') as WebpackModule;\n const version = webpack.version ?? webpack.default?.version;\n return version?.split('.')[0];\n } catch {\n return undefined;\n }\n}\n\n/**\n * Stamps each JS asset's debug ID into the asset itself and its source map asset.\n *\n * Runs after source maps have been generated, so the JS asset no longer needs to carry\n * source map information and can be replaced with a plain `RawSource`.\n */\nfunction addDebugIdsToAssets(compilation: WebpackCompilation, RawSource: WebpackRawSource): void {\n for (const asset of compilation.getAssets()) {\n if (!isJsFile(asset.name)) {\n continue;\n }\n\n const bundleSource = asset.source.source().toString();\n const relatedSourceMap = asset.info.related?.sourceMap;\n const sourceMapName = typeof relatedSourceMap === 'string' ? relatedSourceMap : `${asset.name}.map`;\n const sourceMapAsset = compilation.getAsset(sourceMapName);\n\n const stamped = stampDebugId(bundleSource, sourceMapAsset?.source.source().toString());\n if (!stamped) {\n continue;\n }\n\n compilation.updateAsset(asset.name, new RawSource(stamped.bundleSource));\n if (stamped.sourceMapSource !== undefined) {\n compilation.updateAsset(sourceMapName, new RawSource(stamped.sourceMapSource));\n }\n }\n}\n\n/** Drops a source map asset and its compressed variants from the compilation. */\nfunction deleteSourceMapAssets(compilation: WebpackCompilation, sourceMapName: string): void {\n for (const candidate of compilation.getAssets()) {\n if (candidate.name === sourceMapName || candidate.name.startsWith(`${sourceMapName}.`)) {\n compilation.deleteAsset(candidate.name);\n }\n }\n}\n\n/**\n * Copies each JS asset and its source map into the upload staging folder and drops the source map\n * assets (and their compressed variants) from the compilation, so webpack never emits them.\n *\n * A map the plugin turned on (`pluginEnabledMaps`) never reaches the output, whether or not its\n * asset is uploaded. That covers CSS maps, which `devtool` turns on along with the JS ones. A map\n * the user enabled stays unless it was staged.\n */\nasync function stageSourceMaps(\n compilation: WebpackCompilation,\n staging: UploadStaging,\n logger: { warn: (message: string) => void },\n pluginEnabledMaps: boolean,\n): Promise<void> {\n const outputPath = compilation.outputOptions.path ?? path.resolve();\n\n for (const asset of compilation.getAssets()) {\n const relatedSourceMap = asset.info.related?.sourceMap;\n const sourceMapName = typeof relatedSourceMap === 'string' ? relatedSourceMap : `${asset.name}.map`;\n const sourceMapAsset = compilation.getAsset(sourceMapName);\n if (!sourceMapAsset) {\n continue;\n }\n\n if (!isJsFile(asset.name)) {\n if (pluginEnabledMaps) {\n deleteSourceMapAssets(compilation, sourceMapName);\n }\n continue;\n }\n\n const result = await staging.stage({\n code: asset.source.source().toString(),\n mapSource: sourceMapAsset.source.source().toString(),\n mapDir: path.join(outputPath, path.dirname(sourceMapName)),\n chunkPath: path.join(outputPath, asset.name),\n });\n\n if (result === 'skipped' || result === 'failed') {\n logger.warn(\n pluginEnabledMaps\n ? `Could not prepare ${asset.name} for upload, so it is not uploaded and its source map ${sourceMapName} was removed from the build output.`\n : `Could not prepare ${asset.name} for upload, so its source map ${sourceMapName} stays in the build output.`,\n );\n }\n if (result === 'staged' || pluginEnabledMaps) {\n deleteSourceMapAssets(compilation, sourceMapName);\n }\n }\n}\n\nfunction createSentryWebpackPlugin(userOptions: SentryWebpackPluginOptions = {}) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? '[sentry-webpack-plugin]',\n buildTool: 'webpack',\n buildToolMajorVersion: getWebpackMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n apply() {\n // noop plugin\n },\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const releaseInjectionCode = new CodeInjection();\n const chunkInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n releaseInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n chunkInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n { logger },\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n function decideSourceMaps(compiler: WebpackCompiler): { kind?: SourceMapKind; decision: SourceMapDecision } {\n const kind = compiler.options.mode === 'development' ? undefined : sourceMapKindFromDevtool(compiler);\n if (kind === undefined) {\n return { decision: { enableHidden: false, deleteAfterUpload: false } };\n }\n\n const decision = sentryBuildPluginManager.sourceMaps.decide(kind);\n\n if (decision.enableHidden) {\n compiler.options.devtool = kind === 'visible' ? `hidden-${compiler.options.devtool}` : 'hidden-source-map';\n }\n\n return { kind, decision };\n }\n\n function addCodeInjection(compiler: WebpackCompiler): void {\n if (releaseInjectionCode.isEmpty() && chunkInjectionCode.isEmpty() && !sourcemapsEnabled) {\n return;\n }\n\n const ReplaceSource = compiler.webpack?.sources?.ReplaceSource;\n const processAssetsStage = compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS;\n\n if (!ReplaceSource || processAssetsStage === undefined) {\n logger.warn(\n 'Webpack sources are not available. Skipping code injection. This usually means webpack is not properly configured.',\n );\n return;\n }\n\n compiler.hooks.compilation.tap('sentry-webpack-plugin-injection', compilation => {\n compilation.hooks.processAssets.tap(\n {\n name: 'sentry-webpack-plugin-injection',\n stage: processAssetsStage,\n },\n assets => {\n const injectedAssets = new Set<string>();\n\n for (const chunk of compilation.chunks) {\n for (const assetName of chunk.files) {\n if (injectedAssets.has(assetName) || !WEBPACK_JAVASCRIPT_ASSET_REGEX.test(assetName)) {\n continue;\n }\n\n const source = assets[assetName];\n if (!source) {\n continue;\n }\n injectedAssets.add(assetName);\n\n const sourceContents = source.source();\n const code = typeof sourceContents === 'string' ? sourceContents : Buffer.from(sourceContents).toString();\n const codeToInject = new CodeInjection();\n if (chunk.canBeInitial?.() ?? true) {\n codeToInject.append(releaseInjectionCode);\n }\n codeToInject.append(chunkInjectionCode);\n if (sourcemapsEnabled) {\n const hash = chunk.contentHash?.javascript ?? chunk.hash;\n codeToInject.append(getDebugIdSnippet(hash ? stringToUUID(hash) : randomUUID()));\n }\n\n const injectionPosition = getCodeInjectionPosition(code);\n const injection = injectionPosition === code.length ? `\\n${codeToInject.code()}` : codeToInject.code();\n const updatedSource = new ReplaceSource(source);\n updatedSource.insert(injectionPosition, injection);\n compilation.updateAsset(assetName, updatedSource);\n }\n }\n },\n );\n });\n }\n\n return {\n apply(compiler: WebpackCompiler) {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n const { DefinePlugin } = compiler.webpack ?? {};\n\n // One plugin instance can serve several compilers (`MultiCompiler`) and\n // a compiler several compilations (watch mode), so nothing is shared.\n const { kind: sourceMapKind, decision: sourceMapDecision } = decideSourceMaps(compiler);\n const pendingStagings = new Map<WebpackCompilation, UploadStaging>();\n\n if (sourceMapDecision.deleteAfterUpload) {\n // After `RealContentHashPlugin` rewrote the hash placeholders, so the staged\n // JS equals the emitted file and `[contenthash]` names are final.\n const stage = (compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_REPORT ?? 5000) + 1;\n\n compiler.hooks.thisCompilation.tap('sentry-webpack-plugin', compilation => {\n compilation.hooks.processAssets.tapPromise({ name: 'sentry-webpack-plugin', stage }, async () => {\n const staging = await sentryBuildPluginManager.createUploadStaging();\n pendingStagings.set(compilation, staging);\n await stageSourceMaps(compilation, staging, logger, sourceMapKind === 'unset');\n });\n });\n\n // A staging that `afterEmit` never took belongs to a compilation that\n // failed before emitting, or to one whose assets were emitted without\n // their maps because an earlier `afterEmit` tap failed. Only the\n // second kind has no other copy of the maps.\n const emittedCompilations = new Set<WebpackCompilation>();\n compiler.hooks.emit.tap('sentry-webpack-plugin', compilation => {\n emittedCompilations.add(compilation);\n });\n const settlePendingStagings = (): void => {\n for (const [compilation, staging] of pendingStagings) {\n if (emittedCompilations.has(compilation)) {\n void staging.keep('The source map upload did not run.');\n } else {\n void staging.discard();\n }\n }\n pendingStagings.clear();\n emittedCompilations.clear();\n };\n compiler.hooks.done.tap('sentry-webpack-plugin', settlePendingStagings);\n compiler.hooks.failed?.tap('sentry-webpack-plugin', settlePendingStagings);\n }\n\n // BannerPlugin prepends executable code before directive prologues.\n addCodeInjection(compiler);\n\n // The upload routine (which stamps debug IDs into temp copies of the artifacts) is skipped\n // with `disable-upload`, so the emitted artifacts get stamped in the asset pipeline instead.\n if (sourcemapsEnabled && options.sourcemaps?.disable === 'disable-upload') {\n const RawSource = compiler.webpack?.sources?.RawSource;\n // Right after source map generation (and thus after minification, which would strip the comment),\n // so later stages (real content hashing, subresource integrity) see the final assets.\n const stage = (compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_DEV_TOOLING ?? 500) + 1;\n\n if (!RawSource) {\n logger.warn(\n 'Webpack sources are not available. Skipping debug ID injection into emitted source maps. This usually means webpack is not properly configured.',\n );\n } else {\n compiler.hooks.thisCompilation.tap('sentry-webpack-plugin', compilation => {\n compilation.hooks.processAssets.tap({ name: 'sentry-webpack-plugin', stage }, () => {\n addDebugIdsToAssets(compilation, RawSource);\n });\n });\n }\n }\n\n // Add DefinePlugin for bundle size optimizations\n if (transformReplace && DefinePlugin) {\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(new DefinePlugin(replacementValues));\n }\n\n // Add component name annotation transform\n if (transformAnnotations?.transform) {\n compiler.options.module = compiler.options.module || {};\n compiler.options.module.rules = compiler.options.module.rules || [];\n compiler.options.module.rules.unshift({\n test: /\\.[jt]sx$/,\n exclude: /node_modules/,\n enforce: 'pre',\n use: [\n {\n loader: COMPONENT_ANNOTATION_LOADER,\n options: {\n transform: transformAnnotations.transform,\n },\n },\n ],\n });\n }\n\n compiler.hooks.afterEmit.tapAsync(\n 'sentry-webpack-plugin',\n (compilation: WebpackCompilation, callback: (err?: Error) => void) => {\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n const staging = pendingStagings.get(compilation);\n pendingStagings.delete(compilation);\n let stagingHandedOver = false;\n\n const run = async (): Promise<void> => {\n try {\n await sentryBuildPluginManager.createRelease();\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n const outputPath = compilation.outputOptions.path ?? path.resolve();\n const buildArtifacts = Object.keys(compilation.assets).map(asset => path.join(outputPath, asset));\n stagingHandedOver = true;\n await upload(buildArtifacts, { staging });\n } else {\n stagingHandedOver = true;\n await staging?.discard();\n }\n } catch (e) {\n if (!stagingHandedOver) {\n await staging?.keep('The source map upload did not run.');\n }\n throw e;\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n };\n\n run().then(\n () => callback(),\n (err: Error) => callback(err),\n );\n },\n );\n\n if (userOptions._experiments?.forceExitOnBuildCompletion && compiler.options.mode === 'production') {\n compiler.hooks.done.tap('sentry-webpack-plugin', () => {\n setTimeout(() => {\n logger.debug('Exiting process after debug file upload');\n process.exit(0);\n });\n });\n }\n },\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any = createSentryWebpackPlugin;\n\nexport type SentryWebpackPluginOptions = Options & {\n _experiments?: Options['_experiments'] & {\n /**\n * If enabled, the webpack plugin will exit the build process after the build completes.\n * Use this with caution, as it will terminate the process.\n *\n * More information: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/345\n *\n * @default false\n */\n forceExitOnBuildCompletion?: boolean;\n };\n};\n"],"names":["createRequire","path","fileURLToPath","isJsFile","stampDebugId","createSentryBuildPluginManager","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","createComponentNameAnnotateHooks","getDebugIdSnippet","stringToUUID","randomUUID","getCodeInjectionPosition","createDebugIdUploadFunction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,IAAA,GAAOA,yBAAA,CAAc,kQAAe,CAAA;AAO1C,IAAI,2BAAA;AACJ,IAAI;AACF,EAAA,2BAAA,GAA8B,IAAA,CAAK,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