@sentry/esbuild-plugin 2.0.0 → 2.2.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.
@@ -1,20 +1,364 @@
1
1
  import { sentryUnpluginFactory, getDebugIdSnippet } from '@sentry/bundler-plugin-core';
2
2
  export { sentryCliBinaryExists } from '@sentry/bundler-plugin-core';
3
+ import * as path from 'path';
3
4
  import { v4 } from 'uuid';
4
5
 
6
+ function _regeneratorRuntime() {
7
+ _regeneratorRuntime = function () {
8
+ return exports;
9
+ };
10
+ var exports = {},
11
+ Op = Object.prototype,
12
+ hasOwn = Op.hasOwnProperty,
13
+ defineProperty = Object.defineProperty || function (obj, key, desc) {
14
+ obj[key] = desc.value;
15
+ },
16
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
17
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
18
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
19
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
20
+ function define(obj, key, value) {
21
+ return Object.defineProperty(obj, key, {
22
+ value: value,
23
+ enumerable: !0,
24
+ configurable: !0,
25
+ writable: !0
26
+ }), obj[key];
27
+ }
28
+ try {
29
+ define({}, "");
30
+ } catch (err) {
31
+ define = function (obj, key, value) {
32
+ return obj[key] = value;
33
+ };
34
+ }
35
+ function wrap(innerFn, outerFn, self, tryLocsList) {
36
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
37
+ generator = Object.create(protoGenerator.prototype),
38
+ context = new Context(tryLocsList || []);
39
+ return defineProperty(generator, "_invoke", {
40
+ value: makeInvokeMethod(innerFn, self, context)
41
+ }), generator;
42
+ }
43
+ function tryCatch(fn, obj, arg) {
44
+ try {
45
+ return {
46
+ type: "normal",
47
+ arg: fn.call(obj, arg)
48
+ };
49
+ } catch (err) {
50
+ return {
51
+ type: "throw",
52
+ arg: err
53
+ };
54
+ }
55
+ }
56
+ exports.wrap = wrap;
57
+ var ContinueSentinel = {};
58
+ function Generator() {}
59
+ function GeneratorFunction() {}
60
+ function GeneratorFunctionPrototype() {}
61
+ var IteratorPrototype = {};
62
+ define(IteratorPrototype, iteratorSymbol, function () {
63
+ return this;
64
+ });
65
+ var getProto = Object.getPrototypeOf,
66
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
67
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
68
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
69
+ function defineIteratorMethods(prototype) {
70
+ ["next", "throw", "return"].forEach(function (method) {
71
+ define(prototype, method, function (arg) {
72
+ return this._invoke(method, arg);
73
+ });
74
+ });
75
+ }
76
+ function AsyncIterator(generator, PromiseImpl) {
77
+ function invoke(method, arg, resolve, reject) {
78
+ var record = tryCatch(generator[method], generator, arg);
79
+ if ("throw" !== record.type) {
80
+ var result = record.arg,
81
+ value = result.value;
82
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
83
+ invoke("next", value, resolve, reject);
84
+ }, function (err) {
85
+ invoke("throw", err, resolve, reject);
86
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
87
+ result.value = unwrapped, resolve(result);
88
+ }, function (error) {
89
+ return invoke("throw", error, resolve, reject);
90
+ });
91
+ }
92
+ reject(record.arg);
93
+ }
94
+ var previousPromise;
95
+ defineProperty(this, "_invoke", {
96
+ value: function (method, arg) {
97
+ function callInvokeWithMethodAndArg() {
98
+ return new PromiseImpl(function (resolve, reject) {
99
+ invoke(method, arg, resolve, reject);
100
+ });
101
+ }
102
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
103
+ }
104
+ });
105
+ }
106
+ function makeInvokeMethod(innerFn, self, context) {
107
+ var state = "suspendedStart";
108
+ return function (method, arg) {
109
+ if ("executing" === state) throw new Error("Generator is already running");
110
+ if ("completed" === state) {
111
+ if ("throw" === method) throw arg;
112
+ return doneResult();
113
+ }
114
+ for (context.method = method, context.arg = arg;;) {
115
+ var delegate = context.delegate;
116
+ if (delegate) {
117
+ var delegateResult = maybeInvokeDelegate(delegate, context);
118
+ if (delegateResult) {
119
+ if (delegateResult === ContinueSentinel) continue;
120
+ return delegateResult;
121
+ }
122
+ }
123
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
124
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
125
+ context.dispatchException(context.arg);
126
+ } else "return" === context.method && context.abrupt("return", context.arg);
127
+ state = "executing";
128
+ var record = tryCatch(innerFn, self, context);
129
+ if ("normal" === record.type) {
130
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
131
+ return {
132
+ value: record.arg,
133
+ done: context.done
134
+ };
135
+ }
136
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
137
+ }
138
+ };
139
+ }
140
+ function maybeInvokeDelegate(delegate, context) {
141
+ var methodName = context.method,
142
+ method = delegate.iterator[methodName];
143
+ 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;
144
+ var record = tryCatch(method, delegate.iterator, context.arg);
145
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
146
+ var info = record.arg;
147
+ 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);
148
+ }
149
+ function pushTryEntry(locs) {
150
+ var entry = {
151
+ tryLoc: locs[0]
152
+ };
153
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
154
+ }
155
+ function resetTryEntry(entry) {
156
+ var record = entry.completion || {};
157
+ record.type = "normal", delete record.arg, entry.completion = record;
158
+ }
159
+ function Context(tryLocsList) {
160
+ this.tryEntries = [{
161
+ tryLoc: "root"
162
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
163
+ }
164
+ function values(iterable) {
165
+ if (iterable) {
166
+ var iteratorMethod = iterable[iteratorSymbol];
167
+ if (iteratorMethod) return iteratorMethod.call(iterable);
168
+ if ("function" == typeof iterable.next) return iterable;
169
+ if (!isNaN(iterable.length)) {
170
+ var i = -1,
171
+ next = function next() {
172
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
173
+ return next.value = undefined, next.done = !0, next;
174
+ };
175
+ return next.next = next;
176
+ }
177
+ }
178
+ return {
179
+ next: doneResult
180
+ };
181
+ }
182
+ function doneResult() {
183
+ return {
184
+ value: undefined,
185
+ done: !0
186
+ };
187
+ }
188
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
189
+ value: GeneratorFunctionPrototype,
190
+ configurable: !0
191
+ }), defineProperty(GeneratorFunctionPrototype, "constructor", {
192
+ value: GeneratorFunction,
193
+ configurable: !0
194
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
195
+ var ctor = "function" == typeof genFun && genFun.constructor;
196
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
197
+ }, exports.mark = function (genFun) {
198
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
199
+ }, exports.awrap = function (arg) {
200
+ return {
201
+ __await: arg
202
+ };
203
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
204
+ return this;
205
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
206
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
207
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
208
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
209
+ return result.done ? result.value : iter.next();
210
+ });
211
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
212
+ return this;
213
+ }), define(Gp, "toString", function () {
214
+ return "[object Generator]";
215
+ }), exports.keys = function (val) {
216
+ var object = Object(val),
217
+ keys = [];
218
+ for (var key in object) keys.push(key);
219
+ return keys.reverse(), function next() {
220
+ for (; keys.length;) {
221
+ var key = keys.pop();
222
+ if (key in object) return next.value = key, next.done = !1, next;
223
+ }
224
+ return next.done = !0, next;
225
+ };
226
+ }, exports.values = values, Context.prototype = {
227
+ constructor: Context,
228
+ reset: function (skipTempReset) {
229
+ 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);
230
+ },
231
+ stop: function () {
232
+ this.done = !0;
233
+ var rootRecord = this.tryEntries[0].completion;
234
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
235
+ return this.rval;
236
+ },
237
+ dispatchException: function (exception) {
238
+ if (this.done) throw exception;
239
+ var context = this;
240
+ function handle(loc, caught) {
241
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
242
+ }
243
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
244
+ var entry = this.tryEntries[i],
245
+ record = entry.completion;
246
+ if ("root" === entry.tryLoc) return handle("end");
247
+ if (entry.tryLoc <= this.prev) {
248
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
249
+ hasFinally = hasOwn.call(entry, "finallyLoc");
250
+ if (hasCatch && hasFinally) {
251
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
252
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
253
+ } else if (hasCatch) {
254
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
255
+ } else {
256
+ if (!hasFinally) throw new Error("try statement without catch or finally");
257
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
258
+ }
259
+ }
260
+ }
261
+ },
262
+ abrupt: function (type, arg) {
263
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
264
+ var entry = this.tryEntries[i];
265
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
266
+ var finallyEntry = entry;
267
+ break;
268
+ }
269
+ }
270
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
271
+ var record = finallyEntry ? finallyEntry.completion : {};
272
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
273
+ },
274
+ complete: function (record, afterLoc) {
275
+ if ("throw" === record.type) throw record.arg;
276
+ 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;
277
+ },
278
+ finish: function (finallyLoc) {
279
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
280
+ var entry = this.tryEntries[i];
281
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
282
+ }
283
+ },
284
+ catch: function (tryLoc) {
285
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
286
+ var entry = this.tryEntries[i];
287
+ if (entry.tryLoc === tryLoc) {
288
+ var record = entry.completion;
289
+ if ("throw" === record.type) {
290
+ var thrown = record.arg;
291
+ resetTryEntry(entry);
292
+ }
293
+ return thrown;
294
+ }
295
+ }
296
+ throw new Error("illegal catch attempt");
297
+ },
298
+ delegateYield: function (iterable, resultName, nextLoc) {
299
+ return this.delegate = {
300
+ iterator: values(iterable),
301
+ resultName: resultName,
302
+ nextLoc: nextLoc
303
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
304
+ }
305
+ }, exports;
306
+ }
307
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
308
+ try {
309
+ var info = gen[key](arg);
310
+ var value = info.value;
311
+ } catch (error) {
312
+ reject(error);
313
+ return;
314
+ }
315
+ if (info.done) {
316
+ resolve(value);
317
+ } else {
318
+ Promise.resolve(value).then(_next, _throw);
319
+ }
320
+ }
321
+ function _asyncToGenerator(fn) {
322
+ return function () {
323
+ var self = this,
324
+ args = arguments;
325
+ return new Promise(function (resolve, reject) {
326
+ var gen = fn.apply(self, args);
327
+ function _next(value) {
328
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
329
+ }
330
+ function _throw(err) {
331
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
332
+ }
333
+ _next(undefined);
334
+ });
335
+ };
336
+ }
337
+
5
338
  function esbuildReleaseInjectionPlugin(injectionCode) {
6
339
  var pluginName = "sentry-esbuild-release-injection-plugin";
7
- var virtualReleaseInjectionFilePath = "_sentry-release-injection-file";
340
+ var virtualReleaseInjectionFilePath = path.resolve("_sentry-release-injection-stub"); // needs to be an absolute path for older eslint versions
341
+
8
342
  return {
9
343
  name: pluginName,
10
344
  esbuild: {
11
345
  setup: function setup(_ref) {
12
346
  var initialOptions = _ref.initialOptions,
13
- onLoad = _ref.onLoad;
347
+ onLoad = _ref.onLoad,
348
+ onResolve = _ref.onResolve;
14
349
  initialOptions.inject = initialOptions.inject || [];
15
350
  initialOptions.inject.push(virtualReleaseInjectionFilePath);
351
+ onResolve({
352
+ filter: /_sentry-release-injection-stub/
353
+ }, function (args) {
354
+ return {
355
+ path: args.path,
356
+ sideEffects: true,
357
+ pluginName: pluginName
358
+ };
359
+ });
16
360
  onLoad({
17
- filter: /_sentry-release-injection-file$/
361
+ filter: /_sentry-release-injection-stub/
18
362
  }, function () {
19
363
  return {
20
364
  loader: "js",
@@ -26,38 +370,81 @@ function esbuildReleaseInjectionPlugin(injectionCode) {
26
370
  }
27
371
  };
28
372
  }
29
-
30
373
  function esbuildDebugIdInjectionPlugin() {
31
374
  var pluginName = "sentry-esbuild-debug-id-injection-plugin";
32
- var virtualReleaseInjectionFilePath = "_sentry-debug-id-injection-file";
33
- var debugIdSnippet = getDebugIdSnippet(v4());
375
+ var virtualReleaseInjectionFilePath = path.resolve("_sentry-debug-id-injection-stub"); // needs to be an absolute path for older eslint versions
376
+
34
377
  return {
35
378
  name: pluginName,
36
379
  esbuild: {
37
380
  setup: function setup(_ref2) {
38
381
  var initialOptions = _ref2.initialOptions,
39
- onLoad = _ref2.onLoad;
382
+ onLoad = _ref2.onLoad,
383
+ onResolve = _ref2.onResolve;
40
384
  initialOptions.inject = initialOptions.inject || [];
41
385
  initialOptions.inject.push(virtualReleaseInjectionFilePath);
386
+ onResolve({
387
+ filter: /_sentry-debug-id-injection-stub/
388
+ }, function (args) {
389
+ return {
390
+ path: args.path,
391
+ sideEffects: true,
392
+ pluginName: pluginName,
393
+ suffix: "?sentry-module-id=" + v4() // create different module, each time this is resolved
394
+ };
395
+ });
396
+
42
397
  onLoad({
43
- filter: /_sentry-debug-id-injection-file$/
398
+ filter: /_sentry-debug-id-injection-stub/
44
399
  }, function () {
45
400
  return {
46
401
  loader: "js",
47
402
  pluginName: pluginName,
48
- contents: debugIdSnippet
403
+ contents: getDebugIdSnippet(v4())
49
404
  };
50
405
  });
51
406
  }
52
407
  }
53
408
  };
54
409
  }
55
-
410
+ function esbuildDebugIdUploadPlugin(upload) {
411
+ return {
412
+ name: "sentry-esbuild-debug-id-upload-plugin",
413
+ esbuild: {
414
+ setup: function setup(_ref3) {
415
+ var initialOptions = _ref3.initialOptions,
416
+ onEnd = _ref3.onEnd;
417
+ initialOptions.metafile = true;
418
+ onEnd( /*#__PURE__*/function () {
419
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(result) {
420
+ var buildArtifacts;
421
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
422
+ while (1) switch (_context.prev = _context.next) {
423
+ case 0:
424
+ buildArtifacts = result.metafile ? Object.keys(result.metafile.outputs) : [];
425
+ _context.next = 3;
426
+ return upload(buildArtifacts);
427
+ case 3:
428
+ case "end":
429
+ return _context.stop();
430
+ }
431
+ }, _callee);
432
+ }));
433
+ return function (_x) {
434
+ return _ref4.apply(this, arguments);
435
+ };
436
+ }());
437
+ }
438
+ }
439
+ };
440
+ }
56
441
  var sentryUnplugin = sentryUnpluginFactory({
57
442
  releaseInjectionPlugin: esbuildReleaseInjectionPlugin,
58
- debugIdInjectionPlugin: esbuildDebugIdInjectionPlugin
59
- }); // eslint-disable-next-line @typescript-eslint/no-explicit-any
443
+ debugIdInjectionPlugin: esbuildDebugIdInjectionPlugin,
444
+ debugIdUploadPlugin: esbuildDebugIdUploadPlugin
445
+ });
60
446
 
