@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
@@ -1,222 +1,192 @@
1
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
-
3
- const index = require('../core/index.js');
4
- const path = require('node:path');
5
- const node_module = require('node:module');
6
- const node_crypto = require('node:crypto');
7
- const buildPluginManager = require('../core/build-plugin-manager.js');
8
- const utils = require('../core/utils.js');
9
- const debugIdUpload = require('../core/debug-id-upload.js');
10
-
11
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
12
- function _interopNamespace(e) {
13
- if (e && e.__esModule) return e;
14
- const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
15
- if (e) {
16
- for (const k in e) {
17
- n[k] = e[k];
18
- }
19
- }
20
- n.default = e;
21
- return n;
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
6
+ const require_utils = require("../core/utils.js");
7
+ const require_debug_id_upload = require("../core/debug-id-upload.js");
8
+ const require_build_plugin_manager = require("../core/build-plugin-manager.js");
9
+ const require_index = require("../core/index.js");
10
+ let node_path = require("node:path");
11
+ node_path = require_runtime.__toESM(node_path);
12
+ let node_module = require("node:module");
13
+ let node_crypto = require("node:crypto");
14
+ // src/esbuild/index.ts
15
+ /** Maps esbuild's `sourcemap` setting onto the plugin's source map kinds. */
16
+ function sourceMapKindFromEsbuildSetting(setting) {
17
+ switch (setting) {
18
+ case void 0: return "unset";
19
+ case false: return "off";
20
+ case "external": return "hidden";
21
+ case "inline":
22
+ case "both": return "inline";
23
+ default: return "visible";
24
+ }
22
25
  }
23
-
24
- const path__namespace = /*#__PURE__*/_interopNamespace(path);
25
-
26
26
  function getEsbuildMajorVersion() {
27
- try {
28
- const req = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('esbuild/index.js', document.baseURI).href)));
29
- const esbuild = req("esbuild");
30
- return esbuild.version?.split(".")[1];
31
- } catch {
32
- }
33
- return void 0;
27
+ try {
28
+ return (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("esbuild").version?.split(".")[1];
29
+ } catch {}
34
30
  }
35
31
  const pluginName = "sentry-esbuild-plugin";
