@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,693 +1,636 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const core = require('@sentry/core');
4
- const dotenv = require('dotenv');
5
- const fs = require('fs');
6
- const os = require('os');
7
- const path = require('path');
8
- const glob$1 = require('glob');
9
- const cli = require('./cli.js');
10
- const optionsMapping = require('./options-mapping.js');
11
- const logger = require('./logger.js');
12
- const telemetry = require('./sentry/telemetry.js');
13
- const utils = require('./utils.js');
14
- const debugIdUpload = require('./debug-id-upload.js');
15
- const glob = require('./glob.js');
16
- const sourcemapSettings = require('./sourcemap-settings.js');
17
- const version = require('./version.js');
18
-
19
- function _interopNamespace(e) {
20
- if (e && e.__esModule) return e;
21
- const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
22
- if (e) {
23
- for (const k in e) {
24
- n[k] = e[k];
25
- }
26
- }
27
- n.default = e;
28
- return n;
29
- }
30
-
31
- const dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
32
- const fs__namespace = /*#__PURE__*/_interopNamespace(fs);
33
- const os__namespace = /*#__PURE__*/_interopNamespace(os);
34
- const path__namespace = /*#__PURE__*/_interopNamespace(path);
35
-
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
2
+ const require_cli = require("./cli.js");
3
+ const require_options_mapping = require("./options-mapping.js");
4
+ const require_logger = require("./logger.js");
5
+ const require_telemetry = require("./sentry/telemetry.js");
6
+ const require_utils = require("./utils.js");
7
+ const require_debug_id_upload = require("./debug-id-upload.js");
8
+ const require_glob = require("./glob.js");
9
+ const require_sourcemap_settings = require("./sourcemap-settings.js");
10
+ const require_upload_filter = require("./upload-filter.js");
11
+ const require_version = require("./version.js");
12
+ let path = require("path");
13
+ path = require_runtime.__toESM(path);
14
+ let fs = require("fs");
15
+ fs = require_runtime.__toESM(fs);
16
+ let os = require("os");
17
+ os = require_runtime.__toESM(os);
18
+ let glob = require("glob");
19
+ let _sentry_core = require("@sentry/core");
20
+ let dotenv = require("dotenv");
21
+ dotenv = require_runtime.__toESM(dotenv);
22
+ // src/core/build-plugin-manager.ts
36
23
  const _deployedReleases = /* @__PURE__ */ new Set();
24
+ /**
25
+ * Creates a build plugin manager that exposes primitives for everything that a Sentry JavaScript SDK or build tooling may do during a build.
26
+ *
27
+ * The build plugin manager's behavior strongly depends on the options that are passed in.
28
+ */
37
29
  function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
