@sentry/bundler-plugin-core 2.6.2 → 2.7.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
@@ -717,22 +717,22 @@ function createDebugIdUploadFunction(_ref) {
717
717
  rewriteSourcesHook = _ref.rewriteSourcesHook,
718
718
  filesToDeleteAfterUpload = _ref.filesToDeleteAfterUpload;
719
719
  return /*#__PURE__*/function () {
720
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(buildArtifactPaths) {
721
- var artifactBundleUploadTransaction, folderToCleanUp, mkdtempSpan, tmpUploadFolder, globAssets, globSpan, globResult, debugIdChunkFilePaths, prepareSpan, files, stats, uploadSize, uploadSpan, cliInstance, deleteGlobSpan, filePathsToDelete, deleteSpan, cleanupSpan;
722
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
723
- while (1) switch (_context2.prev = _context2.next) {
720
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(buildArtifactPaths) {
721
+ var artifactBundleUploadTransaction, folderToCleanUp, mkdtempSpan, tmpUploadFolder, globAssets, globSpan, globResult, debugIdChunkFilePaths, prepareSpan, preparationTasks, workers, worker, workerIndex, files, stats, uploadSize, uploadSpan, cliInstance, deleteGlobSpan, filePathsToDelete, deleteSpan, cleanupSpan;
722
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
723
+ while (1) switch (_context3.prev = _context3.next) {
724
724
  case 0:
725
725
  artifactBundleUploadTransaction = sentryHub.startTransaction({
726
726
  name: "debug-id-sourcemap-upload"
727
727
  });
728
- _context2.prev = 1;
728
+ _context3.prev = 1;
729
729
  mkdtempSpan = artifactBundleUploadTransaction.startChild({
730
730
  description: "mkdtemp"
731
731
  });
732
- _context2.next = 5;
732
+ _context3.next = 5;
733
733
  return fs__default["default"].promises.mkdtemp(path__default["default"].join(os__default["default"].tmpdir(), "sentry-bundler-plugin-upload-"));
734
734
  case 5:
735
- tmpUploadFolder = _context2.sent;
735
+ tmpUploadFolder = _context3.sent;
736
736
  mkdtempSpan.finish();
737
737
  folderToCleanUp = tmpUploadFolder;
738
738
  if (assets) {
@@ -744,14 +744,14 @@ function createDebugIdUploadFunction(_ref) {
744
744
  globSpan = artifactBundleUploadTransaction.startChild({
745
745
  description: "glob"
746
746
  });
747
- _context2.next = 12;
747
+ _context3.next = 12;
748
748
  return glob.glob(globAssets, {
749
749
  absolute: true,
750
750
  nodir: true,
751
751
  ignore: ignore
752
752
  });
753
753
  case 12:
754
- globResult = _context2.sent;
754
+ globResult = _context3.sent;
755
755
  globSpan.finish();
756
756
  debugIdChunkFilePaths = globResult.filter(function (debugIdChunkFilePath) {
757
757
  return debugIdChunkFilePath.endsWith(".js") || debugIdChunkFilePath.endsWith(".mjs") || debugIdChunkFilePath.endsWith(".cjs");
@@ -759,27 +759,27 @@ function createDebugIdUploadFunction(_ref) {
759
759
  // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
760
760
  debugIdChunkFilePaths.sort();
761
761
  if (!(Array.isArray(assets) && assets.length === 0)) {
762
- _context2.next = 20;
762
+ _context3.next = 20;
763
763
  break;
764
764
  }
765
765
  logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
766
- _context2.next = 43;
766
+ _context3.next = 47;
767
767
  break;
768
768
  case 20:
769
769
  if (!(debugIdChunkFilePaths.length === 0)) {
770
- _context2.next = 24;
770
+ _context3.next = 24;
771
771
  break;
772
772
  }
773
773
  logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
774
- _context2.next = 43;
774
+ _context3.next = 47;
775
775
  break;
776
776
  case 24:
777
777
  prepareSpan = artifactBundleUploadTransaction.startChild({
778
778
  description: "prepare-bundles"
779
- });
780
- _context2.next = 27;
781
- return Promise.all(debugIdChunkFilePaths.map( /*#__PURE__*/function () {
782
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(chunkFilePath, chunkIndex) {
779
+ }); // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
780
+ // instead we do it with a maximum of 16 concurrent workers
781
+ preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
782
+ return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
783
783
  return _regeneratorRuntime().wrap(function _callee$(_context) {
784
784
  while (1) switch (_context.prev = _context.next) {
785
785
  case 0:
@@ -791,24 +791,57 @@ function createDebugIdUploadFunction(_ref) {
791
791
  }
792
792
  }, _callee);
793
793
  }));
794
- return function (_x2, _x3) {
795
- return _ref3.apply(this, arguments);
794
+ });
795
+ workers = [];
796
+ worker = /*#__PURE__*/function () {
797
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
798
+ var task;
799
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
800
+ while (1) switch (_context2.prev = _context2.next) {
801
+ case 0:
802
+ if (!(preparationTasks.length > 0)) {
803
+ _context2.next = 7;
804
+ break;
805
+ }
806
+ task = preparationTasks.shift();
807
+ if (!task) {
808
+ _context2.next = 5;
809
+ break;
810
+ }
811
+ _context2.next = 5;
812
+ return task();
813
+ case 5:
814
+ _context2.next = 0;
815
+ break;
816
+ case 7:
817
+ case "end":
818
+ return _context2.stop();
819
+ }
820
+ }, _callee2);
821
+ }));
822
+ return function worker() {
823
+ return _ref4.apply(this, arguments);
796
824
  };
797
- }()));
798
- case 27:
825
+ }();
826
+ for (workerIndex = 0; workerIndex < 16; workerIndex++) {
827
+ workers.push(worker());
828
+ }
829
+ _context3.next = 31;
830
+ return Promise.all(workers);
831
+ case 31:
799
832
  prepareSpan.finish();
800
- _context2.next = 30;
833
+ _context3.next = 34;
801
834
  return fs__default["default"].promises.readdir(tmpUploadFolder);
802
- case 30:
803
- files = _context2.sent;
835
+ case 34:
836
+ files = _context3.sent;
804
837
  stats = files.map(function (file) {
805
838
  return fs__default["default"].promises.stat(path__default["default"].join(tmpUploadFolder, file));
806
839
  });
807
- _context2.next = 34;
840
+ _context3.next = 38;
808
841
  return Promise.all(stats);
809
- case 34:
810
- uploadSize = _context2.sent.reduce(function (accumulator, _ref4) {
811
- var size = _ref4.size;
842
+ case 38:
843
+ uploadSize = _context3.sent.reduce(function (accumulator, _ref5) {
844
+ var size = _ref5.size;
812
845
  return accumulator + size;
813
846
  }, 0);
814
847
  artifactBundleUploadTransaction.setMeasurement("files", files.length, "none");
@@ -823,7 +856,7 @@ function createDebugIdUploadFunction(_ref) {
823
856
  baggage: utils.dynamicSamplingContextToSentryBaggageHeader(artifactBundleUploadTransaction.getDynamicSamplingContext())
824
857
  }, sentryCliOptions.headers)
825
858
  }));
