@sentry/bundler-plugins 11.11.0 → 11.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  2. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  3. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  4. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  5. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  6. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  7. package/build/cjs/_virtual/_rolldown/runtime.js +22 -0
  8. package/build/cjs/babel-plugin/component-annotation.js +14 -32
  9. package/build/cjs/babel-plugin/component-annotation.js.map +1 -1
  10. package/build/cjs/babel-plugin/constants.js +140 -122
  11. package/build/cjs/babel-plugin/constants.js.map +1 -1
  12. package/build/cjs/babel-plugin/experimental.js +204 -307
  13. package/build/cjs/babel-plugin/experimental.js.map +1 -1
  14. package/build/cjs/babel-plugin/index.js +315 -437
  15. package/build/cjs/babel-plugin/index.js.map +1 -1
  16. package/build/cjs/bun/index.js +81 -117
  17. package/build/cjs/bun/index.js.map +1 -1
  18. package/build/cjs/core/build-plugin-manager.js +626 -683
  19. package/build/cjs/core/build-plugin-manager.js.map +1 -1
  20. package/build/cjs/core/cli.js +134 -129
  21. package/build/cjs/core/cli.js.map +1 -1
  22. package/build/cjs/core/component-annotate-hooks.js +16 -27
  23. package/build/cjs/core/component-annotate-hooks.js.map +1 -1
  24. package/build/cjs/core/component-annotation-oxc-ast.js +10 -21
  25. package/build/cjs/core/component-annotation-oxc-ast.js.map +1 -1
  26. package/build/cjs/core/component-annotation-oxc-fragments.js +45 -74
  27. package/build/cjs/core/component-annotation-oxc-fragments.js.map +1 -1
  28. package/build/cjs/core/component-annotation-oxc-jsx.js +116 -156
  29. package/build/cjs/core/component-annotation-oxc-jsx.js.map +1 -1
  30. package/build/cjs/core/component-annotation-oxc-walk.js +62 -123
  31. package/build/cjs/core/component-annotation-oxc-walk.js.map +1 -1
  32. package/build/cjs/core/component-annotation-oxc.js +68 -103
  33. package/build/cjs/core/component-annotation-oxc.js.map +1 -1
  34. package/build/cjs/core/debug-id-upload.js +223 -234
  35. package/build/cjs/core/debug-id-upload.js.map +1 -1
  36. package/build/cjs/core/get-code-injection-position.js +59 -74
  37. package/build/cjs/core/get-code-injection-position.js.map +1 -1
  38. package/build/cjs/core/glob.js +9 -7
  39. package/build/cjs/core/glob.js.map +1 -1
  40. package/build/cjs/core/index.js +77 -61
  41. package/build/cjs/core/index.js.map +1 -1
  42. package/build/cjs/core/logger.js +17 -26
  43. package/build/cjs/core/logger.js.map +1 -1
  44. package/build/cjs/core/options-mapping.js +95 -117
  45. package/build/cjs/core/options-mapping.js.map +1 -1
  46. package/build/cjs/core/sentry/telemetry.js +90 -105
  47. package/build/cjs/core/sentry/telemetry.js.map +1 -1
  48. package/build/cjs/core/sentry/transports.js +92 -99
  49. package/build/cjs/core/sentry/transports.js.map +1 -1
  50. package/build/cjs/core/sourcemap-settings.js +98 -61
  51. package/build/cjs/core/sourcemap-settings.js.map +1 -1
  52. package/build/cjs/core/upload-filter.js +52 -0
  53. package/build/cjs/core/upload-filter.js.map +1 -0
  54. package/build/cjs/core/utils.js +228 -219
  55. package/build/cjs/core/utils.js.map +1 -1
  56. package/build/cjs/core/version.js +4 -5
  57. package/build/cjs/core/version.js.map +1 -1
  58. package/build/cjs/esbuild/index.js +180 -210
  59. package/build/cjs/esbuild/index.js.map +1 -1
  60. package/build/cjs/loader-utils/index.js +5 -10
  61. package/build/cjs/rollup/debug-id-injection.js +22 -38
  62. package/build/cjs/rollup/debug-id-injection.js.map +1 -1
  63. package/build/cjs/rollup/debug-id-stamping.js +14 -24
  64. package/build/cjs/rollup/debug-id-stamping.js.map +1 -1
  65. package/build/cjs/rollup/index.js +195 -209
  66. package/build/cjs/rollup/index.js.map +1 -1
  67. package/build/cjs/rollup/source-map-handling.js +178 -0
  68. package/build/cjs/rollup/source-map-handling.js.map +1 -0
  69. package/build/cjs/vite/index.js +19 -35
  70. package/build/cjs/vite/index.js.map +1 -1
  71. package/build/cjs/vite/source-map-hooks.js +116 -0
  72. package/build/cjs/vite/source-map-hooks.js.map +1 -0
  73. package/build/cjs/webpack/component-annotation-transform.js +20 -26
  74. package/build/cjs/webpack/component-annotation-transform.js.map +1 -1
  75. package/build/cjs/webpack/index.js +277 -234
  76. package/build/cjs/webpack/index.js.map +1 -1
  77. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  78. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  79. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  80. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  81. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  82. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  83. package/build/esm/_virtual/_rolldown/runtime.js +2 -0
  84. package/build/esm/babel-plugin/component-annotation.js +13 -29
  85. package/build/esm/babel-plugin/component-annotation.js.map +1 -1
  86. package/build/esm/babel-plugin/constants.js +140 -120
  87. package/build/esm/babel-plugin/constants.js.map +1 -1
  88. package/build/esm/babel-plugin/experimental.js +204 -305
  89. package/build/esm/babel-plugin/experimental.js.map +1 -1
  90. package/build/esm/babel-plugin/index.js +311 -434
  91. package/build/esm/babel-plugin/index.js.map +1 -1
  92. package/build/esm/bun/index.js +76 -101
  93. package/build/esm/bun/index.js.map +1 -1
  94. package/build/esm/core/build-plugin-manager.js +621 -664
  95. package/build/esm/core/build-plugin-manager.js.map +1 -1
  96. package/build/esm/core/cli.js +134 -127
  97. package/build/esm/core/cli.js.map +1 -1
  98. package/build/esm/core/component-annotate-hooks.js +16 -25
  99. package/build/esm/core/component-annotate-hooks.js.map +1 -1
  100. package/build/esm/core/component-annotation-oxc-ast.js +9 -19
  101. package/build/esm/core/component-annotation-oxc-ast.js.map +1 -1
  102. package/build/esm/core/component-annotation-oxc-fragments.js +44 -72
  103. package/build/esm/core/component-annotation-oxc-fragments.js.map +1 -1
  104. package/build/esm/core/component-annotation-oxc-jsx.js +115 -154
  105. package/build/esm/core/component-annotation-oxc-jsx.js.map +1 -1
  106. package/build/esm/core/component-annotation-oxc-walk.js +61 -121
  107. package/build/esm/core/component-annotation-oxc-walk.js.map +1 -1
  108. package/build/esm/core/component-annotation-oxc.js +65 -96
  109. package/build/esm/core/component-annotation-oxc.js.map +1 -1
  110. package/build/esm/core/debug-id-upload.js +218 -213
  111. package/build/esm/core/debug-id-upload.js.map +1 -1
  112. package/build/esm/core/get-code-injection-position.js +59 -72
  113. package/build/esm/core/get-code-injection-position.js.map +1 -1
  114. package/build/esm/core/glob.js +9 -5
  115. package/build/esm/core/glob.js.map +1 -1
  116. package/build/esm/core/index.js +62 -47
  117. package/build/esm/core/index.js.map +1 -1
  118. package/build/esm/core/logger.js +17 -24
  119. package/build/esm/core/logger.js.map +1 -1
  120. package/build/esm/core/options-mapping.js +95 -115
  121. package/build/esm/core/options-mapping.js.map +1 -1
  122. package/build/esm/core/sentry/telemetry.js +89 -102
  123. package/build/esm/core/sentry/telemetry.js.map +1 -1
  124. package/build/esm/core/sentry/transports.js +90 -83
  125. package/build/esm/core/sentry/transports.js.map +1 -1
  126. package/build/esm/core/sourcemap-settings.js +96 -59
  127. package/build/esm/core/sourcemap-settings.js.map +1 -1
  128. package/build/esm/core/upload-filter.js +50 -0
  129. package/build/esm/core/upload-filter.js.map +1 -0
  130. package/build/esm/core/utils.js +221 -209
  131. package/build/esm/core/utils.js.map +1 -1
  132. package/build/esm/core/version.js +4 -3
  133. package/build/esm/core/version.js.map +1 -1
  134. package/build/esm/esbuild/index.js +176 -194
  135. package/build/esm/esbuild/index.js.map +1 -1
  136. package/build/esm/loader-utils/index.js +4 -3
  137. package/build/esm/package.json +1 -1
  138. package/build/esm/rollup/debug-id-injection.js +22 -36
  139. package/build/esm/rollup/debug-id-injection.js.map +1 -1
  140. package/build/esm/rollup/debug-id-stamping.js +14 -22
  141. package/build/esm/rollup/debug-id-stamping.js.map +1 -1
  142. package/build/esm/rollup/index.js +191 -189
  143. package/build/esm/rollup/index.js.map +1 -1
  144. package/build/esm/rollup/source-map-handling.js +173 -0
  145. package/build/esm/rollup/source-map-handling.js.map +1 -0
  146. package/build/esm/vite/index.js +19 -32
  147. package/build/esm/vite/index.js.map +1 -1
  148. package/build/esm/vite/source-map-hooks.js +114 -0
  149. package/build/esm/vite/source-map-hooks.js.map +1 -0
  150. package/build/esm/webpack/component-annotation-transform.js +17 -24
  151. package/build/esm/webpack/component-annotation-transform.js.map +1 -1
  152. package/build/esm/webpack/index.js +274 -216
  153. package/build/esm/webpack/index.js.map +1 -1
  154. package/build/types/core/build-plugin-manager.d.ts +33 -10
  155. package/build/types/core/build-plugin-manager.d.ts.map +1 -1
  156. package/build/types/core/cli.d.ts +6 -1
  157. package/build/types/core/cli.d.ts.map +1 -1
  158. package/build/types/core/debug-id-upload.d.ts +7 -4
  159. package/build/types/core/debug-id-upload.d.ts.map +1 -1
  160. package/build/types/core/index.d.ts +4 -3
  161. package/build/types/core/index.d.ts.map +1 -1
  162. package/build/types/core/options-mapping.d.ts +4 -3
  163. package/build/types/core/options-mapping.d.ts.map +1 -1
  164. package/build/types/core/sentry/telemetry.d.ts.map +1 -1
  165. package/build/types/core/sourcemap-settings.d.ts +10 -1
  166. package/build/types/core/sourcemap-settings.d.ts.map +1 -1
  167. package/build/types/core/types.d.ts +32 -1
  168. package/build/types/core/types.d.ts.map +1 -1
  169. package/build/types/core/upload-filter.d.ts +9 -0
  170. package/build/types/core/upload-filter.d.ts.map +1 -0
  171. package/build/types/core/utils.d.ts +4 -0
  172. package/build/types/core/utils.d.ts.map +1 -1
  173. package/build/types/core/version.d.ts +1 -1
  174. package/build/types/esbuild/index.d.ts +2 -2
  175. package/build/types/esbuild/index.d.ts.map +1 -1
  176. package/build/types/rollup/index.d.ts +107 -7
  177. package/build/types/rollup/index.d.ts.map +1 -1
  178. package/build/types/rollup/source-map-handling.d.ts +59 -0
  179. package/build/types/rollup/source-map-handling.d.ts.map +1 -0
  180. package/build/types/vite/index.d.ts +4 -8
  181. package/build/types/vite/index.d.ts.map +1 -1
  182. package/build/types/vite/source-map-hooks.d.ts +45 -0
  183. package/build/types/vite/source-map-hooks.d.ts.map +1 -0
  184. package/build/types/webpack/index.d.ts +7 -3
  185. package/build/types/webpack/index.d.ts.map +1 -1
  186. package/package.json +33 -38
  187. package/build/cjs/loader-utils/index.js.map +0 -1
  188. package/build/esm/loader-utils/index.js.map +0 -1
