@sentry/bundler-plugin-core 0.6.0 → 0.6.1

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
@@ -1122,7 +1122,7 @@ function makeSentryClient(dsn, allowedToSendTelemetryPromise, userProject) {
1122
1122
  // a dashboard.
1123
1123
  // Yes, this is slightly abusing the purpose of this field.
1124
1124
  dist: userProject,
1125
- release: "0.6.0",
1125
+ release: "0.6.1",
1126
1126
  integrations: [],
1127
1127
  tracePropagationTargets: ["sentry.io/api"],
1128
1128
  stackParser: node.defaultStackParser,
@@ -1985,7 +1985,7 @@ function _prepareBundleForDebugIdUpload() {
1985
1985
  switch (_context.prev = _context.next) {
1986
1986
  case 0:
1987
1987
  if (!sourceMapPath) {
1988
- _context.next = 4;
1988
+ _context.next = 3;
1989
1989
  break;
1990
1990
  }
1991
1991
 
@@ -1993,9 +1993,6 @@ function _prepareBundleForDebugIdUpload() {
1993
1993
  return prepareSourceMapForDebugIdUpload(sourceMapPath, path__namespace.join(uploadFolder, "".concat(uniqueUploadName, ".js.map")), debugId, logger);
1994
1994
 
1995
1995
  case 3:
1996
- return _context.abrupt("return", _context.sent);
1997
-
1998
- case 4:
1999
1996
  case "end":
2000
1997
  return _context.stop();
2001
1998
  }
@@ -2007,9 +2004,14 @@ function _prepareBundleForDebugIdUpload() {
2007
2004
  return _ref.apply(this, arguments);
2008
2005
  };
2009
2006
  }());
2010
- return _context2.abrupt("return", Promise.all([writeSourceFilePromise, writeSourceMapFilePromise]));
2007
+ _context2.next = 19;
2008
+ return writeSourceFilePromise;
2011
2009
 
2012
- case 18:
2010
+ case 19:
2011
+ _context2.next = 21;
2012
+ return writeSourceMapFilePromise;
2013
+
2014
+ case 21:
2013
2015
  case "end":
2014
2016
  return _context2.stop();
2015
2017
  }
@@ -2445,14 +2447,14 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
2445
2447
  * Sentry.io, uploading sourcemaps, associating commits and deploys and finalizing the release)
2446
2448
  */