826
- _context2.next = 41;
859
+ _context3.next = 45;
827
860
  return cliInstance.releases.uploadSourceMaps(releaseName !== null && releaseName !== void 0 ? releaseName : "undefined",
828
861
  // unfortunetly this needs a value for now but it will not matter since debug IDs overpower releases anyhow
829
862
  {
@@ -834,24 +867,24 @@ function createDebugIdUploadFunction(_ref) {
834
867
  }],
835
868
  useArtifactBundle: true
836
869
  });
837
- case 41:
870
+ case 45:
838
871
  uploadSpan.finish();
839
872
  logger.info("Successfully uploaded source maps to Sentry");
840
- case 43:
873
+ case 47:
841
874
  if (!filesToDeleteAfterUpload) {
842
- _context2.next = 54;
875
+ _context3.next = 58;
843
876
  break;
844
877
  }
845
878
  deleteGlobSpan = artifactBundleUploadTransaction.startChild({
846
879
  description: "delete-glob"
847
880
  });
848
- _context2.next = 47;
881
+ _context3.next = 51;
849
882
  return glob.glob(filesToDeleteAfterUpload, {
850
883
  absolute: true,
851
884
  nodir: true
852
885
  });
853
- case 47:
854
- filePathsToDelete = _context2.sent;
886
+ case 51:
887
+ filePathsToDelete = _context3.sent;
855
888
  deleteGlobSpan.finish();