@@ -0,0 +1,178 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
2
+ const require_index = require("../core/index.js");
3
+ let node_path = require("node:path");
4
+ node_path = require_runtime.__toESM(node_path);
5
+ // src/rollup/source-map-handling.ts
6
+ /** Maps Rollup's (and Vite's) `sourcemap` setting onto the plugin's source map kinds. */
7
+ function sourceMapKindFromRollupSetting(setting) {
8
+ switch (setting) {
9
+ case void 0: return "unset";
10
+ case false: return "off";
11
+ case true: return "visible";
12
+ default: return setting;
13
+ }
14
+ }
15
+ /** The directory an output writes to. Decisions and stagings are keyed by it. */
16
+ function getOutputDestination(outputOptions) {
17
+ return node_path.resolve(outputOptions.dir ?? node_path.dirname(outputOptions.file ?? "."));
18
+ }
19
+ const MATCH_KEYS = [
20
+ "dir",
21
+ "file",
22
+ "format",
23
+ "entryFileNames",
24
+ "chunkFileNames",
25
+ "preserveModules",
26
+ "sourcemap"
27
+ ];
28
+ /** The raw options accept aliases that the normalized options do not carry. */
29
+ function normalizeFormat(format) {
30
+ switch (format) {
31
+ case "esm":
32
+ case "module": return "es";
33
+ case "commonjs": return "cjs";
34
+ case "systemjs": return "system";
35
+ default: return format;
36
+ }
37
+ }
38
+ /** The fields of `OutputMatch` an output sets, in the form the normalized options carry them. */
39
+ function getOutputMatch(outputOptions) {
40
+ const match = {};
41
+ for (const key of MATCH_KEYS) {
42
+ const value = outputOptions[key];
43
+ if (value === void 0) continue;
44
+ match[key] = key === "format" ? normalizeFormat(value) : key === "dir" || key === "file" ? node_path.resolve(String(value)) : value;
45
+ }
46
+ return match;
47
+ }
48
+ function matchesOutput(match, outputOptions) {
49
+ const actual = getOutputMatch(outputOptions);
50
+ return MATCH_KEYS.every((key) => match[key] === void 0 || match[key] === actual[key]);
51
+ }
52
+ function isSameMatch(a, b) {
53
+ return MATCH_KEYS.every((key) => a[key] === b[key]);
54
+ }
55
+ function countMatchFields(match) {
56
+ return MATCH_KEYS.filter((key) => match[key] !== void 0).length;
57
+ }
58
+ const DEBUG_ID_PATTERN = /sentry-dbid-([0-9a-f-]{36})|\/\/# debugId=([0-9a-f-]{36})/i;
59
+ /** Identifies the chunks of a bundle by name and debug ID, so a staging can be matched to its write. */
60
+ function getBundleSignature(bundle) {
61
+ const entries = [];
62
+ for (const output of Object.values(bundle)) if (output.type === "chunk" && require_index.isJsFile(output.fileName)) {
63
+ const match = output.code.match(DEBUG_ID_PATTERN);
64
+ entries.push(`${output.fileName}:${match?.[1] ?? match?.[2] ?? ""}`);
65
+ }
66
+ return entries.sort().join("\n");
67
+ }
68
+ function getSourceMapFileName(output) {
69
+ return output.sourcemapFileName ?? `${output.fileName}.map`;
70
+ }
71
+ /**
72
+ * Source map decisions and upload stagings of one plugin instance. Keyed by output destination
73
+ * because one instance can serve several outputs, and watch mode or several `write()` calls
74
+ * rebuild the same one. Outputs that share a directory are told apart by `OutputMatch`.
75
+ */
76
+ function createSourceMapHandling(sentryBuildPluginManager) {
77
+ const decisions = /* @__PURE__ */ new Map();
78
+ const pendingStagings = /* @__PURE__ */ new Map();
79
+ function setDecision(destination, record) {
80
+ const records = decisions.get(destination) ?? [];
81
+ const index = records.findIndex((existing) => isSameMatch(existing.match, record.match));
82
+ if (index === -1) records.push(record);
83
+ else records[index] = record;
84
+ decisions.set(destination, records);
85
+ }
86
+ function findDecision(destination, outputOptions) {
87
+ return (decisions.get(destination) ?? []).filter((record) => matchesOutput(record.match, outputOptions)).sort((a, b) => countMatchFields(b.match) - countMatchFields(a.match))[0];
88
+ }
89
+ function dropSourceMaps(bundle, shouldDrop = () => true) {
90
+ for (const output of Object.values(bundle)) if (output.type === "chunk" && require_index.isJsFile(output.fileName) && shouldDrop(output.fileName)) delete bundle[getSourceMapFileName(output)];
91
+ }
92
+ function dropAssetSourceMaps(bundle) {
93
+ const chunkMaps = /* @__PURE__ */ new Set();
94
+ for (const output of Object.values(bundle)) if (output.type === "chunk") chunkMaps.add(getSourceMapFileName(output));
95
+ for (const [fileName, output] of Object.entries(bundle)) if (output.type === "asset" && fileName.endsWith(".map") && !chunkMaps.has(fileName)) delete bundle[fileName];
96
+ }
97
+ return {
98
+ outputOptions: (rawOutputOptions) => {
99
+ const kind = sourceMapKindFromRollupSetting(rawOutputOptions.sourcemap);
100
+ const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });
101
+ const outputOptions = decision.enableHidden ? {
102
+ ...rawOutputOptions,
103
+ sourcemap: "hidden"
104
+ } : rawOutputOptions;
105
+ setDecision(getOutputDestination(rawOutputOptions), {
106
+ match: getOutputMatch(outputOptions),
107
+ kind,
108
+ decision
109
+ });
110
+ return decision.enableHidden ? outputOptions : null;
111
+ },
112
+ setDecision,
113
+ stageSourceMaps: async (outputOptions, bundle, isWrite) => {
114
+ const destination = getOutputDestination(outputOptions);
115
+ const record = findDecision(destination, outputOptions);
116
+ if (!record) return;
117
+ if (isWrite === false) {
118
+ if (record.kind === "unset" && record.decision.enableHidden) dropSourceMaps(bundle);
119
+ return;
120
+ }
121
+ sentryBuildPluginManager.sourceMaps.logDecision(record.decision);
122
+ if (!record.decision.deleteAfterUpload) return;
123
+ const removeAll = record.decision.removeAllSourceMaps === true;
124
+ if (removeAll && record.kind !== "unset") dropAssetSourceMaps(bundle);
125
+ if (!sentryBuildPluginManager.sourceMaps.uploadPossible) {
126
+ dropSourceMaps(bundle, removeAll ? void 0 : (fileName) => sentryBuildPluginManager.sourceMaps.shouldUpload(node_path.join(destination, fileName)));
127
+ return;
128
+ }
129
+ const staging = await sentryBuildPluginManager.createUploadStaging();
130
+ try {
131
+ for (const output of Object.values(bundle)) {
132
+ if (output.type !== "chunk" || !require_index.isJsFile(output.fileName)) continue;
133
+ const mapFileName = getSourceMapFileName(output);
134
+ const mapAsset = bundle[mapFileName];
135
+ if (mapAsset?.type !== "asset" || typeof mapAsset.source !== "string") continue;
136
+ const result = await staging.stage({
137
+ code: output.code,
138
+ mapSource: mapAsset.source,
139
+ mapDir: node_path.join(destination, node_path.dirname(mapFileName)),
140
+ chunkPath: node_path.join(destination, output.fileName)
141
+ });
142
+ if (result === "staged" || removeAll) delete bundle[mapFileName];
143
+ if (result === "skipped" || result === "failed") sentryBuildPluginManager.logger.warn(removeAll ? `Could not prepare ${output.fileName} for upload, so it is not uploaded and its source map ${mapFileName} was removed from the build output.` : `Could not prepare ${output.fileName} for upload, so its source map ${mapFileName} stays in the build output.`);
144
+ }
145
+ } catch (e) {
146
+ await staging.discard();
147
+ throw e;
148
+ }
149
+ const stagings = pendingStagings.get(destination) ?? [];
150
+ pendingStagings.set(destination, stagings);
151
+ const superseded = stagings.filter((pending) => isSameMatch(pending.match, record.match));
152
+ for (const pending of superseded) stagings.splice(stagings.indexOf(pending), 1);
153
+ stagings.push({
154
+ staging,
155
+ signature: getBundleSignature(bundle),
156
+ match: record.match
157
+ });
158
+ for (const pending of superseded) {
159
+ sentryBuildPluginManager.logger.debug(`Discarding staged source maps of an earlier build of ${destination} that was never written.`);
160
+ await pending.staging.discard();
161
+ }
162
+ },
163
+ takeStaging: async (outputOptions, bundle) => {
164
+ const destination = getOutputDestination(outputOptions);
165
+ const stagings = pendingStagings.get(destination) ?? [];
166
+ if (!bundle) return stagings.shift()?.staging;
167
+ const signature = getBundleSignature(bundle);
168
+ const index = stagings.findIndex((pending) => pending.signature === signature);
169
+ return index === -1 ? void 0 : stagings.splice(index, 1)[0]?.staging;
170
+ }
171
+ };
172
+ }
173
+ exports.createSourceMapHandling = createSourceMapHandling;
174
+ exports.getOutputDestination = getOutputDestination;
175
+ exports.getOutputMatch = getOutputMatch;
176
+ exports.sourceMapKindFromRollupSetting = sourceMapKindFromRollupSetting;
177
+
178
+ //# sourceMappingURL=source-map-handling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-map-handling.js","names":["path","isJsFile"],"sources":["../../../src/rollup/source-map-handling.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { SentryBuildPluginManager, SourceMapDecision, SourceMapKind, UploadStaging } from '../core';\nimport { isJsFile } from '../core';\nimport type { OutputBundle } from './debug-id-stamping';\n\nexport type RollupSourceMapSetting = boolean | 'inline' | 'hidden' | undefined;\n\nexport type OutputDestinationOptions = { dir?: string; file?: string };\n\n/**\n * The output options that tell outputs of one directory apart. Several outputs can write into the\n * same directory at once, for example an ES and a CJS build, each with its own `sourcemap` setting.\n * `sourcemap` holds the setting as the plugin left it, so an output it switched to hidden maps\n * differs from one the user set.\n */\nexport type OutputMatch = {\n dir?: unknown;\n file?: unknown;\n format?: unknown;\n entryFileNames?: unknown;\n chunkFileNames?: unknown;\n preserveModules?: unknown;\n sourcemap?: unknown;\n};\n\nexport type OutputOptions = OutputDestinationOptions & OutputMatch & { sourcemap?: RollupSourceMapSetting };\n\n/** Maps Rollup's (and Vite's) `sourcemap` setting onto the plugin's source map kinds. */\nexport function sourceMapKindFromRollupSetting(setting: RollupSourceMapSetting): SourceMapKind {\n switch (setting) {\n case undefined:\n return 'unset';\n case false:\n return 'off';\n case true:\n return 'visible';\n default:\n return setting;\n }\n}\n\n/** The directory an output writes to. Decisions and stagings are keyed by it. */\nexport function getOutputDestination(outputOptions: OutputDestinationOptions): string {\n return path.resolve(outputOptions.dir ?? path.dirname(outputOptions.file ?? '.'));\n}\n\nconst MATCH_KEYS = [\n 'dir',\n 'file',\n 'format',\n 'entryFileNames',\n 'chunkFileNames',\n 'preserveModules',\n 'sourcemap',\n] as const;\n\n/** The raw options accept aliases that the normalized options do not carry. */\nfunction normalizeFormat(format: unknown): unknown {\n switch (format) {\n case 'esm':\n case 'module':\n return 'es';\n case 'commonjs':\n return 'cjs';\n case 'systemjs':\n return 'system';\n default:\n return format;\n }\n}\n\n/** The fields of `OutputMatch` an output sets, in the form the normalized options carry them. */\nexport function getOutputMatch(outputOptions: OutputMatch): OutputMatch {\n const match: OutputMatch = {};\n for (const key of MATCH_KEYS) {\n const value = outputOptions[key];\n if (value === undefined) {\n continue;\n }\n match[key] =\n key === 'format' ? normalizeFormat(value) : key === 'dir' || key === 'file' ? path.resolve(String(value)) : value;\n }\n return match;\n}\n\nfunction matchesOutput(match: OutputMatch, outputOptions: OutputMatch): boolean {\n const actual = getOutputMatch(outputOptions);\n return MATCH_KEYS.every(key => match[key] === undefined || match[key] === actual[key]);\n}\n\nfunction isSameMatch(a: OutputMatch, b: OutputMatch): boolean {\n return MATCH_KEYS.every(key => a[key] === b[key]);\n}\n\nfunction countMatchFields(match: OutputMatch): number {\n return MATCH_KEYS.filter(key => match[key] !== undefined).length;\n}\n\nconst DEBUG_ID_PATTERN = /sentry-dbid-([0-9a-f-]{36})|\\/\\/# debugId=([0-9a-f-]{36})/i;\n\n/** Identifies the chunks of a bundle by name and debug ID, so a staging can be matched to its write. */\nfunction getBundleSignature(bundle: OutputBundle): string {\n const entries: string[] = [];\n for (const output of Object.values(bundle)) {\n if (output.type === 'chunk' && isJsFile(output.fileName)) {\n const match = output.code.match(DEBUG_ID_PATTERN);\n entries.push(`${output.fileName}:${match?.[1] ?? match?.[2] ?? ''}`);\n }\n }\n return entries.sort().join('\\n');\n}\n\nfunction getSourceMapFileName(output: { fileName: string; sourcemapFileName?: string | null }): string {\n return output.sourcemapFileName ?? `${output.fileName}.map`;\n}\n\ntype PendingStaging = { staging: UploadStaging; signature: string; match: OutputMatch };\n\nexport type DecisionRecord = { match: OutputMatch; kind: SourceMapKind; decision: SourceMapDecision };\n\nexport type SourceMapHandling = {\n /** Rollup's `outputOptions` hook: decides for the output and switches it to hidden source maps when needed. */\n outputOptions: (rawOutputOptions: OutputOptions) => OutputOptions | null;\n /** Records the decision for an output, for bundlers that decide outside `outputOptions`. */\n setDecision: (destination: string, record: DecisionRecord) => void;\n /**\n * `generateBundle` with `order: 'post'`: copies each chunk and its source map into a staging folder\n * and drops the map asset from the bundle, so the bundler never writes it.\n */\n stageSourceMaps: (outputOptions: OutputOptions, bundle: OutputBundle, isWrite?: boolean) => Promise<void>;\n /**\n * Hands the staging of this bundle to `writeBundle`. Without a bundle (SvelteKit calls the hook\n * with output options only) the oldest staging is taken.\n */\n takeStaging: (\n outputOptions: OutputDestinationOptions,\n bundle: OutputBundle | undefined,\n ) => Promise<UploadStaging | undefined>;\n};\n\n/**\n * Source map decisions and upload stagings of one plugin instance. Keyed by output destination\n * because one instance can serve several outputs, and watch mode or several `write()` calls\n * rebuild the same one. Outputs that share a directory are told apart by `OutputMatch`.\n */\nexport function createSourceMapHandling(sentryBuildPluginManager: SentryBuildPluginManager): SourceMapHandling {\n const decisions = new Map<string, DecisionRecord[]>();\n const pendingStagings = new Map<string, PendingStaging[]>();\n\n function setDecision(destination: string, record: DecisionRecord): void {\n const records = decisions.get(destination) ?? [];\n const index = records.findIndex(existing => isSameMatch(existing.match, record.match));\n if (index === -1) {\n records.push(record);\n } else {\n records[index] = record;\n }\n decisions.set(destination, records);\n }\n\n function findDecision(destination: string, outputOptions: OutputOptions): DecisionRecord | undefined {\n const candidates = (decisions.get(destination) ?? []).filter(record => matchesOutput(record.match, outputOptions));\n // The record that sets the most fields describes this output best. Equal\n // candidates keep their order, so the first one recorded wins.\n return candidates.sort((a, b) => countMatchFields(b.match) - countMatchFields(a.match))[0];\n }\n\n function dropSourceMaps(bundle: OutputBundle, shouldDrop: (fileName: string) => boolean = () => true): void {\n for (const output of Object.values(bundle)) {\n if (output.type === 'chunk' && isJsFile(output.fileName) && shouldDrop(output.fileName)) {\n // oxlint-disable-next-line typescript/no-dynamic-delete -- Rollup drops an asset when its key is deleted from the bundle\n delete bundle[getSourceMapFileName(output)];\n }\n }\n }\n\n // Other plugins emit maps as assets, e.g. for CSS or for Vite worker\n // bundles. Chunk maps stay here, because staging still needs them.\n function dropAssetSourceMaps(bundle: OutputBundle): void {\n const chunkMaps = new Set<string>();\n for (const output of Object.values(bundle)) {\n if (output.type === 'chunk') {\n chunkMaps.add(getSourceMapFileName(output));\n }\n }\n for (const [fileName, output] of Object.entries(bundle)) {\n if (output.type === 'asset' && fileName.endsWith('.map') && !chunkMaps.has(fileName)) {\n // oxlint-disable-next-line typescript/no-dynamic-delete -- Rollup drops an asset when its key is deleted from the bundle\n delete bundle[fileName];\n }\n }\n }\n\n return {\n outputOptions: rawOutputOptions => {\n const kind = sourceMapKindFromRollupSetting(rawOutputOptions.sourcemap);\n // Logged in `generateBundle`, which knows whether the output is written.\n const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });\n const outputOptions = decision.enableHidden\n ? { ...rawOutputOptions, sourcemap: 'hidden' as const }\n : rawOutputOptions;\n setDecision(getOutputDestination(rawOutputOptions), { match: getOutputMatch(outputOptions), kind, decision });\n\n return decision.enableHidden ? outputOptions : null;\n },\n\n setDecision,\n\n stageSourceMaps: async (outputOptions, bundle, isWrite) => {\n const destination = getOutputDestination(outputOptions);\n const record = findDecision(destination, outputOptions);\n if (!record) {\n return;\n }\n\n // `generate()` never reaches `writeBundle`, so nothing would upload a staging. Maps the\n // plugin turned on are dropped, so the result holds what the user configured.\n if (isWrite === false) {\n if (record.kind === 'unset' && record.decision.enableHidden) {\n dropSourceMaps(bundle);\n }\n return;\n }\n\n sentryBuildPluginManager.sourceMaps.logDecision(record.decision);\n if (!record.decision.deleteAfterUpload) {\n return;\n }\n\n const removeAll = record.decision.removeAllSourceMaps === true;\n // With `unset` the plugin only turned on the chunk maps. Asset maps\n // come from other plugins' own settings.\n if (removeAll && record.kind !== 'unset') {\n dropAssetSourceMaps(bundle);\n }\n\n if (!sentryBuildPluginManager.sourceMaps.uploadPossible) {\n dropSourceMaps(\n bundle,\n removeAll\n ? undefined\n : fileName => sentryBuildPluginManager.sourceMaps.shouldUpload(path.join(destination, fileName)),\n );\n return;\n }\n\n const staging = await sentryBuildPluginManager.createUploadStaging();\n\n try {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const mapFileName = getSourceMapFileName(output);\n const mapAsset = bundle[mapFileName];\n if (mapAsset?.type !== 'asset' || typeof mapAsset.source !== 'string') {\n continue;\n }\n\n const result = await staging.stage({\n code: output.code,\n mapSource: mapAsset.source,\n mapDir: path.join(destination, path.dirname(mapFileName)),\n chunkPath: path.join(destination, output.fileName),\n });\n\n // A map the plugin or the SDK turned on never reaches the output,\n // whether or not the chunk is uploaded. A map the user enabled\n // stays unless it was staged.\n if (result === 'staged' || removeAll) {\n // oxlint-disable-next-line typescript/no-dynamic-delete -- Rollup drops an asset when its key is deleted from the bundle\n delete bundle[mapFileName];\n }\n if (result === 'skipped' || result === 'failed') {\n sentryBuildPluginManager.logger.warn(\n removeAll\n ? `Could not prepare ${output.fileName} for upload, so it is not uploaded and its source map ${mapFileName} was removed from the build output.`\n : `Could not prepare ${output.fileName} for upload, so its source map ${mapFileName} stays in the build output.`,\n );\n }\n }\n } catch (e) {\n // The error fails the build before anything is written.\n await staging.discard();\n throw e;\n }\n\n // A staging of the same output that no `writeBundle` took belongs to a\n // write that never finished. Stagings of other outputs to this directory\n // may still be in flight, so the shared list changes in place and without\n // an await in between.\n const stagings = pendingStagings.get(destination) ?? [];\n pendingStagings.set(destination, stagings);\n const superseded = stagings.filter(pending => isSameMatch(pending.match, record.match));\n for (const pending of superseded) {\n stagings.splice(stagings.indexOf(pending), 1);\n }\n stagings.push({ staging, signature: getBundleSignature(bundle), match: record.match });\n\n for (const pending of superseded) {\n sentryBuildPluginManager.logger.debug(\n `Discarding staged source maps of an earlier build of ${destination} that was never written.`,\n );\n await pending.staging.discard();\n }\n },\n\n takeStaging: async (outputOptions, bundle) => {\n const destination = getOutputDestination(outputOptions);\n const stagings = pendingStagings.get(destination) ?? [];\n\n if (!bundle) {\n return stagings.shift()?.staging;\n }\n\n const signature = getBundleSignature(bundle);\n const index = stagings.findIndex(pending => pending.signature === signature);\n return index === -1 ? undefined : stagings.splice(index, 1)[0]?.staging;\n },\n };\n}\n"],"mappings":";;;;;;AA4BA,SAAgB,+BAA+B,SAAgD;CAC7F,QAAQ,SAAR;EACE,KAAK,KAAA,GACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,MACH,OAAO;EACT,SACE,OAAO;CACX;AACF;;AAGA,SAAgB,qBAAqB,eAAiD;CACpF,OAAOA,UAAK,QAAQ,cAAc,OAAOA,UAAK,QAAQ,cAAc,QAAQ,GAAG,CAAC;AAClF;AAEA,MAAM,aAAa;CACjB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAS,gBAAgB,QAA0B;CACjD,QAAQ,QAAR;EACE,KAAK;EACL,KAAK,UACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,SACE,OAAO;CACX;AACF;;AAGA,SAAgB,eAAe,eAAyC;CACtE,MAAM,QAAqB,CAAC;CAC5B,KAAK,MAAM,OAAO,YAAY;EAC5B,MAAM,QAAQ,cAAc;EAC5B,IAAI,UAAU,KAAA,GACZ;EAEF,MAAM,OACJ,QAAQ,WAAW,gBAAgB,KAAK,IAAI,QAAQ,SAAS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ACzC,MAAM,aAAa,SAAS,QAAO,YAAW,YAAY,QAAQ,OAAO,OAAO,KAAK,CAAC;GACtF,KAAK,MAAM,WAAW,YACpB,SAAS,OAAO,SAAS,QAAQ,OAAO,GAAG,CAAC;GAE9C,SAAS,KAAK;IAAE;IAAS,WAAW,mBAAmB,MAAM;IAAG,OAAO,OAAO;GAAM,CAAC;GAErF,KAAK,MAAM,WAAW,YAAY;IAChC,yBAAyB,OAAO,MAC9B,wDAAwD,YAAY,yBACtE;IACA,MAAM,QAAQ,QAAQ,QAAQ;GAChC;EACF;EAEA,aAAa,OAAO,eAAe,WAAW;GAC5C,MAAM,cAAc,qBAAqB,aAAa;GACtD,MAAM,WAAW,gBAAgB,IAAI,WAAW,KAAK,CAAC;GAEtD,IAAI,CAAC,QACH,OAAO,SAAS,MAAM,CAAC,EAAE;GAG3B,MAAM,YAAY,mBAAmB,MAAM;GAC3C,MAAM,QAAQ,SAAS,WAAU,YAAW,QAAQ,cAAc,SAAS;GAC3E,OAAO,UAAU,KAAK,KAAA,IAAY,SAAS,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;EAClE;CACF;AACF"}
@@ -1,40 +1,24 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const index = require('../rollup/index.js');
4
- const node_module = require('node:module');
5
- const debugIdStamping = require('../rollup/debug-id-stamping.js');
6
-
7
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_index = require("../rollup/index.js");
3
+ let node_module = require("node:module");
4
+ // src/vite/index.ts
8
5
  function getViteMajorVersion() {
9
- try {
10
- const req = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite/index.js', document.baseURI).href)));
11
- const vite = req("vite");
12
- return vite.version?.split(".")[0];
13
- } catch {
14
- }
15
- return void 0;
6
+ try {
7
+ return (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("vite").version?.split(".")[0];
8
+ } catch {}
16
9
  }
17
10
  const sentryVitePlugin = (options) => {
18
- const plugins = [
19
- {
20
- enforce: "pre",
21
- ...index._rollupPluginInternal(options, "vite", getViteMajorVersion())
22
- }
23
- ];
24
- if (!options?.disable && options?.sourcemaps?.disable === "disable-upload") {
25
- plugins.push({
26
- name: "sentry-vite-debug-id-sourcemaps",
27
- enforce: "post",
28
- generateBundle: {
29
- order: "post",
30
- handler(_outputOptions, bundle) {
31
- debugIdStamping.stampDebugIds(bundle, false);
32
- }
33
- }
34
- });
35
- }
36
- return plugins;
11
+ const { main, post } = require_index._createRollupPluginInternals(options, "vite", getViteMajorVersion());
12
+ const plugins = [{
13
+ enforce: "pre",
14
+ ...main
15
+ }];
16
+ if (post) plugins.push({
17
+ enforce: "post",
18
+ ...post
19
+ });
20
+ return plugins;
37
21
  };
38
-
39
22
  exports.sentryVitePlugin = sentryVitePlugin;
40
- //# sourceMappingURL=index.js.map
23
+
24
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/vite/index.ts"],"sourcesContent":["import type { SentryRollupPluginOptions } from '../rollup';\nimport { _rollupPluginInternal } from '../rollup';\nimport { createRequire } from 'node:module';\nimport { stampDebugIds, type OutputBundle } from '../rollup/debug-id-stamping';\n\ninterface SentryVitePlugin {\n name: string;\n enforce: 'pre' | 'post';\n generateBundle?: {\n order: 'pre' | 'post';\n handler: (_outputOptions: unknown, bundle: OutputBundle) => void;\n };\n}\n\nfunction getViteMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const vite = req('vite') as { version?: string };\n return vite.version?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nexport const sentryVitePlugin = (options?: SentryRollupPluginOptions): SentryVitePlugin[] => {\n const plugins: SentryVitePlugin[] = [\n {\n enforce: 'pre',\n ..._rollupPluginInternal(options, 'vite', getViteMajorVersion()),\n },\n ];\n\n if (!options?.disable && options?.sourcemaps?.disable === 'disable-upload') {\n plugins.push({\n name: 'sentry-vite-debug-id-sourcemaps',\n enforce: 'post',\n generateBundle: {\n order: 'post',\n handler(_outputOptions, bundle) {\n // Vite's module preload rewrite in `generateBundle` regenerates the source map of every\n // chunk with a dynamic import, which drops the debug ID the main plugin stamped in its\n // `pre` hook. Restore it without touching the chunk code, so file hashes stay valid.\n stampDebugIds(bundle, false);\n },\n },\n });\n }\n\n return plugins;\n};\n\nexport type { Options as SentryVitePluginOptions } from '../core';\n"],"names":["createRequire","_rollupPluginInternal","stampDebugIds"],"mappings":";;;;;;;AAcA,SAAS,mBAAA,GAA0C;AACjD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAMA,yBAAA,CAAc,+PAAe,CAAA;AACzC,IAAA,MAAM,IAAA,GAAO,IAAI,MAAM,CAAA;AACvB,IAAA,OAAO,IAAA,CAAK,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACnC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEO,MAAM,gBAAA,GAAmB,CAAC,OAAA,KAA4D;AAC3F,EAAA,MAAM,OAAA,GAA8B;AAAA,IAClC;AAAA,MACE,OAAA,EAAS,KAAA;AAAA,MACT,GAAGC,2BAAA,CAAsB,OAAA,EAAS,MAAA,EAAQ,qBAAqB;AAAA;AACjE,GACF;AAEA,EAAA,IAAI,CAAC,OAAA,EAAS,OAAA,IAAW,OAAA,EAAS,UAAA,EAAY,YAAY,gBAAA,EAAkB;AAC1E,IAAA,OAAA,CAAQ,IAAA,CAAK;AAAA,MACX,IAAA,EAAM,iCAAA;AAAA,MACN,OAAA,EAAS,MAAA;AAAA,MACT,cAAA,EAAgB;AAAA,QACd,KAAA,EAAO,MAAA;AAAA,QACP,OAAA,CAAQ,gBAAgB,MAAA,EAAQ;AAI9B,UAAAC,6BAAA,CAAc,QAAQ,KAAK,CAAA;AAAA,QAC7B;AAAA;AACF,KACD,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,OAAA;AACT;;;;"}
1
+ {"version":3,"file":"index.js","names":["createRequire","_createRollupPluginInternals"],"sources":["../../../src/vite/index.ts"],"sourcesContent":["import type { InternalOptions } from '../core';\nimport { _createRollupPluginInternals } from '../rollup';\nimport { createRequire } from 'node:module';\n\ninterface SentryVitePlugin {\n name: string;\n enforce: 'pre' | 'post';\n [hook: string]: unknown;\n}\n\nfunction getViteMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const vite = req('vite') as { version?: string };\n return vite.version?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nexport const sentryVitePlugin = (options?: InternalOptions): SentryVitePlugin[] => {\n const { main, post } = _createRollupPluginInternals(options, 'vite', getViteMajorVersion());\n\n const plugins: SentryVitePlugin[] = [{ enforce: 'pre', ...main }];\n\n if (post) {\n plugins.push({ enforce: 'post', ...post });\n }\n\n return plugins;\n};\n\nexport type { Options as SentryVitePluginOptions, InternalOptions as SentryVitePluginInternalOptions } from '../core';\n"],"mappings":";;;;AAUA,SAAS,sBAA0C;CACjD,IAAI;EAKF,QAAA,GAFYA,YAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IACG,CAAC,CAAC,MACP,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC;CAClC,QAAQ,CAER;AAGF;AAEA,MAAa,oBAAoB,YAAkD;CACjF,MAAM,EAAE,MAAM,SAASC,cAAAA,6BAA6B,SAAS,QAAQ,oBAAoB,CAAC;CAE1F,MAAM,UAA8B,CAAC;EAAE,SAAS;EAAO,GAAG;CAAK,CAAC;CAEhE,IAAI,MACF,QAAQ,KAAK;EAAE,SAAS;EAAQ,GAAG;CAAK,CAAC;CAG3C,OAAO;AACT"}
@@ -0,0 +1,116 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
2
+ const require_sourcemap_settings = require("../core/sourcemap-settings.js");
3
+ require("../core/index.js");
4
+ const require_source_map_handling = require("../rollup/source-map-handling.js");
5
+ let node_path = require("node:path");
6
+ node_path = require_runtime.__toESM(node_path);
7
+ // src/vite/source-map-hooks.ts
8
+ const NO_CHANGE = {
9
+ enableHidden: false,
10
+ deleteAfterUpload: false
11
+ };
12
+ /**
13
+ * The outputs an environment writes: one per entry of `rollupOptions.output` or
14
+ * `rolldownOptions.output`. An output writes to `build.outDir` (relative to the root) unless it
15
+ * sets its own `dir`, which the bundler resolves from the working directory. An output's own
16
+ * `sourcemap` overrides `build.sourcemap`.
17
+ */
18
+ function getOutputs(root, build) {
19
+ const configured = build.rolldownOptions?.output ?? build.rollupOptions?.output;
20
+ return (Array.isArray(configured) ? configured : [configured ?? {}]).map((output) => {
21
+ const sourcemap = output.sourcemap ?? build.sourcemap;
22
+ return {
23
+ destination: output.dir === void 0 ? node_path.resolve(root, build.outDir ?? "dist") : node_path.resolve(output.dir),
24
+ match: require_source_map_handling.getOutputMatch({
25
+ ...output,
26
+ sourcemap
27
+ }),
28
+ sourcemap,
29
+ ownSetting: output.sourcemap !== void 0
30
+ };
31
+ });
32
+ }
33
+ /**
34
+ * Vite warns about `rollupOptions.output.sourcemap`, so the Vite plugin decides on `build.sourcemap`
35
+ * in a `config` hook. The hook belongs on the post plugin: framework plugins that set
36
+ * `build.sourcemap` themselves run first, and the decision sees the merged setting. The output
37
+ * directories are only known in `configResolved`, which then records the decision for each of them.
38
+ */
39
+ function createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) {
40
+ const decisions = /* @__PURE__ */ new Map();
41
+ return {
42
+ config: (userConfig, env) => {
43
+ if (env.command !== "build") return null;
44
+ decisions.clear();
45
+ const kind = require_source_map_handling.sourceMapKindFromRollupSetting(userConfig.build?.sourcemap);
46
+ const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });
47
+ decisions.set("*", {
48
+ kind,
49
+ decision
50
+ });
51
+ const result = decision.enableHidden ? { build: { sourcemap: "hidden" } } : {};
52
+ for (const [name, environment] of Object.entries(userConfig.environments ?? {})) {
53
+ const setting = environment?.build?.sourcemap;
54
+ if (setting === void 0) continue;
55
+ const environmentKind = require_source_map_handling.sourceMapKindFromRollupSetting(setting);
56
+ const environmentDecision = sentryBuildPluginManager.sourceMaps.decide(environmentKind, {
57
+ log: false,
58
+ environment: name
59
+ });
60
+ decisions.set(name, {
61
+ kind: environmentKind,
62
+ decision: environmentDecision
63
+ });
64
+ if (environmentDecision.enableHidden) result.environments = {
65
+ ...result.environments,
66
+ [name]: { build: { sourcemap: "hidden" } }
67
+ };
68
+ }
69
+ return result;
70
+ },
71
+ configResolved: (config) => {
72
+ const environments = config.environments ?? { client: { build: config.build } };
73
+ for (const [name, environment] of Object.entries(environments)) {
74
+ const { kind, decision } = decisions.get(name) ?? decisions.get("*") ?? {
75
+ kind: "unset",
76
+ decision: NO_CHANGE
77
+ };
78
+ const environmentName = decisions.has(name) ? name : void 0;
79
+ const { normalizedOptions } = sentryBuildPluginManager;
80
+ const deleteOption = require_sourcemap_settings.getDeleteSourcemapsAfterUpload(normalizedOptions, environmentName);
81
+ const sdkEnabledSourceMaps = require_sourcemap_settings.getSdkEnabledSourceMaps(normalizedOptions, environmentName);
82
+ for (const output of getOutputs(config.root, environment.build)) {
83
+ if (output.ownSetting) {
84
+ const outputKind = require_source_map_handling.sourceMapKindFromRollupSetting(output.sourcemap);
85
+ const removeAllSourceMaps = sdkEnabledSourceMaps && (outputKind === "hidden" || outputKind === "visible");
86
+ sourceMapHandling.setDecision(output.destination, {
87
+ match: output.match,
88
+ kind: outputKind,
89
+ decision: {
90
+ enableHidden: false,
91
+ deleteAfterUpload: deleteOption === true && (outputKind === "hidden" || removeAllSourceMaps),
92
+ removeAllSourceMaps
93
+ }
94
+ });
95
+ continue;
96
+ }
97
+ if (decision.deleteAfterUpload && output.sourcemap !== "hidden") {
98
+ sentryBuildPluginManager.logger.debug(`Source maps of the "${name}" environment are set to ${JSON.stringify(output.sourcemap)}. Not removing them after upload.`);
99
+ sourceMapHandling.setDecision(output.destination, {
100
+ match: output.match,
101
+ kind,
102
+ decision: NO_CHANGE
103
+ });
104
+ } else sourceMapHandling.setDecision(output.destination, {
105
+ match: output.match,
106
+ kind,
107
+ decision
108
+ });
109
+ }
110
+ }
111
+ }
112
+ };
113
+ }
114
+ exports.createViteSourceMapHooks = createViteSourceMapHooks;
115
+
116
+ //# sourceMappingURL=source-map-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-map-hooks.js","names":["path","getOutputMatch","sourceMapKindFromRollupSetting","getDeleteSourcemapsAfterUpload","getSdkEnabledSourceMaps"],"sources":["../../../src/vite/source-map-hooks.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { SentryBuildPluginManager, SourceMapDecision, SourceMapKind } from '../core';\nimport { getDeleteSourcemapsAfterUpload, getSdkEnabledSourceMaps } from '../core';\nimport type { OutputMatch, RollupSourceMapSetting, SourceMapHandling } from '../rollup/source-map-handling';\nimport { getOutputMatch, sourceMapKindFromRollupSetting } from '../rollup/source-map-handling';\n\ntype BundlerOutput = OutputMatch & { dir?: string; sourcemap?: RollupSourceMapSetting };\ntype BundlerOutputOptions = BundlerOutput | BundlerOutput[] | undefined;\n\ntype ViteBuildOptions = {\n sourcemap?: RollupSourceMapSetting;\n outDir?: string;\n rollupOptions?: { output?: BundlerOutputOptions };\n rolldownOptions?: { output?: BundlerOutputOptions };\n};\n\nexport type ViteUserConfig = {\n build?: ViteBuildOptions;\n environments?: Record<string, { build?: ViteBuildOptions } | undefined>;\n};\n\nexport type ViteResolvedConfig = {\n root: string;\n build: ViteBuildOptions;\n environments?: Record<string, { build: ViteBuildOptions }>;\n};\n\nexport type ViteSourceMapHooks = {\n config: (userConfig: ViteUserConfig, env: { command: string }) => ViteUserConfig | null;\n configResolved: (config: ViteResolvedConfig) => void;\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\ntype EnvironmentOutput = {\n destination: string;\n match: OutputMatch;\n sourcemap: RollupSourceMapSetting;\n /** The output sets `sourcemap` itself, which overrides `build.sourcemap`. */\n ownSetting: boolean;\n};\n\n/**\n * The outputs an environment writes: one per entry of `rollupOptions.output` or\n * `rolldownOptions.output`. An output writes to `build.outDir` (relative to the root) unless it\n * sets its own `dir`, which the bundler resolves from the working directory. An output's own\n * `sourcemap` overrides `build.sourcemap`.\n */\nfunction getOutputs(root: string, build: ViteBuildOptions): EnvironmentOutput[] {\n const configured = build.rolldownOptions?.output ?? build.rollupOptions?.output;\n const outputs = Array.isArray(configured) ? configured : [configured ?? {}];\n\n return outputs.map(output => {\n const sourcemap = output.sourcemap ?? build.sourcemap;\n return {\n destination: output.dir === undefined ? path.resolve(root, build.outDir ?? 'dist') : path.resolve(output.dir),\n match: getOutputMatch({ ...output, sourcemap }),\n sourcemap,\n ownSetting: output.sourcemap !== undefined,\n };\n });\n}\n\n/**\n * Vite warns about `rollupOptions.output.sourcemap`, so the Vite plugin decides on `build.sourcemap`\n * in a `config` hook. The hook belongs on the post plugin: framework plugins that set\n * `build.sourcemap` themselves run first, and the decision sees the merged setting. The output\n * directories are only known in `configResolved`, which then records the decision for each of them.\n */\nexport function createViteSourceMapHooks(\n sentryBuildPluginManager: SentryBuildPluginManager,\n sourceMapHandling: SourceMapHandling,\n): ViteSourceMapHooks {\n // `'*'` for the top-level setting, otherwise the name of an environment with its own.\n const decisions = new Map<string, { kind: SourceMapKind; decision: SourceMapDecision }>();\n\n return {\n config: (userConfig, env) => {\n if (env.command !== 'build') {\n return null;\n }\n\n // The same plugin instances can serve several builds in a row.\n decisions.clear();\n\n const kind = sourceMapKindFromRollupSetting(userConfig.build?.sourcemap);\n // Logged in `generateBundle`, which knows whether the output is written.\n const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });\n decisions.set('*', { kind, decision });\n\n const result: ViteUserConfig = decision.enableHidden ? { build: { sourcemap: 'hidden' } } : {};\n\n for (const [name, environment] of Object.entries(userConfig.environments ?? {})) {\n const setting = environment?.build?.sourcemap;\n if (setting === undefined) {\n continue;\n }\n\n const environmentKind = sourceMapKindFromRollupSetting(setting);\n const environmentDecision = sentryBuildPluginManager.sourceMaps.decide(environmentKind, {\n log: false,\n environment: name,\n });\n decisions.set(name, { kind: environmentKind, decision: environmentDecision });\n\n if (environmentDecision.enableHidden) {\n result.environments = { ...result.environments, [name]: { build: { sourcemap: 'hidden' } } };\n }\n }\n\n return result;\n },\n\n configResolved: config => {\n const environments = config.environments ?? { client: { build: config.build } };\n\n for (const [name, environment] of Object.entries(environments)) {\n const { kind, decision } = decisions.get(name) ?? decisions.get('*') ?? { kind: 'unset', decision: NO_CHANGE };\n const environmentName = decisions.has(name) ? name : undefined;\n const { normalizedOptions } = sentryBuildPluginManager;\n const deleteOption = getDeleteSourcemapsAfterUpload(normalizedOptions, environmentName);\n const sdkEnabledSourceMaps = getSdkEnabledSourceMaps(normalizedOptions, environmentName);\n\n for (const output of getOutputs(config.root, environment.build)) {\n // The plugin never changes an output's own setting. Hidden maps are\n // removed when the user asks for it, visible ones only when the SDK\n // turned source maps on.\n if (output.ownSetting) {\n const outputKind = sourceMapKindFromRollupSetting(output.sourcemap);\n const removeAllSourceMaps = sdkEnabledSourceMaps && (outputKind === 'hidden' || outputKind === 'visible');\n sourceMapHandling.setDecision(output.destination, {\n match: output.match,\n kind: outputKind,\n decision: {\n enableHidden: false,\n deleteAfterUpload: deleteOption === true && (outputKind === 'hidden' || removeAllSourceMaps),\n removeAllSourceMaps,\n },\n });\n continue;\n }\n\n // A plugin that ran after ours may have changed the setting again.\n if (decision.deleteAfterUpload && output.sourcemap !== 'hidden') {\n sentryBuildPluginManager.logger.debug(\n `Source maps of the \"${name}\" environment are set to ${JSON.stringify(output.sourcemap)}. Not removing them after upload.`,\n );\n sourceMapHandling.setDecision(output.destination, { match: output.match, kind, decision: NO_CHANGE });\n } else {\n sourceMapHandling.setDecision(output.destination, { match: output.match, kind, decision });\n }\n }\n }\n },\n };\n}\n"],"mappings":";;;;;;;AAgCA,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,OAAO,SAAS;GAEvE,MAAM,WAAW,yBAAyB,WAAW,OAAO,MAAM,EAAE,KAAK,MAAM,CAAC;GAChF,UAAU,IAAI,KAAK;IAAE;IAAM;GAAS,CAAC;GAErC,MAAM,SAAyB,SAAS,eAAe,EAAE,OAAO,EAAE,WAAW,SAAS,EAAE,IAAI,CAAC;GAE7F,KAAK,MAAM,CAAC,MAAM,gBAAgB,OAAO,QAAQ,WAAW,g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B,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;CACF;AACF"}
@@ -1,29 +1,23 @@
1
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
-
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ // src/webpack/component-annotation-transform.ts
3
6
  async function transform(source, map) {
4
- const callback = this.async();
5
- const { transform: transformFn } = this.query;
6
- if (!transformFn) {
7
- return callback(null, source, map);
8
- }
9
- try {
10
- const id = this.resourcePath;
11
- const result = await transformFn(source, id);
12
- if (result == null) {
13
- callback(null, source, map);
14
- } else if (typeof result === "string") {
15
- callback(null, result, map);
16
- } else {
17
- callback(null, result.code, result.map || map);
18
- }
19
- } catch (error) {
20
- if (error instanceof Error) {
21
- callback(error);
22
- } else {
23
- callback(new Error(String(error)));
24
- }
25
- }
7
+ const callback = this.async();
8
+ const { transform: transformFn } = this.query;
9
+ if (!transformFn) return callback(null, source, map);
10
+ try {
11
+ const id = this.resourcePath;
12
+ const result = await transformFn(source, id);
13
+ if (result == null) callback(null, source, map);
14
+ else if (typeof result === "string") callback(null, result, map);
15
+ else callback(null, result.code, result.map || map);
16
+ } catch (error) {
17
+ if (error instanceof Error) callback(error);
18
+ else callback(new Error(String(error)));
19
+ }
26
20
  }
27
-
28
21
  exports.default = transform;
29
- //# sourceMappingURL=component-annotation-transform.js.map
22
+
23
+ //# sourceMappingURL=component-annotation-transform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component-annotation-transform.js","sources":["../../../src/webpack/component-annotation-transform.ts"],"sourcesContent":["// Webpack loader for component annotation transform\n// Based on unplugin v1.0.1 transform loader pattern\n\nexport default async function transform(\n this: {\n async: () => (err: Error | null, content?: string, sourceMap?: unknown) => void;\n resourcePath: string;\n query: {\n transform?: (code: string, id: string) => Promise<{ code: string; map?: unknown } | null | undefined | string>;\n };\n },\n source: string,\n map: unknown,\n): Promise<void> {\n const callback = this.async();\n const { transform: transformFn } = this.query;\n\n if (!transformFn) {\n return callback(null, source, map);\n }\n\n try {\n const id = this.resourcePath;\n const result = await transformFn(source, id);\n\n if (result == null) {\n callback(null, source, map);\n } else if (typeof result === 'string') {\n callback(null, result, map);\n } else {\n callback(null, result.code, result.map || map);\n }\n } catch (error) {\n if (error instanceof Error) {\n callback(error);\n } else {\n callback(new Error(String(error)));\n }\n }\n}\n"],"names":[],"mappings":";;AAGA,eAA8B,SAAA,CAQ5B,QACA,GAAA,EACe;AACf,EAAA,MAAM,QAAA,GAAW,KAAK,KAAA,EAAM;AAC5B,EAAA,MAAM,EAAE,SAAA,EAAW,WAAA,EAAY,GAAI,IAAA,CAAK,KAAA;AAExC,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAA,OAAO,QAAA,CAAS,IAAA,EAAM,MAAA,EAAQ,GAAG,CAAA;AAAA,EACnC;AAEA,EAAA,IAAI;AACF,IAAA,MAAM,KAAK,IAAA,CAAK,YAAA;AAChB,IAAA,MAAM,MAAA,GAAS,MAAM,WAAA,CAAY,MAAA,EAAQ,EAAE,CAAA;AAE3C,IAAA,IAAI,UAAU,IAAA,EAAM;AAClB,MAAA,QAAA,CAAS,IAAA,EAAM,QAAQ,GAAG,CAAA;AAAA,IAC5B,CAAA,MAAA,IAAW,OAAO,MAAA,KAAW,QAAA,EAAU;AACrC,MAAA,QAAA,CAAS,IAAA,EAAM,QAAQ,GAAG,CAAA;AAAA,IAC5B,CAAA,MAAO;AACL,MAAA,QAAA,CAAS,IAAA,EAAM,MAAA,CAAO,IAAA,EAAM,MAAA,CAAO,OAAO,GAAG,CAAA;AAAA,IAC/C;AAAA,EACF,SAAS,KAAA,EAAO;AACd,IAAA,IAAI,iBAAiB,KAAA,EAAO;AAC1B,MAAA,QAAA,CAAS,KAAK,CAAA;AAAA,IAChB,CAAA,MAAO;AACL,MAAA,QAAA,CAAS,IAAI,KAAA,CAAM,MAAA,CAAO,KAAK,CAAC,CAAC,CAAA;AAAA,IACnC;AAAA,EACF;AACF;;;;"}
1
+ {"version":3,"file":"component-annotation-transform.js","names":[],"sources":["../../../src/webpack/component-annotation-transform.ts"],"sourcesContent":["// Webpack loader for component annotation transform\n// Based on unplugin v1.0.1 transform loader pattern\n\nexport default async function transform(\n this: {\n async: () => (err: Error | null, content?: string, sourceMap?: unknown) => void;\n resourcePath: string;\n query: {\n transform?: (code: string, id: string) => Promise<{ code: string; map?: unknown } | null | undefined | string>;\n };\n },\n source: string,\n map: unknown,\n): Promise<void> {\n const callback = this.async();\n const { transform: transformFn } = this.query;\n\n if (!transformFn) {\n return callback(null, source, map);\n }\n\n try {\n const id = this.resourcePath;\n const result = await transformFn(source, id);\n\n if (result == null) {\n callback(null, source, map);\n } else if (typeof result === 'string') {\n callback(null, result, map);\n } else {\n callback(null, result.code, result.map || map);\n }\n } catch (error) {\n if (error instanceof Error) {\n callback(error);\n } else {\n callback(new Error(String(error)));\n }\n }\n}\n"],"mappings":";;;;;AAGA,eAA8B,UAQ5B,QACA,KACe;CACf,MAAM,WAAW,KAAK,MAAM;CAC5B,MAAM,EAAE,WAAW,gBAAgB,KAAK;CAExC,IAAI,CAAC,aACH,OAAO,SAAS,MAAM,QAAQ,GAAG;CAGnC,IAAI;EACF,MAAM,KAAK,KAAK;EAChB,MAAM,SAAS,MAAM,YAAY,QAAQ,EAAE;EAE3C,IAAI,UAAU,MACZ,SAAS,MAAM,QAAQ,GAAG;OACrB,IAAI,OAAO,WAAW,UAC3B,SAAS,MAAM,QAAQ,GAAG;OAE1B,SAAS,MAAM,OAAO,MAAM,OAAO,OAAO,GAAG;CAEjD,SAAS,OAAO;EACd,IAAI,iBAAiB,OACnB,SAAS,KAAK;OAEd,SAAS,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;CAErC;AACF"}