@sentry/bundler-plugin-core 4.6.2 → 4.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
@@ -8036,6 +8036,48 @@ function getProjects(project) {
8036
8036
  return undefined;
8037
8037
  }
8038
8038
 
8039
+ /**
8040
+ * Inlined functionality from @sentry/cli helper code to add `--ignore` options.
8041
+ *
8042
+ * Temporary workaround until we expose a function for injecting debug IDs. Currently, we directly call `execute` with CLI args to inject them.
8043
+ */
8044
+ function serializeIgnoreOptions(ignoreValue) {
8045
+ var DEFAULT_IGNORE = ["node_modules"];
8046
+ var ignoreOptions = Array.isArray(ignoreValue) ? ignoreValue : typeof ignoreValue === "string" ? [ignoreValue] : DEFAULT_IGNORE;
8047
+ return ignoreOptions.reduce(function (acc, value) {
8048
+ return acc.concat(["--ignore", String(value)]);
8049
+ }, []);
8050
+ }
8051
+
8052
+ /**
8053
+ * Checks if a chunk contains only import/export statements and no substantial code.
8054
+ *
8055
+ * In Vite MPA (multi-page application) mode, HTML entry points create "facade" chunks
8056
+ * that only contain import statements to load shared modules. These should not have
8057
+ * Sentry code injected. However, in SPA mode, the main bundle also has an HTML facade
8058
+ * but contains substantial application code that SHOULD have debug IDs injected.
8059
+ *
8060
+ * @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829
8061
+ * @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/839
8062
+ */
8063
+ function containsOnlyImports(code) {
8064
+ var codeWithoutImports = code
8065
+ // Remove side effect imports: import '/path'; or import "./path";
8066
+ // Using explicit negated character classes to avoid polynomial backtracking
8067
+ .replace(/^\s*import\s+(?:'[^'\n]*'|"[^"\n]*"|`[^`\n]*`)[\s;]*$/gm, "")
8068
+ // Remove named/default imports: import x from '/path'; import { x } from '/path';
8069
+ .replace(/^\s*import\b[^'"`\n]*\bfrom\s+(?:'[^'\n]*'|"[^"\n]*"|`[^`\n]*`)[\s;]*$/gm, "")
8070
+ // Remove re-exports: export * from '/path'; export { x } from '/path';
8071
+ .replace(/^\s*export\b[^'"`\n]*\bfrom\s+(?:'[^'\n]*'|"[^"\n]*"|`[^`\n]*`)[\s;]*$/gm, "")
8072
+ // Remove block comments
8073
+ .replace(/\/\*[\s\S]*?\*\//g, "")
8074
+ // Remove line comments
8075
+ .replace(/\/\/.*$/gm, "")
8076
+ // Remove "use strict" directives
8077
+ .replace(/["']use strict["']\s*;?/g, "").trim();
8078
+ return codeWithoutImports.length === 0;
8079
+ }
8080
+
8039
8081
  var SENTRY_SAAS_URL = "https://sentry.io";
8040
8082
  function normalizeUserOptions(userOptions) {
8041
8083
  var _userOptions$org, _userOptions$project, _process$env$SENTRY_P, _userOptions$authToke, _ref, _userOptions$url, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$disable, _ref2, _userOptions$release$, _userOptions$release, _userOptions$release$2, _userOptions$release2, _userOptions$release$3, _userOptions$release3, _userOptions$release$4, _userOptions$release4, _ref3, _userOptions$release$5, _userOptions$release5, _userOptions$release6, _userOptions$_metaOpt, _userOptions$_metaOpt2, _userOptions$_experim;
@@ -8336,7 +8378,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
8336
8378
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
8337
8379
  tracesSampleRate: 1,
8338
8380
  sampleRate: 1,
8339
- release: "4.6.2",
8381
+ release: "4.7.0",
8340
8382
  integrations: [],
8341
8383
  tracePropagationTargets: ["sentry.io/api"],
8342
8384
  stackParser: stackParser,
@@ -8945,7 +8987,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8945
8987
  });
8946
8988
 
8947
8989
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
8948
- process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.6.2");
8990
+ process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.7.0");
8949
8991
 
8950
8992
  // Propagate debug flag to Sentry CLI via environment variable
8951
8993
  // Only set if not already defined to respect user's explicit configuration
@@ -9313,14 +9355,14 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9313
9355
  scope: sentryScope,
9314
9356
  forceTransaction: true
9315
9357
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
9316
- var _options$debug, cliInstance;
9358
+ var _options$sourcemaps, cliInstance;
9317
9359
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
9318
9360
  while (1) switch (_context8.prev = _context8.next) {
9319
9361
  case 0:
9320
9362
  _context8.prev = 0;
9321
9363
  cliInstance = createCliInstance(options);
9322
9364
  _context8.next = 4;
9323
- return cliInstance.execute(["sourcemaps", "inject"].concat(_toConsumableArray(buildArtifactPaths)), (_options$debug = options.debug) !== null && _options$debug !== void 0 ? _options$debug : false);
9365
+ return cliInstance.execute(["sourcemaps", "inject"].concat(_toConsumableArray(serializeIgnoreOptions((_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.ignore)), _toConsumableArray(buildArtifactPaths)), options.debug ? "rejectOnError" : false);
9324
9366
  case 4:
9325
9367
  _context8.next = 10;
9326
9368
  break;
@@ -9360,7 +9402,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9360
9402
  */
9361
9403
  uploadSourcemaps: function uploadSourcemaps(buildArtifactPaths, opts) {
9362
9404
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
9363
- var _options$sourcemaps;
9405
+ var _options$sourcemaps2;
9364
9406
  var assets;
9365
9407
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
9366
9408
  while (1) switch (_context19.prev = _context19.next) {
@@ -9372,7 +9414,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9372
9414
  return _context19.abrupt("return");
9373
9415
  case 2:
9374
9416
  // Early exit if assets is explicitly set to an empty array
9375
- assets = (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets;
9417
+ assets = (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.assets;
9376
9418
  if (!(Array.isArray(assets) && assets.length === 0)) {
9377
9419
  _context19.next = 6;
9378
9420
  break;
@@ -9389,7 +9431,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9389
9431
  forceTransaction: true
9390
9432
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
9391
9433
  var _opts$prepareArtifact;
9392
- var shouldPrepare, folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps2, _options$sourcemaps3, _options$sourcemaps4, _options$sourcemaps5, pathsToUpload, ignorePaths, globAssets, globResult, debugIdChunkFilePaths, tmpUploadFolder, _process$env2;
9434
+ var shouldPrepare, folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps3, _options$sourcemaps4, _options$sourcemaps5, _options$sourcemaps6, pathsToUpload, ignorePaths, globAssets, globResult, debugIdChunkFilePaths, tmpUploadFolder, _process$env2;
9393
9435
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
9394
9436
  while (1) switch (_context18.prev = _context18.next) {
9395
9437
  case 0:
@@ -9412,7 +9454,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9412
9454
  // Use original paths e.g. like ['.next/server'] directly –> preferred way when no globbing is done
9413
9455
  pathsToUpload = buildArtifactPaths;
9414
9456
  }
9415
- ignorePaths = (_options$sourcemaps2 = options.sourcemaps) !== null && _options$sourcemaps2 !== void 0 && _options$sourcemaps2.ignore ? Array.isArray((_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.ignore) ? (_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.ignore : [(_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.ignore] : [];
9457
+ ignorePaths = (_options$sourcemaps3 = options.sourcemaps) !== null && _options$sourcemaps3 !== void 0 && _options$sourcemaps3.ignore ? Array.isArray((_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.ignore) ? (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.ignore : [(_options$sourcemaps6 = options.sourcemaps) === null || _options$sourcemaps6 === void 0 ? void 0 : _options$sourcemaps6.ignore] : [];
9416
9458
  _context18.next = 8;
9417
9459
  return startSpan({
9418
9460
  name: "upload",
@@ -9459,7 +9501,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9459
9501
  name: "glob",
9460
9502
  scope: sentryScope
9461
9503
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
9462
- var _options$sourcemaps6;
9504
+ var _options$sourcemaps7;
9463
9505
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
9464
9506
  while (1) switch (_context11.prev = _context11.next) {
9465
9507
  case 0:
@@ -9468,7 +9510,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9468
9510
  absolute: true,
9469
9511
  nodir: true,
9470
9512
  // We need individual files for preparation
9471
- ignore: (_options$sourcemaps6 = options.sourcemaps) === null || _options$sourcemaps6 === void 0 ? void 0 : _options$sourcemaps6.ignore
9513
+ ignore: (_options$sourcemaps7 = options.sourcemaps) === null || _options$sourcemaps7 === void 0 ? void 0 : _options$sourcemaps7.ignore
9472
9514
  });
9473
9515
  case 2:
9474
9516
  return _context11.abrupt("return", _context11.sent);
@@ -9538,12 +9580,12 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9538
9580
  // instead we do it with a maximum of 16 concurrent workers
9539
9581
  preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
9540
9582
  return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
9541
- var _options$sourcemaps$r, _options$sourcemaps7, _options$sourcemaps8;
9583
+ var _options$sourcemaps$r, _options$sourcemaps8, _options$sourcemaps9;
9542
9584
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
9543
9585
  while (1) switch (_context13.prev = _context13.next) {
9544
9586
  case 0:
9545
9587
  _context13.next = 2;
9546
- return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger, (_options$sourcemaps$r = (_options$sourcemaps7 = options.sourcemaps) === null || _options$sourcemaps7 === void 0 ? void 0 : _options$sourcemaps7.rewriteSources) !== null && _options$sourcemaps$r !== void 0 ? _options$sourcemaps$r : defaultRewriteSourcesHook, (_options$sourcemaps8 = options.sourcemaps) === null || _options$sourcemaps8 === void 0 ? void 0 : _options$sourcemaps8.resolveSourceMap);
9588
+ return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger, (_options$sourcemaps$r = (_options$sourcemaps8 = options.sourcemaps) === null || _options$sourcemaps8 === void 0 ? void 0 : _options$sourcemaps8.rewriteSources) !== null && _options$sourcemaps$r !== void 0 ? _options$sourcemaps$r : defaultRewriteSourcesHook, (_options$sourcemaps9 = options.sourcemaps) === null || _options$sourcemaps9 === void 0 ? void 0 : _options$sourcemaps9.resolveSourceMap);
9547
9589
  case 2:
9548
9590
  case "end":
9549
9591
  return _context13.stop();
@@ -9706,13 +9748,13 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9706
9748
  */
9707
9749
  deleteArtifacts: function deleteArtifacts() {
9708
9750
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
9709
- var _options$sourcemaps9, filesToDelete, filePathsToDelete;
9751
+ var _options$sourcemaps10, filesToDelete, filePathsToDelete;
9710
9752
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
9711
9753
  while (1) switch (_context20.prev = _context20.next) {
9712
9754
  case 0:
9713
9755
  _context20.prev = 0;
9714
9756
  _context20.next = 3;
9715
- return (_options$sourcemaps9 = options.sourcemaps) === null || _options$sourcemaps9 === void 0 ? void 0 : _options$sourcemaps9.filesToDeleteAfterUpload;
9757
+ return (_options$sourcemaps10 = options.sourcemaps) === null || _options$sourcemaps10 === void 0 ? void 0 : _options$sourcemaps10.filesToDeleteAfterUpload;
9716
9758
  case 3:
9717
9759
  filesToDelete = _context20.sent;
9718
9760
  if (!(filesToDelete !== undefined)) {
@@ -9766,8 +9808,8 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9766
9808
  };
9767
9809
  }
9768
9810
  function canUploadSourceMaps(options, logger, isDevMode) {
9769
- var _options$sourcemaps10, _getProjects3;
9770
- if ((_options$sourcemaps10 = options.sourcemaps) !== null && _options$sourcemaps10 !== void 0 && _options$sourcemaps10.disable) {
9811
+ var _options$sourcemaps11, _getProjects3;
9812
+ if ((_options$sourcemaps11 = options.sourcemaps) !== null && _options$sourcemaps11 !== void 0 && _options$sourcemaps11.disable) {
9771
9813
  logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
9772
9814
  return false;
9773
9815
  }
@@ -9794,14 +9836,12 @@ function canUploadSourceMaps(options, logger, isDevMode) {
9794
9836
  * Creates an unplugin instance used to create Sentry plugins for Vite, Rollup, esbuild, and Webpack.
9795
9837
  */
9796
9838
  function sentryUnpluginFactory(_ref) {
9797
- var releaseInjectionPlugin = _ref.releaseInjectionPlugin,
9839
+ var injectionPlugin = _ref.injectionPlugin,
9798
9840
  componentNameAnnotatePlugin = _ref.componentNameAnnotatePlugin,
9799
- moduleMetadataInjectionPlugin = _ref.moduleMetadataInjectionPlugin,
9800
- debugIdInjectionPlugin = _ref.debugIdInjectionPlugin,
9801
9841
  debugIdUploadPlugin = _ref.debugIdUploadPlugin,
9802
9842
  bundleSizeOptimizationsPlugin = _ref.bundleSizeOptimizationsPlugin;
9803
9843
  return unplugin.createUnplugin(function () {
9804
- var _userOptions$_metaOpt, _userOptions$_metaOpt2, _options$sourcemaps;
9844
+ var _userOptions$_metaOpt, _userOptions$_metaOpt2, _options$sourcemaps, _options$sourcemaps3;
9805
9845
  var userOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9806
9846
  var unpluginMetaContext = arguments.length > 1 ? arguments[1] : undefined;
9807
9847
  var sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {
@@ -9838,20 +9878,33 @@ function sentryUnpluginFactory(_ref) {
9838
9878
  if (Object.keys(bundleSizeOptimizationReplacementValues).length > 0) {
9839
9879
  plugins.push(bundleSizeOptimizationsPlugin(bundleSizeOptimizationReplacementValues));
9840
9880
  }
9881
+ var injectionCode = "";
9841
9882
  if (!options.release.inject) {
9842
9883
  logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
9843
9884
  } else if (!options.release.name) {
9844
9885
  logger.debug("No release name provided. Will not inject release. Please set the `release.name` option to identify your release.");
9845
9886
  } else {
9846
- var _injectionCode = generateGlobalInjectorCode({
9887
+ var _code = generateGlobalInjectorCode({
9847
9888
  release: options.release.name,
9848
9889
  injectBuildInformation: options._experiments.injectBuildInformation || false
9849
9890
  });
9850
- plugins.push(releaseInjectionPlugin(_injectionCode));
9891
+ if (typeof injectionPlugin !== "function") {
9892
+ plugins.push(injectionPlugin.releaseInjectionPlugin(_code));
9893
+ } else {
9894
+ injectionCode += _code;
9895
+ }
9851
9896
  }
9852
9897
  if (Object.keys(sentryBuildPluginManager.bundleMetadata).length > 0) {
9853
- var _injectionCode2 = generateModuleMetadataInjectorCode(sentryBuildPluginManager.bundleMetadata);
9854
- plugins.push(moduleMetadataInjectionPlugin(_injectionCode2));
9898
+ var _code2 = generateModuleMetadataInjectorCode(sentryBuildPluginManager.bundleMetadata);
9899
+ if (typeof injectionPlugin !== "function") {
9900
+ plugins.push(injectionPlugin.moduleMetadataInjectionPlugin(_code2));
9901
+ } else {
9902
+ injectionCode += _code2;
9903
+ }
9904
+ }
9905
+ if (typeof injectionPlugin === "function" && (injectionCode !== "" || ((_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.disable) !== true)) {
9906
+ var _options$sourcemaps2;
9907
+ plugins.push(injectionPlugin(injectionCode, ((_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.disable) !== true, logger));
9855
9908
  }
9856
9909
 
9857
9910
  // Add plugin to create and finalize releases, and also take care of adding commits and legacy sourcemaps
@@ -9878,10 +9931,12 @@ function sentryUnpluginFactory(_ref) {
9878
9931
  }))();
9879
9932
  }
9880
9933
  });
9881
- if (((_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.disable) !== true) {
9882
- var _options$sourcemaps2;
9883
- plugins.push(debugIdInjectionPlugin(logger));
9884
- if (((_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.disable) !== "disable-upload") {
9934
+ if (((_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.disable) !== true) {
9935
+ var _options$sourcemaps4;
9936
+ if (typeof injectionPlugin !== "function") {
9937
+ plugins.push(injectionPlugin.debugIdInjectionPlugin(logger));
9938
+ }
9939
+ if (((_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.disable) !== "disable-upload") {
9885
9940
  // This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
9886
9941
  var _webpack_forceExitOnBuildComplete = typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" ? options._experiments["forceExitOnBuildCompletion"] : undefined;
9887
9942
  plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
@@ -9960,6 +10015,9 @@ function isJsFile(fileName) {
9960
10015
  * HTML entry points create "facade" chunks that should not contain injected code.
9961
10016
  * See: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829
9962
10017
  *
10018
+ * However, in SPA mode, the main bundle also has an HTML facade but contains
10019
+ * substantial application code. We should NOT skip injection for these bundles.
10020
+ *
9963
10021
  * @param code - The chunk's code content
9964
10022
  * @param facadeModuleId - The facade module ID (if any) - HTML files create facade chunks
9965
10023
  * @returns true if the chunk should be skipped
@@ -9970,48 +10028,12 @@ function shouldSkipCodeInjection(code, facadeModuleId) {
9970
10028
  return true;
9971
10029
  }
9972
10030
 
9973
- // Skip HTML facade chunks
9974
- // They only contain import statements and should not have Sentry code injected
10031
+ // For HTML facade chunks, only skip if they contain only import statements
9975
10032
  if (facadeModuleId && stripQueryAndHashFromPath(facadeModuleId).endsWith(".html")) {
9976
- return true;
10033
+ return containsOnlyImports(code);
9977
10034
  }
9978
10035
  return false;
9979
10036
  }
9980
- function createRollupReleaseInjectionHooks(injectionCode) {
9981
- return {
9982
- renderChunk: function renderChunk(code, chunk) {
9983
- var _code$match;
9984
- if (!isJsFile(chunk.fileName)) {
9985
- return null; // returning null means not modifying the chunk at all
9986
- }
9987
-
9988
- // Skip empty chunks and HTML facade chunks (Vite MPA)
9989
- if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {
9990
- return null;
9991
- }
9992
- var ms = new MagicString__default["default"](code, {
9993
- filename: chunk.fileName
9994
- });
9995
- var match = (_code$match = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match === void 0 ? void 0 : _code$match[0];
9996
- if (match) {
9997
- // Add injected code after any comments or "use strict" at the beginning of the bundle.
9998
- ms.appendLeft(match.length, injectionCode);
9999
- } else {
10000
- // ms.replace() doesn't work when there is an empty string match (which happens if
10001
- // there is neither, a comment, nor a "use strict" at the top of the chunk) so we
10002
- // need this special case here.
10003
- ms.prepend(injectionCode);
10004
- }
10005
- return {
10006
- code: ms.toString(),
10007
- map: ms.generateMap({
10008
- file: chunk.fileName,
10009
- hires: "boundary"
10010
- })
10011
- };
10012
- }
10013
- };
10014
- }
10015
10037
  function createRollupBundleSizeOptimizationHooks(replacementValues) {
10016
10038
  return {
10017
10039
  transform: function transform(code) {
@@ -10019,10 +10041,10 @@ function createRollupBundleSizeOptimizationHooks(replacementValues) {
10019
10041
  }
10020
10042
  };
10021
10043
  }
10022
- function createRollupDebugIdInjectionHooks() {
10044
+ function createRollupInjectionHooks(injectionCode, debugIds) {
10023
10045
  return {
10024
10046
  renderChunk: function renderChunk(code, chunk) {
10025
- var _code$match2;
10047
+ var _code$match;
10026
10048
  if (!isJsFile(chunk.fileName)) {
10027
10049
  return null; // returning null means not modifying the chunk at all
10028
10050
  }
@@ -10031,20 +10053,20 @@ function createRollupDebugIdInjectionHooks() {
10031
10053
  if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {
10032
10054
  return null;
10033
10055
  }
10034
-
10035
- // Check if a debug ID has already been injected to avoid duplicate injection (e.g. by another plugin or Sentry CLI)
10036
- var chunkStartSnippet = code.slice(0, 6000);
10037
- var chunkEndSnippet = code.slice(-500);
10038
- if (chunkStartSnippet.includes("_sentryDebugIdIdentifier") || chunkEndSnippet.includes("//# debugId=")) {
10039
- return null; // Debug ID already present, skip injection
10056
+ var codeToInject = injectionCode;
10057
+ if (debugIds) {
10058
+ // Check if a debug ID has already been injected to avoid duplicate injection (e.g. by another plugin or Sentry CLI)
10059
+ var chunkStartSnippet = code.slice(0, 6000);
10060
+ var chunkEndSnippet = code.slice(-500);
10061
+ if (!(chunkStartSnippet.includes("_sentryDebugIdIdentifier") || chunkEndSnippet.includes("//# debugId="))) {
10062
+ var debugId = stringToUUID(code); // generate a deterministic debug ID
10063
+ codeToInject += getDebugIdSnippet(debugId);
10064
+ }
10040
10065
  }
10041
-
10042
- var debugId = stringToUUID(code); // generate a deterministic debug ID
10043
- var codeToInject = getDebugIdSnippet(debugId);
10044
10066
  var ms = new MagicString__default["default"](code, {
10045
10067
  filename: chunk.fileName
10046
10068
  });
10047
- var match = (_code$match2 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match2 === void 0 ? void 0 : _code$match2[0];
10069
+ var match = (_code$match = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match === void 0 ? void 0 : _code$match[0];
10048
10070
  if (match) {
10049
10071
  // Add injected code after any comments or "use strict" at the beginning of the bundle.
10050
10072
  ms.appendLeft(match.length, codeToInject);
@@ -10064,41 +10086,6 @@ function createRollupDebugIdInjectionHooks() {
10064
10086
  }
10065
10087
  };
10066
10088
  }
10067
- function createRollupModuleMetadataInjectionHooks(injectionCode) {
10068
- return {
10069
- renderChunk: function renderChunk(code, chunk) {
10070
- var _code$match3;
10071
- if (!isJsFile(chunk.fileName)) {
10072
- return null; // returning null means not modifying the chunk at all
10073
- }
10074
-
10075
- // Skip empty chunks and HTML facade chunks (Vite MPA)
10076
- if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {
10077
- return null;
10078
- }
10079
- var ms = new MagicString__default["default"](code, {
10080
- filename: chunk.fileName
10081
- });
10082
- var match = (_code$match3 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match3 === void 0 ? void 0 : _code$match3[0];
10083
- if (match) {
10084
- // Add injected code after any comments or "use strict" at the beginning of the bundle.
10085
- ms.appendLeft(match.length, injectionCode);
10086
- } else {
10087
- // ms.replace() doesn't work when there is an empty string match (which happens if
10088
- // there is neither, a comment, nor a "use strict" at the top of the chunk) so we
10089
- // need this special case here.
10090
- ms.prepend(injectionCode);
10091
- }
10092
- return {
10093
- code: ms.toString(),
10094
- map: ms.generateMap({
10095
- file: chunk.fileName,
10096
- hires: "boundary"
10097
- })
10098
- };
10099
- }
10100
- };
10101
- }
10102
10089
  function createRollupDebugIdUploadHooks(upload, _logger, createDependencyOnBuildArtifacts) {
10103
10090
  var freeGlobalDependencyOnDebugIdSourcemapArtifacts = createDependencyOnBuildArtifacts();
10104
10091
  return {
@@ -10236,10 +10223,8 @@ function getDebugIdSnippet(debugId) {
10236
10223
 
10237
10224
  exports.createComponentNameAnnotateHooks = createComponentNameAnnotateHooks;
10238
10225
  exports.createRollupBundleSizeOptimizationHooks = createRollupBundleSizeOptimizationHooks;
10239
- exports.createRollupDebugIdInjectionHooks = createRollupDebugIdInjectionHooks;
10240
10226
  exports.createRollupDebugIdUploadHooks = createRollupDebugIdUploadHooks;
10241
- exports.createRollupModuleMetadataInjectionHooks = createRollupModuleMetadataInjectionHooks;
10242
- exports.createRollupReleaseInjectionHooks = createRollupReleaseInjectionHooks;
10227
+ exports.createRollupInjectionHooks = createRollupInjectionHooks;
10243
10228
  exports.createSentryBuildPluginManager = createSentryBuildPluginManager;
10244
10229
  exports.getDebugIdSnippet = getDebugIdSnippet;
10245
10230
  exports.replaceBooleanFlagsInCode = replaceBooleanFlagsInCode;