36
32
  function sentryEsbuildPlugin(userOptions = {}) {
37
- const sentryBuildPluginManager = buildPluginManager.createSentryBuildPluginManager(userOptions, {
38
- loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[${pluginName}]`,
39
- buildTool: "esbuild",
40
- buildToolMajorVersion: getEsbuildMajorVersion()
41
- });
42
- const {
43
- logger,
44
- normalizedOptions: options,
45
- bundleSizeOptimizationReplacementValues: replacementValues,
46
- bundleMetadata,
47
- createDependencyOnBuildArtifacts
48
- } = sentryBuildPluginManager;
49
- if (options.disable) {
50
- return {
51
- name: "sentry-esbuild-noop-plugin",
52
- setup() {
53
- }
54
- };
55
- }
56
- if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) {
57
- logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
58
- }
59
- const sourcemapsEnabled = options.sourcemaps?.disable !== true;
60
- const staticInjectionCode = new utils.CodeInjection();
61
- if (!options.release.inject) {
62
- logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
63
- } else if (!options.release.name) {
64
- logger.debug(
65
- "No release name provided. Will not inject release. Please set the `release.name` option to identify your release."
66
- );
67
- } else {
68
- staticInjectionCode.append(
69
- utils.generateReleaseInjectorCode({
70
- release: options.release.name,
71
- injectBuildInformation: options._experiments.injectBuildInformation || false
72
- })
73
- );
74
- }
75
- if (Object.keys(bundleMetadata).length > 0) {
76
- staticInjectionCode.append(utils.generateModuleMetadataInjectorCode(bundleMetadata));
77
- }
78
- if (options.reactComponentAnnotation?.enabled) {
79
- logger.warn(
80
- "Component name annotation is not supported in esbuild. Please use a separate transform step or consider using a different bundler."
81
- );
82
- }
83
- const transformReplace = Object.keys(replacementValues).length > 0;
84
- const debugIdWrappedPaths = /* @__PURE__ */ new Set();
85
- void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {
86
- });
87
- return {
88
- name: pluginName,
89
- setup({ initialOptions, onLoad, onResolve, onStart, onEnd }) {
90
- if (!staticInjectionCode.isEmpty()) {
91
- const virtualInjectionFilePath = path__namespace.resolve("_sentry-injection-stub");
92
- initialOptions.inject = initialOptions.inject || [];
93
- initialOptions.inject.push(virtualInjectionFilePath);
94
- onResolve({ filter: /_sentry-injection-stub/ }, (args) => {
95
- return {
96
- path: args.path,
97
- sideEffects: true,
98
- pluginName
99
- };
100
- });
101
- onLoad({ filter: /_sentry-injection-stub/ }, () => {
102
- return {
103
- loader: "js",
104
- pluginName,
105
- contents: staticInjectionCode.code()
106
- };
107
- });
108
- }
109
- if (transformReplace) {
110
- const replacementStringValues = {};
111
- Object.entries(replacementValues).forEach(([key, value]) => {
112
- replacementStringValues[key] = JSON.stringify(value);
113
- });
114
- initialOptions.define = { ...initialOptions.define, ...replacementStringValues };
115
- }
116
- if (sourcemapsEnabled) {
117
- onStart(() => debugIdWrappedPaths.clear());
118
- if (!initialOptions.bundle) {
119
- logger.warn(
120
- "The Sentry esbuild plugin only supports esbuild with `bundle: true` being set in the esbuild build options. Esbuild will probably crash now. Sorry about that. If you need to upload sourcemaps without `bundle: true`, it is recommended to use Sentry CLI instead: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/"
121
- );
122
- }
123
- onResolve({ filter: /.*/ }, (args) => {
124
- if (args.kind !== "entry-point") {
125
- return;
126
- }
127
- if (initialOptions.inject?.includes(args.path)) {
128
- return;
129
- }
130
- const resolvedPath = path__namespace.isAbsolute(args.path) ? args.path : path__namespace.join(args.resolveDir, args.path);
131
- if (debugIdWrappedPaths.has(resolvedPath)) {
132
- return;
133
- }
134
- debugIdWrappedPaths.add(resolvedPath);
135
- return {
136
- pluginName,
137
- path: resolvedPath,
138
- pluginData: {
139
- isDebugIdProxy: true,
140
- originalPath: args.path,
141
- originalResolveDir: args.resolveDir
142
- },
143
- // We need to add a suffix here, otherwise esbuild will mark the entrypoint as resolved and won't traverse
144
- // the module tree any further down past the proxy module because we're essentially creating a dependency
145
- // loop back to the proxy module.
146
- // By setting a suffix we're telling esbuild that the entrypoint and proxy module are two different things,
147
- // making it re-resolve the entrypoint when it is imported from the proxy module.
148
- // Super confusing? Yes. Works? Apparently... Let's see.
149
- suffix: "?sentryDebugIdProxy=true"
150
- };
151
- });
152
- onLoad({ filter: /.*/ }, (args) => {
153
- if (!args.pluginData?.isDebugIdProxy) {
154
- return null;
155
- }
156
- const originalPath = args.pluginData.originalPath;
157
- const originalResolveDir = args.pluginData.originalResolveDir;
158
- return {
159
- loader: "js",
160
- pluginName,
161
- contents: `
33
+ const sentryBuildPluginManager = require_build_plugin_manager.createSentryBuildPluginManager(userOptions, {
34
+ loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[${pluginName}]`,
35
+ buildTool: "esbuild",
36
+ buildToolMajorVersion: getEsbuildMajorVersion()
37
+ });
38
+ const { logger, normalizedOptions: options, bundleSizeOptimizationReplacementValues: replacementValues, bundleMetadata, createDependencyOnBuildArtifacts } = sentryBuildPluginManager;
39
+ if (options.disable) return {
40
+ name: "sentry-esbuild-noop-plugin",
41
+ setup() {}
42
+ };
43
+ if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
44
+ const sourcemapsEnabled = options.sourcemaps?.disable !== true;
45
+ const staticInjectionCode = new require_utils.CodeInjection();
46
+ if (!options.release.inject) logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
47
+ else if (!options.release.name) logger.debug("No release name provided. Will not inject release. Please set the `release.name` option to identify your release.");
48
+ else staticInjectionCode.append(require_utils.generateReleaseInjectorCode({
49
+ release: options.release.name,
50
+ injectBuildInformation: options._experiments.injectBuildInformation || false
51
+ }));
52
+ if (Object.keys(bundleMetadata).length > 0) staticInjectionCode.append(require_utils.generateModuleMetadataInjectorCode(bundleMetadata));
53
+ if (options.reactComponentAnnotation?.enabled) logger.warn("Component name annotation is not supported in esbuild. Please use a separate transform step or consider using a different bundler.");
54
+ const transformReplace = Object.keys(replacementValues).length > 0;
55
+ const debugIdWrappedPaths = /* @__PURE__ */ new Set();
56
+ sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {});
57
+ return {
58
+ name: pluginName,
59
+ setup({ initialOptions, onLoad, onResolve, onStart, onEnd }) {
60
+ if (!staticInjectionCode.isEmpty()) {
61
+ const virtualInjectionFilePath = node_path.resolve("_sentry-injection-stub");
62
+ initialOptions.inject = initialOptions.inject || [];
63
+ initialOptions.inject.push(virtualInjectionFilePath);
64
+ onResolve({ filter: /_sentry-injection-stub/ }, (args) => {
65
+ return {
66
+ path: args.path,
67
+ sideEffects: true,
68
+ pluginName
69
+ };
70
+ });
71
+ onLoad({ filter: /_sentry-injection-stub/ }, () => {
72
+ return {
73
+ loader: "js",
74
+ pluginName,
75
+ contents: staticInjectionCode.code()
76
+ };
77
+ });
78
+ }
79
+ if (transformReplace) {
80
+ const replacementStringValues = {};
81
+ Object.entries(replacementValues).forEach(([key, value]) => {
82
+ replacementStringValues[key] = JSON.stringify(value);
83
+ });
84
+ initialOptions.define = {
85
+ ...initialOptions.define,
86
+ ...replacementStringValues
87
+ };
88
+ }
89
+ if (sourcemapsEnabled) {
90
+ onStart(() => debugIdWrappedPaths.clear());
91
+ initialOptions.logOverride = {
92
+ "import-is-undefined": "silent",
93
+ ...initialOptions.logOverride
94
+ };
95
+ if (!initialOptions.bundle) logger.warn("The Sentry esbuild plugin only supports esbuild with `bundle: true` being set in the esbuild build options. Esbuild will probably crash now. Sorry about that. If you need to upload sourcemaps without `bundle: true`, it is recommended to use Sentry CLI instead: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/");
96
+ onResolve({ filter: /.*/ }, (args) => {
97
+ if (args.kind !== "entry-point") return;
98
+ if (initialOptions.inject?.includes(args.path)) return;
99
+ const resolvedPath = node_path.isAbsolute(args.path) ? args.path : node_path.join(args.resolveDir, args.path);
100
+ if (debugIdWrappedPaths.has(resolvedPath)) return;
101
+ debugIdWrappedPaths.add(resolvedPath);
102
+ return {
103
+ pluginName,
104
+ path: resolvedPath,
105
+ pluginData: {
106
+ isDebugIdProxy: true,
107
+ originalPath: args.path,
108
+ originalResolveDir: args.resolveDir
109
+ },
110
+ suffix: "?sentryDebugIdProxy=true"
111
+ };
112
+ });
113
+ onLoad({ filter: /.*/ }, (args) => {
114
+ if (!args.pluginData?.isDebugIdProxy) return null;
115
+ const originalPath = args.pluginData.originalPath;
116
+ const originalResolveDir = args.pluginData.originalResolveDir;
117
+ return {
118
+ loader: "js",
119
+ pluginName,
120
+ contents: `
162
121
  import "_sentry-debug-id-injection-stub";
163
122
  import * as OriginalModule from ${JSON.stringify(originalPath)};
164
123
  export default OriginalModule.default;
165
124
  export * from ${JSON.stringify(originalPath)};`,
166
- resolveDir: originalResolveDir
167
- };
168
- });
169
- onResolve({ filter: /_sentry-debug-id-injection-stub/ }, (args) => {
170
- return {
171
- path: args.path,
172
- sideEffects: true,
173
- pluginName,
174
- namespace: "sentry-debug-id-stub",
175
- suffix: `?sentry-module-id=${node_crypto.randomUUID()}`
176
- };
177
- });
178
- onLoad({ filter: /_sentry-debug-id-injection-stub/, namespace: "sentry-debug-id-stub" }, () => {
179
- return {
180
- loader: "js",
181
- pluginName,
182
- contents: index.getDebugIdSnippet(node_crypto.randomUUID()).code()
183
- };
184
- });
185
- }
186
- const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
187
- const upload = debugIdUpload.createDebugIdUploadFunction({ sentryBuildPluginManager });
188
- initialOptions.metafile = true;
189
- onEnd(async (result) => {
190
- try {
191
- await sentryBuildPluginManager.createRelease();
192
- if (sourcemapsEnabled) {
193
- const buildArtifacts = result.metafile ? Object.keys(result.metafile.outputs) : [];
194
- if (options.sourcemaps?.disable !== "disable-upload") {
195
- await upload(buildArtifacts);
196
- } else if (initialOptions.write === false) {
197
- logger.debug("Build output is not written to disk. Skipping debug ID injection into build artifacts.");
198
- } else {
199
- const outputDir = initialOptions.absWorkingDir ?? process.cwd();
200
- await Promise.all(
201
- buildArtifacts.filter(index.isJsFile).map(
202
- (bundle) => debugIdUpload.addDebugIdToEmittedArtifacts(
203
- path__namespace.resolve(outputDir, bundle),
204
- logger,
205
- options.sourcemaps?.resolveSourceMap
206
- )
207
- )
208
- );
209
- }
210
- }
211
- } finally {
212
- freeGlobalDependencyOnBuildArtifacts();
213
- await sentryBuildPluginManager.deleteArtifacts();
214
- }
215
- });
216
- }
217
- };
125
+ resolveDir: originalResolveDir
126
+ };
127
+ });
128
+ onResolve({ filter: /_sentry-debug-id-injection-stub/ }, (args) => {
129
+ return {
130
+ path: args.path,
131
+ sideEffects: true,
132
+ pluginName,
133
+ namespace: "sentry-debug-id-stub",
134
+ suffix: `?sentry-module-id=${(0, node_crypto.randomUUID)()}`
135
+ };
136
+ });
137
+ onLoad({
138
+ filter: /_sentry-debug-id-injection-stub/,
139
+ namespace: "sentry-debug-id-stub"
140
+ }, () => {
141
+ return {
142
+ loader: "js",
143
+ pluginName,
144
+ contents: require_index.getDebugIdSnippet((0, node_crypto.randomUUID)()).code()
145
+ };
146
+ });
147
+ }
148
+ const sourceMapKind = sourceMapKindFromEsbuildSetting(initialOptions.sourcemap);
149
+ const sourceMapDecision = initialOptions.write === false ? {
150
+ enableHidden: false,
151
+ deleteAfterUpload: false
152
+ } : sentryBuildPluginManager.sourceMaps.decide(sourceMapKind);
153
+ if (sourceMapDecision.enableHidden) initialOptions.sourcemap = "external";
154
+ const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
155
+ const upload = require_debug_id_upload.createDebugIdUploadFunction({ sentryBuildPluginManager });
156
+ initialOptions.metafile = true;
157
+ onEnd(async (result) => {
158
+ try {
159
+ await sentryBuildPluginManager.createRelease();
160
+ const outputDir = initialOptions.absWorkingDir ?? process.cwd();
161
+ const buildArtifacts = result.metafile ? Object.keys(result.metafile.outputs).map((output) => node_path.resolve(outputDir, output)) : [];
162
+ const { sourceMaps } = sentryBuildPluginManager;
163
+ const allMaps = buildArtifacts.filter((artifact) => artifact.endsWith(".map"));
164
+ const deleteWithoutUpload = sourceMapDecision.deleteAfterUpload && !sourceMaps.uploadPossible;
165
+ if (sourcemapsEnabled && options.sourcemaps?.disable === "disable-upload") {
166
+ if (initialOptions.write === false) logger.debug("Build output is not written to disk. Skipping debug ID injection into build artifacts.");
167
+ else await Promise.all(buildArtifacts.filter(require_index.isJsFile).map((bundle) => require_debug_id_upload.addDebugIdToEmittedArtifacts(bundle, logger, options.sourcemaps?.resolveSourceMap)));
168
+ } else if (sourcemapsEnabled) {
169
+ const { uploaded, uploadedSourceMapPaths } = await upload(buildArtifacts.map((artifact) => artifact.split(node_path.sep).join("/")));
170
+ if (sourceMapDecision.deleteAfterUpload && !deleteWithoutUpload) {
171
+ const mapsToDelete = sourceMapDecision.removeAllSourceMaps ? allMaps : uploadedSourceMapPaths;
172
+ if (uploaded) await sourceMaps.deleteFromOutput(mapsToDelete);
173
+ else if (mapsToDelete.length > 0) logger.error("The source maps were not uploaded, so they stay in the build output.");
174
+ }
175
+ }
176
+ if (deleteWithoutUpload) {
177
+ const bundleOf = (map) => map.slice(0, -4);
178
+ const isUploaded = (map) => require_index.isJsFile(bundleOf(map)) && sourceMaps.shouldUpload(bundleOf(map));
179
+ await sourceMaps.deleteFromOutput(sourceMapDecision.removeAllSourceMaps ? allMaps : allMaps.filter(isUploaded));
180
+ }
181
+ } finally {
182
+ freeGlobalDependencyOnBuildArtifacts();
183
+ await sentryBuildPluginManager.deleteArtifacts();
184
+ }
185
+ });
186
+ }
187
+ };
218
188
  }
219
-
220
189
  exports.default = sentryEsbuildPlugin;
221
190
  exports.sentryEsbuildPlugin = sentryEsbuildPlugin;
222
- //# sourceMappingURL=index.js.map
191
+
192
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/esbuild/index.ts"],"sourcesContent":["import type { Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n CodeInjection,\n addDebugIdToEmittedArtifacts,\n isJsFile,\n} from '../core';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport { randomUUID } from 'node:crypto';\n\ninterface EsbuildOnResolveArgs {\n path: string;\n kind: string;\n importer?: string;\n resolveDir: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnResolveResult {\n path: string;\n sideEffects?: boolean;\n pluginName?: string;\n namespace?: string;\n suffix?: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnLoadArgs {\n path: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnLoadResult {\n loader: string;\n pluginName: string;\n contents: string;\n resolveDir?: string;\n}\n\ninterface EsbuildOnEndArgs {\n metafile?: {\n outputs: Record<string, unknown>;\n };\n}\n\ninterface EsbuildInitialOptions {\n bundle?: boolean;\n inject?: string[];\n metafile?: boolean;\n define?: Record<string, string>;\n write?: boolean;\n absWorkingDir?: string;\n}\n\ninterface EsbuildPluginBuild {\n initialOptions: EsbuildInitialOptions;\n onLoad: (\n options: { filter: RegExp; namespace?: string },\n callback: (args: EsbuildOnLoadArgs) => EsbuildOnLoadResult | null,\n ) => void;\n onResolve: (\n options: { filter: RegExp },\n callback: (args: EsbuildOnResolveArgs) => EsbuildOnResolveResult | undefined,\n ) => void;\n onStart: (callback: () => void) => void;\n onEnd: (callback: (result: EsbuildOnEndArgs) => void | Promise<void>) => void;\n}\n\nfunction getEsbuildMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - esbuild transpiles this for us\n const req = createRequire(import.meta.url);\n const esbuild = req('esbuild') as { version?: string };\n // esbuild hasn't released a v1 yet, so we'll return the minor version as the major version\n return esbuild.version?.split('.')[1];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nconst pluginName = 'sentry-esbuild-plugin';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function sentryEsbuildPlugin(userOptions: Options = {}): any {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[${pluginName}]`,\n buildTool: 'esbuild',\n buildToolMajorVersion: getEsbuildMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n name: 'sentry-esbuild-noop-plugin',\n setup() {\n // noop plugin\n },\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n // Component annotation warning\n if (options.reactComponentAnnotation?.enabled) {\n logger.warn(\n 'Component name annotation is not supported in esbuild. Please use a separate transform step or consider using a different bundler.',\n );\n }\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n // Track entry points wrapped for debug ID injection\n const debugIdWrappedPaths = new Set<string>();\n\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n return {\n name: pluginName,\n setup({ initialOptions, onLoad, onResolve, onStart, onEnd }: EsbuildPluginBuild) {\n // Release and/or metadata injection\n if (!staticInjectionCode.isEmpty()) {\n const virtualInjectionFilePath = path.resolve('_sentry-injection-stub');\n initialOptions.inject = initialOptions.inject || [];\n // esbuild emits injected files after an entry's directive prologue. A banner would precede\n // \"use strict\" and turn it into an ordinary string expression.\n initialOptions.inject.push(virtualInjectionFilePath);\n\n onResolve({ filter: /_sentry-injection-stub/ }, args => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n };\n });\n\n onLoad({ filter: /_sentry-injection-stub/ }, () => {\n return {\n loader: 'js',\n pluginName,\n contents: staticInjectionCode.code(),\n };\n });\n }\n\n // Bundle size optimizations\n if (transformReplace) {\n const replacementStringValues: Record<string, string> = {};\n Object.entries(replacementValues).forEach(([key, value]) => {\n replacementStringValues[key] = JSON.stringify(value);\n });\n\n initialOptions.define = { ...initialOptions.define, ...replacementStringValues };\n }\n\n // Debug ID injection - requires per-entry-point unique IDs\n if (sourcemapsEnabled) {\n // `setup` runs once per context, `onStart` once per build, so a\n // rebuild wraps the entry points again.\n onStart(() => debugIdWrappedPaths.clear());\n\n if (!initialOptions.bundle) {\n logger.warn(\n 'The Sentry esbuild plugin only supports esbuild with `bundle: true` being set in the esbuild build options. Esbuild will probably crash now. Sorry about that. If you need to upload sourcemaps without `bundle: true`, it is recommended to use Sentry CLI instead: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/',\n );\n }\n\n // Wrap entry points to inject debug IDs\n onResolve({ filter: /.*/ }, args => {\n if (args.kind !== 'entry-point') {\n return;\n }\n\n // Skip injecting debug IDs into modules specified in the esbuild `inject` option\n // since they're already part of the entry points\n if (initialOptions.inject?.includes(args.path)) {\n return;\n }\n\n const resolvedPath = path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path);\n\n // Skip injecting debug IDs into paths that have already been wrapped\n if (debugIdWrappedPaths.has(resolvedPath)) {\n return;\n }\n debugIdWrappedPaths.add(resolvedPath);\n\n return {\n pluginName,\n path: resolvedPath,\n pluginData: {\n isDebugIdProxy: true,\n originalPath: args.path,\n originalResolveDir: args.resolveDir,\n },\n // We need to add a suffix here, otherwise esbuild will mark the entrypoint as resolved and won't traverse\n // the module tree any further down past the proxy module because we're essentially creating a dependency\n // loop back to the proxy module.\n // By setting a suffix we're telling esbuild that the entrypoint and proxy module are two different things,\n // making it re-resolve the entrypoint when it is imported from the proxy module.\n // Super confusing? Yes. Works? Apparently... Let's see.\n suffix: '?sentryDebugIdProxy=true',\n };\n });\n\n onLoad({ filter: /.*/ }, args => {\n if (!(args.pluginData as { isDebugIdProxy?: boolean })?.isDebugIdProxy) {\n return null;\n }\n\n const originalPath = (args.pluginData as { originalPath: string }).originalPath;\n const originalResolveDir = (args.pluginData as { originalResolveDir: string }).originalResolveDir;\n\n return {\n loader: 'js',\n pluginName,\n contents: `\n import \"_sentry-debug-id-injection-stub\";\n import * as OriginalModule from ${JSON.stringify(originalPath)};\n export default OriginalModule.default;\n export * from ${JSON.stringify(originalPath)};`,\n resolveDir: originalResolveDir,\n };\n });\n\n onResolve({ filter: /_sentry-debug-id-injection-stub/ }, args => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n namespace: 'sentry-debug-id-stub',\n suffix: `?sentry-module-id=${randomUUID()}`,\n };\n });\n\n onLoad({ filter: /_sentry-debug-id-injection-stub/, namespace: 'sentry-debug-id-stub' }, () => {\n return {\n loader: 'js',\n pluginName,\n contents: getDebugIdSnippet(randomUUID()).code(),\n };\n });\n }\n\n // Create release and optionally upload\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n initialOptions.metafile = true;\n onEnd(async result => {\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (sourcemapsEnabled) {\n const buildArtifacts = result.metafile ? Object.keys(result.metafile.outputs) : [];\n\n if (options.sourcemaps?.disable !== 'disable-upload') {\n await upload(buildArtifacts);\n } else if (initialOptions.write === false) {\n logger.debug('Build output is not written to disk. Skipping debug ID injection into build artifacts.');\n } else {\n // The upload routine (which stamps debug IDs into temp copies of the artifacts) is\n // skipped with `disable-upload`. esbuild has no hook to modify outputs before they are\n // written, so the emitted artifacts get stamped on disk instead.\n const outputDir = initialOptions.absWorkingDir ?? process.cwd();\n await Promise.all(\n buildArtifacts\n .filter(isJsFile)\n .map(bundle =>\n addDebugIdToEmittedArtifacts(\n path.resolve(outputDir, bundle),\n logger,\n options.sourcemaps?.resolveSourceMap,\n ),\n ),\n );\n }\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n });\n },\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport default sentryEsbuildPlugin;\nexport type { Options as SentryEsbuildPluginOptions } from '../core';\n"],"names":["createRequire","createSentryBuildPluginManager","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","path","randomUUID","getDebugIdSnippet","createDebugIdUploadFunction","isJsFile","addDebugIdToEmittedArtifacts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,SAAS,sBAAA,GAA6C;AACpD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAMA,yBAAA,CAAc,kQAAe,CAAA;AACzC,IAAA,MAAM,OAAA,GAAU,IAAI,SAAS,CAAA;AAE7B,IAAA,OAAO,OAAA,CAAQ,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACtC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEA,MAAM,UAAA,GAAa,uBAAA;AAGZ,SAAS,mBAAA,CAAoB,WAAA,GAAuB,EAAC,EAAQ;AAClE,EAAA,MAAM,wBAAA,GAA2BC,kDAA+B,WAAA,EAAa;AAAA,IAC3E,YAAA,EAAc,WAAA,CAAY,YAAA,EAAc,oBAAA,IAAwB,IAAI,UAAU,CAAA,CAAA,CAAA;AAAA,IAC9E,SAAA,EAAW,SAAA;AAAA,IACX,uBAAuB,sBAAA;AAAuB,GAC/C,CAAA;AAED,EAAA,MAAM;AAAA,IACJ,MAAA;AAAA,IACA,iBAAA,EAAmB,OAAA;AAAA,IACnB,uCAAA,EAAyC,iBAAA;AAAA,IACzC,cAAA;AAAA,IACA;AAAA,GACF,GAAI,wBAAA;AAEJ,EAAA,IAAI,QAAQ,OAAA,EAAS;AACnB,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,4BAAA;AAAA,MACN,KAAA,GAAQ;AAAA,MAER;AAAA,KACF;AAAA,EACF;AAEA,EAAA,IAAI,OAAA,CAAQ,GAAA,EAAI,CAAE,KAAA,CAAM,mCAAmC,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cAAA,GAAiB,OAAO,QAAA,GAAW,MAAA,CAAO,KAAK,MAAA,CAAO,QAAA,CAAS,OAAO,CAAA,GAAI,EAAC;AAEjF,YAAA,IAAI,OAAA,CAAQ,UAAA,EAAY,OAAA,KAAY,gBAAA,EAAkB;AACpD,cAAA,MAAM,OAAO,cAAc,CAAA;AAAA,YAC7B,CAAA,MAAA,IAAW,cAAA,CAAe,KAAA,KAAU,KAAA,EAAO;AACzC,cAAA,MAAA,CAAO,MAAM,wFAAwF,CAAA;AAAA,YACvG,CAAA,MAAO;AAIL,cAAA,MAAM,SAAA,GAAY,cAAA,CAAe,aAAA,IAAiB,OAAA,CAAQ,GAAA,EAAI;AAC9D,cAAA,MAAM,OAAA,CAAQ,GAAA;AAAA,gBACZ,cAAA,CACG,MAAA,CAAOC,cAAQ,CAAA,CACf,GAAA;AAAA,kBAAI,CAAA,MAAA,KACHC,0CAAA;AAAA,oBACEL,eAAA,CAAK,OAAA,CAAQ,SAAA,EAAW,MAAM,CAAA;AAAA,oBAC9B,MAAA;AAAA,oBACA,QAAQ,UAAA,EAAY;AAAA;AACtB;AACF,eACJ;AAAA,YACF;AAAA,UACF;AAAA,QACF,CAAA,SAAE;AACA,UAAA,oCAAA,EAAqC;AACrC,UAAA,MAAM,yBAAyB,eAAA,EAAgB;AAAA,QACjD;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF;;;;;"}
1
+ {"version":3,"file":"index.js","names":["createRequire","createSentryBuildPluginManager","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","path","randomUUID","getDebugIdSnippet","createDebugIdUploadFunction","isJsFile","addDebugIdToEmittedArtifacts"],"sources":["../../../src/esbuild/index.ts"],"sourcesContent":["import type { InternalOptions, SourceMapDecision, SourceMapKind } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n CodeInjection,\n addDebugIdToEmittedArtifacts,\n isJsFile,\n} from '../core';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport { randomUUID } from 'node:crypto';\n\ninterface EsbuildOnResolveArgs {\n path: string;\n kind: string;\n importer?: string;\n resolveDir: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnResolveResult {\n path: string;\n sideEffects?: boolean;\n pluginName?: string;\n namespace?: string;\n suffix?: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnLoadArgs {\n path: string;\n pluginData?: unknown;\n}\n\ninterface EsbuildOnLoadResult {\n loader: string;\n pluginName: string;\n contents: string;\n resolveDir?: string;\n}\n\ninterface EsbuildOnEndArgs {\n metafile?: {\n outputs: Record<string, unknown>;\n };\n}\n\ntype EsbuildSourceMapSetting = boolean | 'inline' | 'external' | 'linked' | 'both' | undefined;\n\ninterface EsbuildInitialOptions {\n bundle?: boolean;\n inject?: string[];\n metafile?: boolean;\n define?: Record<string, string>;\n write?: boolean;\n absWorkingDir?: string;\n logOverride?: Record<string, string>;\n sourcemap?: EsbuildSourceMapSetting;\n}\n\n/** Maps esbuild's `sourcemap` setting onto the plugin's source map kinds. */\nfunction sourceMapKindFromEsbuildSetting(setting: EsbuildSourceMapSetting): SourceMapKind {\n switch (setting) {\n case undefined:\n return 'unset';\n case false:\n return 'off';\n case 'external':\n return 'hidden';\n case 'inline':\n case 'both':\n return 'inline';\n default:\n return 'visible';\n }\n}\n\ninterface EsbuildPluginBuild {\n initialOptions: EsbuildInitialOptions;\n onLoad: (\n options: { filter: RegExp; namespace?: string },\n callback: (args: EsbuildOnLoadArgs) => EsbuildOnLoadResult | null,\n ) => void;\n onResolve: (\n options: { filter: RegExp },\n callback: (args: EsbuildOnResolveArgs) => EsbuildOnResolveResult | undefined,\n ) => void;\n onStart: (callback: () => void) => void;\n onEnd: (callback: (result: EsbuildOnEndArgs) => void | Promise<void>) => void;\n}\n\nfunction getEsbuildMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - esbuild transpiles this for us\n const req = createRequire(import.meta.url);\n const esbuild = req('esbuild') as { version?: string };\n // esbuild hasn't released a v1 yet, so we'll return the minor version as the major version\n return esbuild.version?.split('.')[1];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nconst pluginName = 'sentry-esbuild-plugin';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function sentryEsbuildPlugin(userOptions: InternalOptions = {}): any {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[${pluginName}]`,\n buildTool: 'esbuild',\n buildToolMajorVersion: getEsbuildMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n name: 'sentry-esbuild-noop-plugin',\n setup() {\n // noop plugin\n },\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n // Component annotation warning\n if (options.reactComponentAnnotation?.enabled) {\n logger.warn(\n 'Component name annotation is not supported in esbuild. Please use a separate transform step or consider using a different bundler.',\n );\n }\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n // Track entry points wrapped for debug ID injection\n const debugIdWrappedPaths = new Set<string>();\n\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n return {\n name: pluginName,\n setup({ initialOptions, onLoad, onResolve, onStart, onEnd }: EsbuildPluginBuild) {\n // Release and/or metadata injection\n if (!staticInjectionCode.isEmpty()) {\n const virtualInjectionFilePath = path.resolve('_sentry-injection-stub');\n initialOptions.inject = initialOptions.inject || [];\n // esbuild emits injected files after an entry's directive prologue. A banner would precede\n // \"use strict\" and turn it into an ordinary string expression.\n initialOptions.inject.push(virtualInjectionFilePath);\n\n onResolve({ filter: /_sentry-injection-stub/ }, args => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n };\n });\n\n onLoad({ filter: /_sentry-injection-stub/ }, () => {\n return {\n loader: 'js',\n pluginName,\n contents: staticInjectionCode.code(),\n };\n });\n }\n\n // Bundle size optimizations\n if (transformReplace) {\n const replacementStringValues: Record<string, string> = {};\n Object.entries(replacementValues).forEach(([key, value]) => {\n replacementStringValues[key] = JSON.stringify(value);\n });\n\n initialOptions.define = { ...initialOptions.define, ...replacementStringValues };\n }\n\n // Debug ID injection - requires per-entry-point unique IDs\n if (sourcemapsEnabled) {\n // `setup` runs once per context, `onStart` once per build, so a\n // rebuild wraps the entry points again.\n onStart(() => debugIdWrappedPaths.clear());\n\n // The proxy module re-exports `OriginalModule.default` statically so downstream bundlers can tree-shake it,\n // but esbuild warns about that access when the entry point has no default export.\n initialOptions.logOverride = { 'import-is-undefined': 'silent', ...initialOptions.logOverride };\n\n if (!initialOptions.bundle) {\n logger.warn(\n 'The Sentry esbuild plugin only supports esbuild with `bundle: true` being set in the esbuild build options. Esbuild will probably crash now. Sorry about that. If you need to upload sourcemaps without `bundle: true`, it is recommended to use Sentry CLI instead: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/',\n );\n }\n\n // Wrap entry points to inject debug IDs\n onResolve({ filter: /.*/ }, args => {\n if (args.kind !== 'entry-point') {\n return;\n }\n\n // Skip injecting debug IDs into modules specified in the esbuild `inject` option\n // since they're already part of the entry points\n if (initialOptions.inject?.includes(args.path)) {\n return;\n }\n\n const resolvedPath = path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path);\n\n // Skip injecting debug IDs into paths that have already been wrapped\n if (debugIdWrappedPaths.has(resolvedPath)) {\n return;\n }\n debugIdWrappedPaths.add(resolvedPath);\n\n return {\n pluginName,\n path: resolvedPath,\n pluginData: {\n isDebugIdProxy: true,\n originalPath: args.path,\n originalResolveDir: args.resolveDir,\n },\n // We need to add a suffix here, otherwise esbuild will mark the entrypoint as resolved and won't traverse\n // the module tree any further down past the proxy module because we're essentially creating a dependency\n // loop back to the proxy module.\n // By setting a suffix we're telling esbuild that the entrypoint and proxy module are two different things,\n // making it re-resolve the entrypoint when it is imported from the proxy module.\n // Super confusing? Yes. Works? Apparently... Let's see.\n suffix: '?sentryDebugIdProxy=true',\n };\n });\n\n onLoad({ filter: /.*/ }, args => {\n if (!(args.pluginData as { isDebugIdProxy?: boolean })?.isDebugIdProxy) {\n return null;\n }\n\n const originalPath = (args.pluginData as { originalPath: string }).originalPath;\n const originalResolveDir = (args.pluginData as { originalResolveDir: string }).originalResolveDir;\n\n return {\n loader: 'js',\n pluginName,\n contents: `\n import \"_sentry-debug-id-injection-stub\";\n import * as OriginalModule from ${JSON.stringify(originalPath)};\n export default OriginalModule.default;\n export * from ${JSON.stringify(originalPath)};`,\n resolveDir: originalResolveDir,\n };\n });\n\n onResolve({ filter: /_sentry-debug-id-injection-stub/ }, args => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n namespace: 'sentry-debug-id-stub',\n suffix: `?sentry-module-id=${randomUUID()}`,\n };\n });\n\n onLoad({ filter: /_sentry-debug-id-injection-stub/, namespace: 'sentry-debug-id-stub' }, () => {\n return {\n loader: 'js',\n pluginName,\n contents: getDebugIdSnippet(randomUUID()).code(),\n };\n });\n }\n\n // With `write: false` nothing reaches the disk, so nothing can be uploaded or deleted.\n const sourceMapKind = sourceMapKindFromEsbuildSetting(initialOptions.sourcemap);\n const sourceMapDecision: SourceMapDecision =\n initialOptions.write === false\n ? { enableHidden: false, deleteAfterUpload: false }\n : sentryBuildPluginManager.sourceMaps.decide(sourceMapKind);\n if (sourceMapDecision.enableHidden) {\n initialOptions.sourcemap = 'external';\n }\n\n // Create release and optionally upload\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n initialOptions.metafile = true;\n onEnd(async result => {\n try {\n await sentryBuildPluginManager.createRelease();\n\n // The metafile lists outputs relative to `absWorkingDir`, not to the process.\n const outputDir = initialOptions.absWorkingDir ?? process.cwd();\n const buildArtifacts = result.metafile\n ? Object.keys(result.metafile.outputs).map(output => path.resolve(outputDir, output))\n : [];\n\n const { sourceMaps } = sentryBuildPluginManager;\n const allMaps = buildArtifacts.filter(artifact => artifact.endsWith('.map'));\n const deleteWithoutUpload = sourceMapDecision.deleteAfterUpload && !sourceMaps.uploadPossible;\n if (sourcemapsEnabled && options.sourcemaps?.disable === 'disable-upload') {\n if (initialOptions.write === false) {\n logger.debug('Build output is not written to disk. Skipping debug ID injection into build artifacts.');\n } else {\n // The upload routine (which stamps debug IDs into temp copies of the artifacts) is\n // skipped with `disable-upload`. esbuild has no hook to modify outputs before they are\n // written, so the emitted artifacts get stamped on disk instead.\n await Promise.all(\n buildArtifacts\n .filter(isJsFile)\n .map(bundle => addDebugIdToEmittedArtifacts(bundle, logger, options.sourcemaps?.resolveSourceMap)),\n );\n }\n } else if (sourcemapsEnabled) {\n // The upload globs the paths, and glob reads backslashes as escapes.\n // When no upload can run, this logs why.\n const { uploaded, uploadedSourceMapPaths } = await upload(\n buildArtifacts.map(artifact => artifact.split(path.sep).join('/')),\n );\n\n // esbuild writes before `onEnd` runs, so the maps are deleted from disk\n // afterwards instead of being dropped from the output like in other bundlers.\n // A map the plugin turned on never stays in the output. A map the user\n // enabled is only deleted once it was uploaded.\n if (sourceMapDecision.deleteAfterUpload && !deleteWithoutUpload) {\n const mapsToDelete = sourceMapDecision.removeAllSourceMaps ? allMaps : uploadedSourceMapPaths;\n\n if (uploaded) {\n await sourceMaps.deleteFromOutput(mapsToDelete);\n } else if (mapsToDelete.length > 0) {\n logger.error('The source maps were not uploaded, so they stay in the build output.');\n }\n }\n }\n\n if (deleteWithoutUpload) {\n const bundleOf = (map: string): string => map.slice(0, -'.map'.length);\n const isUploaded = (map: string): boolean =>\n isJsFile(bundleOf(map)) && sourceMaps.shouldUpload(bundleOf(map));\n await sourceMaps.deleteFromOutput(\n sourceMapDecision.removeAllSourceMaps ? allMaps : allMaps.filter(isUploaded),\n );\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n });\n },\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport default sentryEsbuildPlugin;\nexport type { Options as SentryEsbuildPluginOptions } from '../core';\n"],"mappings":";;;;;;;;;;;;;;;AAgEA,SAAS,gCAAgC,SAAiD;CACxF,QAAQ,SAAR;EACE,KAAK,KAAA,GACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK;EACL,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAgBA,SAAS,yBAA6C;CACpD,IAAI;EAMF,QAAA,GAHYA,YAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IACM,CAAC,CAAC,SAEP,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC;CACrC,QAAQ,CAER;AAGF;AAEA,MAAM,aAAa;AAGnB,SAAgB,oBAAoB,cAA+B,CAAC,GAAQ;CAC1E,MAAM,2BAA2BC,6BAAAA,+BAA+B,aAAa;EAC3E,cAAc,YAAY,cAAc,wBAAwB,IAAI,WAAW;EAC/E,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AAmB;MAG5B,MAAM,EAAE,UAAU,2BAA2B,MAAM,OACjD,eAAe,KAAI,aAAY,SAAS,MAAML,UAAK,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CACnE;MAMA,IAAI,kBAAkB,qBAAqB,CAAC,qBAAqB;OAC/D,MAAM,eAAe,kBAAkB,sBAAsB,UAAU;OAEvE,IAAI,UACF,MAAM,WAAW,iBAAiB,YAAY;YACzC,IAAI,aAAa,SAAS,GAC/B,OAAO,MAAM,sEAAsE;MAEvF;KACF;KAEA,IAAI,qBAAqB;MACvB,MAAM,YAAY,QAAwB,IAAI,MAAM,GAAG,EAAc;MACrE,MAAM,cAAc,QAClBI,cAAAA,SAAS,SAAS,GAAG,CAAC,KAAK,WAAW,aAAa,SAAS,GAAG,CAAC;MAClE,MAAM,WAAW,iBACf,kBAAkB,sBAAsB,UAAU,QAAQ,OAAO,UAAU,CAC7E;KACF;IACF,UAAU;KACR,qCAAqC;KACrC,MAAM,yBAAyB,gBAAgB;IACjD;GACF,CAAC;EACH;CACF;AACF"}
@@ -1,10 +1,5 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const getCodeInjectionPosition = require('../core/get-code-injection-position.js');
4
- const componentAnnotateHooks = require('../core/component-annotate-hooks.js');
5
-
6
-
7
-
8
- exports.getCodeInjectionPosition = getCodeInjectionPosition.getCodeInjectionPosition;
9
- exports.createComponentNameAnnotateHooks = componentAnnotateHooks.createComponentNameAnnotateHooks;
10
- //# sourceMappingURL=index.js.map
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_get_code_injection_position = require("../core/get-code-injection-position.js");
3
+ const require_component_annotate_hooks = require("../core/component-annotate-hooks.js");
4
+ exports.createComponentNameAnnotateHooks = require_component_annotate_hooks.createComponentNameAnnotateHooks;
5
+ exports.getCodeInjectionPosition = require_get_code_injection_position.getCodeInjectionPosition;
@@ -1,53 +1,37 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const utils = require('../core/utils.js');
4
-
1
+ const require_utils = require("../core/utils.js");
2
+ require("../core/index.js");
3
+ // src/rollup/debug-id-injection.ts
5
4
  const ROLLDOWN_DEBUG_ID_PLACEHOLDER = "SENTRY_DEBUG_ID_PLACEHOLDER_00000000";
6
5
  const SENTRY_DEBUG_ID_IDENTIFIER = "_sentryDebugIdIdentifier";
7
6
  const SENTRY_DEBUG_ID_IDENTIFIER_PREFIX = "sentry-dbid-";
8
7
  function hasExistingDebugID(code) {
9
- const chunkStartSnippet = code.slice(0, 6e3);
10
- const chunkEndSnippet = code.slice(-500);
11
- return chunkStartSnippet.includes(SENTRY_DEBUG_ID_IDENTIFIER) || chunkEndSnippet.includes("//# debugId=");
8
+ const chunkStartSnippet = code.slice(0, 6e3);
9
+ const chunkEndSnippet = code.slice(-500);
10
+ return chunkStartSnippet.includes(SENTRY_DEBUG_ID_IDENTIFIER) || chunkEndSnippet.includes("//# debugId=");
12
11
  }
13
12
  function getDebugIdForChunk(code, isRolldown) {
14
- return isRolldown ? ROLLDOWN_DEBUG_ID_PLACEHOLDER : utils.stringToUUID(code);
13
+ return isRolldown ? ROLLDOWN_DEBUG_ID_PLACEHOLDER : require_utils.stringToUUID(code);
15
14
  }
16
15
  function replaceAt(code, start, search, replacement) {
17
- return `${code.slice(0, start)}${replacement}${code.slice(start + search.length)}`;
16
+ return `${code.slice(0, start)}${replacement}${code.slice(start + search.length)}`;
18
17
  }
19
18
  function finalizeRolldownDebugIds(bundle) {
20
- for (const [fileName, output] of Object.entries(bundle)) {
21
- if (output.type !== "chunk") {
22
- continue;
23
- }
24
- const identifier = `${SENTRY_DEBUG_ID_IDENTIFIER_PREFIX}${ROLLDOWN_DEBUG_ID_PLACEHOLDER}`;
25
- const identifierPropertyStart = output.code.indexOf(SENTRY_DEBUG_ID_IDENTIFIER);
26
- const identifierStart = output.code.indexOf(
27
- identifier,
28
- identifierPropertyStart + SENTRY_DEBUG_ID_IDENTIFIER.length
29
- );
30
- if (identifierStart === -1) {
31
- continue;
32
- }
33
- const identifierPlaceholderStart = identifierStart + SENTRY_DEBUG_ID_IDENTIFIER_PREFIX.length;
34
- const debugIdsPlaceholderStart = output.code.lastIndexOf(ROLLDOWN_DEBUG_ID_PLACEHOLDER, identifierStart - 1);
35
- if (debugIdsPlaceholderStart === -1) {
36
- throw new Error(`Failed to locate the Sentry debug ID placeholder for chunk \`${fileName}\`.`);
37
- }
38
- const debugId = utils.stringToUUID(output.code);
39
- const codeWithIdentifier = replaceAt(
40
- output.code,
41
- identifierPlaceholderStart,
42
- ROLLDOWN_DEBUG_ID_PLACEHOLDER,
43
- debugId
44
- );
45
- output.code = replaceAt(codeWithIdentifier, debugIdsPlaceholderStart, ROLLDOWN_DEBUG_ID_PLACEHOLDER, debugId);
46
- }
19
+ for (const [fileName, output] of Object.entries(bundle)) {
20
+ if (output.type !== "chunk") continue;
21
+ const identifier = `${SENTRY_DEBUG_ID_IDENTIFIER_PREFIX}${ROLLDOWN_DEBUG_ID_PLACEHOLDER}`;
22
+ const identifierPropertyStart = output.code.indexOf(SENTRY_DEBUG_ID_IDENTIFIER);
23
+ const identifierStart = output.code.indexOf(identifier, identifierPropertyStart + 24);
24
+ if (identifierStart === -1) continue;
25
+ const identifierPlaceholderStart = identifierStart + 12;
26
+ const debugIdsPlaceholderStart = output.code.lastIndexOf(ROLLDOWN_DEBUG_ID_PLACEHOLDER, identifierStart - 1);
27
+ if (debugIdsPlaceholderStart === -1) throw new Error(`Failed to locate the Sentry debug ID placeholder for chunk \`${fileName}\`.`);
28
+ const debugId = require_utils.stringToUUID(output.code);
29
+ output.code = replaceAt(replaceAt(output.code, identifierPlaceholderStart, ROLLDOWN_DEBUG_ID_PLACEHOLDER, debugId), debugIdsPlaceholderStart, ROLLDOWN_DEBUG_ID_PLACEHOLDER, debugId);
30
+ }
47
31
  }
48
-
49
32
  exports.ROLLDOWN_DEBUG_ID_PLACEHOLDER = ROLLDOWN_DEBUG_ID_PLACEHOLDER;
50
33
  exports.finalizeRolldownDebugIds = finalizeRolldownDebugIds;
51
34
  exports.getDebugIdForChunk = getDebugIdForChunk;
52
35
  exports.hasExistingDebugID = hasExistingDebugID;
53
- //# sourceMappingURL=debug-id-injection.js.map
36
+
37
+ //# sourceMappingURL=debug-id-injection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"debug-id-injection.js","sources":["../../../src/rollup/debug-id-injection.ts"],"sourcesContent":["import { stringToUUID } from '../core';\n\nexport const ROLLDOWN_DEBUG_ID_PLACEHOLDER = 'SENTRY_DEBUG_ID_PLACEHOLDER_00000000';\n\ntype GeneratedChunk = {\n type: 'chunk';\n fileName: string;\n code: string;\n};\n\ntype GeneratedAsset = {\n type: 'asset';\n fileName: string;\n};\n\nexport type GeneratedBundle = Record<string, GeneratedChunk | GeneratedAsset>;\n\nconst SENTRY_DEBUG_ID_IDENTIFIER = '_sentryDebugIdIdentifier';\nconst SENTRY_DEBUG_ID_IDENTIFIER_PREFIX = 'sentry-dbid-';\n\nexport function hasExistingDebugID(code: string): boolean {\n const chunkStartSnippet = code.slice(0, 6000);\n const chunkEndSnippet = code.slice(-500);\n\n return chunkStartSnippet.includes(SENTRY_DEBUG_ID_IDENTIFIER) || chunkEndSnippet.includes('//# debugId=');\n}\n\nexport function getDebugIdForChunk(code: string, isRolldown: boolean): string {\n return isRolldown ? ROLLDOWN_DEBUG_ID_PLACEHOLDER : stringToUUID(code);\n}\n\nfunction replaceAt(code: string, start: number, search: string, replacement: string): string {\n return `${code.slice(0, start)}${replacement}${code.slice(start + search.length)}`;\n}\n\nexport function finalizeRolldownDebugIds(bundle: GeneratedBundle): void {\n for (const [fileName, output] of Object.entries(bundle)) {\n if (output.type !== 'chunk') {\n continue;\n }\n\n const identifier = `${SENTRY_DEBUG_ID_IDENTIFIER_PREFIX}${ROLLDOWN_DEBUG_ID_PLACEHOLDER}`;\n const identifierPropertyStart = output.code.indexOf(SENTRY_DEBUG_ID_IDENTIFIER);\n const identifierStart = output.code.indexOf(\n identifier,\n identifierPropertyStart + SENTRY_DEBUG_ID_IDENTIFIER.length,\n );\n if (identifierStart === -1) {\n continue;\n }\n\n const identifierPlaceholderStart = identifierStart + SENTRY_DEBUG_ID_IDENTIFIER_PREFIX.length;\n const debugIdsPlaceholderStart = output.code.lastIndexOf(ROLLDOWN_DEBUG_ID_PLACEHOLDER, identifierStart - 1);\n if (debugIdsPlaceholderStart === -1) {\n throw new Error(`Failed to locate the Sentry debug ID placeholder for chunk \\`${fileName}\\`.`);\n }\n\n // The fixed-width replacement happens after Rolldown computes [hash], so the emitted file name\n // still matches the placeholder-bearing chunk. Hashing only the code keeps byte-identical chunks\n // on one ID, as Rollup builds do.\n const debugId = stringToUUID(output.code);\n const codeWithIdentifier = replaceAt(\n output.code,\n identifierPlaceholderStart,\n ROLLDOWN_DEBUG_ID_PLACEHOLDER,\n debugId,\n );\n output.code = replaceAt(codeWithIdentifier, debugIdsPlaceholderStart, ROLLDOWN_DEBUG_ID_PLACEHOLDER, debugId);\n }\n}\n"],"names":["stringToUUID"],"mappings":";;;;AAEO,MAAM,6BAAA,GAAgC;AAe7C,MAAM,0BAAA,GAA6B,0BAAA;AACnC,MAAM,iCAAA,GAAoC,cAAA;AAEnC,SAAS,mBAAmB,IAAA,EAAuB;AACxD,EAAA,MAAM,iBAAA,GAAoB,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,GAAI,CAAA;AAC5C,EAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA;AAEvC,EAAA,OAAO,kBAAkB,QAAA,CAAS,0BAA0B,CAAA,IAAK,eAAA,CAAgB,SAAS,cAAc,CAAA;AAC1G;AAEO,SAAS,kBAAA,CAAmB,MAAc,UAAA,EAA6B;AAC5E,EAAA,OAAO,UAAA,GAAa,6BAAA,GAAgCA,kBAAA,CAAa,IAAI,CAAA;AACvE;AAEA,SAAS,SAAA,CAAU,IAAA,EAAc,KAAA,EAAe,MAAA,EAAgB,WAAA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;AAAA,KACF;AACA,IAAA,MAAA,CAAO,IAAA,GAAO,SAAA,CAAU,kBAAA,EAAoB,wBAAA,EAA0B,+BAA+B,OAAO,CAAA;AAAA,EAC9G;AACF;;;;;;;"}
1
+ {"version":3,"file":"debug-id-injection.js","names":["stringToUUID"],"sources":["../../../src/rollup/debug-id-injection.ts"],"sourcesContent":["import { stringToUUID } from '../core';\n\nexport const ROLLDOWN_DEBUG_ID_PLACEHOLDER = 'SENTRY_DEBUG_ID_PLACEHOLDER_00000000';\n\ntype GeneratedChunk = {\n type: 'chunk';\n fileName: string;\n code: string;\n};\n\ntype GeneratedAsset = {\n type: 'asset';\n fileName: string;\n};\n\nexport type GeneratedBundle = Record<string, GeneratedChunk | GeneratedAsset>;\n\nconst SENTRY_DEBUG_ID_IDENTIFIER = '_sentryDebugIdIdentifier';\nconst SENTRY_DEBUG_ID_IDENTIFIER_PREFIX = 'sentry-dbid-';\n\nexport function hasExistingDebugID(code: string): boolean {\n const chunkStartSnippet = code.slice(0, 6000);\n const chunkEndSnippet = code.slice(-500);\n\n return chunkStartSnippet.includes(SENTRY_DEBUG_ID_IDENTIFIER) || chunkEndSnippet.includes('//# debugId=');\n}\n\nexport function getDebugIdForChunk(code: string, isRolldown: boolean): string {\n return isRolldown ? ROLLDOWN_DEBUG_ID_PLACEHOLDER : stringToUUID(code);\n}\n\nfunction replaceAt(code: string, start: number, search: string, replacement: string): string {\n return `${code.slice(0, start)}${replacement}${code.slice(start + search.length)}`;\n}\n\nexport function finalizeRolldownDebugIds(bundle: GeneratedBundle): void {\n for (const [fileName, output] of Object.entries(bundle)) {\n if (output.type !== 'chunk') {\n continue;\n }\n\n const identifier = `${SENTRY_DEBUG_ID_IDENTIFIER_PREFIX}${ROLLDOWN_DEBUG_ID_PLACEHOLDER}`;\n const identifierPropertyStart = output.code.indexOf(SENTRY_DEBUG_ID_IDENTIFIER);\n const identifierStart = output.code.indexOf(\n identifier,\n identifierPropertyStart + SENTRY_DEBUG_ID_IDENTIFIER.length,\n );\n if (identifierStart === -1) {\n continue;\n }\n\n const identifierPlaceholderStart = identifierStart + SENTRY_DEBUG_ID_IDENTIFIER_PREFIX.length;\n const debugIdsPlaceholderStart = output.code.lastIndexOf(ROLLDOWN_DEBUG_ID_PLACEHOLDER, identifierStart - 1);\n if (debugIdsPlaceholderStart === -1) {\n throw new Error(`Failed to locate the Sentry debug ID placeholder for chunk \\`${fileName}\\`.`);\n }\n\n // The fixed-width replacement happens after Rolldown computes [hash], so the emitted file name\n // still matches the placeholder-bearing chunk. Hashing only the code keeps byte-identical chunks\n // on one ID, as Rollup builds do.\n const debugId = stringToUUID(output.code);\n const codeWithIdentifier = replaceAt(\n output.code,\n identifierPlaceholderStart,\n ROLLDOWN_DEBUG_ID_PLACEHOLDER,\n debugId,\n );\n output.code = replaceAt(codeWithIdentifier, debugIdsPlaceholderStart, ROLLDOWN_DEBUG_ID_PLACEHOLDER, debugId);\n }\n}\n"],"mappings":";;;AAEA,MAAa,gCAAgC;AAe7C,MAAM,6BAA6B;AACnC,MAAM,oCAAoC;AAE1C,SAAgB,mBAAmB,MAAuB;CACxD,MAAM,oBAAoB,KAAK,MAAM,GAAG,GAAI;CAC5C,MAAM,kBAAkB,KAAK,MAAM,IAAI;CAEvC,OAAO,kBAAkB,SAAS,0BAA0B,KAAK,gBAAgB,SAAS,cAAc;AAC1G;AAEA,SAAgB,mBAAmB,MAAc,YAA6B;CAC5E,OAAO,aAAa,gCAAgCA,cAAAA,aAAa,IAAI;AACvE;AAEA,SAAS,UAAU,MAAc,OAAe,QAAgB,aAA6B;CAC3F,OAAO,GAAG,KAAK,MAAM,GAAG,KAAK,IAAI,cAAc,KAAK,MAAM,QAAQ,OAAO,MAAM;AACjF;AAEA,SAAgB,yBAAyB,QAA+B;CACtE,KAAK,MAAM,CAAC,UAAU,WAAW,OAAO,QAAQ,MAAM,GAAG;EACvD,IAAI,OAAO,SAAS,SAClB;EAGF,MAAM,aAAa,GAAG,oCAAoC;EAC1D,MAAM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