856
889
  filePathsToDelete.forEach(function (filePathToDelete) {
857
890
  logger.debug("Deleting asset after upload: ".concat(filePathToDelete));
@@ -859,7 +892,7 @@ function createDebugIdUploadFunction(_ref) {
859
892
  deleteSpan = artifactBundleUploadTransaction.startChild({
860
893
  description: "delete-files-after-upload"
861
894
  });
862
- _context2.next = 53;
895
+ _context3.next = 57;
863
896
  return Promise.all(filePathsToDelete.map(function (filePathToDelete) {
864
897
  return fs__default["default"].promises.rm(filePathToDelete, {
865
898
  force: true
@@ -868,21 +901,21 @@ function createDebugIdUploadFunction(_ref) {
868
901
  logger.debug("An error occured while attempting to delete asset: ".concat(filePathToDelete), e);
869
902
  });
870
903
  }));
871
- case 53:
904
+ case 57:
872
905
  deleteSpan.finish();
873
- case 54:
874
- _context2.next = 60;
906
+ case 58:
907
+ _context3.next = 64;
875
908
  break;
876
- case 56:
877
- _context2.prev = 56;
878
- _context2.t0 = _context2["catch"](1);
909
+ case 60:
910
+ _context3.prev = 60;
911
+ _context3.t0 = _context3["catch"](1);
879
912
  sentryHub.withScope(function (scope) {
880
913
  scope.setSpan(artifactBundleUploadTransaction);
881
914
  sentryHub.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
882
915
  });
883
- handleRecoverableError(_context2.t0);
884
- case 60:
885
- _context2.prev = 60;
916
+ handleRecoverableError(_context3.t0);
917
+ case 64:
918
+ _context3.prev = 64;
886
919
  if (folderToCleanUp) {
887
920
  cleanupSpan = artifactBundleUploadTransaction.startChild({
888
921
  description: "cleanup"
@@ -894,22 +927,22 @@ function createDebugIdUploadFunction(_ref) {
894
927
  cleanupSpan.finish();
895
928
  }
896
929
  artifactBundleUploadTransaction.finish();
897
- _context2.next = 65;
930
+ _context3.next = 69;
898
931
  return sentryClient.flush();
899
- case 65:
900
- return _context2.finish(60);
901
- case 66:
932
+ case 69:
933
+ return _context3.finish(64);
934
+ case 70:
902
935
  case "end":
903
- return _context2.stop();
936
+ return _context3.stop();
904
937
  }
905
- }, _callee2, null, [[1, 56, 60, 66]]);
938
+ }, _callee3, null, [[1, 60, 64, 70]]);
906
939
  }));
907
940
  return function (_x) {
908
941
  return _ref2.apply(this, arguments);
909
942
  };
910
943
  }();
911
944
  }
