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