2447
2449
  writeBundle: function writeBundle() {
2448
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
2450
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
2449
2451
  var _releaseInjectionSpan;
2450
2452
 
2451
- var releasePipelineSpan, ctx, releaseName, tmpUploadFolder, _transaction, debugIdChunkFilePaths, sourceFileUploadFolderPromise, _transaction2, _transaction3;
2453
+ var releasePipelineSpan, ctx, releaseName, tmpUploadFolder, _transaction, debugIdChunkFilePaths, sourceFileUploadFolderPromise, preparationTasks, workers, worker, workerIndex, _transaction2, _transaction3;
2452
2454
 
2453
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
2455
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
2454
2456
  while (1) {
2455
- switch (_context4.prev = _context4.next) {
2457
+ switch (_context5.prev = _context5.next) {
2456
2458
  case 0:
2457
2459
  logger.debug('Called "writeBundle"');
2458
2460
  (_releaseInjectionSpan = releaseInjectionSpan) === null || _releaseInjectionSpan === void 0 ? void 0 : _releaseInjectionSpan.finish();
@@ -2472,24 +2474,24 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
2472
2474
  logger: logger,
2473
2475
  cli: cli
2474
2476
  };
2475
- _context4.next = 7;
2477
+ _context5.next = 7;
2476
2478
  return releaseNamePromise;
2477
2479
 
2478
2480
  case 7:
2479
- releaseName = _context4.sent;
2480
- _context4.prev = 8;
2481
+ releaseName = _context5.sent;
2482
+ _context5.prev = 8;
2481
2483
 
2482
2484
  if (unpluginMetaContext.watchMode) {
2483
- _context4.next = 34;
2485
+ _context5.next = 38;
2484
2486
  break;
2485
2487
  }
2486
2488
 
2487
2489
  if (!internalOptions._experiments.debugIdUpload) {
2488
- _context4.next = 22;
2490
+ _context5.next = 26;
2489
2491
  break;
2490
2492
  }
2491
2493
 
2492
- _context4.next = 13;
2494
+ _context5.next = 13;
2493
2495
  return glob.glob(internalOptions._experiments.debugIdUpload.include, {
2494
2496
  absolute: true,
2495
2497
  nodir: true,
@@ -2497,13 +2499,14 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
2497
2499
  });
2498
2500
 
2499
2501
  case 13:
2500
- debugIdChunkFilePaths = _context4.sent.filter(function (p) {
2502
+ debugIdChunkFilePaths = _context5.sent.filter(function (p) {
2501
2503
  return p.endsWith(".js") || p.endsWith(".mjs");
2502
2504
  });
2503
- sourceFileUploadFolderPromise = util__default["default"].promisify(fs__default["default"].mkdtemp)(path__default["default"].join(os__default["default"].tmpdir(), "sentry-bundler-plugin-upload-"));
2504
- _context4.next = 17;
2505
- return Promise.all(debugIdChunkFilePaths.map( /*#__PURE__*/function () {
2506
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(chunkFilePath, chunkIndex) {
2505
+ sourceFileUploadFolderPromise = util__default["default"].promisify(fs__default["default"].mkdtemp)(path__default["default"].join(os__default["default"].tmpdir(), "sentry-bundler-plugin-upload-")); // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
2506
+ // instead we do it with a maximum of 16 concurrent workers
2507
+
2508
+ preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
2509
+ return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
2507
2510
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
2508
2511
  while (1) {
2509
2512
  switch (_context3.prev = _context3.next) {
@@ -2527,62 +2530,105 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
2527
2530
  }
2528
2531
  }, _callee3);
2529
2532
  }));
2533
+ });
2534
+ workers = [];
2535
+
2536
+ worker = /*#__PURE__*/function () {
2537
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
2538
+ var task;
2539
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
2540
+ while (1) {
2541
+ switch (_context4.prev = _context4.next) {
2542
+ case 0:
2543
+ if (!(preparationTasks.length > 0)) {
2544
+ _context4.next = 7;
2545
+ break;
2546
+ }
2547
+
2548
+ task = preparationTasks.shift();
2549
+
2550
+ if (!task) {
2551
+ _context4.next = 5;
2552
+ break;
2553
+ }
2554
+
2555
+ _context4.next = 5;
2556
+ return task();
2557
+
2558
+ case 5:
2559
+ _context4.next = 0;
2560
+ break;
2561
+
2562
+ case 7:
2563
+ case "end":
2564
+ return _context4.stop();
2565
+ }
2566
+ }
2567
+ }, _callee4);
2568
+ }));
2530
2569
 
2531
- return function (_x, _x2) {
2532
- return _ref2.apply(this, arguments);
2570
+ return function worker() {
2571
+ return _ref3.apply(this, arguments);
2533
2572
  };
2534
- }()));
2573
+ }();
2574
+
2575
+ for (workerIndex = 0; workerIndex < 16; workerIndex++) {
2576
+ workers.push(worker());
2577
+ }
2578
+
2579
+ _context5.next = 21;
2580
+ return Promise.all(workers);
2535
2581
 
2536
- case 17:
2537
- _context4.next = 19;
2582
+ case 21:
2583
+ _context5.next = 23;
2538
2584
  return sourceFileUploadFolderPromise;
2539
2585
 
2540
- case 19:
2541
- tmpUploadFolder = _context4.sent;
2542
- _context4.next = 22;
2586
+ case 23:
2587
+ tmpUploadFolder = _context5.sent;
2588
+ _context5.next = 26;
2543
2589
  return uploadDebugIdSourcemaps(internalOptions, ctx, tmpUploadFolder, releaseName);
2544
2590
 
2545
- case 22:
2546
- _context4.next = 24;
2591
+ case 26:
2592
+ _context5.next = 28;
2547
2593
  return createNewRelease(internalOptions, ctx, releaseName);
2548
2594
 
2549
- case 24:
2550
- _context4.next = 26;
2595
+ case 28:
2596
+ _context5.next = 30;
2551
2597
  return cleanArtifacts(internalOptions, ctx, releaseName);
2552
2598
 
2553
- case 26:
2554
- _context4.next = 28;
2599
+ case 30:
2600
+ _context5.next = 32;
2555
2601
  return uploadSourceMaps(internalOptions, ctx, releaseName);
2556
2602
 
2557
- case 28:
2558
- _context4.next = 30;
2603
+ case 32:
2604
+ _context5.next = 34;
2559
2605
  return setCommits(internalOptions, ctx, releaseName);
2560
2606
 
2561
- case 30:
2562
- _context4.next = 32;
2607
+ case 34:
2608
+ _context5.next = 36;
2563
2609
  return finalizeRelease(internalOptions, ctx, releaseName);