912
- function prepareBundleForDebugIdUpload(_x4, _x5, _x6, _x7, _x8) {
945
+ function prepareBundleForDebugIdUpload(_x2, _x3, _x4, _x5, _x6) {
913
946
  return _prepareBundleForDebugIdUpload.apply(this, arguments);
914
947
  }
915
948
 
@@ -920,64 +953,66 @@ function prepareBundleForDebugIdUpload(_x4, _x5, _x6, _x7, _x8) {
920
953
  * The string pattern is injected via the debug ID injection snipped.
921
954
  */
922
955
  function _prepareBundleForDebugIdUpload() {
923
- _prepareBundleForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(bundleFilePath, uploadFolder, chunkIndex, logger, rewriteSourcesHook) {
956
+ _prepareBundleForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(bundleFilePath, uploadFolder, chunkIndex, logger, rewriteSourcesHook) {
924
957
  var bundleContent, debugId, uniqueUploadName, writeSourceFilePromise, writeSourceMapFilePromise;
925
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
926
- while (1) switch (_context4.prev = _context4.next) {
958
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
959
+ while (1) switch (_context5.prev = _context5.next) {
927
960
  case 0:
928
- _context4.prev = 0;
929
- _context4.next = 3;
961
+ _context5.prev = 0;
962
+ _context5.next = 3;
930
963
  return util.promisify(fs__default["default"].readFile)(bundleFilePath, "utf8");
931
964
  case 3:
932
- bundleContent = _context4.sent;
933
- _context4.next = 10;
965
+ bundleContent = _context5.sent;
966
+ _context5.next = 10;
934
967
  break;
935
968
  case 6:
936
- _context4.prev = 6;
937
- _context4.t0 = _context4["catch"](0);
938
- logger.error("Could not read bundle to determine debug ID and source map: ".concat(bundleFilePath), _context4.t0);
939
- return _context4.abrupt("return");
969
+ _context5.prev = 6;
970
+ _context5.t0 = _context5["catch"](0);
971
+ logger.error("Could not read bundle to determine debug ID and source map: ".concat(bundleFilePath), _context5.t0);
972
+ return _context5.abrupt("return");
940
973
  case 10:
941
974
  debugId = determineDebugIdFromBundleSource(bundleContent);
942
975
  if (!(debugId === undefined)) {
943
- _context4.next = 14;
976
+ _context5.next = 14;
944
977
  break;
945
978
  }
946
979
  logger.debug("Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: ".concat(bundleFilePath));
947
- return _context4.abrupt("return");
980
+ return _context5.abrupt("return");
948
981
  case 14:
949
982
  uniqueUploadName = "".concat(debugId, "-").concat(chunkIndex);
950
983
  bundleContent += "\n//# debugId=".concat(debugId);
951
984
  writeSourceFilePromise = fs__default["default"].promises.writeFile(path__default["default"].join(uploadFolder, "".concat(uniqueUploadName, ".js")), bundleContent, "utf-8");
952
985
  writeSourceMapFilePromise = determineSourceMapPathFromBundle(bundleFilePath, bundleContent, logger).then( /*#__PURE__*/function () {
953
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sourceMapPath) {
954
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
955
- while (1) switch (_context3.prev = _context3.next) {
986
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(sourceMapPath) {
987
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
988
+ while (1) switch (_context4.prev = _context4.next) {
956
989
  case 0:
957
990
  if (!sourceMapPath) {
958
- _context3.next = 4;
991
+ _context4.next = 3;
959
992
  break;
960
993
  }
961
- _context3.next = 3;
994
+ _context4.next = 3;
962
995
  return prepareSourceMapForDebugIdUpload(sourceMapPath, path__default["default"].join(uploadFolder, "".concat(uniqueUploadName, ".js.map")), debugId, rewriteSourcesHook, logger);
963
996
  case 3:
964
- return _context3.abrupt("return", _context3.sent);
965
- case 4:
966
997
  case "end":
967
- return _context3.stop();
998
+ return _context4.stop();
968
999
  }
969
- }, _callee3);
1000
+ }, _callee4);
970
1001
  }));
971
- return function (_x17) {
972
- return _ref5.apply(this, arguments);
1002
+ return function (_x15) {
1003
+ return _ref6.apply(this, arguments);
973
1004
  };
974
1005
  }());
975
- return _context4.abrupt("return", Promise.all([writeSourceFilePromise, writeSourceMapFilePromise]));
976
- case 19:
1006
+ _context5.next = 20;
1007
+ return writeSourceFilePromise;
1008
+ case 20:
1009
+ _context5.next = 22;
1010
+ return writeSourceMapFilePromise;
1011
+ case 22:
977
1012
  case "end":
978
- return _context4.stop();
1013
+ return _context5.stop();
979
1014
  }
980
- }, _callee4, null, [[0, 6]]);
1015
+ }, _callee5, null, [[0, 6]]);
981
1016
  }));
