@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.
@@ -7999,6 +7999,48 @@ function getProjects(project) {
7999
7999
  return undefined;
8000
8000
  }
8001
8001
 
8002
+ /**
8003
+ * Inlined functionality from @sentry/cli helper code to add `--ignore` options.
8004
+ *
8005
+ * Temporary workaround until we expose a function for injecting debug IDs. Currently, we directly call `execute` with CLI args to inject them.
8006
+ */
8007
+ function serializeIgnoreOptions(ignoreValue) {
8008
+ var DEFAULT_IGNORE = ["node_modules"];
8009
+ var ignoreOptions = Array.isArray(ignoreValue) ? ignoreValue : typeof ignoreValue === "string" ? [ignoreValue] : DEFAULT_IGNORE;
8010
+ return ignoreOptions.reduce(function (acc, value) {
8011
+ return acc.concat(["--ignore", String(value)]);
8012
+ }, []);
8013
+ }
8014
+
8015
+ /**
8016
+ * Checks if a chunk contains only import/export statements and no substantial code.
8017
+ *
8018
+ * In Vite MPA (multi-page application) mode, HTML entry points create "facade" chunks
8019
+ * that only contain import statements to load shared modules. These should not have
8020
+ * Sentry code injected. However, in SPA mode, the main bundle also has an HTML facade
8021
+ * but contains substantial application code that SHOULD have debug IDs injected.
8022
+ *
8023
+ * @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829
8024
+ * @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/839
8025
+ */
8026
+ function containsOnlyImports(code) {
8027
+ var codeWithoutImports = code
8028
+ // Remove side effect imports: import '/path'; or import "./path";
8029
+ // Using explicit negated character classes to avoid polynomial backtracking
8030
+ .replace(/^\s*import\s+(?:'[^'\n]*'|"[^"\n]*"|`[^`\n]*`)[\s;]*$/gm, "")
8031
+ // Remove named/default imports: import x from '/path'; import { x } from '/path';
8032
+ .replace(/^\s*import\b[^'"`\n]*\bfrom\s+(?:'[^'\n]*'|"[^"\n]*"|`[^`\n]*`)[\s;]*$/gm, "")
8033
+ // Remove re-exports: export * from '/path'; export { x } from '/path';
8034
+ .replace(/^\s*export\b[^'"`\n]*\bfrom\s+(?:'[^'\n]*'|"[^"\n]*"|`[^`\n]*`)[\s;]*$/gm, "")
8035
+ // Remove block comments
8036
+ .replace(/\/\*[\s\S]*?\*\//g, "")
8037
+ // Remove line comments
8038
+ .replace(/\/\/.*$/gm, "")
8039
+ // Remove "use strict" directives
8040
+ .replace(/["']use strict["']\s*;?/g, "").trim();
8041
+ return codeWithoutImports.length === 0;
8042
+ }
8043
+
8002
8044
  var SENTRY_SAAS_URL = "https://sentry.io";
8003
8045
  function normalizeUserOptions(userOptions) {
8004
8046
  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;
@@ -8299,7 +8341,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
8299
8341
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
8300
8342
  tracesSampleRate: 1,
8301
8343
  sampleRate: 1,
8302
- release: "4.6.2",
8344
+ release: "4.7.0",
8303
8345
  integrations: [],
8304
8346
  tracePropagationTargets: ["sentry.io/api"],
8305
8347
  stackParser: stackParser,
@@ -8908,7 +8950,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8908
8950
  });
8909
8951
 
8910
8952
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
8911
- process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.6.2");
8953
+ process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.7.0");
8912
8954
 
8913
8955
  // Propagate debug flag to Sentry CLI via environment variable
8914
8956
  // Only set if not already defined to respect user's explicit configuration
@@ -9276,14 +9318,14 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9276
9318
  scope: sentryScope,
9277
9319
  forceTransaction: true
9278
9320
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
9279
- var _options$debug, cliInstance;
9321
+ var _options$sourcemaps, cliInstance;
9280
9322
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
9281
9323
  while (1) switch (_context8.prev = _context8.next) {
9282
9324
  case 0:
9283
9325
  _context8.prev = 0;
9284
9326
  cliInstance = createCliInstance(options);
9285
9327
  _context8.next = 4;
9286
- return cliInstance.execute(["sourcemaps", "inject"].concat(_toConsumableArray(buildArtifactPaths)), (_options$debug = options.debug) !== null && _options$debug !== void 0 ? _options$debug : false);
9328
+ 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);
9287
9329
  case 4:
9288
9330
  _context8.next = 10;
9289
9331
  break;
@@ -9323,7 +9365,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9323
9365
  */
9324
9366
  uploadSourcemaps: function uploadSourcemaps(buildArtifactPaths, opts) {
9325
9367
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
9326
- var _options$sourcemaps;
9368
+ var _options$sourcemaps2;
9327
9369
  var assets;
9328
9370
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
9329
9371
  while (1) switch (_context19.prev = _context19.next) {
@@ -9335,7 +9377,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9335
9377
  return _context19.abrupt("return");
9336
9378
  case 2:
9337
9379
  // Early exit if assets is explicitly set to an empty array
9338
- assets = (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets;
9380
+ assets = (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.assets;
9339
9381
  if (!(Array.isArray(assets) && assets.length === 0)) {
9340
9382
  _context19.next = 6;
9341
9383
  break;
@@ -9352,7 +9394,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9352
9394
  forceTransaction: true
9353
9395
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
9354
9396
  var _opts$prepareArtifact;
9355
- var shouldPrepare, folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps2, _options$sourcemaps3, _options$sourcemaps4, _options$sourcemaps5, pathsToUpload, ignorePaths, globAssets, globResult, debugIdChunkFilePaths, tmpUploadFolder, _process$env2;
9397
+ var shouldPrepare, folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps3, _options$sourcemaps4, _options$sourcemaps5, _options$sourcemaps6, pathsToUpload, ignorePaths, globAssets, globResult, debugIdChunkFilePaths, tmpUploadFolder, _process$env2;
9356
9398
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
9357
9399
  while (1) switch (_context18.prev = _context18.next) {
9358
9400
  case 0:
@@ -9375,7 +9417,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9375
9417
  // Use original paths e.g. like ['.next/server'] directly –> preferred way when no globbing is done
9376
9418
  pathsToUpload = buildArtifactPaths;
9377
9419
  }
9378
- 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] : [];
9420
+ 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] : [];
9379
9421
  _context18.next = 8;
9380
9422
  return startSpan({
9381
9423
  name: "upload",
@@ -9422,7 +9464,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9422
9464
  name: "glob",
9423
9465
  scope: sentryScope
9424
9466
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
9425
- var _options$sourcemaps6;
9467
+ var _options$sourcemaps7;
9426
9468
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
9427
9469
  while (1) switch (_context11.prev = _context11.next) {
9428
9470
  case 0:
@@ -9431,7 +9473,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9431
9473
  absolute: true,
9432
9474
  nodir: true,
9433
9475
  // We need individual files for preparation
9434
- ignore: (_options$sourcemaps6 = options.sourcemaps) === null || _options$sourcemaps6 === void 0 ? void 0 : _options$sourcemaps6.ignore
9476
+ ignore: (_options$sourcemaps7 = options.sourcemaps) === null || _options$sourcemaps7 === void 0 ? void 0 : _options$sourcemaps7.ignore
9435
9477
  });
9436
9478
  case 2:
9437
9479
  return _context11.abrupt("return", _context11.sent);
@@ -9501,12 +9543,12 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9501
9543
  // instead we do it with a maximum of 16 concurrent workers
9502
9544
  preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
9503
9545
  return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
9504
- var _options$sourcemaps$r, _options$sourcemaps7, _options$sourcemaps8;
9546
+ var _options$sourcemaps$r, _options$sourcemaps8, _options$sourcemaps9;
9505
9547
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
9506
9548
  while (1) switch (_context13.prev = _context13.next) {
9507
9549
  case 0:
9508
9550
  _context13.next = 2;
9509
- 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);
9551
+ 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);
9510
9552
  case 2:
9511
9553
  case "end":
9512
9554
  return _context13.stop();
@@ -9669,13 +9711,13 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9669
9711
  */
9670
9712
  deleteArtifacts: function deleteArtifacts() {
9671
9713
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
9672
- var _options$sourcemaps9, filesToDelete, filePathsToDelete;
9714
+ var _options$sourcemaps10, filesToDelete, filePathsToDelete;
9673
9715
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
9674
9716
  while (1) switch (_context20.prev = _context20.next) {
9675
9717
  case 0:
9676
9718
  _context20.prev = 0;
9677
9719
  _context20.next = 3;
9678
- return (_options$sourcemaps9 = options.sourcemaps) === null || _options$sourcemaps9 === void 0 ? void 0 : _options$sourcemaps9.filesToDeleteAfterUpload;
9720
+ return (_options$sourcemaps10 = options.sourcemaps) === null || _options$sourcemaps10 === void 0 ? void 0 : _options$sourcemaps10.filesToDeleteAfterUpload;
9679
9721
  case 3:
9680
9722
  filesToDelete = _context20.sent;
9681
9723
  if (!(filesToDelete !== undefined)) {
@@ -9729,8 +9771,8 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9729
9771
  };
9730
9772
  }
9731
9773
  function canUploadSourceMaps(options, logger, isDevMode) {
9732
- var _options$sourcemaps10, _getProjects3;
9733
- if ((_options$sourcemaps10 = options.sourcemaps) !== null && _options$sourcemaps10 !== void 0 && _options$sourcemaps10.disable) {
9774
+ var _options$sourcemaps11, _getProjects3;
9775
+ if ((_options$sourcemaps11 = options.sourcemaps) !== null && _options$sourcemaps11 !== void 0 && _options$sourcemaps11.disable) {
9734
9776
  logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
9735
9777
  return false;
9736
9778
  }
@@ -9757,14 +9799,12 @@ function canUploadSourceMaps(options, logger, isDevMode) {
9757
9799
  * Creates an unplugin instance used to create Sentry plugins for Vite, Rollup, esbuild, and Webpack.
9758
9800
  */
9759
9801
  function sentryUnpluginFactory(_ref) {
9760
- var releaseInjectionPlugin = _ref.releaseInjectionPlugin,
9802
+ var injectionPlugin = _ref.injectionPlugin,
9761
9803
  componentNameAnnotatePlugin = _ref.componentNameAnnotatePlugin,
9762
- moduleMetadataInjectionPlugin = _ref.moduleMetadataInjectionPlugin,
9763
- debugIdInjectionPlugin = _ref.debugIdInjectionPlugin,
9764
9804
  debugIdUploadPlugin = _ref.debugIdUploadPlugin,
9765
9805
  bundleSizeOptimizationsPlugin = _ref.bundleSizeOptimizationsPlugin;
9766
9806
  return createUnplugin(function () {
9767
- var _userOptions$_metaOpt, _userOptions$_metaOpt2, _options$sourcemaps;
9807
+ var _userOptions$_metaOpt, _userOptions$_metaOpt2, _options$sourcemaps, _options$sourcemaps3;
9768
9808
  var userOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9769
9809
  var unpluginMetaContext = arguments.length > 1 ? arguments[1] : undefined;
9770
9810
  var sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {
@@ -9801,20 +9841,33 @@ function sentryUnpluginFactory(_ref) {
9801
9841
  if (Object.keys(bundleSizeOptimizationReplacementValues).length > 0) {
9802
9842
  plugins.push(bundleSizeOptimizationsPlugin(bundleSizeOptimizationReplacementValues));
9803
9843
  }
9844
+ var injectionCode = "";
9804
9845
  if (!options.release.inject) {
9805
9846
  logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
9806
9847
  } else if (!options.release.name) {
9807
9848
  logger.debug("No release name provided. Will not inject release. Please set the `release.name` option to identify your release.");
9808
9849
  } else {
9809
- var _injectionCode = generateGlobalInjectorCode({
9850
+ var _code = generateGlobalInjectorCode({
9810
9851
  release: options.release.name,
9811
9852
  injectBuildInformation: options._experiments.injectBuildInformation || false
9812
9853
  });
9813
- plugins.push(releaseInjectionPlugin(_injectionCode));
9854
+ if (typeof injectionPlugin !== "function") {
9855
+ plugins.push(injectionPlugin.releaseInjectionPlugin(_code));
9856
+ } else {
9857
+ injectionCode += _code;
9858
+ }
9814
9859
  }
9815
9860
  if (Object.keys(sentryBuildPluginManager.bundleMetadata).length > 0) {
9816
- var _injectionCode2 = generateModuleMetadataInjectorCode(sentryBuildPluginManager.bundleMetadata);
9817
- plugins.push(moduleMetadataInjectionPlugin(_injectionCode2));
9861
+ var _code2 = generateModuleMetadataInjectorCode(sentryBuildPluginManager.bundleMetadata);
9862
+ if (typeof injectionPlugin !== "function") {
9863
+ plugins.push(injectionPlugin.moduleMetadataInjectionPlugin(_code2));
9864
+ } else {
9865
+ injectionCode += _code2;
9866
+ }
9867
+ }
9868
+ if (typeof injectionPlugin === "function" && (injectionCode !== "" || ((_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.disable) !== true)) {
9869
+ var _options$sourcemaps2;
9870
+ plugins.push(injectionPlugin(injectionCode, ((_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.disable) !== true, logger));
9818
9871
  }
9819
9872
 
9820
9873
  // Add plugin to create and finalize releases, and also take care of adding commits and legacy sourcemaps
@@ -9841,10 +9894,12 @@ function sentryUnpluginFactory(_ref) {
9841
9894
  }))();
9842
9895
  }
9843
9896
  });
9844
- if (((_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.disable) !== true) {
9845
- var _options$sourcemaps2;
9846
- plugins.push(debugIdInjectionPlugin(logger));
9847
- if (((_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.disable) !== "disable-upload") {
9897
+ if (((_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.disable) !== true) {
9898
+ var _options$sourcemaps4;
9899
+ if (typeof injectionPlugin !== "function") {
9900
+ plugins.push(injectionPlugin.debugIdInjectionPlugin(logger));
9901
+ }
9902
+ if (((_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.disable) !== "disable-upload") {
9848
9903
  // This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
9849
9904
  var _webpack_forceExitOnBuildComplete = typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" ? options._experiments["forceExitOnBuildCompletion"] : undefined;
9850
9905
  plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
@@ -9923,6 +9978,9 @@ function isJsFile(fileName) {
9923
9978
  * HTML entry points create "facade" chunks that should not contain injected code.
9924
9979
  * See: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829
9925
9980
  *
9981
+ * However, in SPA mode, the main bundle also has an HTML facade but contains
9982
+ * substantial application code. We should NOT skip injection for these bundles.
9983
+ *
9926
9984
  * @param code - The chunk's code content
9927
9985
  * @param facadeModuleId - The facade module ID (if any) - HTML files create facade chunks
9928
9986
  * @returns true if the chunk should be skipped
@@ -9933,48 +9991,12 @@ function shouldSkipCodeInjection(code, facadeModuleId) {
9933
9991
  return true;
9934
9992
  }
9935
9993
 
9936
- // Skip HTML facade chunks
9937
- // They only contain import statements and should not have Sentry code injected
9994
+ // For HTML facade chunks, only skip if they contain only import statements
9938
9995
  if (facadeModuleId && stripQueryAndHashFromPath(facadeModuleId).endsWith(".html")) {
9939
- return true;
9996
+ return containsOnlyImports(code);
9940
9997
  }
9941
9998
  return false;
9942
9999
  }
9943
- function createRollupReleaseInjectionHooks(injectionCode) {
9944
- return {
9945
- renderChunk: function renderChunk(code, chunk) {
9946
- var _code$match;
9947
- if (!isJsFile(chunk.fileName)) {
9948
- return null; // returning null means not modifying the chunk at all
9949
- }
9950
-
9951
- // Skip empty chunks and HTML facade chunks (Vite MPA)
9952
- if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {
9953
- return null;
9954
- }
9955
- var ms = new MagicString(code, {
9956
- filename: chunk.fileName
9957
- });
9958
- var match = (_code$match = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match === void 0 ? void 0 : _code$match[0];
9959
- if (match) {
9960
- // Add injected code after any comments or "use strict" at the beginning of the bundle.
9961
- ms.appendLeft(match.length, injectionCode);
9962
- } else {
9963
- // ms.replace() doesn't work when there is an empty string match (which happens if
9964
- // there is neither, a comment, nor a "use strict" at the top of the chunk) so we
9965
- // need this special case here.
9966
- ms.prepend(injectionCode);
9967
- }
9968
- return {
9969
- code: ms.toString(),
9970
- map: ms.generateMap({
9971
- file: chunk.fileName,
9972
- hires: "boundary"
9973
- })
9974
- };
9975
- }
9976
- };
9977
- }
9978
10000
  function createRollupBundleSizeOptimizationHooks(replacementValues) {
9979
10001
  return {
9980
10002
  transform: function transform(code) {
@@ -9982,10 +10004,10 @@ function createRollupBundleSizeOptimizationHooks(replacementValues) {
9982
10004
  }
9983
10005
  };
9984
10006
  }
9985
- function createRollupDebugIdInjectionHooks() {
10007
+ function createRollupInjectionHooks(injectionCode, debugIds) {
9986
10008
  return {
9987
10009
  renderChunk: function renderChunk(code, chunk) {
9988
- var _code$match2;
10010
+ var _code$match;
9989
10011
  if (!isJsFile(chunk.fileName)) {
9990
10012
  return null; // returning null means not modifying the chunk at all
9991
10013
  }
@@ -9994,20 +10016,20 @@ function createRollupDebugIdInjectionHooks() {
9994
10016
  if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {
9995
10017
  return null;
9996
10018
  }
9997
-
9998
- // Check if a debug ID has already been injected to avoid duplicate injection (e.g. by another plugin or Sentry CLI)
9999
- var chunkStartSnippet = code.slice(0, 6000);
10000
- var chunkEndSnippet = code.slice(-500);
10001
- if (chunkStartSnippet.includes("_sentryDebugIdIdentifier") || chunkEndSnippet.includes("//# debugId=")) {
10002
- return null; // Debug ID already present, skip injection
10019
+ var codeToInject = injectionCode;
10020
+ if (debugIds) {
10021
+ // Check if a debug ID has already been injected to avoid duplicate injection (e.g. by another plugin or Sentry CLI)
10022
+ var chunkStartSnippet = code.slice(0, 6000);
10023
+ var chunkEndSnippet = code.slice(-500);
10024
+ if (!(chunkStartSnippet.includes("_sentryDebugIdIdentifier") || chunkEndSnippet.includes("//# debugId="))) {
10025
+ var debugId = stringToUUID(code); // generate a deterministic debug ID
10026
+ codeToInject += getDebugIdSnippet(debugId);
10027
+ }
10003
10028
  }
10004
-
10005
- var debugId = stringToUUID(code); // generate a deterministic debug ID
10006
- var codeToInject = getDebugIdSnippet(debugId);
10007
10029
  var ms = new MagicString(code, {
10008
10030
  filename: chunk.fileName
10009
10031
  });
10010
- var match = (_code$match2 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match2 === void 0 ? void 0 : _code$match2[0];
10032
+ var match = (_code$match = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match === void 0 ? void 0 : _code$match[0];
10011
10033
  if (match) {
10012
10034
  // Add injected code after any comments or "use strict" at the beginning of the bundle.
10013
10035
  ms.appendLeft(match.length, codeToInject);
@@ -10027,41 +10049,6 @@ function createRollupDebugIdInjectionHooks() {
10027
10049
  }
10028
10050
  };
10029
10051
  }
10030
- function createRollupModuleMetadataInjectionHooks(injectionCode) {
10031
- return {
10032
- renderChunk: function renderChunk(code, chunk) {
10033
- var _code$match3;
10034
- if (!isJsFile(chunk.fileName)) {
10035
- return null; // returning null means not modifying the chunk at all
10036
- }
10037
-
10038
- // Skip empty chunks and HTML facade chunks (Vite MPA)
10039
- if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {
10040
- return null;
10041
- }
10042
- var ms = new MagicString(code, {
10043
- filename: chunk.fileName
10044
- });
10045
- var match = (_code$match3 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match3 === void 0 ? void 0 : _code$match3[0];
10046
- if (match) {
10047
- // Add injected code after any comments or "use strict" at the beginning of the bundle.
10048
- ms.appendLeft(match.length, injectionCode);
10049
- } else {
10050
- // ms.replace() doesn't work when there is an empty string match (which happens if
10051
- // there is neither, a comment, nor a "use strict" at the top of the chunk) so we
10052
- // need this special case here.
10053
- ms.prepend(injectionCode);
10054
- }
10055
- return {
10056
- code: ms.toString(),
10057
- map: ms.generateMap({
10058
- file: chunk.fileName,
10059
- hires: "boundary"
10060
- })
10061
- };
10062
- }
10063
- };
10064
- }
10065
10052
  function createRollupDebugIdUploadHooks(upload, _logger, createDependencyOnBuildArtifacts) {
10066
10053
  var freeGlobalDependencyOnDebugIdSourcemapArtifacts = createDependencyOnBuildArtifacts();
10067
10054
  return {
@@ -10197,5 +10184,5 @@ function getDebugIdSnippet(debugId) {
10197
10184
  return ";{try{(function(){var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"".concat(debugId, "\",e._sentryDebugIdIdentifier=\"sentry-dbid-").concat(debugId, "\");})();}catch(e){}};");
10198
10185
  }
10199
10186
 
10200
- export { createComponentNameAnnotateHooks, createRollupBundleSizeOptimizationHooks, createRollupDebugIdInjectionHooks, createRollupDebugIdUploadHooks, createRollupModuleMetadataInjectionHooks, createRollupReleaseInjectionHooks, createSentryBuildPluginManager, getDebugIdSnippet, replaceBooleanFlagsInCode, sentryCliBinaryExists, sentryUnpluginFactory, stringToUUID };
10187
+ export { createComponentNameAnnotateHooks, createRollupBundleSizeOptimizationHooks, createRollupDebugIdUploadHooks, createRollupInjectionHooks, createSentryBuildPluginManager, getDebugIdSnippet, replaceBooleanFlagsInCode, sentryCliBinaryExists, sentryUnpluginFactory, stringToUUID };
10201
10188
  //# sourceMappingURL=index.mjs.map