@sentry/esbuild-plugin 2.0.0 → 2.1.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/dist/cjs/index.js CHANGED
@@ -3,21 +3,385 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var bundlerPluginCore = require('@sentry/bundler-plugin-core');
6
+ var path = require('path');
6
7
  var uuid = require('uuid');
7
8
 
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n["default"] = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var path__namespace = /*#__PURE__*/_interopNamespace(path);
28
+
29
+ function _regeneratorRuntime() {
30
+ _regeneratorRuntime = function () {
31
+ return exports;
32
+ };
33
+ var exports = {},
34
+ Op = Object.prototype,
35
+ hasOwn = Op.hasOwnProperty,
36
+ defineProperty = Object.defineProperty || function (obj, key, desc) {
37
+ obj[key] = desc.value;
38
+ },
39
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
40
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
41
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
42
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
43
+ function define(obj, key, value) {
44
+ return Object.defineProperty(obj, key, {
45
+ value: value,
46
+ enumerable: !0,
47
+ configurable: !0,
48
+ writable: !0
49
+ }), obj[key];
50
+ }
51
+ try {
52
+ define({}, "");
53
+ } catch (err) {
54
+ define = function (obj, key, value) {
55
+ return obj[key] = value;
56
+ };
57
+ }
58
+ function wrap(innerFn, outerFn, self, tryLocsList) {
59
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
60
+ generator = Object.create(protoGenerator.prototype),
61
+ context = new Context(tryLocsList || []);
62
+ return defineProperty(generator, "_invoke", {
63
+ value: makeInvokeMethod(innerFn, self, context)
64
+ }), generator;
65
+ }
66
+ function tryCatch(fn, obj, arg) {
67
+ try {
68
+ return {
69
+ type: "normal",
70
+ arg: fn.call(obj, arg)
71
+ };
72
+ } catch (err) {
73
+ return {
74
+ type: "throw",
75
+ arg: err
76
+ };
77
+ }
78
+ }
79
+ exports.wrap = wrap;
80
+ var ContinueSentinel = {};
81
+ function Generator() {}
82
+ function GeneratorFunction() {}
83
+ function GeneratorFunctionPrototype() {}
84
+ var IteratorPrototype = {};
85
+ define(IteratorPrototype, iteratorSymbol, function () {
86
+ return this;
87
+ });
88
+ var getProto = Object.getPrototypeOf,
89
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
90
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
91
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
92
+ function defineIteratorMethods(prototype) {
93
+ ["next", "throw", "return"].forEach(function (method) {
94
+ define(prototype, method, function (arg) {
95
+ return this._invoke(method, arg);
96
+ });
97
+ });
98
+ }
99
+ function AsyncIterator(generator, PromiseImpl) {
100
+ function invoke(method, arg, resolve, reject) {
101
+ var record = tryCatch(generator[method], generator, arg);
102
+ if ("throw" !== record.type) {
103
+ var result = record.arg,
104
+ value = result.value;
105
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
106
+ invoke("next", value, resolve, reject);
107
+ }, function (err) {
108
+ invoke("throw", err, resolve, reject);
109
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
110
+ result.value = unwrapped, resolve(result);
111
+ }, function (error) {
112
+ return invoke("throw", error, resolve, reject);
113
+ });
114
+ }
115
+ reject(record.arg);
116
+ }
117
+ var previousPromise;
118
+ defineProperty(this, "_invoke", {
119
+ value: function (method, arg) {
120
+ function callInvokeWithMethodAndArg() {
121
+ return new PromiseImpl(function (resolve, reject) {
122
+ invoke(method, arg, resolve, reject);
123
+ });
124
+ }
125
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
126
+ }
127
+ });
128
+ }
129
+ function makeInvokeMethod(innerFn, self, context) {
130
+ var state = "suspendedStart";
131
+ return function (method, arg) {
132
+ if ("executing" === state) throw new Error("Generator is already running");
133
+ if ("completed" === state) {
134
+ if ("throw" === method) throw arg;
135
+ return doneResult();
136
+ }
137
+ for (context.method = method, context.arg = arg;;) {
138
+ var delegate = context.delegate;
139
+ if (delegate) {
140
+ var delegateResult = maybeInvokeDelegate(delegate, context);
141
+ if (delegateResult) {
142
+ if (delegateResult === ContinueSentinel) continue;
143
+ return delegateResult;
144
+ }
145
+ }
146
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
147
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
148
+ context.dispatchException(context.arg);
149
+ } else "return" === context.method && context.abrupt("return", context.arg);
150
+ state = "executing";
151
+ var record = tryCatch(innerFn, self, context);
152
+ if ("normal" === record.type) {
153
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
154
+ return {
155
+ value: record.arg,
156
+ done: context.done
157
+ };
158
+ }
159
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
160
+ }
161
+ };
162
+ }
163
+ function maybeInvokeDelegate(delegate, context) {
164
+ var methodName = context.method,
165
+ method = delegate.iterator[methodName];
166
+ if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
167
+ var record = tryCatch(method, delegate.iterator, context.arg);
168
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
169
+ var info = record.arg;
170
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
171
+ }
172
+ function pushTryEntry(locs) {
173
+ var entry = {
174
+ tryLoc: locs[0]
175
+ };
176
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
177
+ }
178
+ function resetTryEntry(entry) {
179
+ var record = entry.completion || {};
180
+ record.type = "normal", delete record.arg, entry.completion = record;
181
+ }
182
+ function Context(tryLocsList) {
183
+ this.tryEntries = [{
184
+ tryLoc: "root"
185
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
186
+ }
187
+ function values(iterable) {
188
+ if (iterable) {
189
+ var iteratorMethod = iterable[iteratorSymbol];
190
+ if (iteratorMethod) return iteratorMethod.call(iterable);
191
+ if ("function" == typeof iterable.next) return iterable;
192
+ if (!isNaN(iterable.length)) {
193
+ var i = -1,
194
+ next = function next() {
195
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
196
+ return next.value = undefined, next.done = !0, next;
197
+ };
198
+ return next.next = next;
199
+ }
200
+ }
201
+ return {
202
+ next: doneResult
203
+ };
204
+ }
205
+ function doneResult() {
206
+ return {
207
+ value: undefined,
208
+ done: !0
209
+ };
210
+ }
211
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
212
+ value: GeneratorFunctionPrototype,
213
+ configurable: !0
214
+ }), defineProperty(GeneratorFunctionPrototype, "constructor", {
215
+ value: GeneratorFunction,
216
+ configurable: !0
217
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
218
+ var ctor = "function" == typeof genFun && genFun.constructor;
219
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
220
+ }, exports.mark = function (genFun) {
221
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
222
+ }, exports.awrap = function (arg) {
223
+ return {
224
+ __await: arg
225
+ };
226
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
227
+ return this;
228
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
229
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
230
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
231
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
232
+ return result.done ? result.value : iter.next();
233
+ });
234
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
235
+ return this;
236
+ }), define(Gp, "toString", function () {
237
+ return "[object Generator]";
238
+ }), exports.keys = function (val) {
239
+ var object = Object(val),
240
+ keys = [];
241
+ for (var key in object) keys.push(key);
242
+ return keys.reverse(), function next() {
243
+ for (; keys.length;) {
244
+ var key = keys.pop();
245
+ if (key in object) return next.value = key, next.done = !1, next;
246
+ }
247
+ return next.done = !0, next;
248
+ };
249
+ }, exports.values = values, Context.prototype = {
250
+ constructor: Context,
251
+ reset: function (skipTempReset) {
252
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
253
+ },
254
+ stop: function () {
255
+ this.done = !0;
256
+ var rootRecord = this.tryEntries[0].completion;
257
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
258
+ return this.rval;
259
+ },
260
+ dispatchException: function (exception) {
261
+ if (this.done) throw exception;
262
+ var context = this;
263
+ function handle(loc, caught) {
264
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
265
+ }
266
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
267
+ var entry = this.tryEntries[i],
268
+ record = entry.completion;
269
+ if ("root" === entry.tryLoc) return handle("end");
270
+ if (entry.tryLoc <= this.prev) {
271
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
272
+ hasFinally = hasOwn.call(entry, "finallyLoc");
273
+ if (hasCatch && hasFinally) {
274
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
275
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
276
+ } else if (hasCatch) {
277
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
278
+ } else {
279
+ if (!hasFinally) throw new Error("try statement without catch or finally");
280
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
281
+ }
282
+ }
283
+ }
284
+ },
285
+ abrupt: function (type, arg) {
286
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
287
+ var entry = this.tryEntries[i];
288
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
289
+ var finallyEntry = entry;
290
+ break;
291
+ }
292
+ }
293
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
294
+ var record = finallyEntry ? finallyEntry.completion : {};
295
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
296
+ },
297
+ complete: function (record, afterLoc) {
298
+ if ("throw" === record.type) throw record.arg;
299
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
300
+ },
301
+ finish: function (finallyLoc) {
302
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
303
+ var entry = this.tryEntries[i];
304
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
305
+ }
306
+ },
307
+ catch: function (tryLoc) {
308
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
309
+ var entry = this.tryEntries[i];
310
+ if (entry.tryLoc === tryLoc) {
311
+ var record = entry.completion;
312
+ if ("throw" === record.type) {
313
+ var thrown = record.arg;
314
+ resetTryEntry(entry);
315
+ }
316
+ return thrown;
317
+ }
318
+ }
319
+ throw new Error("illegal catch attempt");
320
+ },
321
+ delegateYield: function (iterable, resultName, nextLoc) {
322
+ return this.delegate = {
323
+ iterator: values(iterable),
324
+ resultName: resultName,
325
+ nextLoc: nextLoc
326
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
327
+ }
328
+ }, exports;
329
+ }
330
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
331
+ try {
332
+ var info = gen[key](arg);
333
+ var value = info.value;
334
+ } catch (error) {
335
+ reject(error);
336
+ return;
337
+ }
338
+ if (info.done) {
339
+ resolve(value);
340
+ } else {
341
+ Promise.resolve(value).then(_next, _throw);
342
+ }
343
+ }
344
+ function _asyncToGenerator(fn) {
345
+ return function () {
346
+ var self = this,
347
+ args = arguments;
348
+ return new Promise(function (resolve, reject) {
349
+ var gen = fn.apply(self, args);
350
+ function _next(value) {
351
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
352
+ }
353
+ function _throw(err) {
354
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
355
+ }
356
+ _next(undefined);
357
+ });
358
+ };
359
+ }
360
+
8
361
  function esbuildReleaseInjectionPlugin(injectionCode) {
9
362
  var pluginName = "sentry-esbuild-release-injection-plugin";
10
- var virtualReleaseInjectionFilePath = "_sentry-release-injection-file";
363
+ var virtualReleaseInjectionFilePath = path__namespace.resolve("_sentry-release-injection-stub"); // needs to be an absolute path for older eslint versions
364
+
11
365
  return {
12
366
  name: pluginName,
13
367
  esbuild: {
14
368
  setup: function setup(_ref) {
15
369
  var initialOptions = _ref.initialOptions,
16
- onLoad = _ref.onLoad;
370
+ onLoad = _ref.onLoad,
371
+ onResolve = _ref.onResolve;
17
372
  initialOptions.inject = initialOptions.inject || [];
18
373
  initialOptions.inject.push(virtualReleaseInjectionFilePath);
374
+ onResolve({
375
+ filter: /_sentry-release-injection-stub/
376
+ }, function (args) {
377
+ return {
378
+ path: args.path,
379
+ sideEffects: true,
380
+ pluginName: pluginName
381
+ };
382
+ });
19
383
  onLoad({
20
- filter: /_sentry-release-injection-file$/
384
+ filter: /_sentry-release-injection-stub/
21
385
  }, function () {
22
386
  return {
23
387
  loader: "js",
@@ -29,38 +393,81 @@ function esbuildReleaseInjectionPlugin(injectionCode) {
29
393
  }
30
394
  };
31
395
  }
32
-
33
396
  function esbuildDebugIdInjectionPlugin() {
34
397
  var pluginName = "sentry-esbuild-debug-id-injection-plugin";
35
- var virtualReleaseInjectionFilePath = "_sentry-debug-id-injection-file";
36
- var debugIdSnippet = bundlerPluginCore.getDebugIdSnippet(uuid.v4());
398
+ var virtualReleaseInjectionFilePath = path__namespace.resolve("_sentry-debug-id-injection-stub"); // needs to be an absolute path for older eslint versions
399
+
37
400
  return {
38
401
  name: pluginName,
39
402
  esbuild: {
40
403
  setup: function setup(_ref2) {
41
404
  var initialOptions = _ref2.initialOptions,
42
- onLoad = _ref2.onLoad;
405
+ onLoad = _ref2.onLoad,
406
+ onResolve = _ref2.onResolve;
43
407
  initialOptions.inject = initialOptions.inject || [];
44
408
  initialOptions.inject.push(virtualReleaseInjectionFilePath);
409
+ onResolve({
410
+ filter: /_sentry-debug-id-injection-stub/
411
+ }, function (args) {
412
+ return {
413
+ path: args.path,
414
+ sideEffects: true,
415
+ pluginName: pluginName,
416
+ suffix: "?sentry-module-id=" + uuid.v4() // create different module, each time this is resolved
417
+ };
418
+ });
419
+
45
420
  onLoad({
46
- filter: /_sentry-debug-id-injection-file$/
421
+ filter: /_sentry-debug-id-injection-stub/
47
422
  }, function () {
48
423
  return {
49
424
  loader: "js",
50
425
  pluginName: pluginName,
51
- contents: debugIdSnippet
426
+ contents: bundlerPluginCore.getDebugIdSnippet(uuid.v4())
52
427
  };
53
428
  });
54
429
  }
55
430
  }
56
431
  };
57
432
  }
58
-
433
+ function esbuildDebugIdUploadPlugin(upload) {
434
+ return {
435
+ name: "sentry-esbuild-debug-id-upload-plugin",
436
+ esbuild: {
437
+ setup: function setup(_ref3) {
438
+ var initialOptions = _ref3.initialOptions,
439
+ onEnd = _ref3.onEnd;
440
+ initialOptions.metafile = true;
441
+ onEnd( /*#__PURE__*/function () {
442
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(result) {
443
+ var buildArtifacts;
444
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
445
+ while (1) switch (_context.prev = _context.next) {
446
+ case 0:
447
+ buildArtifacts = result.metafile ? Object.keys(result.metafile.outputs) : [];
448
+ _context.next = 3;
449
+ return upload(buildArtifacts);
450
+ case 3:
451
+ case "end":
452
+ return _context.stop();
453
+ }
454
+ }, _callee);
455
+ }));
456
+ return function (_x) {
457
+ return _ref4.apply(this, arguments);
458
+ };
459
+ }());
460
+ }
461
+ }
462
+ };
463
+ }
59
464
  var sentryUnplugin = bundlerPluginCore.sentryUnpluginFactory({
60
465
  releaseInjectionPlugin: esbuildReleaseInjectionPlugin,
61
- debugIdInjectionPlugin: esbuildDebugIdInjectionPlugin
62
- }); // eslint-disable-next-line @typescript-eslint/no-explicit-any
466
+ debugIdInjectionPlugin: esbuildDebugIdInjectionPlugin,
467
+ debugIdUploadPlugin: esbuildDebugIdUploadPlugin
468
+ });
63
469
 