982
1017
  return _prepareBundleForDebugIdUpload.apply(this, arguments);
983
1018
  }
@@ -995,22 +1030,22 @@ function determineDebugIdFromBundleSource(code) {
995
1030
  *
996
1031
  * @returns the path to the bundle's source map or `undefined` if none could be found.
997
1032
  */
998
- function determineSourceMapPathFromBundle(_x9, _x10, _x11) {
1033
+ function determineSourceMapPathFromBundle(_x7, _x8, _x9) {
999
1034
  return _determineSourceMapPathFromBundle.apply(this, arguments);
1000
1035
  }
1001
1036
  /**
1002
1037
  * Reads a source map, injects debug ID fields, and writes the source map to the target path.
1003
1038
  */
1004
1039
  function _determineSourceMapPathFromBundle() {
1005
- _determineSourceMapPathFromBundle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(bundlePath, bundleSource, logger) {
1040
+ _determineSourceMapPathFromBundle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(bundlePath, bundleSource, logger) {
1006
1041
  var sourceMappingUrlMatch, sourceMappingUrl, isUrl, isSupportedUrl, url, absoluteSourceMapPath, adjacentSourceMapFilePath;
1007
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1008
- while (1) switch (_context5.prev = _context5.next) {
1042
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1043
+ while (1) switch (_context6.prev = _context6.next) {
1009
1044
  case 0:
1010
1045
  // 1. try to find source map at `sourceMappingURL` location
1011
1046
  sourceMappingUrlMatch = bundleSource.match(/^\s*\/\/# sourceMappingURL=(.*)$/m);
1012
1047
  if (!sourceMappingUrlMatch) {
1013
- _context5.next = 21;
1048
+ _context6.next = 21;
1014
1049
  break;
1015
1050
  }
1016
1051
  sourceMappingUrl = path__default["default"].normalize(sourceMappingUrlMatch[1]);
@@ -1023,18 +1058,18 @@ function _determineSourceMapPathFromBundle() {
1023
1058
  isSupportedUrl = false;
1024
1059
  }
1025
1060
  if (!isSupportedUrl) {
1026
- _context5.next = 8;
1061
+ _context6.next = 8;
1027
1062
  break;
1028
1063
  }
1029
1064
  absoluteSourceMapPath = sourceMappingUrl;
1030
- _context5.next = 13;
1065
+ _context6.next = 13;
1031
1066
  break;
1032
1067
  case 8:
1033
1068
  if (!isUrl) {
1034
- _context5.next = 12;
1069
+ _context6.next = 12;
1035
1070
  break;
1036
1071
  }
1037
- return _context5.abrupt("return");
1072
+ return _context6.abrupt("return");
1038
1073
  case 12:
1039
1074
  if (path__default["default"].isAbsolute(sourceMappingUrl)) {
1040
1075
  absoluteSourceMapPath = sourceMappingUrl;
@@ -1042,96 +1077,96 @@ function _determineSourceMapPathFromBundle() {
1042
1077
  absoluteSourceMapPath = path__default["default"].join(path__default["default"].dirname(bundlePath), sourceMappingUrl);
1043
1078
  }
1044
1079
  case 13:
1045
- _context5.prev = 13;
1046
- _context5.next = 16;
1080
+ _context6.prev = 13;
1081
+ _context6.next = 16;
1047
1082
  return util__namespace.promisify(fs__default["default"].access)(absoluteSourceMapPath);
1048
1083
  case 16:
1049
- return _context5.abrupt("return", absoluteSourceMapPath);
1084
+ return _context6.abrupt("return", absoluteSourceMapPath);
1050
1085
  case 19:
1051
- _context5.prev = 19;
1052
- _context5.t0 = _context5["catch"](13);
1086
+ _context6.prev = 19;
1087
+ _context6.t0 = _context6["catch"](13);
1053
1088
  case 21:
1054
- _context5.prev = 21;
1089
+ _context6.prev = 21;
1055
1090
  adjacentSourceMapFilePath = bundlePath + ".map";
1056
- _context5.next = 25;
1091
+ _context6.next = 25;
1057
1092
  return util__namespace.promisify(fs__default["default"].access)(adjacentSourceMapFilePath);
1058
1093
  case 25:
1059
- return _context5.abrupt("return", adjacentSourceMapFilePath);
1094
+ return _context6.abrupt("return", adjacentSourceMapFilePath);
1060
1095
  case 28:
1061
- _context5.prev = 28;
1062
- _context5.t1 = _context5["catch"](21);
1096
+ _context6.prev = 28;
1097
+ _context6.t1 = _context6["catch"](21);
1063
1098
  case 30:
1064
1099
  // This is just a debug message because it can be quite spammy for some frameworks
1065
1100
  logger.debug("Could not determine source map path for bundle: ".concat(bundlePath, " - Did you turn on source map generation in your bundler?"));
1066
- return _context5.abrupt("return", undefined);
1101
+ return _context6.abrupt("return", undefined);
1067
1102
  case 32:
1068
1103
  case "end":
1069
- return _context5.stop();
1104
+ return _context6.stop();
1070
1105
  }
1071
- }, _callee5, null, [[13, 19], [21, 28]]);
1106
+ }, _callee6, null, [[13, 19], [21, 28]]);
1072
1107
  }));
1073
1108
  return _determineSourceMapPathFromBundle.apply(this, arguments);
1074
1109
  }