38
- const logger$1 = logger.createLogger({
39
- prefix: bundlerPluginMetaContext.loggerPrefix,
40
- silent: userOptions.silent ?? false,
41
- debug: userOptions.debug ?? false
42
- });
43
- try {
44
- const dotenvFile = fs__namespace.readFileSync(path__namespace.join(process.cwd(), ".env.sentry-build-plugin"), "utf-8");
45
- const dotenvResult = dotenv__namespace.parse(dotenvFile);
46
- Object.assign(process.env, dotenvResult);
47
- logger$1.info('Using environment variables configured in ".env.sentry-build-plugin".');
48
- } catch (e) {
49
- if (typeof e === "object" && e && "code" in e && e.code !== "ENOENT") {
50
- throw e;
51
- }
52
- }
53
- const options = optionsMapping.normalizeUserOptions(userOptions);
54
- if (options.disable) {
55
- return {
56
- normalizedOptions: options,
57
- logger: logger$1,
58
- bundleSizeOptimizationReplacementValues: {},
59
- telemetry: {
60
- emitBundlerPluginExecutionSignal: async () => {
61
- }
62
- },
63
- bundleMetadata: {},
64
- createRelease: async () => {
65
- },
66
- uploadSourcemaps: async () => ({ uploaded: false }),
67
- createUploadStaging: async () => ({
68
- dir: "",
69
- count: 0,
70
- stagedChunkPaths: /* @__PURE__ */ new Set(),
71
- stage: async () => "skipped",
72
- discard: async () => {
73
- },
74
- keep: async () => {
75
- }
76
- }),
77
- sourceMaps: {
78
- uploadPossible: false,
79
- decide: () => ({ enableHidden: false, deleteAfterUpload: false })
80
- },
81
- deleteArtifacts: async () => {
82
- },
83
- createDependencyOnBuildArtifacts: () => () => {
84
- },
85
- injectDebugIds: async () => {
86
- }
87
- };
88
- }
89
- const shouldSendTelemetry = telemetry.allowedToSendTelemetry(options);
90
- const { sentryScope, sentryClient } = telemetry.createSentryInstance(
91
- options,
92
- shouldSendTelemetry,
93
- bundlerPluginMetaContext.buildTool,
94
- bundlerPluginMetaContext.buildToolMajorVersion
95
- );
96
- const { release, environment = core.DEFAULT_ENVIRONMENT } = sentryClient.getOptions();
97
- const sentrySession = core.makeSession({ release, environment });
98
- sentryScope.setSession(sentrySession);
99
- sentryClient.captureSession(sentrySession);
100
- let sessionHasEnded = false;
101
- function endSession() {
102
- if (sessionHasEnded) {
103
- return;
104
- }
105
- core.closeSession(sentrySession);
106
- sentryClient.captureSession(sentrySession);
107
- sessionHasEnded = true;
108
- }
109
- process.on("beforeExit", () => {
110
- endSession();
111
- });
112
- process.env["SENTRY_PIPELINE"] = `${bundlerPluginMetaContext.buildTool}-plugin/${version.LIB_VERSION}`;
113
- if (options.debug && !process.env["SENTRY_LOG_LEVEL"]) {
114
- process.env["SENTRY_LOG_LEVEL"] = "debug";
115
- }
116
- const isDevMode = process.env["NODE_ENV"] === "development";
117
- function handleRecoverableError(unknownError, throwByDefault) {
118
- sentrySession.status = "abnormal";
119
- try {
120
- if (options.errorHandler) {
121
- try {
122
- if (unknownError instanceof Error) {
123
- options.errorHandler(unknownError);
124
- } else {
125
- options.errorHandler(new Error("An unknown error occurred"));
126
- }
127
- } catch (e) {
128
- sentrySession.status = "crashed";
129
- throw e;
130
- }
131
- } else {
132
- sentrySession.status = "crashed";
133
- if (throwByDefault) {
134
- throw unknownError;
135
- }
136
- logger$1.error("An error occurred. Couldn't finish all operations:", unknownError);
137
- }
138
- } finally {
139
- endSession();
140
- }
141
- }
142
- if (!optionsMapping.validateOptions(options, logger$1)) {
143
- handleRecoverableError(new Error("Options were not set correctly. See output above for more details."), true);
144
- }
145
- const dependenciesOnBuildArtifacts = /* @__PURE__ */ new Set();
146
- const buildArtifactsDependencySubscribers = [];
147
- function notifyBuildArtifactDependencySubscribers() {
148
- buildArtifactsDependencySubscribers.forEach((subscriber) => {
149
- subscriber();
150
- });
151
- }
152
- function createDependencyOnBuildArtifacts() {
153
- const dependencyIdentifier = /* @__PURE__ */ Symbol();
154
- dependenciesOnBuildArtifacts.add(dependencyIdentifier);
155
- return function freeDependencyOnBuildArtifacts() {
156
- dependenciesOnBuildArtifacts.delete(dependencyIdentifier);
157
- notifyBuildArtifactDependencySubscribers();
158
- };
159
- }
160
- const sourceMapUploadPossible = getSourceMapUploadBlocker(options, isDevMode) === void 0;
161
- const loggedSourceMapMessages = /* @__PURE__ */ new Set();
162
- function waitUntilBuildArtifactDependenciesAreFreed() {
163
- return new Promise((resolve) => {
164
- buildArtifactsDependencySubscribers.push(() => {
165
- if (dependenciesOnBuildArtifacts.size === 0) {
166
- resolve();
167
- }
168
- });
169
- if (dependenciesOnBuildArtifacts.size === 0) {
170
- resolve();
171
- }
172
- });
173
- }
174
- const bundleSizeOptimizationReplacementValues = {};
175
- if (options.bundleSizeOptimizations) {
176
- const { bundleSizeOptimizations } = options;
177
- if (bundleSizeOptimizations.excludeDebugStatements) {
178
- bundleSizeOptimizationReplacementValues["__SENTRY_DEBUG__"] = false;
179
- }
180
- if (bundleSizeOptimizations.excludeTracing) {
181
- bundleSizeOptimizationReplacementValues["__SENTRY_TRACING__"] = false;
182
- }
183
- if (bundleSizeOptimizations.excludeChannelInjection) {
184
- bundleSizeOptimizationReplacementValues["__SENTRY_CHANNEL_INJECTION__"] = false;
185
- }
186
- if (bundleSizeOptimizations.excludeReplayCanvas) {
187
- bundleSizeOptimizationReplacementValues["__RRWEB_EXCLUDE_CANVAS__"] = true;
188
- }
189
- if (bundleSizeOptimizations.excludeReplayIframe) {
190
- bundleSizeOptimizationReplacementValues["__RRWEB_EXCLUDE_IFRAME__"] = true;
191
- }
192
- if (bundleSizeOptimizations.excludeReplayShadowDom) {
193
- bundleSizeOptimizationReplacementValues["__RRWEB_EXCLUDE_SHADOW_DOM__"] = true;
194
- }
195
- if (bundleSizeOptimizations.excludeReplayWorker) {
196
- bundleSizeOptimizationReplacementValues["__SENTRY_EXCLUDE_REPLAY_WORKER__"] = true;
197
- }
198
- }
199
- let bundleMetadata = {};
200
- if (options.moduleMetadata || options.applicationKey) {
201
- if (options.applicationKey) {
202
- bundleMetadata[`_sentryBundlerPluginAppKey:${options.applicationKey}`] = true;
203
- }
204
- if (typeof options.moduleMetadata === "function") {
205
- const args = {
206
- org: options.org,
207
- project: utils.getProjects(options.project)?.[0],
208
- projects: utils.getProjects(options.project),
209
- release: options.release.name
210
- };
211
- bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata(args) };
212
- } else {
213
- bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata };
214
- }
215
- }
216
- return {
217
- /**
218
- * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)
219
- */
220
- logger: logger$1,
221
- /**
222
- * Options after normalization. Includes things like the inferred release name.
223
- */
224
- normalizedOptions: options,
225
- /**
226
- * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes
227
- * into account the options passed to the build plugin manager.
228
- */
229
- bundleSizeOptimizationReplacementValues,
230
- /**
231
- * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.
232
- */
233
- // See `generateModuleMetadataInjectorCode` for how this should be used exactly
234
- bundleMetadata,
235
- /**
236
- * Contains utility functions for emitting telemetry via the build plugin manager.
237
- */
238
- telemetry: {
239
- /**
240
- * Emits a `Sentry Bundler Plugin execution` signal.
241
- */
242
- async emitBundlerPluginExecutionSignal() {
243
- if (await shouldSendTelemetry) {
244
- logger$1.info(
245
- "Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`."
246
- );
247
- core.startSpan({ name: "Sentry Bundler Plugin execution", scope: sentryScope }, () => {
248
- });
249
- await telemetry.safeFlushTelemetry(sentryClient);
250
- }
251
- }
252
- },
253
- /**
254
- * Will potentially create a release based on the build plugin manager options.
255
- *
256
- * Also
257
- * - finalizes the release
258
- * - sets commits
259
- * - uploads legacy sourcemaps
260
- * - adds deploy information
261
- */
262
- async createRelease() {
263
- if (!options.release.name) {
264
- logger$1.debug(
265
- "No release name provided. Will not create release. Please set the `release.name` option to identify your release."
266
- );
267
- return;
268
- } else if (isDevMode) {
269
- logger$1.debug("Running in development mode. Will not create release.");
270
- return;
271
- } else if (!options.authToken) {
272
- logger$1.warn(
273
- `No auth token provided. Will not create release. Please set the \`authToken\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${utils.getTurborepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN")}`
274
- );
275
- return;
276
- } else if (!options.org && !options.authToken.startsWith("sntrys_")) {
277
- logger$1.warn(
278
- `No organization slug provided. Will not create release. Please set the \`org\` option to your Sentry organization slug.${utils.getTurborepoEnvPassthroughWarning("SENTRY_ORG")}`
279
- );
280
- return;
281
- } else if (!options.project || Array.isArray(options.project) && options.project.length === 0) {
282
- logger$1.warn(
283
- `No project provided. Will not create release. Please set the \`project\` option to your Sentry project slug.${utils.getTurborepoEnvPassthroughWarning("SENTRY_PROJECT")}`
284
- );
285
- return;
286
- }
287
- const freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnBuildArtifacts();
288
- const releaseName = options.release.name;
289
- try {
290
- const cliInstance = new cli.SentryCliAdapter(options);
291
- if (options.release.create) {
292
- const releaseOutput = await cliInstance.createRelease(releaseName);
293
- logger$1.debug("Release created:", releaseOutput);
294
- }
295
- if (options.release.uploadLegacySourcemaps) {
296
- const uploadTargets = utils.arrayify(options.release.uploadLegacySourcemaps).map((includeItem) => typeof includeItem === "string" ? { paths: [includeItem] } : includeItem).flatMap(
297
- (includeEntry) => includeEntry.paths.map((directory) => ({
298
- directory,
299
- dist: options.release.dist,
300
- ext: includeEntry.ext ? includeEntry.ext.map((extension) => `.${extension.replace(/^\./, "")}`) : [".js", ".map", ".jsbundle", ".bundle"],
301
- // The old CLI only skipped `node_modules` when neither ignore source was configured.
302
- ignore: includeEntry.ignore ? utils.arrayify(includeEntry.ignore) : includeEntry.ignoreFile ? void 0 : ["node_modules"],
303
- ignoreFile: includeEntry.ignoreFile,
304
- urlPrefix: includeEntry.urlPrefix
305
- }))
306
- );
307
- await cliInstance.uploadSourcemaps(releaseName, uploadTargets);
308
- }
309
- if (options.release.setCommits !== false) {
310
- try {
311
- await cliInstance.setCommits(
312
- releaseName,
313
- // set commits always exists due to the normalize function
314
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
315
- options.release.setCommits
316
- );
317
- } catch (e) {
318
- if (options.release.setCommits && "shouldNotThrowOnFailure" in options.release.setCommits && options.release.setCommits.shouldNotThrowOnFailure) {
319
- logger$1.debug(
320
- "An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):",
321
- e
322
- );
323
- } else {
324
- throw e;
325
- }
326
- }
327
- }
328
- if (options.release.finalize) {
329
- await cliInstance.finalizeRelease(releaseName);
330
- }
331
- if (options.release.deploy && !_deployedReleases.has(releaseName)) {
332
- await cliInstance.newDeploy(releaseName, options.release.deploy);
333
- _deployedReleases.add(releaseName);
334
- }
335
- } catch (e) {
336
- sentryScope.captureException('Error in "releaseManagementPlugin" writeBundle hook');
337
- await telemetry.safeFlushTelemetry(sentryClient);
338
- handleRecoverableError(e, false);
339
- } finally {
340
- freeWriteBundleInvocationDependencyOnSourcemapFiles();
341
- }
342
- },
343
- /*
344
- Injects debug IDs into the build artifacts.
345
-
346
- This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.
347
- Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.
348
- Only use this if you need to manually inject debug IDs into the build artifacts.
349
- */
350
- async injectDebugIds(buildArtifactPaths) {
351
- await core.startSpan({ name: "inject-debug-ids", scope: sentryScope, forceTransaction: true }, async () => {
352
- try {
353
- const cliInstance = new cli.SentryCliAdapter(options);
354
- await cliInstance.injectDebugIds(buildArtifactPaths, options.sourcemaps?.ignore);
355
- } catch (e) {
356
- sentryScope.captureException('Error in "debugIdInjectionPlugin" writeBundle hook');
357
- handleRecoverableError(e, false);
358
- } finally {
359
- await telemetry.safeFlushTelemetry(sentryClient);
360
- }
361
- });
362
- },
363
- /**
364
- * Uploads sourcemaps using the "Debug ID" method.
365
- *
366
- * By default, this prepares bundles in a temporary folder before uploading. You can opt into an
367
- * in-place, direct upload path by setting `prepareArtifacts` to `false`. If `prepareArtifacts` is set to
368
- * `false`, no preparation (e.g. adding `//# debugId=...` and writing adjusted source maps) is performed and no temp folder is used.
369
- *
370
- * @param buildArtifactPaths - The paths of the build artifacts to upload
371
- * @param opts - Optional flags to control temp folder usage and preparation
372
- */
373
- async uploadSourcemaps(buildArtifactPaths, opts) {
374
- const staging = opts?.staging;
375
- if (!canUploadSourceMaps(options, logger$1, isDevMode)) {
376
- await staging?.discard();
377
- return { uploaded: false };
378
- }
379
- const assets = options.sourcemaps?.assets;
380
- let uploaded = false;
381
- await core.startSpan(
382
- // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.
383
- // oxlint-disable-next-line typescript/no-deprecated
384
- { name: "debug-id-sourcemap-upload", scope: sentryScope, forceTransaction: true },
385
- async () => {
386
- const shouldPrepare = opts?.prepareArtifacts ?? true;
387
- let folderToCleanUp = staging?.dir;
388
- const freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
389
- try {
390
- if (!shouldPrepare) {
391
- let pathsToUpload;
392
- if (assets) {
393
- pathsToUpload = Array.isArray(assets) ? assets : [assets];
394
- logger$1.debug(
395
- `Direct upload mode: passing user-provided assets directly to CLI: ${pathsToUpload.join(", ")}`
396
- );
397
- } else {
398
- pathsToUpload = buildArtifactPaths;
399
- }
400
- if (staging && staging.count > 0) {
401
- pathsToUpload = [...pathsToUpload, staging.dir];
402
- }
403
- if (pathsToUpload.length === 0) {
404
- logger$1.warn(
405
- "Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option."
406
- );
407
- return;
408
- }
409
- await core.startSpan({ name: "upload", scope: sentryScope }, async () => {
410
- const cliInstance = new cli.SentryCliAdapter(options);
411
- await cliInstance.uploadSourcemaps(
412
- options.release.name ?? "undefined",
413
- pathsToUpload.map((directory) => ({
414
- directory,
415
- dist: options.release.dist,
416
- ignore: options.sourcemaps?.ignore
417
- }))
418
- );
419
- });
420
- uploaded = true;
421
- logger$1.info("Successfully uploaded source maps to Sentry");
422
- } else {
423
- let globAssets;
424
- if (assets) {
425
- globAssets = assets;
426
- } else {
427
- logger$1.debug(
428
- "No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts."
429
- );
430
- globAssets = buildArtifactPaths.map((asset) => glob$1.escape(asset.split(path__namespace.sep).join("/")));
431
- }
432
- const globResult = await core.startSpan(
433
- { name: "glob", scope: sentryScope },
434
- async () => glob.globFiles(globAssets, { ignore: options.sourcemaps?.ignore })
435
- );
436
- const debugIdChunkFilePaths = globResult.filter((debugIdChunkFilePath) => {
437
- const filePath = utils.stripQueryAndHashFromPath(debugIdChunkFilePath);
438
- return !!filePath.match(/\.(js|mjs|cjs)$/) && !staging?.stagedChunkPaths.has(path__namespace.resolve(filePath));
439
- });
440
- debugIdChunkFilePaths.sort();
441
- const stagedCount = staging?.count ?? 0;
442
- if (debugIdChunkFilePaths.length === 0 && stagedCount === 0) {
443
- logger$1.warn(
444
- "Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option."
445
- );
446
- } else {
447
- const tmpUploadFolder = staging?.dir ?? await core.startSpan({ name: "mkdtemp", scope: sentryScope }, () => createTempUploadFolder());
448
- folderToCleanUp = tmpUploadFolder;
449
- await core.startSpan({ name: "prepare-bundles", scope: sentryScope }, async (prepBundlesSpan) => {
450
- const preparationTasks = debugIdChunkFilePaths.map((chunkFilePath, chunkIndex) => async () => {
451
- await debugIdUpload.prepareBundleForDebugIdUpload(
452
- chunkFilePath,
453
- tmpUploadFolder,
454
- stagedCount + chunkIndex,
455
- logger$1,
456
- options.sourcemaps?.rewriteSources ?? debugIdUpload.defaultRewriteSourcesHook,
457
- options.sourcemaps?.resolveSourceMap
458
- );
459
- });
460
- const workers = [];
461
- const worker = async () => {
462
- while (preparationTasks.length > 0) {
463
- const task = preparationTasks.shift();
464
- if (task) {
465
- await task();
466
- }
467
- }
468
- };
469
- for (let workerIndex = 0; workerIndex < 16; workerIndex++) {
470
- workers.push(worker());
471
- }
472
- await Promise.all(workers);
473
- const files = await fs__namespace.promises.readdir(tmpUploadFolder);
474
- const stats = files.map((file) => fs__namespace.promises.stat(path__namespace.join(tmpUploadFolder, file)));
475
- const uploadSize = (await Promise.all(stats)).reduce(
476
- (accumulator, { size }) => accumulator + size,
477
- 0
478
- );
479
- core.setMeasurement("files", files.length, "none", prepBundlesSpan);
480
- core.setMeasurement("upload_size", uploadSize, "byte", prepBundlesSpan);
481
- if (files.length === 0) {
482
- logger$1.warn(
483
- `No source maps found for any of the ${debugIdChunkFilePaths.length + stagedCount} matched build artifacts, so no source maps were uploaded to Sentry. This usually means source map generation is not enabled in your bundler. Enable it so Sentry can un-minify your stack traces.`
484
- );
485
- return;
486
- }
487
- await core.startSpan({ name: "upload", scope: sentryScope }, async () => {
488
- const cliInstance = new cli.SentryCliAdapter(options);
489
- await cliInstance.uploadSourcemaps(options.release.name ?? "undefined", [
490
- {
491
- directory: tmpUploadFolder,
492
- dist: options.release.dist
493
- }
494
- ]);
495
- });
496
- uploaded = true;
497
- logger$1.info("Successfully uploaded source maps to Sentry");
498
- });
499
- }
500
- }
501
- } catch (e) {
502
- if (staging && folderToCleanUp) {
503
- await staging.keep("Source map upload failed.");
504
- folderToCleanUp = void 0;
505
- }
506
- sentryScope.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
507
- handleRecoverableError(e, false);
508
- } finally {
509
- if (folderToCleanUp && !process.env?.["SENTRY_TEST_OVERRIDE_TEMP_DIR"]) {
510
- logger$1.debug("Cleaning up temporary files...");
511
- try {
512
- await core.startSpan({ name: "cleanup", scope: sentryScope }, async () => {
513
- if (folderToCleanUp) {
514
- await fs__namespace.promises.rm(folderToCleanUp, { recursive: true, force: true });
515
- logger$1.debug(`Temporary folder deleted: ${folderToCleanUp}`);
516
- }
517
- });
518
- } catch (e) {
519
- logger$1.debug("Failed to clean up temporary folder:", e);
520
- }
521
- }
522
- logger$1.debug("Freeing upload dependencies...");
523
- freeUploadDependencyOnBuildArtifacts();
524
- logger$1.debug("Flushing telemetry data...");
525
- await telemetry.safeFlushTelemetry(sentryClient);
526
- logger$1.debug("Telemetry flushed. Plugin upload process complete.");
527
- }
528
- }
529
- );
530
- return { uploaded };
531
- },
532
- async createUploadStaging() {
533
- const dir = await createTempUploadFolder();
534
- const rewriteSourcesHook = options.sourcemaps?.rewriteSources ?? debugIdUpload.defaultRewriteSourcesHook;
535
- let count = 0;
536
- let discarded = false;
537
- const stagedChunkPaths = /* @__PURE__ */ new Set();
538
- const discard = async () => {
539
- if (discarded) {
540
- return;
541
- }
542
- discarded = true;
543
- if (process.env["SENTRY_TEST_OVERRIDE_TEMP_DIR"]) {
544
- return;
545
- }
546
- try {
547
- await fs__namespace.promises.rm(dir, { recursive: true, force: true });
548
- } catch (e) {
549
- logger$1.debug(`Failed to remove staging folder ${dir}:`, e);
550
- }
551
- };
552
- return {
553
- dir,
554
- get count() {
555
- return count;
556
- },
557
- stagedChunkPaths,
558
- async stage(input) {
559
- const result = debugIdUpload.prepareArtifactForUpload({
560
- code: input.code,
561
- mapSource: input.mapSource,
562
- mapDir: input.mapDir,
563
- rewriteSourcesHook
564
- });
565
- if (!result.ok) {
566
- logger$1.debug(`Not staging ${input.fileName} for upload: ${result.reason}`);
567
- return "skipped";
568
- }
569
- const index = count++;
570
- try {
571
- await debugIdUpload.writePreparedArtifact(dir, `${result.artifact.debugId}-${index}`, result.artifact);
572
- stagedChunkPaths.add(path__namespace.resolve(input.mapDir, path__namespace.basename(input.fileName)));
573
- return "staged";
574
- } catch (e) {
575
- sentryScope.captureException("Error staging build artifact for upload");
576
- handleRecoverableError(e, true);
577
- return "failed";
578
- }
579
- },
580
- discard,
581
- async keep(reason) {
582
- if (count === 0) {
583
- await discard();
584
- return;
585
- }
586
- if (discarded) {
587
- return;
588
- }
589
- discarded = true;
590
- logger$1.error(
591
- `${reason} The source maps were kept in ${dir}. Upload them with \`sentry sourcemap upload ${dir}\`.`
592
- );
593
- }
594
- };
595
- },
596
- sourceMaps: {
597
- uploadPossible: sourceMapUploadPossible,
598
- decide(kind) {
599
- const decision = sourcemapSettings.decideSourceMapHandling(kind, options, sourceMapUploadPossible);
600
- if (decision.log && !loggedSourceMapMessages.has(decision.log.message)) {
601
- loggedSourceMapMessages.add(decision.log.message);
602
- logger$1[decision.log.level](decision.log.message);
603
- }
604
- return decision;
605
- }
606
- },
607
- /**
608
- * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.
609
- */
610
- async deleteArtifacts() {
611
- try {
612
- const filesToDelete = await options.sourcemaps?.filesToDeleteAfterUpload;
613
- if (filesToDelete !== void 0) {
614
- const filePathsToDelete = await glob.globFiles(filesToDelete);
615
- logger$1.debug("Waiting for dependencies on generated files to be freed before deleting...");
616
- await waitUntilBuildArtifactDependenciesAreFreed();
617
- filePathsToDelete.forEach((filePathToDelete) => {
618
- logger$1.debug(`Deleting asset after upload: ${filePathToDelete}`);
619
- });
620
- await Promise.all(
621
- filePathsToDelete.map(
622
- (filePathToDelete) => fs__namespace.promises.rm(filePathToDelete, { force: true }).catch((e) => {
623
- logger$1.debug(`An error occurred while attempting to delete asset: ${filePathToDelete}`, e);
624
- })
625
- )
626
- );
627
- }
628
- } catch (e) {
629
- sentryScope.captureException('Error in "sentry-file-deletion-plugin" buildEnd hook');
630
- await telemetry.safeFlushTelemetry(sentryClient);
631
- handleRecoverableError(e, true);
632
- }
633
- },
634
- createDependencyOnBuildArtifacts
635
- };
30
+ const logger = require_logger.createLogger({
31
+ prefix: bundlerPluginMetaContext.loggerPrefix,
32
+ silent: userOptions.silent ?? false,
33
+ debug: userOptions.debug ?? false
34
+ });
35
+ try {
36
+ const dotenvFile = fs.readFileSync(path.join(process.cwd(), ".env.sentry-build-plugin"), "utf-8");
37
+ const dotenvResult = dotenv.parse(dotenvFile);
38
+ Object.assign(process.env, dotenvResult);
39
+ logger.info("Using environment variables configured in \".env.sentry-build-plugin\".");
40
+ } catch (e) {
41
+ if (typeof e === "object" && e && "code" in e && e.code !== "ENOENT") throw e;
42
+ }
43
+ const options = require_options_mapping.normalizeUserOptions(userOptions);
44
+ if (options.disable) return {
45
+ normalizedOptions: options,
46
+ logger,
47
+ bundleSizeOptimizationReplacementValues: {},
48
+ telemetry: { emitBundlerPluginExecutionSignal: async () => {} },
49
+ bundleMetadata: {},
50
+ createRelease: async () => {},
51
+ uploadSourcemaps: async () => ({
52
+ uploaded: false,
53
+ uploadedSourceMapPaths: []
54
+ }),
55
+ createUploadStaging: async () => ({
56
+ dir: "",
57
+ count: 0,
58
+ stagedChunkPaths: /* @__PURE__ */ new Set(),
59
+ stage: async () => "skipped",
60
+ discard: async () => {},
61
+ keep: async () => {}
62
+ }),
63
+ sourceMaps: {
64
+ uploadPossible: false,
65
+ decide: () => ({
66
+ enableHidden: false,
67
+ deleteAfterUpload: false
68
+ }),
69
+ logDecision: () => void 0,
70
+ shouldUpload: () => false,
71
+ deleteFromOutput: async () => {}
72
+ },
73
+ deleteArtifacts: async () => {},
74
+ createDependencyOnBuildArtifacts: () => () => {},
75
+ injectDebugIds: async () => {}
76
+ };
77
+ const shouldSendTelemetry = require_telemetry.allowedToSendTelemetry(options);
78
+ const { sentryScope, sentryClient } = require_telemetry.createSentryInstance(options, shouldSendTelemetry, bundlerPluginMetaContext.buildTool, bundlerPluginMetaContext.buildToolMajorVersion);
79
+ const { release, environment = _sentry_core.DEFAULT_ENVIRONMENT } = sentryClient.getOptions();
80
+ const sentrySession = (0, _sentry_core.makeSession)({
81
+ release,
82
+ environment
83
+ });
84
+ sentryScope.setSession(sentrySession);
85
+ sentryClient.captureSession(sentrySession);
86
+ let sessionHasEnded = false;
87
+ function endSession() {
88
+ if (sessionHasEnded) return;
89
+ (0, _sentry_core.closeSession)(sentrySession);
90
+ sentryClient.captureSession(sentrySession);
91
+ sessionHasEnded = true;
92
+ }
93
+ process.on("beforeExit", () => {
94
+ endSession();
95
+ });
96
+ process.env["SENTRY_PIPELINE"] = `${bundlerPluginMetaContext.buildTool}-plugin/${require_version.LIB_VERSION}`;
97
+ if (options.debug && !process.env["SENTRY_LOG_LEVEL"]) process.env["SENTRY_LOG_LEVEL"] = "debug";
98
+ const isDevMode = process.env.NODE_ENV === "development";
99
+ /**
100
+ * Handles errors caught and emitted in various areas of the plugin.
101
+ *
102
+ * Also sets the sentry session status according to the error handling.
103
+ *
104
+ * If users specify their custom `errorHandler` we'll leave the decision to throw
105
+ * or continue up to them. By default, @param throwByDefault controls if the plugin
106
+ * should throw an error (which causes a build fail in most bundlers) or continue.
107
+ */
108
+ function handleRecoverableError(unknownError, throwByDefault) {
109
+ sentrySession.status = "abnormal";
110
+ try {
111
+ if (options.errorHandler) try {
112
+ if (unknownError instanceof Error) options.errorHandler(unknownError);
113
+ else options.errorHandler(/* @__PURE__ */ new Error("An unknown error occurred"));
114
+ } catch (e) {
115
+ sentrySession.status = "crashed";
116
+ throw e;
117
+ }
118
+ else {
119
+ sentrySession.status = "crashed";
120
+ if (throwByDefault) throw unknownError;
121
+ logger.error("An error occurred. Couldn't finish all operations:", unknownError);
122
+ }
123
+ } finally {
124
+ endSession();
125
+ }
126
+ }
127
+ if (!require_options_mapping.validateOptions(options, logger)) handleRecoverableError(/* @__PURE__ */ new Error("Options were not set correctly. See output above for more details."), true);
128
+ const dependenciesOnBuildArtifacts = /* @__PURE__ */ new Set();
129
+ const buildArtifactsDependencySubscribers = [];
130
+ function notifyBuildArtifactDependencySubscribers() {
131
+ buildArtifactsDependencySubscribers.forEach((subscriber) => {
132
+ subscriber();
133
+ });
134
+ }
135
+ function createDependencyOnBuildArtifacts() {
136
+ const dependencyIdentifier = Symbol();
137
+ dependenciesOnBuildArtifacts.add(dependencyIdentifier);
138
+ return function freeDependencyOnBuildArtifacts() {
139
+ dependenciesOnBuildArtifacts.delete(dependencyIdentifier);
140
+ notifyBuildArtifactDependencySubscribers();
141
+ };
142
+ }
143
+ const sourceMapUploadPossible = getSourceMapUploadBlocker(options, isDevMode) === void 0;
144
+ const loggedSourceMapMessages = /* @__PURE__ */ new Set();
145
+ const shouldUpload = require_upload_filter.createUploadFilter(options);
146
+ function logDecision(decision) {
147
+ if (decision.log && !loggedSourceMapMessages.has(decision.log.message)) {
148
+ loggedSourceMapMessages.add(decision.log.message);
149
+ logger[decision.log.level](decision.log.message);
150
+ }
151
+ }
152
+ /**
153
+ * Returns a Promise that resolves when all the currently active dependencies are freed again.
154
+ *
155
+ * It is very important that this function is called as late as possible before wanting to await the Promise to give
156
+ * the dependency producers as much time as possible to register themselves.
157
+ */
158
+ function waitUntilBuildArtifactDependenciesAreFreed() {
159
+ return new Promise((resolve) => {
160
+ buildArtifactsDependencySubscribers.push(() => {
161
+ if (dependenciesOnBuildArtifacts.size === 0) resolve();
162
+ });
163
+ if (dependenciesOnBuildArtifacts.size === 0) resolve();
164
+ });
165
+ }
166
+ const bundleSizeOptimizationReplacementValues = {};
167
+ if (options.bundleSizeOptimizations) {
168
+ const { bundleSizeOptimizations } = options;
169
+ if (bundleSizeOptimizations.excludeDebugStatements) bundleSizeOptimizationReplacementValues["__SENTRY_DEBUG__"] = false;
170
+ if (bundleSizeOptimizations.excludeTracing) bundleSizeOptimizationReplacementValues["__SENTRY_TRACING__"] = false;
171
+ if (bundleSizeOptimizations.excludeChannelInjection) bundleSizeOptimizationReplacementValues["__SENTRY_CHANNEL_INJECTION__"] = false;
172
+ if (bundleSizeOptimizations.excludeReplayCanvas) bundleSizeOptimizationReplacementValues["__RRWEB_EXCLUDE_CANVAS__"] = true;
173
+ if (bundleSizeOptimizations.excludeReplayIframe) bundleSizeOptimizationReplacementValues["__RRWEB_EXCLUDE_IFRAME__"] = true;
174
+ if (bundleSizeOptimizations.excludeReplayShadowDom) bundleSizeOptimizationReplacementValues["__RRWEB_EXCLUDE_SHADOW_DOM__"] = true;
175
+ if (bundleSizeOptimizations.excludeReplayWorker) bundleSizeOptimizationReplacementValues["__SENTRY_EXCLUDE_REPLAY_WORKER__"] = true;
176
+ }
177
+ let bundleMetadata = {};
178
+ if (options.moduleMetadata || options.applicationKey) {
179
+ if (options.applicationKey) bundleMetadata[`_sentryBundlerPluginAppKey:${options.applicationKey}`] = true;
180
+ if (typeof options.moduleMetadata === "function") {
181
+ const args = {
182
+ org: options.org,
183
+ project: require_utils.getProjects(options.project)?.[0],
184
+ projects: require_utils.getProjects(options.project),
185
+ release: options.release.name
186
+ };
187
+ bundleMetadata = {
188
+ ...bundleMetadata,
189
+ ...options.moduleMetadata(args)
190
+ };
191
+ } else bundleMetadata = {
192
+ ...bundleMetadata,
193
+ ...options.moduleMetadata
194
+ };
195
+ }
196
+ return {
197
+ /**
198
+ * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)
199
+ */
200
+ logger,
201
+ /**
202
+ * Options after normalization. Includes things like the inferred release name.
203
+ */
204
+ normalizedOptions: options,
205
+ /**
206
+ * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes
207
+ * into account the options passed to the build plugin manager.
208
+ */
209
+ bundleSizeOptimizationReplacementValues,
210
+ /**
211
+ * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.
212
+ */
213
+ bundleMetadata,
214
+ /**
215
+ * Contains utility functions for emitting telemetry via the build plugin manager.
216
+ */
217
+ telemetry: {
218
+ /**
219
+ * Emits a `Sentry Bundler Plugin execution` signal.
220
+ */
221
+ async emitBundlerPluginExecutionSignal() {
222
+ if (await shouldSendTelemetry) {
223
+ logger.info("Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.");
224
+ (0, _sentry_core.startSpan)({
225
+ name: "Sentry Bundler Plugin execution",
226
+ scope: sentryScope
227
+ }, () => {});
228
+ await require_telemetry.safeFlushTelemetry(sentryClient);
229
+ }
230
+ } },
231
+ /**
232
+ * Will potentially create a release based on the build plugin manager options.
233
+ *
234
+ * Also
235
+ * - finalizes the release
236
+ * - sets commits
237
+ * - uploads legacy sourcemaps
238
+ * - adds deploy information
239
+ */
240
+ async createRelease() {
241
+ if (!options.release.name) {
242
+ logger.debug("No release name provided. Will not create release. Please set the `release.name` option to identify your release.");
243
+ return;
244
+ } else if (isDevMode) {
245
+ logger.debug("Running in development mode. Will not create release.");
246
+ return;
247
+ } else if (!options.authToken) {
248
+ logger.warn(`No auth token provided. Will not create release. Please set the \`authToken\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${require_utils.getTurborepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN")}`);
249
+ return;
250
+ } else if (!options.org && !options.authToken.startsWith("sntrys_")) {
251
+ logger.warn(`No organization slug provided. Will not create release. Please set the \`org\` option to your Sentry organization slug.${require_utils.getTurborepoEnvPassthroughWarning("SENTRY_ORG")}`);
252
+ return;
253
+ } else if (!options.project || Array.isArray(options.project) && options.project.length === 0) {
254
+ logger.warn(`No project provided. Will not create release. Please set the \`project\` option to your Sentry project slug.${require_utils.getTurborepoEnvPassthroughWarning("SENTRY_PROJECT")}`);
255
+ return;
256
+ }
257
+ const freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnBuildArtifacts();
258
+ const releaseName = options.release.name;
259
+ try {
260
+ const cliInstance = new require_cli.SentryCliAdapter(options);
261
+ if (options.release.create) {
262
+ const releaseOutput = await cliInstance.createRelease(releaseName);
263
+ logger.debug("Release created:", releaseOutput);
264
+ }
265
+ if (options.release.uploadLegacySourcemaps) {
266
+ const uploadTargets = require_utils.arrayify(options.release.uploadLegacySourcemaps).map((includeItem) => typeof includeItem === "string" ? { paths: [includeItem] } : includeItem).flatMap((includeEntry) => includeEntry.paths.map((directory) => ({
267
+ directory,
268
+ dist: options.release.dist,
269
+ ext: includeEntry.ext ? includeEntry.ext.map((extension) => `.${extension.replace(/^\./, "")}`) : [
270
+ ".js",
271
+ ".map",
272
+ ".jsbundle",
273
+ ".bundle"
274
+ ],
275
+ ignore: includeEntry.ignore ? require_utils.arrayify(includeEntry.ignore) : includeEntry.ignoreFile ? void 0 : ["node_modules"],
276
+ ignoreFile: includeEntry.ignoreFile,
277
+ urlPrefix: includeEntry.urlPrefix
278
+ })));
279
+ warnAboutDirectoriesWithoutSourcemaps(logger, await cliInstance.uploadSourcemaps(releaseName, uploadTargets));
280
+ }
281
+ if (options.release.setCommits !== false) try {
282
+ await cliInstance.setCommits(releaseName, options.release.setCommits);
283
+ } catch (e) {
284
+ if (options.release.setCommits && "shouldNotThrowOnFailure" in options.release.setCommits && options.release.setCommits.shouldNotThrowOnFailure) logger.debug("An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):", e);
285
+ else throw e;
286
+ }
287
+ if (options.release.finalize) await cliInstance.finalizeRelease(releaseName);
288
+ if (options.release.deploy && !_deployedReleases.has(releaseName)) {
289
+ await cliInstance.newDeploy(releaseName, options.release.deploy);
290
+ _deployedReleases.add(releaseName);
291
+ }
292
+ } catch (e) {
293
+ sentryScope.captureException("Error in \"releaseManagementPlugin\" writeBundle hook");
294
+ await require_telemetry.safeFlushTelemetry(sentryClient);
295
+ handleRecoverableError(e, false);
296
+ } finally {
297
+ freeWriteBundleInvocationDependencyOnSourcemapFiles();
298
+ }
299
+ },
300
+ async injectDebugIds(buildArtifactPaths) {
301
+ await (0, _sentry_core.startSpan)({
302
+ name: "inject-debug-ids",
303
+ scope: sentryScope,
304
+ forceTransaction: true
305
+ }, async () => {
306
+ try {
307
+ await new require_cli.SentryCliAdapter(options).injectDebugIds(buildArtifactPaths, options.sourcemaps?.ignore);
308
+ } catch (e) {
309
+ sentryScope.captureException("Error in \"debugIdInjectionPlugin\" writeBundle hook");
310
+ handleRecoverableError(e, false);
311
+ } finally {
312
+ await require_telemetry.safeFlushTelemetry(sentryClient);
313
+ }
314
+ });
315
+ },
316
+ /**
317
+ * Uploads sourcemaps using the "Debug ID" method.
318
+ *
319
+ * By default, this prepares bundles in a temporary folder before uploading. You can opt into an
320
+ * in-place, direct upload path by setting `prepareArtifacts` to `false`. If `prepareArtifacts` is set to
321
+ * `false`, no preparation (e.g. adding `//# debugId=...` and writing adjusted source maps) is performed and no temp folder is used.
322
+ *
323
+ * @param buildArtifactPaths - The paths of the build artifacts to upload
324
+ * @param opts - Optional flags to control temp folder usage and preparation
325
+ */
326
+ async uploadSourcemaps(buildArtifactPaths, opts) {
327
+ const staging = opts?.staging;
328
+ if (!canUploadSourceMaps(options, logger, isDevMode)) {
329
+ await staging?.discard();
330
+ return {
331
+ uploaded: false,
332
+ uploadedSourceMapPaths: []
333
+ };
334
+ }
335
+ const assets = options.sourcemaps?.assets;
336
+ let uploaded = false;
337
+ const preparedSourceMapPaths = [];
338
+ await (0, _sentry_core.startSpan)({
339
+ name: "debug-id-sourcemap-upload",
340
+ scope: sentryScope,
341
+ forceTransaction: true
342
+ }, async () => {
343
+ const shouldPrepare = opts?.prepareArtifacts ?? true;
344
+ let folderToCleanUp = staging?.dir;
345
+ const freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
346
+ try {
347
+ if (!shouldPrepare) {
348
+ let pathsToUpload;
349
+ if (assets) {
350
+ pathsToUpload = Array.isArray(assets) ? assets : [assets];
351
+ logger.debug(`Direct upload mode: passing user-provided assets directly to CLI: ${pathsToUpload.join(", ")}`);
352
+ } else pathsToUpload = buildArtifactPaths;
353
+ if (staging && staging.count > 0) pathsToUpload = [...pathsToUpload, staging.dir];
354
+ if (pathsToUpload.length === 0) {
355
+ logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
356
+ return;
357
+ }
358
+ const emptyDirectories = await (0, _sentry_core.startSpan)({
359
+ name: "upload",
360
+ scope: sentryScope
361
+ }, async () => {
362
+ return new require_cli.SentryCliAdapter(options).uploadSourcemaps(options.release.name ?? "undefined", pathsToUpload.map((directory) => ({
363
+ directory,
364
+ dist: options.release.dist,
365
+ ignore: options.sourcemaps?.ignore
366
+ })));
367
+ });
368
+ warnAboutDirectoriesWithoutSourcemaps(logger, emptyDirectories);
369
+ if (emptyDirectories.length < pathsToUpload.length) {
370
+ uploaded = true;
371
+ logger.info("Successfully uploaded source maps to Sentry");
372
+ }
373
+ } else {
374
+ let globAssets;
375
+ if (assets) globAssets = assets;
376
+ else {
377
+ logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
378
+ globAssets = buildArtifactPaths.map((asset) => (0, glob.escape)(asset.split(path.sep).join("/")));
379
+ }
380
+ const debugIdChunkFilePaths = (await (0, _sentry_core.startSpan)({
381
+ name: "glob",
382
+ scope: sentryScope
383
+ }, async () => require_glob.globFiles(globAssets, { ignore: options.sourcemaps?.ignore }))).filter((debugIdChunkFilePath) => {
384
+ const filePath = require_utils.stripQueryAndHashFromPath(debugIdChunkFilePath);
385
+ return !!filePath.match(/\.(js|mjs|cjs)$/) && !staging?.stagedChunkPaths.has(path.resolve(filePath));
386
+ });
387
+ debugIdChunkFilePaths.sort();
388
+ const stagedCount = staging?.count ?? 0;
389
+ if (debugIdChunkFilePaths.length === 0 && stagedCount === 0) logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
390
+ else {
391
+ const tmpUploadFolder = staging?.dir ?? await (0, _sentry_core.startSpan)({
392
+ name: "mkdtemp",
393
+ scope: sentryScope
394
+ }, () => createTempUploadFolder());
395
+ folderToCleanUp = tmpUploadFolder;
396
+ await (0, _sentry_core.startSpan)({
397
+ name: "prepare-bundles",
398
+ scope: sentryScope
399
+ }, async (prepBundlesSpan) => {
400
+ const preparationTasks = debugIdChunkFilePaths.map((chunkFilePath, chunkIndex) => async () => {
401
+ const prepared = await require_debug_id_upload.prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, stagedCount + chunkIndex, logger, options.sourcemaps?.rewriteSources ?? require_debug_id_upload.defaultRewriteSourcesHook, options.sourcemaps?.resolveSourceMap);
402
+ if (prepared?.sourceMapPath !== void 0) preparedSourceMapPaths.push(prepared.sourceMapPath);
403
+ });
404
+ const workers = [];
405
+ const worker = async () => {
406
+ while (preparationTasks.length > 0) {
407
+ const task = preparationTasks.shift();
408
+ if (task) await task();
409
+ }
410
+ };
411
+ for (let workerIndex = 0; workerIndex < 16; workerIndex++) workers.push(worker());
412
+ await Promise.all(workers);
413
+ const files = await fs.promises.readdir(tmpUploadFolder);
414
+ const stats = files.map((file) => fs.promises.stat(path.join(tmpUploadFolder, file)));
415
+ const uploadSize = (await Promise.all(stats)).reduce((accumulator, { size }) => accumulator + size, 0);
416
+ (0, _sentry_core.setMeasurement)("files", files.length, "none", prepBundlesSpan);
417
+ (0, _sentry_core.setMeasurement)("upload_size", uploadSize, "byte", prepBundlesSpan);
418
+ if (files.length === 0) {
419
+ logger.warn(`No source maps found for any of the ${debugIdChunkFilePaths.length + stagedCount} matched build artifacts, so no source maps were uploaded to Sentry. This usually means source map generation is not enabled in your bundler. Enable it so Sentry can un-minify your stack traces.`);
420
+ return;
421
+ }
422
+ await (0, _sentry_core.startSpan)({
423
+ name: "upload",
424
+ scope: sentryScope
425
+ }, async () => {
426
+ await new require_cli.SentryCliAdapter(options).uploadSourcemaps(options.release.name ?? "undefined", [{
427
+ directory: tmpUploadFolder,
428
+ dist: options.release.dist
429
+ }]);
430
+ });
431
+ uploaded = true;
432
+ logger.info("Successfully uploaded source maps to Sentry");
433
+ });
434
+ }
435
+ }
436
+ } catch (e) {
437
+ if (staging && folderToCleanUp) {
438
+ await staging.keep("Source map upload failed.");
439
+ folderToCleanUp = void 0;
440
+ }
441
+ sentryScope.captureException("Error in \"debugIdUploadPlugin\" writeBundle hook");
442
+ handleRecoverableError(e, false);
443
+ } finally {
444
+ if (folderToCleanUp && !process.env?.["SENTRY_TEST_OVERRIDE_TEMP_DIR"]) {
445
+ logger.debug("Cleaning up temporary files...");
446
+ try {
447
+ await (0, _sentry_core.startSpan)({
448
+ name: "cleanup",
449
+ scope: sentryScope
450
+ }, async () => {
451
+ if (folderToCleanUp) {
452
+ await fs.promises.rm(folderToCleanUp, {
453
+ recursive: true,
454
+ force: true
455
+ });
456
+ logger.debug(`Temporary folder deleted: ${folderToCleanUp}`);
457
+ }
458
+ });
459
+ } catch (e) {
460
+ logger.debug("Failed to clean up temporary folder:", e);
461
+ }
462
+ }
463
+ logger.debug("Freeing upload dependencies...");
464
+ freeUploadDependencyOnBuildArtifacts();
465
+ logger.debug("Flushing telemetry data...");
466
+ await require_telemetry.safeFlushTelemetry(sentryClient);
467
+ logger.debug("Telemetry flushed. Plugin upload process complete.");
468
+ }
469
+ });
470
+ return {
471
+ uploaded,
472
+ uploadedSourceMapPaths: uploaded ? preparedSourceMapPaths.sort() : []
473
+ };
474
+ },
475
+ async createUploadStaging() {
476
+ const dir = await createTempUploadFolder();
477
+ const rewriteSourcesHook = options.sourcemaps?.rewriteSources ?? require_debug_id_upload.defaultRewriteSourcesHook;
478
+ let count = 0;
479
+ let discarded = false;
480
+ const stagedChunkPaths = /* @__PURE__ */ new Set();
481
+ const discard = async () => {
482
+ if (discarded) return;
483
+ discarded = true;
484
+ if (process.env["SENTRY_TEST_OVERRIDE_TEMP_DIR"]) return;
485
+ try {
486
+ await fs.promises.rm(dir, {
487
+ recursive: true,
488
+ force: true
489
+ });
490
+ } catch (e) {
491
+ logger.debug(`Failed to remove staging folder ${dir}:`, e);
492
+ }
493
+ };
494
+ return {
495
+ dir,
496
+ get count() {
497
+ return count;
498
+ },
499
+ stagedChunkPaths,
500
+ async stage(input) {
501
+ const chunkPath = path.resolve(input.chunkPath);
502
+ const chunkName = path.basename(chunkPath);
503
+ if (!shouldUpload(chunkPath)) {
504
+ logger.debug(`Not staging ${chunkName} for upload: excluded by \`sourcemaps.assets\` or \`sourcemaps.ignore\`.`);
505
+ return "excluded";
506
+ }
507
+ const result = require_debug_id_upload.prepareArtifactForUpload({
508
+ code: input.code,
509
+ mapSource: input.mapSource,
510
+ mapDir: input.mapDir,
511
+ rewriteSourcesHook
512
+ });
513
+ if (!result.ok) {
514
+ logger.debug(`Not staging ${chunkName} for upload: ${result.reason}`);
515
+ return "skipped";
516
+ }
517
+ const index = count++;
518
+ try {
519
+ await require_debug_id_upload.writePreparedArtifact(dir, `${result.artifact.debugId}-${index}`, result.artifact);
520
+ stagedChunkPaths.add(chunkPath);
521
+ return "staged";
522
+ } catch (e) {
523
+ sentryScope.captureException("Error staging build artifact for upload");
524
+ handleRecoverableError(e, true);
525
+ return "failed";
526
+ }
527
+ },
528
+ discard,
529
+ async keep(reason) {
530
+ if (count === 0) {
531
+ await discard();
532
+ return;
533
+ }
534
+ if (discarded) return;
535
+ discarded = true;
536
+ logger.error(`${reason} The source maps were kept in ${dir}. Upload them with \`sentry sourcemap upload ${dir}\`.`);
537
+ }
538
+ };
539
+ },
540
+ sourceMaps: {
541
+ uploadPossible: sourceMapUploadPossible,
542
+ decide(kind, { log = true, environment } = {}) {
543
+ const decision = isDevMode ? {
544
+ enableHidden: false,
545
+ deleteAfterUpload: false
546
+ } : require_sourcemap_settings.decideSourceMapHandling(kind, options, sourceMapUploadPossible, environment);
547
+ if (log) logDecision(decision);
548
+ return decision;
549
+ },
550
+ logDecision,
551
+ shouldUpload,
552
+ async deleteFromOutput(sourceMapPaths) {
553
+ try {
554
+ await Promise.all(sourceMapPaths.map(async (sourceMapPath) => {
555
+ try {
556
+ await fs.promises.rm(sourceMapPath, { force: true });
557
+ } catch (e) {
558
+ logger.error(`Could not delete source map ${sourceMapPath} from the build output.`);
559
+ throw e;
560
+ }
561
+ }));
562
+ } catch (e) {
563
+ sentryScope.captureException("Error deleting source maps after upload");
564
+ await require_telemetry.safeFlushTelemetry(sentryClient);
565
+ handleRecoverableError(e, true);
566
+ }
567
+ }
568
+ },
569
+ /**
570
+ * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.
571
+ */
572
+ async deleteArtifacts() {
573
+ try {
574
+ const filesToDelete = await options.sourcemaps?.filesToDeleteAfterUpload;
575
+ if (filesToDelete !== void 0) {
576
+ const filePathsToDelete = await require_glob.globFiles(filesToDelete);
577
+ logger.debug("Waiting for dependencies on generated files to be freed before deleting...");
578
+ await waitUntilBuildArtifactDependenciesAreFreed();
579
+ filePathsToDelete.forEach((filePathToDelete) => {
580
+ logger.debug(`Deleting asset after upload: ${filePathToDelete}`);
581
+ });
582
+ await Promise.all(filePathsToDelete.map((filePathToDelete) => fs.promises.rm(filePathToDelete, { force: true }).catch((e) => {
583
+ logger.debug(`An error occurred while attempting to delete asset: ${filePathToDelete}`, e);
584
+ })));
585
+ }
586
+ } catch (e) {
587
+ sentryScope.captureException("Error in \"sentry-file-deletion-plugin\" buildEnd hook");
588
+ await require_telemetry.safeFlushTelemetry(sentryClient);
589
+ handleRecoverableError(e, true);
590
+ }
591
+ },
592
+ createDependencyOnBuildArtifacts
593
+ };
636
594
  }