447
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
448
  var sentryEsbuildPlugin = sentryUnplugin.esbuild;
62
449
 
63
450
  export { sentryEsbuildPlugin };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","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","sentryUnplugin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F,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,qBAAqB,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.mjs","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,CAAA;EAC5D,IAAMC,+BAA+B,GAAGC,IAAI,CAACC,OAAO,CAAC,gCAAgC,CAAC,CAAC;;EAEvF,OAAO;AACLC,IAAAA,IAAI,EAAEJ,UAAU;AAEhBK,IAAAA,OAAO,EAAE;MACPC,KAAK,EAAA,SAAAA,KAAAC,CAAAA,IAAA,EAAwC;AAAA,QAAA,IAArCC,cAAc,GAAAD,IAAA,CAAdC,cAAc;UAAEC,MAAM,GAAAF,IAAA,CAANE,MAAM;UAAEC,SAAS,GAAAH,IAAA,CAATG,SAAS,CAAA;AACvCF,QAAAA,cAAc,CAACG,MAAM,GAAGH,cAAc,CAACG,MAAM,IAAI,EAAE,CAAA;AACnDH,QAAAA,cAAc,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AAI,CAACR,MAAM,CAACN,QAAQ,CAACe,OAAO,CAAC,GAAG,EAAE,CAAA;AAAAL,kBAAAA,QAAA,CAAAE,IAAA,GAAA,CAAA,CAAA;kBAAA,OAC5Ef,MAAM,CAACU,cAAc,CAAC,CAAA;AAAA,gBAAA,KAAA,CAAA,CAAA;AAAA,gBAAA,KAAA,KAAA;kBAAA,OAAAG,QAAA,CAAAM,IAAA,EAAA,CAAA;AAAA,eAAA;AAAA,aAAA,EAAAX,OAAA,CAAA,CAAA;WAC7B,CAAA,CAAA,CAAA;AAAA,UAAA,OAAA,UAAAY,EAAA,EAAA;AAAA,YAAA,OAAAhB,KAAA,CAAAiB,KAAA,CAAA,IAAA,EAAAC,SAAA,CAAA,CAAA;AAAA,WAAA,CAAA;SAAC,EAAA,CAAA,CAAA;AACJ,OAAA;AACF,KAAA;GACD,CAAA;AACH,CAAA;AAEA,IAAMC,cAAc,GAAGC,qBAAqB,CAAC;AAC3CC,EAAAA,sBAAsB,EAAEnD,6BAA6B;AACrDoD,EAAAA,sBAAsB,EAAEhC,6BAA6B;AACrDiC,EAAAA,mBAAmB,EAAE5B,0BAAAA;AACvB,CAAC,CAAC,CAAA;;AAEF;AACa6B,IAAAA,mBAA8C,GAAGL,cAAc,CAAC1C;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/esbuild-plugin",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Official Sentry esbuild plugin",
5
5
  "repository": "git@github.com:getsentry/sentry-javascript-bundler-plugins.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/esbuild-plugin",
@@ -48,7 +48,7 @@
48
48
  "prepack": "ts-node ./src/prepack.ts"
49
49
  },
50
50
  "dependencies": {
51
- "@sentry/bundler-plugin-core": "2.0.0",
51
+ "@sentry/bundler-plugin-core": "2.2.0",
52
52
  "unplugin": "1.0.1",
53
53
  "uuid": "^9.0.0"
54
54
  },
@@ -58,8 +58,8 @@
58
58
  "@babel/preset-typescript": "7.17.12",
59
59
  "@rollup/plugin-babel": "5.3.1",
60
60
  "@rollup/plugin-node-resolve": "13.3.0",
61
- "@sentry-internal/eslint-config": "2.0.0",
62
- "@sentry-internal/sentry-bundler-plugin-tsconfig": "2.0.0",
61
+ "@sentry-internal/eslint-config": "2.2.0",
62
+ "@sentry-internal/sentry-bundler-plugin-tsconfig": "2.2.0",
63
63
  "@swc/core": "^1.2.205",
64
64
  "@swc/jest": "^0.2.21",
65
65
  "@types/jest": "^28.1.3",