1075
- function prepareSourceMapForDebugIdUpload(_x12, _x13, _x14, _x15, _x16) {
1110
+ function prepareSourceMapForDebugIdUpload(_x10, _x11, _x12, _x13, _x14) {
1076
1111
  return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
1077
1112
  }
1078
1113
  function _prepareSourceMapForDebugIdUpload() {
1079
- _prepareSourceMapForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(sourceMapPath, targetPath, debugId, rewriteSourcesHook, logger) {
1114
+ _prepareSourceMapForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(sourceMapPath, targetPath, debugId, rewriteSourcesHook, logger) {
1080
1115
  var sourceMapFileContent, map;
1081
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1082
- while (1) switch (_context6.prev = _context6.next) {
1116
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1117
+ while (1) switch (_context7.prev = _context7.next) {
1083
1118
  case 0:
1084
- _context6.prev = 0;
1085
- _context6.next = 3;
1119
+ _context7.prev = 0;
1120
+ _context7.next = 3;
1086
1121
  return util__namespace.promisify(fs__default["default"].readFile)(sourceMapPath, {
1087
1122
  encoding: "utf8"
1088
1123
  });
1089
1124
  case 3:
1090
- sourceMapFileContent = _context6.sent;
1091
- _context6.next = 10;
1125
+ sourceMapFileContent = _context7.sent;
1126
+ _context7.next = 10;
1092
1127
  break;
1093
1128
  case 6:
1094
- _context6.prev = 6;
1095
- _context6.t0 = _context6["catch"](0);
1096
- logger.error("Failed to read source map for debug ID upload: ".concat(sourceMapPath), _context6.t0);
1097
- return _context6.abrupt("return");
1129
+ _context7.prev = 6;
1130
+ _context7.t0 = _context7["catch"](0);
1131
+ logger.error("Failed to read source map for debug ID upload: ".concat(sourceMapPath), _context7.t0);
1132
+ return _context7.abrupt("return");
1098
1133
  case 10:
1099
- _context6.prev = 10;
1134
+ _context7.prev = 10;
1100
1135
  map = JSON.parse(sourceMapFileContent);
1101
1136
  // For now we write both fields until we know what will become the standard - if ever.
1102
1137
  map["debug_id"] = debugId;
1103
1138
  map["debugId"] = debugId;
1104
- _context6.next = 20;
1139
+ _context7.next = 20;
1105
1140
  break;
1106
1141
  case 16:
1107
- _context6.prev = 16;
1108
- _context6.t1 = _context6["catch"](10);
1142
+ _context7.prev = 16;
1143
+ _context7.t1 = _context7["catch"](10);
1109
1144
  logger.error("Failed to parse source map for debug ID upload: ".concat(sourceMapPath));
1110
- return _context6.abrupt("return");
1145
+ return _context7.abrupt("return");
1111
1146
  case 20:
1112
1147
  if (map["sources"] && Array.isArray(map["sources"])) {
1113
1148
  map["sources"].map(function (source) {
1114
1149
  return rewriteSourcesHook(source, map);
1115
1150
  });
1116
1151
  }
1117
- _context6.prev = 21;
1118
- _context6.next = 24;
1152
+ _context7.prev = 21;
1153
+ _context7.next = 24;
1119
1154
  return util__namespace.promisify(fs__default["default"].writeFile)(targetPath, JSON.stringify(map), {
1120
1155
  encoding: "utf8"
1121
1156
  });
1122
1157
  case 24:
1123
- _context6.next = 30;
1158
+ _context7.next = 30;
1124
1159
  break;
1125
1160
  case 26:
1126
- _context6.prev = 26;
1127
- _context6.t2 = _context6["catch"](21);
1128
- logger.error("Failed to prepare source map for debug ID upload: ".concat(sourceMapPath), _context6.t2);
1129
- return _context6.abrupt("return");
1161
+ _context7.prev = 26;
1162
+ _context7.t2 = _context7["catch"](21);
1163
+ logger.error("Failed to prepare source map for debug ID upload: ".concat(sourceMapPath), _context7.t2);
1164
+ return _context7.abrupt("return");
1130
1165
  case 30:
1131
1166
  case "end":
1132
- return _context6.stop();
1167
+ return _context7.stop();
1133
1168
  }
1134
- }, _callee6, null, [[0, 6], [10, 16], [21, 26]]);
1169
+ }, _callee7, null, [[0, 6], [10, 16], [21, 26]]);
1135
1170
  }));