637
595
  async function createTempUploadFolder() {
638
- return process.env["SENTRY_TEST_OVERRIDE_TEMP_DIR"] || await fs__namespace.promises.mkdtemp(path__namespace.join(os__namespace.tmpdir(), "sentry-bundler-plugin-upload-"));
596
+ return process.env["SENTRY_TEST_OVERRIDE_TEMP_DIR"] || await fs.promises.mkdtemp(path.join(os.tmpdir(), "sentry-bundler-plugin-upload-"));
639
597
  }
640
598
  function getSourceMapUploadBlocker(options, isDevMode) {
641
- if (options.sourcemaps?.disable) {
642
- return "disabled";
643
- }
644
- if (Array.isArray(options.sourcemaps?.assets) && options.sourcemaps.assets.length === 0) {
645
- return "no-assets";
646
- }
647
- if (isDevMode) {
648
- return "dev-mode";
649
- }
650
- if (!options.authToken) {
651
- return "no-auth-token";
652
- }
653
- if (!options.org && !options.authToken.startsWith("sntrys_")) {
654
- return "no-org";
655
- }
656
- if (!utils.getProjects(options.project)?.[0]) {
657
- return "no-project";
658
- }
659
- return void 0;
599
+ if (options.sourcemaps?.disable) return "disabled";
600
+ if (Array.isArray(options.sourcemaps?.assets) && options.sourcemaps.assets.length === 0) return "no-assets";
601
+ if (isDevMode) return "dev-mode";
602
+ if (!options.authToken) return "no-auth-token";
603
+ if (!options.org && !options.authToken.startsWith("sntrys_")) return "no-org";
604
+ if (!require_utils.getProjects(options.project)?.[0]) return "no-project";
660
605
  }