2564
2610
 
2565
- case 32:
2566
- _context4.next = 34;
2611
+ case 36:
2612
+ _context5.next = 38;
2567
2613
  return addDeploy(internalOptions, ctx, releaseName);
2568
2614
 
2569
- case 34:
2615
+ case 38:
2570
2616
  (_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
2571
- _context4.next = 42;
2617
+ _context5.next = 46;
2572
2618
  break;
2573
2619
 
2574
- case 37:
2575
- _context4.prev = 37;
2576
- _context4.t0 = _context4["catch"](8);
2620
+ case 41:
2621
+ _context5.prev = 41;
2622
+ _context5.t0 = _context5["catch"](8);
2577
2623
  (_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
2578
2624
  sentryHub.addBreadcrumb({
2579
2625
  level: "error",
2580
2626
  message: "Error during writeBundle"
2581
2627
  });
2582
- handleError(_context4.t0, logger, internalOptions.errorHandler);
2628
+ handleError(_context5.t0, logger, internalOptions.errorHandler);
2583
2629
 
2584
- case 42:
2585
- _context4.prev = 42;
2630
+ case 46:
2631
+ _context5.prev = 46;
2586
2632
 
2587
2633
  if (tmpUploadFolder) {
2588
2634
  fs__default["default"].rm(tmpUploadFolder, {
@@ -2594,26 +2640,26 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
2594
2640
 
2595
2641
  releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
2596
2642
  (_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
2597
- _context4.next = 48;
2643
+ _context5.next = 52;
2598
2644
  return sentryClient.flush().then(null, function () {
2599
2645
  logger.warn("Sending of telemetry failed");
2600
2646
  });
2601
2647
 
2602
- case 48:
2603
- return _context4.finish(42);
2648
+ case 52:
2649
+ return _context5.finish(46);
2604
2650
 
2605
- case 49:
2651
+ case 53:
2606
2652
  sentryHub.addBreadcrumb({
2607
2653
  category: "writeBundle:finish",
2608
2654
  level: "info"
2609
2655
  });
2610
2656
 
2611
- case 50:
2657
+ case 54:
2612
2658
  case "end":
2613
- return _context4.stop();
2659
+ return _context5.stop();
2614
2660
  }
2615
2661
  }
2616
- }, _callee4, null, [[8, 37, 42, 49]]);
2662
+ }, _callee5, null, [[8, 41, 46, 53]]);
2617
2663
  }))();
2618
2664
  },
2619
2665
  rollup: {
@@ -2719,12 +2765,12 @@ function handleError(unknownError, logger, errorHandler) {
2719
2765
  */
2720
2766
 
2721
2767
 
2722
- function generateGlobalInjectorCode(_ref3) {
2723
- var release = _ref3.release,
2724
- injectReleasesMap = _ref3.injectReleasesMap,
2725
- injectBuildInformation = _ref3.injectBuildInformation,
2726
- org = _ref3.org,
2727
- project = _ref3.project;
2768
+ function generateGlobalInjectorCode(_ref4) {
2769
+ var release = _ref4.release,
2770
+ injectReleasesMap = _ref4.injectReleasesMap,
2771
+ injectBuildInformation = _ref4.injectBuildInformation,
2772
+ org = _ref4.org,
2773
+ project = _ref4.project;
2728
2774
  // The code below is mostly ternary operators because it saves bundle size.
2729
2775
  // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
2730
2776
  var code = "\n var _global =\n typeof window !== 'undefined' ?\n window :\n typeof global !== 'undefined' ?\n global :\n typeof self !== 'undefined' ?\n self :\n {};\n\n _global.SENTRY_RELEASE={id:\"".concat(release, "\"};");
@@ -2745,12 +2791,12 @@ function generateGlobalInjectorCode(_ref3) {
2745
2791
  function getBuildInformation() {
2746
2792
  var packageJson = getPackageJson();
2747
2793
 
2748
- var _ref4 = packageJson ? getDependencies(packageJson) : {
2794
+ var _ref5 = packageJson ? getDependencies(packageJson) : {
2749
2795
  deps: [],
2750
2796
  depsVersions: {}
2751
2797
  },
2752
- deps = _ref4.deps,
2753
- depsVersions = _ref4.depsVersions;
2798
+ deps = _ref5.deps,
2799
+ depsVersions = _ref5.depsVersions;
2754
2800
 
2755
2801
  return {
2756
2802
  deps: deps,