1136
1171
  return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
1137
1172
  }
@@ -1332,7 +1367,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
1332
1367
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
1333
1368
  tracesSampleRate: 1,
1334
1369
  sampleRate: 1,
1335
- release: "2.6.2",
1370
+ release: "2.7.0",
1336
1371
  integrations: [],
1337
1372
  tracePropagationTargets: ["sentry.io/api"],
1338
1373
  stackParser: node.defaultStackParser,
@@ -1564,7 +1599,7 @@ function sentryUnpluginFactory(_ref) {
1564
1599
  });
1565
1600
 
1566
1601
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
1567
- process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.6.2");
1602
+ process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.7.0");
1568
1603
  function handleRecoverableError(unknownError) {
1569
1604
  sentrySession.status = "abnormal";
1570
1605
  try {
@@ -1763,11 +1798,19 @@ function createRollupReleaseInjectionHooks(injectionCode) {
1763
1798
  ms.append("\n\n;import \"".concat(virtualReleaseInjectionFileId, "\";"));
1764
1799
  return {
1765
1800
  code: ms.toString(),
1766
- map: ms.generateMap()
1801
+ map: ms.generateMap({
1802
+ hires: true
1803
+ })
1767
1804
  };
1768
1805
  }
1769
1806
  };
1770
1807
  }