470
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
471
  var sentryEsbuildPlugin = sentryUnplugin.esbuild;
65
472
 
66
473
  Object.defineProperty(exports, 'sentryCliBinaryExists', {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { sentryUnpluginFactory, Options, getDebugIdSnippet } from \"@sentry/bundler-plugin-core\";\nimport type { UnpluginOptions } from \"unplugin\";\n\nimport { v4 as uuidv4 } from \"uuid\";\n\nfunction esbuildReleaseInjectionPlugin(injectionCode: string): UnpluginOptions {\n const pluginName = \"sentry-esbuild-release-injection-plugin\";\n const virtualReleaseInjectionFilePath = \"_sentry-release-injection-file\";\n\n return {\n name: pluginName,\n\n esbuild: {\n setup({ initialOptions, onLoad }) {\n initialOptions.inject = initialOptions.inject || [];\n initialOptions.inject.push(virtualReleaseInjectionFilePath);\n\n onLoad(\n {\n filter: /_sentry-release-injection-file$/,\n },\n () => {\n return {\n loader: \"js\",\n pluginName,\n contents: injectionCode,\n };\n }\n );\n },\n },\n };\n}\n\nfunction esbuildDebugIdInjectionPlugin(): UnpluginOptions {\n const pluginName = \"sentry-esbuild-debug-id-injection-plugin\";\n const virtualReleaseInjectionFilePath = \"_sentry-debug-id-injection-file\";\n\n const debugIdSnippet = getDebugIdSnippet(uuidv4());\n\n return {\n name: pluginName,\n\n esbuild: {\n setup({ initialOptions, onLoad }) {\n initialOptions.inject = initialOptions.inject || [];\n initialOptions.inject.push(virtualReleaseInjectionFilePath);\n\n onLoad(\n {\n filter: /_sentry-debug-id-injection-file$/,\n },\n () => {\n return {\n loader: \"js\",\n pluginName,\n contents: debugIdSnippet,\n };\n }\n );\n },\n },\n };\n}\n\nconst sentryUnplugin = sentryUnpluginFactory({\n releaseInjectionPlugin: esbuildReleaseInjectionPlugin,\n debugIdInjectionPlugin: esbuildDebugIdInjectionPlugin,\n});\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryEsbuildPlugin: (options: Options) => any = sentryUnplugin.esbuild;\n\nexport type { Options as SentryEsbuildPluginOptions } from \"@sentry/bundler-plugin-core\";\nexport { sentryCliBinaryExists } from \"@sentry/bundler-plugin-core\";\n"],"names":["esbuildReleaseInjectionPlugin","injectionCode","pluginName","virtualReleaseInjectionFilePath","name","esbuild","setup","initialOptions","onLoad","inject","push","filter","loader","contents","esbuildDebugIdInjectionPlugin","debugIdSnippet","getDebugIdSnippet","uuidv4","sentryUnplugin","sentryUnpluginFactory","releaseInjectionPlugin","debugIdInjectionPlugin","sentryEsbuildPlugin"],"mappings":";;;;;;;AAKA,SAASA,6BAAT,CAAuCC,aAAvC,EAA+E;EAC7E,IAAMC,UAAU,GAAG,yCAAnB,CAAA;EACA,IAAMC,+BAA+B,GAAG,gCAAxC,CAAA;EAEA,OAAO;AACLC,IAAAA,IAAI,EAAEF,UADD;AAGLG,IAAAA,OAAO,EAAE;AACPC,MAAAA,KADO,EAC2B,SAAA,KAAA,CAAA,IAAA,EAAA;QAAA,IAA1BC,cAA0B,QAA1BA,cAA0B;YAAVC,MAAU,QAAVA,MAAU,CAAA;AAChCD,QAAAA,cAAc,CAACE,MAAf,GAAwBF,cAAc,CAACE,MAAf,IAAyB,EAAjD,CAAA;AACAF,QAAAA,cAAc,CAACE,MAAf,CAAsBC,IAAtB,CAA2BP,+BAA3B,CAAA,CAAA;AAEAK,QAAAA,MAAM,CACJ;AACEG,UAAAA,MAAM,EAAE,iCAAA;AADV,SADI,EAIJ,YAAM;UACJ,OAAO;AACLC,YAAAA,MAAM,EAAE,IADH;AAELV,YAAAA,UAAU,EAAVA,UAFK;AAGLW,YAAAA,QAAQ,EAAEZ,aAAAA;WAHZ,CAAA;AAKD,SAVG,CAAN,CAAA;AAYD,OAAA;AAjBM,KAAA;GAHX,CAAA;AAuBD,CAAA;;AAED,SAASa,6BAAT,GAA0D;EACxD,IAAMZ,UAAU,GAAG,0CAAnB,CAAA;EACA,IAAMC,+BAA+B,GAAG,iCAAxC,CAAA;AAEA,EAAA,IAAMY,cAAc,GAAGC,mCAAiB,CAACC,OAAM,EAAP,CAAxC,CAAA;EAEA,OAAO;AACLb,IAAAA,IAAI,EAAEF,UADD;AAGLG,IAAAA,OAAO,EAAE;AACPC,MAAAA,KADO,EAC2B,SAAA,KAAA,CAAA,KAAA,EAAA;QAAA,IAA1BC,cAA0B,SAA1BA,cAA0B;YAAVC,MAAU,SAAVA,MAAU,CAAA;AAChCD,QAAAA,cAAc,CAACE,MAAf,GAAwBF,cAAc,CAACE,MAAf,IAAyB,EAAjD,CAAA;AACAF,QAAAA,cAAc,CAACE,MAAf,CAAsBC,IAAtB,CAA2BP,+BAA3B,CAAA,CAAA;AAEAK,QAAAA,MAAM,CACJ;AACEG,UAAAA,MAAM,EAAE,kCAAA;AADV,SADI,EAIJ,YAAM;UACJ,OAAO;AACLC,YAAAA,MAAM,EAAE,IADH;AAELV,YAAAA,UAAU,EAAVA,UAFK;AAGLW,YAAAA,QAAQ,EAAEE,cAAAA;WAHZ,CAAA;AAKD,SAVG,CAAN,CAAA;AAYD,OAAA;AAjBM,KAAA;GAHX,CAAA;AAuBD,CAAA;;AAED,IAAMG,cAAc,GAAGC,uCAAqB,CAAC;AAC3CC,EAAAA,sBAAsB,EAAEpB,6BADmB;AAE3CqB,EAAAA,sBAAsB,EAAEP,6BAAAA;AAFmB,CAAD,CAA5C;;AAMaQ,IAAAA,mBAA8C,GAAGJ,cAAc,CAACb;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { sentryUnpluginFactory, Options, getDebugIdSnippet } from \"@sentry/bundler-plugin-core\";\nimport type { UnpluginOptions } from \"unplugin\";\nimport * as path from \"path\";\n\nimport { v4 as uuidv4 } from \"uuid\";\n\nfunction esbuildReleaseInjectionPlugin(injectionCode: string): UnpluginOptions {\n const pluginName = \"sentry-esbuild-release-injection-plugin\";\n const virtualReleaseInjectionFilePath = path.resolve(\"_sentry-release-injection-stub\"); // needs to be an absolute path for older eslint versions\n\n return {\n name: pluginName,\n\n esbuild: {\n setup({ initialOptions, onLoad, onResolve }) {\n initialOptions.inject = initialOptions.inject || [];\n initialOptions.inject.push(virtualReleaseInjectionFilePath);\n\n onResolve({ filter: /_sentry-release-injection-stub/ }, (args) => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n };\n });\n\n onLoad({ filter: /_sentry-release-injection-stub/ }, () => {\n return {\n loader: \"js\",\n pluginName,\n contents: injectionCode,\n };\n });\n },\n },\n };\n}\n\nfunction esbuildDebugIdInjectionPlugin(): UnpluginOptions {\n const pluginName = \"sentry-esbuild-debug-id-injection-plugin\";\n const virtualReleaseInjectionFilePath = path.resolve(\"_sentry-debug-id-injection-stub\"); // needs to be an absolute path for older eslint versions\n\n return {\n name: pluginName,\n\n esbuild: {\n setup({ initialOptions, onLoad, onResolve }) {\n initialOptions.inject = initialOptions.inject || [];\n initialOptions.inject.push(virtualReleaseInjectionFilePath);\n\n onResolve({ filter: /_sentry-debug-id-injection-stub/ }, (args) => {\n return {\n path: args.path,\n sideEffects: true,\n pluginName,\n suffix: \"?sentry-module-id=\" + uuidv4(), // create different module, each time this is resolved\n };\n });\n\n onLoad({ filter: /_sentry-debug-id-injection-stub/ }, () => {\n return {\n loader: \"js\",\n pluginName,\n contents: getDebugIdSnippet(uuidv4()),\n };\n });\n },\n },\n };\n}\n\nfunction esbuildDebugIdUploadPlugin(\n upload: (buildArtifacts: string[]) => Promise<void>\n): UnpluginOptions {\n return {\n name: \"sentry-esbuild-debug-id-upload-plugin\",\n esbuild: {\n setup({ initialOptions, onEnd }) {\n initialOptions.metafile = true;\n onEnd(async (result) => {\n const buildArtifacts = result.metafile ? Object.keys(result.metafile.outputs) : [];\n await upload(buildArtifacts);\n });\n },\n },\n };\n}\n\nconst sentryUnplugin = sentryUnpluginFactory({\n releaseInjectionPlugin: esbuildReleaseInjectionPlugin,\n debugIdInjectionPlugin: esbuildDebugIdInjectionPlugin,\n debugIdUploadPlugin: esbuildDebugIdUploadPlugin,\n});\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryEsbuildPlugin: (options: Options) => any = sentryUnplugin.esbuild;\n\nexport type { Options as SentryEsbuildPluginOptions } from \"@sentry/bundler-plugin-core\";\nexport { sentryCliBinaryExists } from \"@sentry/bundler-plugin-core\";\n"],"names":["esbuildReleaseInjectionPlugin","injectionCode","pluginName","virtualReleaseInjectionFilePath","path","resolve","name","esbuild","setup","_ref","initialOptions","onLoad","onResolve","inject","push","filter","args","sideEffects","loader","contents","esbuildDebugIdInjectionPlugin","_ref2","suffix","uuidv4","getDebugIdSnippet","esbuildDebugIdUploadPlugin","upload","_ref3","onEnd","metafile","_ref4","_asyncToGenerator","_regeneratorRuntime","mark","_callee","result","buildArtifacts","wrap","_callee$","_context","prev","next","Object","keys","outputs","stop","_x","apply","arguments","sentryUnplugin","sentryUnpluginFactory","releaseInjectionPlugin","debugIdInjectionPlugin","debugIdUploadPlugin","sentryEsbuildPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAASA,6BAA6BA,CAACC,aAAqB,EAAmB;EAC7E,IAAMC,UAAU,GAAG,yCAAyC,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