661
606
  function canUploadSourceMaps(options, logger, isDevMode) {
662
- switch (getSourceMapUploadBlocker(options, isDevMode)) {
663
- case "disabled":
664
- logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
665
- return false;
666
- case "no-assets":
667
- logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
668
- return false;
669
- case "dev-mode":
670
- logger.debug("Running in development mode. Will not upload sourcemaps.");
671
- return false;
672
- case "no-auth-token":
673
- logger.warn(
674
- `No auth token provided. Will not upload source maps. Please set the \`authToken\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${utils.getTurborepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN")}`
675
- );
676
- return false;
677
- case "no-org":
678
- logger.warn(
679
- `No org provided. Will not upload source maps. Please set the \`org\` option to your Sentry organization slug.${utils.getTurborepoEnvPassthroughWarning("SENTRY_ORG")}`
680
- );
681
- return false;
682
- case "no-project":
683
- logger.warn(
684
- `No project provided. Will not upload source maps. Please set the \`project\` option to your Sentry project slug.${utils.getTurborepoEnvPassthroughWarning("SENTRY_PROJECT")}`
685
- );
686
- return false;
687
- default:
688
- return true;
689
- }
607
+ switch (getSourceMapUploadBlocker(options, isDevMode)) {
608
+ case "disabled":
609
+ logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
610
+ return false;
611
+ case "no-assets":
612
+ logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
613
+ return false;
614
+ case "dev-mode":
615
+ logger.debug("Running in development mode. Will not upload sourcemaps.");
616
+ return false;
617
+ case "no-auth-token":
618
+ logger.warn(`No auth token provided. Will not upload source maps. Please set the \`authToken\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${require_utils.getTurborepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN")}`);
619
+ return false;
620
+ case "no-org":
621
+ logger.warn(`No org provided. Will not upload source maps. Please set the \`org\` option to your Sentry organization slug.${require_utils.getTurborepoEnvPassthroughWarning("SENTRY_ORG")}`);
622
+ return false;
623
+ case "no-project":
624
+ logger.warn(`No project provided. Will not upload source maps. Please set the \`project\` option to your Sentry project slug.${require_utils.getTurborepoEnvPassthroughWarning("SENTRY_PROJECT")}`);
625
+ return false;
626
+ default: return true;
627
+ }
628
+ }
629
+ function warnAboutDirectoriesWithoutSourcemaps(logger, directories) {
630
+ if (directories.length === 0) return;
631
+ const list = directories.map((directory) => ` - ${directory}`).join("\n");
632
+ logger.warn(`No source maps found in the following directories, so nothing was uploaded from them:\n${list}\nThis usually means source map generation is not enabled for these build outputs. Enable it so Sentry can un-minify stack traces from these files.`);
690
633
  }
691
-
692
634
  exports.createSentryBuildPluginManager = createSentryBuildPluginManager;
693
- //# sourceMappingURL=build-plugin-manager.js.map
635
+
636
+ //# sourceMappingURL=build-plugin-manager.js.map