1808
+
1809
+ // We need to be careful not to inject the snippet before any `"use strict";`s.
1810
+ // As an additional complication `"use strict";`s may come after any number of comments.
1811
+ var COMMENT_USE_STRICT_REGEX =
1812
+ // Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.
1813
+ /^(?:\s*|\/\*(?:.|\r|\n)*?\*\/|\/\/.*[\n\r])*(?:"[^"]*";|'[^']*';)?/;
1771
1814
  function createRollupDebugIdInjectionHooks() {
1772
1815
  return {
1773
1816
  renderChunk: function renderChunk(code, chunk) {
@@ -1781,13 +1824,7 @@ function createRollupDebugIdInjectionHooks() {
1781
1824
  var ms = new MagicString__default["default"](code, {
1782
1825
  filename: chunk.fileName
1783
1826
  });
1784
-
1785
- // We need to be careful not to inject the snippet before any `"use strict";`s.
1786
- // As an additional complication `"use strict";`s may come after any number of comments.
1787
- var commentUseStrictRegex =
1788
- // Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.
1789
- /^(?:\s*|\/\*(?:.|\r|\n)*?\*\/|\/\/.*[\n\r])*(?:"[^"]*";|'[^']*';)?/;
1790
- var match = (_code$match = code.match(commentUseStrictRegex)) === null || _code$match === void 0 ? void 0 : _code$match[0];
1827
+ var match = (_code$match = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match === void 0 ? void 0 : _code$match[0];
1791
1828
  if (match) {
1792
1829
  // Add injected code after any comments or "use strict" at the beginning of the bundle.
1793
1830
  ms.appendLeft(match.length, codeToInject);
@@ -1800,7 +1837,43 @@ function createRollupDebugIdInjectionHooks() {
1800
1837
  return {
1801
1838
  code: ms.toString(),
1802
1839
  map: ms.generateMap({
1803
- file: chunk.fileName
1840
+ file: chunk.fileName,
1841
+ hires: true
1842
+ })
1843
+ };
1844
+ } else {
1845
+ return null; // returning null means not modifying the chunk at all
1846
+ }
1847
+ }
1848
+ };
1849
+ }
1850
+
1851
+ function createRollupModuleMetadataInjectionHooks(injectionCode) {
1852
+ return {
1853
+ renderChunk: function renderChunk(code, chunk) {
1854
+ if ([".js", ".mjs", ".cjs"].some(function (ending) {
1855
+ return chunk.fileName.endsWith(ending);
1856
+ }) // chunks could be any file (html, md, ...)
1857
+ ) {
1858
+ var _code$match2;
1859
+ var ms = new MagicString__default["default"](code, {
1860
+ filename: chunk.fileName
1861
+ });
1862
+ var match = (_code$match2 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match2 === void 0 ? void 0 : _code$match2[0];
1863
+ if (match) {
1864
+ // Add injected code after any comments or "use strict" at the beginning of the bundle.
1865
+ ms.appendLeft(match.length, injectionCode);
1866
+ } else {
1867
+ // ms.replace() doesn't work when there is an empty string match (which happens if
1868
+ // there is neither, a comment, nor a "use strict" at the top of the chunk) so we
1869
+ // need this special case here.
1870
+ ms.prepend(injectionCode);
1871
+ }
1872
+ return {
1873
+ code: ms.toString(),
1874
+ map: ms.generateMap({
1875
+ file: chunk.fileName,
1876
+ hires: true
1804
1877
  })
1805
1878
  };
1806
1879
  } else {
@@ -1867,6 +1940,7 @@ function getDebugIdSnippet(debugId) {
1867
1940
 
1868
1941
  exports.createRollupDebugIdInjectionHooks = createRollupDebugIdInjectionHooks;
1869
1942
  exports.createRollupDebugIdUploadHooks = createRollupDebugIdUploadHooks;
1943
+ exports.createRollupModuleMetadataInjectionHooks = createRollupModuleMetadataInjectionHooks;
1870
1944
  exports.createRollupReleaseInjectionHooks = createRollupReleaseInjectionHooks;
1871
1945
  exports.getBuildInformation = getBuildInformation;
1872
1946
  exports.getDebugIdSnippet = getDebugIdSnippet;