@sentry/bundler-plugins 11.2.0 → 11.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const LIB_VERSION = "11.2.0";
3
+ const LIB_VERSION = "11.3.0";
4
4
 
5
5
  exports.LIB_VERSION = LIB_VERSION;
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.2.0\";\n"],"names":[],"mappings":";;AAAO,MAAM,WAAA,GAAc;;;;"}
1
+ {"version":3,"file":"version.js","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.3.0\";\n"],"names":[],"mappings":";;AAAO,MAAM,WAAA,GAAc;;;;"}
@@ -0,0 +1,53 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const utils = require('../core/utils.js');
4
+
5
+ const ROLLDOWN_DEBUG_ID_PLACEHOLDER = "SENTRY_DEBUG_ID_PLACEHOLDER_00000000";
6
+ const SENTRY_DEBUG_ID_IDENTIFIER = "_sentryDebugIdIdentifier";
7
+ const SENTRY_DEBUG_ID_IDENTIFIER_PREFIX = "sentry-dbid-";
8
+ function hasExistingDebugID(code) {
9
+ const chunkStartSnippet = code.slice(0, 6e3);
10
+ const chunkEndSnippet = code.slice(-500);
11
+ return chunkStartSnippet.includes(SENTRY_DEBUG_ID_IDENTIFIER) || chunkEndSnippet.includes("//# debugId=");
12
+ }
13
+ function getDebugIdForChunk(code, isRolldown) {
14
+ return isRolldown ? ROLLDOWN_DEBUG_ID_PLACEHOLDER : utils.stringToUUID(code);
15
+ }
16
+ function replaceAt(code, start, search, replacement) {
17
+ return `${code.slice(0, start)}${replacement}${code.slice(start + search.length)}`;
18
+ }
19
+ function finalizeRolldownDebugIds(bundle) {
20
+ for (const [fileName, output] of Object.entries(bundle)) {
21
+ if (output.type !== "chunk") {
22
+ continue;
23
+ }
24
+ const identifier = `${SENTRY_DEBUG_ID_IDENTIFIER_PREFIX}${ROLLDOWN_DEBUG_ID_PLACEHOLDER}`;
25
+ const identifierPropertyStart = output.code.indexOf(SENTRY_DEBUG_ID_IDENTIFIER);
26
+ const identifierStart = output.code.indexOf(
27
+ identifier,
28
+ identifierPropertyStart + SENTRY_DEBUG_ID_IDENTIFIER.length
29
+ );
30
+ if (identifierStart === -1) {
31
+ continue;
32
+ }
33
+ const identifierPlaceholderStart = identifierStart + SENTRY_DEBUG_ID_IDENTIFIER_PREFIX.length;
34
+ const debugIdsPlaceholderStart = output.code.lastIndexOf(ROLLDOWN_DEBUG_ID_PLACEHOLDER, identifierStart - 1);
35
+ if (debugIdsPlaceholderStart === -1) {
36
+ throw new Error(`Failed to locate the Sentry debug ID placeholder for chunk \`${fileName}\`.`);
37
+ }
38
+ const debugId = utils.stringToUUID(output.code);
39
+ const codeWithIdentifier = replaceAt(
40
+ output.code,
41
+ identifierPlaceholderStart,
42
+ ROLLDOWN_DEBUG_ID_PLACEHOLDER,
43
+ debugId
44
+ );
45
+ output.code = replaceAt(codeWithIdentifier, debugIdsPlaceholderStart, ROLLDOWN_DEBUG_ID_PLACEHOLDER, debugId);
46
+ }
47
+ }
48
+
49
+ exports.ROLLDOWN_DEBUG_ID_PLACEHOLDER = ROLLDOWN_DEBUG_ID_PLACEHOLDER;
50
+ exports.finalizeRolldownDebugIds = finalizeRolldownDebugIds;
51
+ exports.getDebugIdForChunk = getDebugIdForChunk;
52
+ exports.hasExistingDebugID = hasExistingDebugID;
53
+ //# sourceMappingURL=debug-id-injection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-id-injection.js","sources":["../../../src/rollup/debug-id-injection.ts"],"sourcesContent":["import { stringToUUID } from '../core';\n\nexport const ROLLDOWN_DEBUG_ID_PLACEHOLDER = 'SENTRY_DEBUG_ID_PLACEHOLDER_00000000';\n\ntype GeneratedChunk = {\n type: 'chunk';\n fileName: string;\n code: string;\n};\n\ntype GeneratedAsset = {\n type: 'asset';\n fileName: string;\n};\n\nexport type GeneratedBundle = Record<string, GeneratedChunk | GeneratedAsset>;\n\nconst SENTRY_DEBUG_ID_IDENTIFIER = '_sentryDebugIdIdentifier';\nconst SENTRY_DEBUG_ID_IDENTIFIER_PREFIX = 'sentry-dbid-';\n\nexport function hasExistingDebugID(code: string): boolean {\n const chunkStartSnippet = code.slice(0, 6000);\n const chunkEndSnippet = code.slice(-500);\n\n return chunkStartSnippet.includes(SENTRY_DEBUG_ID_IDENTIFIER) || chunkEndSnippet.includes('//# debugId=');\n}\n\nexport function getDebugIdForChunk(code: string, isRolldown: boolean): string {\n return isRolldown ? ROLLDOWN_DEBUG_ID_PLACEHOLDER : stringToUUID(code);\n}\n\nfunction replaceAt(code: string, start: number, search: string, replacement: string): string {\n return `${code.slice(0, start)}${replacement}${code.slice(start + search.length)}`;\n}\n\nexport function finalizeRolldownDebugIds(bundle: GeneratedBundle): void {\n for (const [fileName, output] of Object.entries(bundle)) {\n if (output.type !== 'chunk') {\n continue;\n }\n\n const identifier = `${SENTRY_DEBUG_ID_IDENTIFIER_PREFIX}${ROLLDOWN_DEBUG_ID_PLACEHOLDER}`;\n const identifierPropertyStart = output.code.indexOf(SENTRY_DEBUG_ID_IDENTIFIER);\n const identifierStart = output.code.indexOf(\n identifier,\n identifierPropertyStart + SENTRY_DEBUG_ID_IDENTIFIER.length,\n );\n if (identifierStart === -1) {\n continue;\n }\n\n const identifierPlaceholderStart = identifierStart + SENTRY_DEBUG_ID_IDENTIFIER_PREFIX.length;\n const debugIdsPlaceholderStart = output.code.lastIndexOf(ROLLDOWN_DEBUG_ID_PLACEHOLDER, identifierStart - 1);\n if (debugIdsPlaceholderStart === -1) {\n throw new Error(`Failed to locate the Sentry debug ID placeholder for chunk \\`${fileName}\\`.`);\n }\n\n // The fixed-width replacement happens after Rolldown computes [hash], so the emitted file name\n // still matches the placeholder-bearing chunk. Hashing only the code keeps byte-identical chunks\n // on one ID, as Rollup builds do.\n const debugId = stringToUUID(output.code);\n const codeWithIdentifier = replaceAt(\n output.code,\n identifierPlaceholderStart,\n ROLLDOWN_DEBUG_ID_PLACEHOLDER,\n debugId,\n );\n output.code = replaceAt(codeWithIdentifier, debugIdsPlaceholderStart, ROLLDOWN_DEBUG_ID_PLACEHOLDER, debugId);\n }\n}\n"],"names":["stringToUUID"],"mappings":";;;;AAEO,MAAM,6BAAA,GAAgC;AAe7C,MAAM,0BAAA,GAA6B,0BAAA;AACnC,MAAM,iCAAA,GAAoC,cAAA;AAEnC,SAAS,mBAAmB,IAAA,EAAuB;AACxD,EAAA,MAAM,iBAAA,GAAoB,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,GAAI,CAAA;AAC5C,EAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA;AAEvC,EAAA,OAAO,kBAAkB,QAAA,CAAS,0BAA0B,CAAA,IAAK,eAAA,CAAgB,SAAS,cAAc,CAAA;AAC1G;AAEO,SAAS,kBAAA,CAAmB,MAAc,UAAA,EAA6B;AAC5E,EAAA,OAAO,UAAA,GAAa,6BAAA,GAAgCA,kBAAA,CAAa,IAAI,CAAA;AACvE;AAEA,SAAS,SAAA,CAAU,IAAA,EAAc,KAAA,EAAe,MAAA,EAAgB,WAAA,EAA6B;AAC3F,EAAA,OAAO,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,KAAK,CAAC,CAAA,EAAG,WAAW,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,KAAA,GAAQ,MAAA,CAAO,MAAM,CAAC,CAAA,CAAA;AAClF;AAEO,SAAS,yBAAyB,MAAA,EAA+B;AACtE,EAAA,KAAA,MAAW,CAAC,QAAA,EAAU,MAAM,KAAK,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,EAAG;AACvD,IAAA,IAAI,MAAA,CAAO,SAAS,OAAA,EAAS;AAC3B,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,UAAA,GAAa,CAAA,EAAG,iCAAiC,CAAA,EAAG,6BAA6B,CAAA,CAAA;AACvF,IAAA,MAAM,uBAAA,GAA0B,MAAA,CAAO,IAAA,CAAK,OAAA,CAAQ,0BAA0B,CAAA;AAC9E,IAAA,MAAM,eAAA,GAAkB,OAAO,IAAA,CAAK,OAAA;AAAA,MAClC,UAAA;AAAA,MACA,0BAA0B,0BAAA,CAA2B;AAAA,KACvD;AACA,IAAA,IAAI,oBAAoB,EAAA,EAAI;AAC1B,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,0BAAA,GAA6B,kBAAkB,iCAAA,CAAkC,MAAA;AACvF,IAAA,MAAM,2BAA2B,MAAA,CAAO,IAAA,CAAK,WAAA,CAAY,6BAAA,EAA+B,kBAAkB,CAAC,CAAA;AAC3G,IAAA,IAAI,6BAA6B,EAAA,EAAI;AACnC,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,6DAAA,EAAgE,QAAQ,CAAA,GAAA,CAAK,CAAA;AAAA,IAC/F;AAKA,IAAA,MAAM,OAAA,GAAUA,kBAAA,CAAa,MAAA,CAAO,IAAI,CAAA;AACxC,IAAA,MAAM,kBAAA,GAAqB,SAAA;AAAA,MACzB,MAAA,CAAO,IAAA;AAAA,MACP,0BAAA;AAAA,MACA,6BAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,MAAA,CAAO,IAAA,GAAO,SAAA,CAAU,kBAAA,EAAoB,wBAAA,EAA0B,+BAA+B,OAAO,CAAA;AAAA,EAC9G;AACF;;;;;;;"}
@@ -0,0 +1,27 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const index = require('../core/index.js');
4
+ const debugIdUpload = require('../core/debug-id-upload.js');
5
+
6
+ function stampDebugIds(bundle, updateChunkCode) {
7
+ for (const output of Object.values(bundle)) {
8
+ if (output.type !== "chunk" || !index.isJsFile(output.fileName)) {
9
+ continue;
10
+ }
11
+ const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];
12
+ const sourceMapSource = sourceMapAsset?.type === "asset" && typeof sourceMapAsset.source === "string" ? sourceMapAsset.source : void 0;
13
+ const stamped = debugIdUpload.stampDebugId(output.code, sourceMapSource);
14
+ if (!stamped) {
15
+ continue;
16
+ }
17
+ if (updateChunkCode) {
18
+ output.code = stamped.bundleSource;
19
+ }
20
+ if (stamped.sourceMapSource !== void 0 && sourceMapAsset?.type === "asset") {
21
+ sourceMapAsset.source = stamped.sourceMapSource;
22
+ }
23
+ }
24
+ }
25
+
26
+ exports.stampDebugIds = stampDebugIds;
27
+ //# sourceMappingURL=debug-id-stamping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-id-stamping.js","sources":["../../../src/rollup/debug-id-stamping.ts"],"sourcesContent":["import { isJsFile, stampDebugId } from '../core';\n\n// The subset of Rollup's `OutputBundle` the stamping hooks read.\nexport type OutputBundle = Record<\n string,\n | { type: 'chunk'; fileName: string; code: string; sourcemapFileName?: string | null }\n | { type: 'asset'; fileName: string; source: string | Uint8Array }\n>;\n\nexport function stampDebugIds(bundle: OutputBundle, updateChunkCode: boolean): void {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];\n const sourceMapSource =\n sourceMapAsset?.type === 'asset' && typeof sourceMapAsset.source === 'string' ? sourceMapAsset.source : undefined;\n\n const stamped = stampDebugId(output.code, sourceMapSource);\n if (!stamped) {\n continue;\n }\n\n if (updateChunkCode) {\n output.code = stamped.bundleSource;\n }\n if (stamped.sourceMapSource !== undefined && sourceMapAsset?.type === 'asset') {\n sourceMapAsset.source = stamped.sourceMapSource;\n }\n }\n}\n"],"names":["isJsFile","stampDebugId"],"mappings":";;;;;AASO,SAAS,aAAA,CAAc,QAAsB,eAAA,EAAgC;AAClF,EAAA,KAAA,MAAW,MAAA,IAAU,MAAA,CAAO,MAAA,CAAO,MAAM,CAAA,EAAG;AAC1C,IAAA,IAAI,OAAO,IAAA,KAAS,OAAA,IAAW,CAACA,cAAA,CAAS,MAAA,CAAO,QAAQ,CAAA,EAAG;AACzD,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,iBAAiB,MAAA,CAAO,MAAA,CAAO,qBAAqB,CAAA,EAAG,MAAA,CAAO,QAAQ,CAAA,IAAA,CAAM,CAAA;AAClF,IAAA,MAAM,eAAA,GACJ,gBAAgB,IAAA,KAAS,OAAA,IAAW,OAAO,cAAA,CAAe,MAAA,KAAW,QAAA,GAAW,cAAA,CAAe,MAAA,GAAS,MAAA;AAE1G,IAAA,MAAM,OAAA,GAAUC,0BAAA,CAAa,MAAA,CAAO,IAAA,EAAM,eAAe,CAAA;AACzD,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,eAAA,EAAiB;AACnB,MAAA,MAAA,CAAO,OAAO,OAAA,CAAQ,YAAA;AAAA,IACxB;AACA,IAAA,IAAI,OAAA,CAAQ,eAAA,KAAoB,MAAA,IAAa,cAAA,EAAgB,SAAS,OAAA,EAAS;AAC7E,MAAA,cAAA,CAAe,SAAS,OAAA,CAAQ,eAAA;AAAA,IAClC;AAAA,EACF;AACF;;;;"}
@@ -4,12 +4,14 @@ const index = require('../core/index.js');
4
4
  const MagicString = require('magic-string');
5
5
  const path = require('node:path');
6
6
  const node_module = require('node:module');
7
+ const debugIdInjection = require('./debug-id-injection.js');
8
+ const debugIdStamping = require('./debug-id-stamping.js');
7
9
  const buildPluginManager = require('../core/build-plugin-manager.js');
8
10
  const utils = require('../core/utils.js');
9
11
  const componentAnnotateHooks = require('../core/component-annotate-hooks.js');
10
12
  const glob = require('../core/glob.js');
11
- const debugIdUpload = require('../core/debug-id-upload.js');
12
13
  const getCodeInjectionPosition = require('../core/get-code-injection-position.js');
14
+ const debugIdUpload = require('../core/debug-id-upload.js');
13
15
 
14
16
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
15
17
  const _interopDefault = e => e && e.__esModule ? e.default : e;
@@ -31,14 +33,6 @@ const path__namespace = /*#__PURE__*/_interopNamespace(path);
31
33
 
32
34
  let viteParseAstAsyncPromise;
33
35
  const JS_MODULE_ID_FILTER = /\.[cm]?[jt]sx?(?:[?#].*)?$/;
34
- function hasExistingDebugID(code) {
35
- const chunkStartSnippet = code.slice(0, 6e3);
36
- const chunkEndSnippet = code.slice(-500);
37
- if (chunkStartSnippet.includes("_sentryDebugIdIdentifier") || chunkEndSnippet.includes("//# debugId=")) {
38
- return true;
39
- }
40
- return false;
41
- }
42
36
  function getRollupMajorVersion() {
43
37
  try {
44
38
  const req = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('rollup/index.js', document.baseURI).href)));
@@ -142,8 +136,8 @@ function _rollupPluginInternal(userOptions = {}, buildTool, buildToolMajorVersio
142
136
  return null;
143
137
  }
144
138
  const injectCode = staticInjectionCode.clone();
145
- if (sourcemapsEnabled && !hasExistingDebugID(code)) {
146
- const debugId = utils.stringToUUID(code);
139
+ if (sourcemapsEnabled && !debugIdInjection.hasExistingDebugID(code)) {
140
+ const debugId = debugIdInjection.getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);
147
141
  injectCode.append(index.getDebugIdSnippet(debugId));
148
142
  }
149
143
  if (injectCode.isEmpty()) {
@@ -163,21 +157,13 @@ ${injectCode.code()}` : injectCode.code();
163
157
  };
164
158
  }
165
159
  function generateBundle(_outputOptions, bundle) {
166
- for (const output of Object.values(bundle)) {
167
- if (output.type !== "chunk" || !index.isJsFile(output.fileName)) {
168
- continue;
169
- }
170
- const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];
171
- const sourceMapSource = sourceMapAsset?.type === "asset" && typeof sourceMapAsset.source === "string" ? sourceMapAsset.source : void 0;
172
- const stamped = debugIdUpload.stampDebugId(output.code, sourceMapSource);
173
- if (!stamped) {
174
- continue;
175
- }
176
- output.code = stamped.bundleSource;
177
- if (stamped.sourceMapSource !== void 0 && sourceMapAsset?.type === "asset") {
178
- sourceMapAsset.source = stamped.sourceMapSource;
179
- }
160
+ if (this?.meta?.rolldownVersion) {
161
+ debugIdInjection.finalizeRolldownDebugIds(bundle);
162
+ }
163
+ if (options.sourcemaps?.disable !== "disable-upload") {
164
+ return;
180
165
  }
166
+ debugIdStamping.stampDebugIds(bundle, true);
181
167
  }
182
168
  async function writeBundle(outputOptions, bundle) {
183
169
  try {
@@ -217,7 +203,7 @@ ${injectCode.code()}` : injectCode.code();
217
203
  buildStart,
218
204
  ...shouldTransform ? { transform: transformHook } : {},
219
205
  renderChunk,
220
- ...options.sourcemaps?.disable === "disable-upload" ? { generateBundle: { order: "pre", handler: generateBundle } } : {},
206
+ generateBundle: { order: "pre", handler: generateBundle },
221
207
  writeBundle
222
208
  };
223
209
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/rollup/index.ts"],"sourcesContent":["import type { Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n stringToUUID,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\n stampDebugId,\n getCodeInjectionPosition,\n} from '../core';\nimport type { ComponentAnnotationTransformMeta } from '../core/component-annotation-oxc';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\n\n// The subset of Rollup's `TransformResult` that this plugin's `transform`\n// hook actually returns. Defined locally instead of imported from `rollup`\n// because `rollup` is an optional dependency.\ntype TransformResult = { code: string; map?: SourceMap | string | { mappings: string } | null } | null | undefined;\n\n// The subset of Rollup's `OutputBundle` the stamping hook reads.\ntype OutputBundle = Record<\n string,\n | { type: 'chunk'; fileName: string; code: string; sourcemapFileName?: string | null }\n | { type: 'asset'; fileName: string; source: string | Uint8Array }\n>;\n\ntype ViteModule = {\n parseAstAsync?: (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n};\n\ntype ViteParseAstAsync = NonNullable<ViteModule['parseAstAsync']>;\n\nlet viteParseAstAsyncPromise: Promise<ViteParseAstAsync | null> | undefined;\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\n\nfunction hasExistingDebugID(code: string): boolean {\n // Check if a debug ID has already been injected to avoid duplicate injection (e.g. by another plugin or Sentry CLI)\n const chunkStartSnippet = code.slice(0, 6000);\n const chunkEndSnippet = code.slice(-500);\n\n if (chunkStartSnippet.includes('_sentryDebugIdIdentifier') || chunkEndSnippet.includes('//# debugId=')) {\n return true; // Debug ID already present, skip injection\n }\n\n return false;\n}\n\nfunction getRollupMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const rollup = req('rollup') as { VERSION?: string };\n return rollup.VERSION?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nfunction getViteParseAstAsync(): Promise<ViteParseAstAsync | null> {\n if (!viteParseAstAsyncPromise) {\n viteParseAstAsyncPromise = Promise.resolve()\n .then(async () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Vite is an optional runtime peer for this package\n const viteModule = createRequire(import.meta.url)('vite') as ViteModule;\n\n if (typeof viteModule.parseAstAsync !== 'function') {\n return null;\n }\n\n try {\n await viteModule.parseAstAsync('const x = <div />;', { lang: 'tsx' });\n } catch {\n return null;\n }\n\n return viteModule.parseAstAsync;\n })\n .catch(() => null);\n }\n\n return viteParseAstAsyncPromise;\n}\n\n/**\n * @ignore - this is the internal plugin factory function only used for the Vite plugin!\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _rollupPluginInternal(\n userOptions: Options = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,\n buildTool,\n buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n name: 'sentry-noop-plugin',\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n {\n // Vite 8 already loads an oxc-based parser, so reuse it.\n getParseAstAsync: buildTool === 'vite' && buildToolMajorVersion === '8' ? getViteParseAstAsync : undefined,\n logger,\n },\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n const shouldTransform = transformAnnotations || transformReplace;\n\n function buildStart(): void {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n }\n\n async function transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<TransformResult> {\n // Component annotations are only in user code and boolean flag replacements are\n // only in Sentry code. If we successfully add annotations, we can return early.\n if (transformAnnotations) {\n const result = await transformAnnotations.transform(code, id, meta);\n if (result) {\n return result;\n }\n }\n\n if (transformReplace) {\n return replaceBooleanFlagsInCode(code, replacementValues);\n }\n\n return null;\n }\n\n function renderChunk(\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null },\n _?: unknown,\n meta?: { magicString?: MagicString },\n ): {\n code: string;\n map?: SourceMap;\n } | null {\n if (!isJsFile(chunk.fileName)) {\n return null; // returning null means not modifying the chunk at all\n }\n\n // Skip empty chunks and HTML facade chunks (Vite MPA)\n if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {\n return null;\n }\n\n const injectCode = staticInjectionCode.clone();\n\n if (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = stringToUUID(code); // generate a deterministic debug ID\n injectCode.append(getDebugIdSnippet(debugId));\n }\n\n if (injectCode.isEmpty()) {\n return null;\n }\n\n const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName });\n const injectionPosition = getCodeInjectionPosition(code);\n const codeToInject = injectionPosition === code.length ? `\\n${injectCode.code()}` : injectCode.code();\n ms.appendLeft(injectionPosition, codeToInject);\n\n // Rolldown can pass a native MagicString instance in meta.magicString\n // https://rolldown.rs/in-depth/native-magic-string#usage-examples\n if (ms?.constructor?.name === 'BindingMagicString') {\n // Rolldown docs say to return the magic string instance directly in this case\n return { code: ms as unknown as string };\n }\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' }),\n };\n }\n\n /**\n * Stamps debug IDs into the emitted chunks and source maps.\n *\n * `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted\n * artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the\n * comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final\n * assets afterwards (e.g. subresource integrity) see the stamped content.\n */\n function generateBundle(_outputOptions: unknown, bundle: OutputBundle): void {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];\n const sourceMapSource =\n sourceMapAsset?.type === 'asset' && typeof sourceMapAsset.source === 'string'\n ? sourceMapAsset.source\n : undefined;\n\n const stamped = stampDebugId(output.code, sourceMapSource);\n if (!stamped) {\n continue;\n }\n\n output.code = stamped.bundleSource;\n if (stamped.sourceMapSource !== undefined && sourceMapAsset?.type === 'asset') {\n sourceMapAsset.source = stamped.sourceMapSource;\n }\n }\n }\n\n async function writeBundle(\n outputOptions: { dir?: string; file?: string },\n bundle: { [fileName: string]: unknown },\n ): Promise<void> {\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n if (outputOptions.dir) {\n const outputDir = outputOptions.dir;\n const JS_AND_MAP_PATTERNS = [\n '/**/*.js',\n '/**/*.mjs',\n '/**/*.cjs',\n '/**/*.js.map',\n '/**/*.mjs.map',\n '/**/*.cjs.map',\n ].map(q => `${q}?(\\\\?*)?(#*)`); // We want to allow query and hash strings at the end of files\n const buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });\n await upload(buildArtifacts);\n } else if (outputOptions.file) {\n await upload([outputOptions.file]);\n } else {\n const buildArtifacts = Object.keys(bundle).map(asset => path.join(path.resolve(), asset));\n await upload(buildArtifacts);\n }\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n }\n\n const name = `sentry-${buildTool}-plugin`;\n const transformHook =\n buildTool === 'vite'\n ? {\n filter: { id: JS_MODULE_ID_FILTER },\n handler: transform,\n }\n : transform;\n\n return {\n name,\n buildStart,\n ...(shouldTransform ? { transform: transformHook } : {}),\n renderChunk,\n ...(options.sourcemaps?.disable === 'disable-upload'\n ? { generateBundle: { order: 'pre' as const, handler: generateBundle } }\n : {}),\n writeBundle,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-explicit-any\nexport function sentryRollupPlugin(userOptions: Options = {}): any {\n // We return an array here so we don't break backwards compatibility with what\n // unplugin used to return\n return [_rollupPluginInternal(userOptions, 'rollup')];\n}\n\nexport type { Options as SentryRollupPluginOptions } from '../core';\n"],"names":["createRequire","createSentryBuildPluginManager","createDebugIdUploadFunction","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","createComponentNameAnnotateHooks","replaceBooleanFlagsInCode","isJsFile","shouldSkipCodeInjection","stringToUUID","getDebugIdSnippet","MagicString","getCodeInjectionPosition","stampDebugId","globFiles","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAI,wBAAA;AAEJ,MAAM,mBAAA,GAAsB,4BAAA;AAE5B,SAAS,mBAAmB,IAAA,EAAuB;AAEjD,EAAA,MAAM,iBAAA,GAAoB,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,GAAI,CAAA;AAC5C,EAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA;AAEvC,EAAA,IAAI,kBAAkB,QAAA,CAAS,0BAA0B,KAAK,eAAA,CAAgB,QAAA,CAAS,cAAc,CAAA,EAAG;AACtG,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,qBAAA,GAA4C;AACnD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,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up/index.ts"],"sourcesContent":["import type { Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\n getCodeInjectionPosition,\n} from '../core';\nimport type { ComponentAnnotationTransformMeta } from '../core/component-annotation-oxc';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport { finalizeRolldownDebugIds, getDebugIdForChunk, hasExistingDebugID } from './debug-id-injection';\nimport { stampDebugIds, type OutputBundle } from './debug-id-stamping';\n\n// The subset of Rollup's `TransformResult` that this plugin's `transform`\n// hook actually returns. Defined locally instead of imported from `rollup`\n// because `rollup` is an optional dependency.\ntype TransformResult = { code: string; map?: SourceMap | string | { mappings: string } | null } | null | undefined;\n\ntype ViteModule = {\n parseAstAsync?: (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n};\n\ntype ViteParseAstAsync = NonNullable<ViteModule['parseAstAsync']>;\n\nlet viteParseAstAsyncPromise: Promise<ViteParseAstAsync | null> | undefined;\n\n// Rolldown sets `meta.rolldownVersion` on the plugin context.\ntype PluginContext = { meta?: { rolldownVersion?: string } };\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\n\nfunction getRollupMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const rollup = req('rollup') as { VERSION?: string };\n return rollup.VERSION?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nfunction getViteParseAstAsync(): Promise<ViteParseAstAsync | null> {\n if (!viteParseAstAsyncPromise) {\n viteParseAstAsyncPromise = Promise.resolve()\n .then(async () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Vite is an optional runtime peer for this package\n const viteModule = createRequire(import.meta.url)('vite') as ViteModule;\n\n if (typeof viteModule.parseAstAsync !== 'function') {\n return null;\n }\n\n try {\n await viteModule.parseAstAsync('const x = <div />;', { lang: 'tsx' });\n } catch {\n return null;\n }\n\n return viteModule.parseAstAsync;\n })\n .catch(() => null);\n }\n\n return viteParseAstAsyncPromise;\n}\n\n/**\n * @ignore - this is the internal plugin factory function only used for the Vite plugin!\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _rollupPluginInternal(\n userOptions: Options = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,\n buildTool,\n buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n name: 'sentry-noop-plugin',\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n {\n // Vite 8 already loads an oxc-based parser, so reuse it.\n getParseAstAsync: buildTool === 'vite' && buildToolMajorVersion === '8' ? getViteParseAstAsync : undefined,\n logger,\n },\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n const shouldTransform = transformAnnotations || transformReplace;\n\n function buildStart(): void {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n }\n\n async function transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<TransformResult> {\n // Component annotations are only in user code and boolean flag replacements are\n // only in Sentry code. If we successfully add annotations, we can return early.\n if (transformAnnotations) {\n const result = await transformAnnotations.transform(code, id, meta);\n if (result) {\n return result;\n }\n }\n\n if (transformReplace) {\n return replaceBooleanFlagsInCode(code, replacementValues);\n }\n\n return null;\n }\n\n function renderChunk(\n this: PluginContext | undefined,\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null },\n _?: unknown,\n meta?: { magicString?: MagicString },\n ): {\n code: string;\n map?: SourceMap;\n } | null {\n if (!isJsFile(chunk.fileName)) {\n return null; // returning null means not modifying the chunk at all\n }\n\n // Skip empty chunks and HTML facade chunks (Vite MPA)\n if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {\n return null;\n }\n\n const injectCode = staticInjectionCode.clone();\n\n if (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);\n injectCode.append(getDebugIdSnippet(debugId));\n }\n\n if (injectCode.isEmpty()) {\n return null;\n }\n\n const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName });\n const injectionPosition = getCodeInjectionPosition(code);\n const codeToInject = injectionPosition === code.length ? `\\n${injectCode.code()}` : injectCode.code();\n ms.appendLeft(injectionPosition, codeToInject);\n\n // Rolldown can pass a native MagicString instance in meta.magicString\n // https://rolldown.rs/in-depth/native-magic-string#usage-examples\n if (ms?.constructor?.name === 'BindingMagicString') {\n // Rolldown docs say to return the magic string instance directly in this case\n return { code: ms as unknown as string };\n }\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' }),\n };\n }\n\n /**\n * Resolves Rolldown's placeholder debug IDs, then stamps debug IDs into the emitted chunks and\n * source maps.\n *\n * `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted\n * artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the\n * comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final\n * assets afterwards (e.g. subresource integrity) see the stamped content.\n */\n function generateBundle(this: PluginContext | undefined, _outputOptions: unknown, bundle: OutputBundle): void {\n if (this?.meta?.rolldownVersion) {\n finalizeRolldownDebugIds(bundle);\n }\n\n if (options.sourcemaps?.disable !== 'disable-upload') {\n return;\n }\n\n stampDebugIds(bundle, true);\n }\n\n async function writeBundle(\n outputOptions: { dir?: string; file?: string },\n bundle: { [fileName: string]: unknown },\n ): Promise<void> {\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n if (outputOptions.dir) {\n const outputDir = outputOptions.dir;\n const JS_AND_MAP_PATTERNS = [\n '/**/*.js',\n '/**/*.mjs',\n '/**/*.cjs',\n '/**/*.js.map',\n '/**/*.mjs.map',\n '/**/*.cjs.map',\n ].map(q => `${q}?(\\\\?*)?(#*)`); // We want to allow query and hash strings at the end of files\n const buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });\n await upload(buildArtifacts);\n } else if (outputOptions.file) {\n await upload([outputOptions.file]);\n } else {\n const buildArtifacts = Object.keys(bundle).map(asset => path.join(path.resolve(), asset));\n await upload(buildArtifacts);\n }\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n }\n\n const name = `sentry-${buildTool}-plugin`;\n const transformHook =\n buildTool === 'vite'\n ? {\n filter: { id: JS_MODULE_ID_FILTER },\n handler: transform,\n }\n : transform;\n\n return {\n name,\n buildStart,\n ...(shouldTransform ? { transform: transformHook } : {}),\n renderChunk,\n generateBundle: { order: 'pre' as const, handler: generateBundle },\n writeBundle,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-explicit-any\nexport function sentryRollupPlugin(userOptions: Options = {}): any {\n // We return an array here so we don't break backwards compatibility with what\n // unplugin used to return\n return [_rollupPluginInternal(userOptions, 'rollup')];\n}\n\nexport type { Options as SentryRollupPluginOptions } from '../core';\n"],"names":["createRequire","createSentryBuildPluginManager","createDebugIdUploadFunction","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","createComponentNameAnnotateHooks","replaceBooleanFlagsInCode","isJsFile","shouldSkipCodeInjection","hasExistingDebugID","getDebugIdForChunk","getDebugIdSnippet","MagicString","getCodeInjectionPosition","finalizeRolldownDebugIds","stampDebugIds","globFiles","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAI,wBAAA;AAKJ,MAAM,mBAAA,GAAsB,4BAAA;AAE5B,SAAS,qBAAA,GAA4C;AACnD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAMA,yBAAA,CAAc,iQAAe,CAAA;AACzC,IAAA,MAAM,MAAA,GAAS,IAAI,QAAQ,CAAA;AAC3B,IAAA,OAAO,MAAA,CAAO,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACrC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,oBAAA,GAA0D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AA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,GAAI,eAAA,GAAkB,EAAE,SAAA,EAAW,aAAA,KAAkB,EAAC;AAAA,IACtD,WAAA;AAAA,IACA,cAAA,EAAgB,EAAE,KAAA,EAAO,KAAA,EAAgB,SAAS,cAAA,EAAe;AAAA,IACjE;AAAA,GACF;AACF;AAGO,SAAS,kBAAA,CAAmB,WAAA,GAAuB,EAAC,EAAQ;AAGjE,EAAA,OAAO,CAAC,qBAAA,CAAsB,WAAA,EAAa,QAAQ,CAAC,CAAA;AACtD;;;;;"}
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const index = require('../rollup/index.js');
4
4
  const node_module = require('node:module');
5
+ const debugIdStamping = require('../rollup/debug-id-stamping.js');
5
6
 
6
7
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
7
8
  function getViteMajorVersion() {
@@ -14,12 +15,25 @@ function getViteMajorVersion() {
14
15
  return void 0;
15
16
  }
16
17
  const sentryVitePlugin = (options) => {
17
- return [
18
+ const plugins = [
18
19
  {
19
20
  enforce: "pre",
20
21
  ...index._rollupPluginInternal(options, "vite", getViteMajorVersion())
21
22
  }
22
23
  ];
24
+ if (!options?.disable && options?.sourcemaps?.disable === "disable-upload") {
25
+ plugins.push({
26
+ name: "sentry-vite-debug-id-sourcemaps",
27
+ enforce: "post",
28
+ generateBundle: {
29
+ order: "post",
30
+ handler(_outputOptions, bundle) {
31
+ debugIdStamping.stampDebugIds(bundle, false);
32
+ }
33
+ }
34
+ });
35
+ }
36
+ return plugins;
23
37
  };
24
38
 
25
39
  exports.sentryVitePlugin = sentryVitePlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/vite/index.ts"],"sourcesContent":["import type { SentryRollupPluginOptions } from '../rollup';\nimport { _rollupPluginInternal } from '../rollup';\nimport { createRequire } from 'node:module';\n\ninterface SentryVitePlugin {\n name: string;\n enforce: 'pre';\n}\n\nfunction getViteMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const vite = req('vite') as { version?: string };\n return vite.version?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nexport const sentryVitePlugin = (options?: SentryRollupPluginOptions): SentryVitePlugin[] => {\n return [\n {\n enforce: 'pre',\n ..._rollupPluginInternal(options, 'vite', getViteMajorVersion()),\n },\n ];\n};\n\nexport type { Options as SentryVitePluginOptions } from '../core';\n"],"names":["createRequire","_rollupPluginInternal"],"mappings":";;;;;;AASA,SAAS,mBAAA,GAA0C;AACjD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAMA,yBAAA,CAAc,+PAAe,CAAA;AACzC,IAAA,MAAM,IAAA,GAAO,IAAI,MAAM,CAAA;AACvB,IAAA,OAAO,IAAA,CAAK,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACnC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEO,MAAM,gBAAA,GAAmB,CAAC,OAAA,KAA4D;AAC3F,EAAA,OAAO;AAAA,IACL;AAAA,MACE,OAAA,EAAS,KAAA;AAAA,MACT,GAAGC,2BAAA,CAAsB,OAAA,EAAS,MAAA,EAAQ,qBAAqB;AAAA;AACjE,GACF;AACF;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/vite/index.ts"],"sourcesContent":["import type { SentryRollupPluginOptions } from '../rollup';\nimport { _rollupPluginInternal } from '../rollup';\nimport { createRequire } from 'node:module';\nimport { stampDebugIds, type OutputBundle } from '../rollup/debug-id-stamping';\n\ninterface SentryVitePlugin {\n name: string;\n enforce: 'pre' | 'post';\n generateBundle?: {\n order: 'pre' | 'post';\n handler: (_outputOptions: unknown, bundle: OutputBundle) => void;\n };\n}\n\nfunction getViteMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const vite = req('vite') as { version?: string };\n return vite.version?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nexport const sentryVitePlugin = (options?: SentryRollupPluginOptions): SentryVitePlugin[] => {\n const plugins: SentryVitePlugin[] = [\n {\n enforce: 'pre',\n ..._rollupPluginInternal(options, 'vite', getViteMajorVersion()),\n },\n ];\n\n if (!options?.disable && options?.sourcemaps?.disable === 'disable-upload') {\n plugins.push({\n name: 'sentry-vite-debug-id-sourcemaps',\n enforce: 'post',\n generateBundle: {\n order: 'post',\n handler(_outputOptions, bundle) {\n // Vite's module preload rewrite in `generateBundle` regenerates the source map of every\n // chunk with a dynamic import, which drops the debug ID the main plugin stamped in its\n // `pre` hook. Restore it without touching the chunk code, so file hashes stay valid.\n stampDebugIds(bundle, false);\n },\n },\n });\n }\n\n return plugins;\n};\n\nexport type { Options as SentryVitePluginOptions } from '../core';\n"],"names":["createRequire","_rollupPluginInternal","stampDebugIds"],"mappings":";;;;;;;AAcA,SAAS,mBAAA,GAA0C;AACjD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAMA,yBAAA,CAAc,+PAAe,CAAA;AACzC,IAAA,MAAM,IAAA,GAAO,IAAI,MAAM,CAAA;AACvB,IAAA,OAAO,IAAA,CAAK,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACnC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEO,MAAM,gBAAA,GAAmB,CAAC,OAAA,KAA4D;AAC3F,EAAA,MAAM,OAAA,GAA8B;AAAA,IAClC;AAAA,MACE,OAAA,EAAS,KAAA;AAAA,MACT,GAAGC,2BAAA,CAAsB,OAAA,EAAS,MAAA,EAAQ,qBAAqB;AAAA;AACjE,GACF;AAEA,EAAA,IAAI,CAAC,OAAA,EAAS,OAAA,IAAW,OAAA,EAAS,UAAA,EAAY,YAAY,gBAAA,EAAkB;AAC1E,IAAA,OAAA,CAAQ,IAAA,CAAK;AAAA,MACX,IAAA,EAAM,iCAAA;AAAA,MACN,OAAA,EAAS,MAAA;AAAA,MACT,cAAA,EAAgB;AAAA,QACd,KAAA,EAAO,MAAA;AAAA,QACP,OAAA,CAAQ,gBAAgB,MAAA,EAAQ;AAI9B,UAAAC,6BAAA,CAAc,QAAQ,KAAK,CAAA;AAAA,QAC7B;AAAA;AACF,KACD,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,OAAA;AACT;;;;"}
@@ -1,4 +1,4 @@
1
- const LIB_VERSION = "11.2.0";
1
+ const LIB_VERSION = "11.3.0";
2
2
 
3
3
  export { LIB_VERSION };
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.2.0\";\n"],"names":[],"mappings":"AAAO,MAAM,WAAA,GAAc;;;;"}
1
+ {"version":3,"file":"version.js","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.3.0\";\n"],"names":[],"mappings":"AAAO,MAAM,WAAA,GAAc;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"11.2.0","sideEffects":["./sentry-release-injection-file.js","./sentry-esbuild-debugid-injection-file.js"]}
1
+ {"type":"module","version":"11.3.0","sideEffects":["./sentry-release-injection-file.js","./sentry-esbuild-debugid-injection-file.js"]}
@@ -0,0 +1,48 @@
1
+ import { stringToUUID } from '../core/utils.js';
2
+
3
+ const ROLLDOWN_DEBUG_ID_PLACEHOLDER = "SENTRY_DEBUG_ID_PLACEHOLDER_00000000";
4
+ const SENTRY_DEBUG_ID_IDENTIFIER = "_sentryDebugIdIdentifier";
5
+ const SENTRY_DEBUG_ID_IDENTIFIER_PREFIX = "sentry-dbid-";
6
+ function hasExistingDebugID(code) {
7
+ const chunkStartSnippet = code.slice(0, 6e3);
8
+ const chunkEndSnippet = code.slice(-500);
9
+ return chunkStartSnippet.includes(SENTRY_DEBUG_ID_IDENTIFIER) || chunkEndSnippet.includes("//# debugId=");
10
+ }
11
+ function getDebugIdForChunk(code, isRolldown) {
12
+ return isRolldown ? ROLLDOWN_DEBUG_ID_PLACEHOLDER : stringToUUID(code);
13
+ }
14
+ function replaceAt(code, start, search, replacement) {
15
+ return `${code.slice(0, start)}${replacement}${code.slice(start + search.length)}`;
16
+ }
17
+ function finalizeRolldownDebugIds(bundle) {
18
+ for (const [fileName, output] of Object.entries(bundle)) {
19
+ if (output.type !== "chunk") {
20
+ continue;
21
+ }
22
+ const identifier = `${SENTRY_DEBUG_ID_IDENTIFIER_PREFIX}${ROLLDOWN_DEBUG_ID_PLACEHOLDER}`;
23
+ const identifierPropertyStart = output.code.indexOf(SENTRY_DEBUG_ID_IDENTIFIER);
24
+ const identifierStart = output.code.indexOf(
25
+ identifier,
26
+ identifierPropertyStart + SENTRY_DEBUG_ID_IDENTIFIER.length
27
+ );
28
+ if (identifierStart === -1) {
29
+ continue;
30
+ }
31
+ const identifierPlaceholderStart = identifierStart + SENTRY_DEBUG_ID_IDENTIFIER_PREFIX.length;
32
+ const debugIdsPlaceholderStart = output.code.lastIndexOf(ROLLDOWN_DEBUG_ID_PLACEHOLDER, identifierStart - 1);
33
+ if (debugIdsPlaceholderStart === -1) {
34
+ throw new Error(`Failed to locate the Sentry debug ID placeholder for chunk \`${fileName}\`.`);
35
+ }
36
+ const debugId = stringToUUID(output.code);
37
+ const codeWithIdentifier = replaceAt(
38
+ output.code,
39
+ identifierPlaceholderStart,
40
+ ROLLDOWN_DEBUG_ID_PLACEHOLDER,
41
+ debugId
42
+ );
43
+ output.code = replaceAt(codeWithIdentifier, debugIdsPlaceholderStart, ROLLDOWN_DEBUG_ID_PLACEHOLDER, debugId);
44
+ }
45
+ }
46
+
47
+ export { ROLLDOWN_DEBUG_ID_PLACEHOLDER, finalizeRolldownDebugIds, getDebugIdForChunk, hasExistingDebugID };
48
+ //# sourceMappingURL=debug-id-injection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-id-injection.js","sources":["../../../src/rollup/debug-id-injection.ts"],"sourcesContent":["import { stringToUUID } from '../core';\n\nexport const ROLLDOWN_DEBUG_ID_PLACEHOLDER = 'SENTRY_DEBUG_ID_PLACEHOLDER_00000000';\n\ntype GeneratedChunk = {\n type: 'chunk';\n fileName: string;\n code: string;\n};\n\ntype GeneratedAsset = {\n type: 'asset';\n fileName: string;\n};\n\nexport type GeneratedBundle = Record<string, GeneratedChunk | GeneratedAsset>;\n\nconst SENTRY_DEBUG_ID_IDENTIFIER = '_sentryDebugIdIdentifier';\nconst SENTRY_DEBUG_ID_IDENTIFIER_PREFIX = 'sentry-dbid-';\n\nexport function hasExistingDebugID(code: string): boolean {\n const chunkStartSnippet = code.slice(0, 6000);\n const chunkEndSnippet = code.slice(-500);\n\n return chunkStartSnippet.includes(SENTRY_DEBUG_ID_IDENTIFIER) || chunkEndSnippet.includes('//# debugId=');\n}\n\nexport function getDebugIdForChunk(code: string, isRolldown: boolean): string {\n return isRolldown ? ROLLDOWN_DEBUG_ID_PLACEHOLDER : stringToUUID(code);\n}\n\nfunction replaceAt(code: string, start: number, search: string, replacement: string): string {\n return `${code.slice(0, start)}${replacement}${code.slice(start + search.length)}`;\n}\n\nexport function finalizeRolldownDebugIds(bundle: GeneratedBundle): void {\n for (const [fileName, output] of Object.entries(bundle)) {\n if (output.type !== 'chunk') {\n continue;\n }\n\n const identifier = `${SENTRY_DEBUG_ID_IDENTIFIER_PREFIX}${ROLLDOWN_DEBUG_ID_PLACEHOLDER}`;\n const identifierPropertyStart = output.code.indexOf(SENTRY_DEBUG_ID_IDENTIFIER);\n const identifierStart = output.code.indexOf(\n identifier,\n identifierPropertyStart + SENTRY_DEBUG_ID_IDENTIFIER.length,\n );\n if (identifierStart === -1) {\n continue;\n }\n\n const identifierPlaceholderStart = identifierStart + SENTRY_DEBUG_ID_IDENTIFIER_PREFIX.length;\n const debugIdsPlaceholderStart = output.code.lastIndexOf(ROLLDOWN_DEBUG_ID_PLACEHOLDER, identifierStart - 1);\n if (debugIdsPlaceholderStart === -1) {\n throw new Error(`Failed to locate the Sentry debug ID placeholder for chunk \\`${fileName}\\`.`);\n }\n\n // The fixed-width replacement happens after Rolldown computes [hash], so the emitted file name\n // still matches the placeholder-bearing chunk. Hashing only the code keeps byte-identical chunks\n // on one ID, as Rollup builds do.\n const debugId = stringToUUID(output.code);\n const codeWithIdentifier = replaceAt(\n output.code,\n identifierPlaceholderStart,\n ROLLDOWN_DEBUG_ID_PLACEHOLDER,\n debugId,\n );\n output.code = replaceAt(codeWithIdentifier, debugIdsPlaceholderStart, ROLLDOWN_DEBUG_ID_PLACEHOLDER, debugId);\n }\n}\n"],"names":[],"mappings":";;AAEO,MAAM,6BAAA,GAAgC;AAe7C,MAAM,0BAAA,GAA6B,0BAAA;AACnC,MAAM,iCAAA,GAAoC,cAAA;AAEnC,SAAS,mBAAmB,IAAA,EAAuB;AACxD,EAAA,MAAM,iBAAA,GAAoB,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,GAAI,CAAA;AAC5C,EAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA;AAEvC,EAAA,OAAO,kBAAkB,QAAA,CAAS,0BAA0B,CAAA,IAAK,eAAA,CAAgB,SAAS,cAAc,CAAA;AAC1G;AAEO,SAAS,kBAAA,CAAmB,MAAc,UAAA,EAA6B;AAC5E,EAAA,OAAO,UAAA,GAAa,6BAAA,GAAgC,YAAA,CAAa,IAAI,CAAA;AACvE;AAEA,SAAS,SAAA,CAAU,IAAA,EAAc,KAAA,EAAe,MAAA,EAAgB,WAAA,EAA6B;AAC3F,EAAA,OAAO,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,KAAK,CAAC,CAAA,EAAG,WAAW,CAAA,EAAG,IAAA,CAAK,KAA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 -0,0 +1,25 @@
1
+ import { isJsFile } from '../core/index.js';
2
+ import { stampDebugId } from '../core/debug-id-upload.js';
3
+
4
+ function stampDebugIds(bundle, updateChunkCode) {
5
+ for (const output of Object.values(bundle)) {
6
+ if (output.type !== "chunk" || !isJsFile(output.fileName)) {
7
+ continue;
8
+ }
9
+ const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];
10
+ const sourceMapSource = sourceMapAsset?.type === "asset" && typeof sourceMapAsset.source === "string" ? sourceMapAsset.source : void 0;
11
+ const stamped = stampDebugId(output.code, sourceMapSource);
12
+ if (!stamped) {
13
+ continue;
14
+ }
15
+ if (updateChunkCode) {
16
+ output.code = stamped.bundleSource;
17
+ }
18
+ if (stamped.sourceMapSource !== void 0 && sourceMapAsset?.type === "asset") {
19
+ sourceMapAsset.source = stamped.sourceMapSource;
20
+ }
21
+ }
22
+ }
23
+
24
+ export { stampDebugIds };
25
+ //# sourceMappingURL=debug-id-stamping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-id-stamping.js","sources":["../../../src/rollup/debug-id-stamping.ts"],"sourcesContent":["import { isJsFile, stampDebugId } from '../core';\n\n// The subset of Rollup's `OutputBundle` the stamping hooks read.\nexport type OutputBundle = Record<\n string,\n | { type: 'chunk'; fileName: string; code: string; sourcemapFileName?: string | null }\n | { type: 'asset'; fileName: string; source: string | Uint8Array }\n>;\n\nexport function stampDebugIds(bundle: OutputBundle, updateChunkCode: boolean): void {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];\n const sourceMapSource =\n sourceMapAsset?.type === 'asset' && typeof sourceMapAsset.source === 'string' ? sourceMapAsset.source : undefined;\n\n const stamped = stampDebugId(output.code, sourceMapSource);\n if (!stamped) {\n continue;\n }\n\n if (updateChunkCode) {\n output.code = stamped.bundleSource;\n }\n if (stamped.sourceMapSource !== undefined && sourceMapAsset?.type === 'asset') {\n sourceMapAsset.source = stamped.sourceMapSource;\n }\n }\n}\n"],"names":[],"mappings":";;;AASO,SAAS,aAAA,CAAc,QAAsB,eAAA,EAAgC;AAClF,EAAA,KAAA,MAAW,MAAA,IAAU,MAAA,CAAO,MAAA,CAAO,MAAM,CAAA,EAAG;AAC1C,IAAA,IAAI,OAAO,IAAA,KAAS,OAAA,IAAW,CAAC,QAAA,CAAS,MAAA,CAAO,QAAQ,CAAA,EAAG;AACzD,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,iBAAiB,MAAA,CAAO,MAAA,CAAO,qBAAqB,CAAA,EAAG,MAAA,CAAO,QAAQ,CAAA,IAAA,CAAM,CAAA;AAClF,IAAA,MAAM,eAAA,GACJ,gBAAgB,IAAA,KAAS,OAAA,IAAW,OAAO,cAAA,CAAe,MAAA,KAAW,QAAA,GAAW,cAAA,CAAe,MAAA,GAAS,MAAA;AAE1G,IAAA,MAAM,OAAA,GAAU,YAAA,CAAa,MAAA,CAAO,IAAA,EAAM,eAAe,CAAA;AACzD,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,eAAA,EAAiB;AACnB,MAAA,MAAA,CAAO,OAAO,OAAA,CAAQ,YAAA;AAAA,IACxB;AACA,IAAA,IAAI,OAAA,CAAQ,eAAA,KAAoB,MAAA,IAAa,cAAA,EAAgB,SAAS,OAAA,EAAS;AAC7E,MAAA,cAAA,CAAe,SAAS,OAAA,CAAQ,eAAA;AAAA,IAClC;AAAA,EACF;AACF;;;;"}
@@ -2,23 +2,17 @@ import { isJsFile, shouldSkipCodeInjection, getDebugIdSnippet } from '../core/in
2
2
  import MagicString from 'magic-string';
3
3
  import * as path from 'node:path';
4
4
  import { createRequire } from 'node:module';
5
+ import { finalizeRolldownDebugIds, hasExistingDebugID, getDebugIdForChunk } from './debug-id-injection.js';
6
+ import { stampDebugIds } from './debug-id-stamping.js';
5
7
  import { createSentryBuildPluginManager } from '../core/build-plugin-manager.js';
6
- import { CodeInjection, generateReleaseInjectorCode, generateModuleMetadataInjectorCode, stringToUUID, replaceBooleanFlagsInCode } from '../core/utils.js';
8
+ import { CodeInjection, generateReleaseInjectorCode, generateModuleMetadataInjectorCode, replaceBooleanFlagsInCode } from '../core/utils.js';
7
9
  import { createComponentNameAnnotateHooks } from '../core/component-annotate-hooks.js';
8
10
  import { globFiles } from '../core/glob.js';
9
- import { stampDebugId, createDebugIdUploadFunction } from '../core/debug-id-upload.js';
10
11
  import { getCodeInjectionPosition } from '../core/get-code-injection-position.js';
12
+ import { createDebugIdUploadFunction } from '../core/debug-id-upload.js';
11
13
 
12
14
  let viteParseAstAsyncPromise;
13
15
  const JS_MODULE_ID_FILTER = /\.[cm]?[jt]sx?(?:[?#].*)?$/;
14
- function hasExistingDebugID(code) {
15
- const chunkStartSnippet = code.slice(0, 6e3);
16
- const chunkEndSnippet = code.slice(-500);
17
- if (chunkStartSnippet.includes("_sentryDebugIdIdentifier") || chunkEndSnippet.includes("//# debugId=")) {
18
- return true;
19
- }
20
- return false;
21
- }
22
16
  function getRollupMajorVersion() {
23
17
  try {
24
18
  const req = createRequire(import.meta.url);
@@ -123,7 +117,7 @@ function _rollupPluginInternal(userOptions = {}, buildTool, buildToolMajorVersio
123
117
  }
124
118
  const injectCode = staticInjectionCode.clone();
125
119
  if (sourcemapsEnabled && !hasExistingDebugID(code)) {
126
- const debugId = stringToUUID(code);
120
+ const debugId = getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);
127
121
  injectCode.append(getDebugIdSnippet(debugId));
128
122
  }
129
123
  if (injectCode.isEmpty()) {
@@ -143,21 +137,13 @@ ${injectCode.code()}` : injectCode.code();
143
137
  };
144
138
  }
145
139
  function generateBundle(_outputOptions, bundle) {
146
- for (const output of Object.values(bundle)) {
147
- if (output.type !== "chunk" || !isJsFile(output.fileName)) {
148
- continue;
149
- }
150
- const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];
151
- const sourceMapSource = sourceMapAsset?.type === "asset" && typeof sourceMapAsset.source === "string" ? sourceMapAsset.source : void 0;
152
- const stamped = stampDebugId(output.code, sourceMapSource);
153
- if (!stamped) {
154
- continue;
155
- }
156
- output.code = stamped.bundleSource;
157
- if (stamped.sourceMapSource !== void 0 && sourceMapAsset?.type === "asset") {
158
- sourceMapAsset.source = stamped.sourceMapSource;
159
- }
140
+ if (this?.meta?.rolldownVersion) {
141
+ finalizeRolldownDebugIds(bundle);
142
+ }
143
+ if (options.sourcemaps?.disable !== "disable-upload") {
144
+ return;
160
145
  }
146
+ stampDebugIds(bundle, true);
161
147
  }
162
148
  async function writeBundle(outputOptions, bundle) {
163
149
  try {
@@ -197,7 +183,7 @@ ${injectCode.code()}` : injectCode.code();
197
183
  buildStart,
198
184
  ...shouldTransform ? { transform: transformHook } : {},
199
185
  renderChunk,
200
- ...options.sourcemaps?.disable === "disable-upload" ? { generateBundle: { order: "pre", handler: generateBundle } } : {},
186
+ generateBundle: { order: "pre", handler: generateBundle },
201
187
  writeBundle
202
188
  };
203
189
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/rollup/index.ts"],"sourcesContent":["import type { Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n stringToUUID,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\n stampDebugId,\n getCodeInjectionPosition,\n} from '../core';\nimport type { ComponentAnnotationTransformMeta } from '../core/component-annotation-oxc';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\n\n// The subset of Rollup's `TransformResult` that this plugin's `transform`\n// hook actually returns. Defined locally instead of imported from `rollup`\n// because `rollup` is an optional dependency.\ntype TransformResult = { code: string; map?: SourceMap | string | { mappings: string } | null } | null | undefined;\n\n// The subset of Rollup's `OutputBundle` the stamping hook reads.\ntype OutputBundle = Record<\n string,\n | { type: 'chunk'; fileName: string; code: string; sourcemapFileName?: string | null }\n | { type: 'asset'; fileName: string; source: string | Uint8Array }\n>;\n\ntype ViteModule = {\n parseAstAsync?: (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n};\n\ntype ViteParseAstAsync = NonNullable<ViteModule['parseAstAsync']>;\n\nlet viteParseAstAsyncPromise: Promise<ViteParseAstAsync | null> | undefined;\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\n\nfunction hasExistingDebugID(code: string): boolean {\n // Check if a debug ID has already been injected to avoid duplicate injection (e.g. by another plugin or Sentry CLI)\n const chunkStartSnippet = code.slice(0, 6000);\n const chunkEndSnippet = code.slice(-500);\n\n if (chunkStartSnippet.includes('_sentryDebugIdIdentifier') || chunkEndSnippet.includes('//# debugId=')) {\n return true; // Debug ID already present, skip injection\n }\n\n return false;\n}\n\nfunction getRollupMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const rollup = req('rollup') as { VERSION?: string };\n return rollup.VERSION?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nfunction getViteParseAstAsync(): Promise<ViteParseAstAsync | null> {\n if (!viteParseAstAsyncPromise) {\n viteParseAstAsyncPromise = Promise.resolve()\n .then(async () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Vite is an optional runtime peer for this package\n const viteModule = createRequire(import.meta.url)('vite') as ViteModule;\n\n if (typeof viteModule.parseAstAsync !== 'function') {\n return null;\n }\n\n try {\n await viteModule.parseAstAsync('const x = <div />;', { lang: 'tsx' });\n } catch {\n return null;\n }\n\n return viteModule.parseAstAsync;\n })\n .catch(() => null);\n }\n\n return viteParseAstAsyncPromise;\n}\n\n/**\n * @ignore - this is the internal plugin factory function only used for the Vite plugin!\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _rollupPluginInternal(\n userOptions: Options = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,\n buildTool,\n buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n name: 'sentry-noop-plugin',\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n {\n // Vite 8 already loads an oxc-based parser, so reuse it.\n getParseAstAsync: buildTool === 'vite' && buildToolMajorVersion === '8' ? getViteParseAstAsync : undefined,\n logger,\n },\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n const shouldTransform = transformAnnotations || transformReplace;\n\n function buildStart(): void {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n }\n\n async function transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<TransformResult> {\n // Component annotations are only in user code and boolean flag replacements are\n // only in Sentry code. If we successfully add annotations, we can return early.\n if (transformAnnotations) {\n const result = await transformAnnotations.transform(code, id, meta);\n if (result) {\n return result;\n }\n }\n\n if (transformReplace) {\n return replaceBooleanFlagsInCode(code, replacementValues);\n }\n\n return null;\n }\n\n function renderChunk(\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null },\n _?: unknown,\n meta?: { magicString?: MagicString },\n ): {\n code: string;\n map?: SourceMap;\n } | null {\n if (!isJsFile(chunk.fileName)) {\n return null; // returning null means not modifying the chunk at all\n }\n\n // Skip empty chunks and HTML facade chunks (Vite MPA)\n if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {\n return null;\n }\n\n const injectCode = staticInjectionCode.clone();\n\n if (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = stringToUUID(code); // generate a deterministic debug ID\n injectCode.append(getDebugIdSnippet(debugId));\n }\n\n if (injectCode.isEmpty()) {\n return null;\n }\n\n const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName });\n const injectionPosition = getCodeInjectionPosition(code);\n const codeToInject = injectionPosition === code.length ? `\\n${injectCode.code()}` : injectCode.code();\n ms.appendLeft(injectionPosition, codeToInject);\n\n // Rolldown can pass a native MagicString instance in meta.magicString\n // https://rolldown.rs/in-depth/native-magic-string#usage-examples\n if (ms?.constructor?.name === 'BindingMagicString') {\n // Rolldown docs say to return the magic string instance directly in this case\n return { code: ms as unknown as string };\n }\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' }),\n };\n }\n\n /**\n * Stamps debug IDs into the emitted chunks and source maps.\n *\n * `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted\n * artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the\n * comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final\n * assets afterwards (e.g. subresource integrity) see the stamped content.\n */\n function generateBundle(_outputOptions: unknown, bundle: OutputBundle): void {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];\n const sourceMapSource =\n sourceMapAsset?.type === 'asset' && typeof sourceMapAsset.source === 'string'\n ? sourceMapAsset.source\n : undefined;\n\n const stamped = stampDebugId(output.code, sourceMapSource);\n if (!stamped) {\n continue;\n }\n\n output.code = stamped.bundleSource;\n if (stamped.sourceMapSource !== undefined && sourceMapAsset?.type === 'asset') {\n sourceMapAsset.source = stamped.sourceMapSource;\n }\n }\n }\n\n async function writeBundle(\n outputOptions: { dir?: string; file?: string },\n bundle: { [fileName: string]: unknown },\n ): Promise<void> {\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n if (outputOptions.dir) {\n const outputDir = outputOptions.dir;\n const JS_AND_MAP_PATTERNS = [\n '/**/*.js',\n '/**/*.mjs',\n '/**/*.cjs',\n '/**/*.js.map',\n '/**/*.mjs.map',\n '/**/*.cjs.map',\n ].map(q => `${q}?(\\\\?*)?(#*)`); // We want to allow query and hash strings at the end of files\n const buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });\n await upload(buildArtifacts);\n } else if (outputOptions.file) {\n await upload([outputOptions.file]);\n } else {\n const buildArtifacts = Object.keys(bundle).map(asset => path.join(path.resolve(), asset));\n await upload(buildArtifacts);\n }\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n }\n\n const name = `sentry-${buildTool}-plugin`;\n const transformHook =\n buildTool === 'vite'\n ? {\n filter: { id: JS_MODULE_ID_FILTER },\n handler: transform,\n }\n : transform;\n\n return {\n name,\n buildStart,\n ...(shouldTransform ? { transform: transformHook } : {}),\n renderChunk,\n ...(options.sourcemaps?.disable === 'disable-upload'\n ? { generateBundle: { order: 'pre' as const, handler: generateBundle } }\n : {}),\n writeBundle,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-explicit-any\nexport function sentryRollupPlugin(userOptions: Options = {}): any {\n // We return an array here so we don't break backwards compatibility with what\n // unplugin used to return\n return [_rollupPluginInternal(userOptions, 'rollup')];\n}\n\nexport type { Options as SentryRollupPluginOptions } from '../core';\n"],"names":[],"mappings":";;;;;;;;;;;AAyCA,IAAI,wBAAA;AAEJ,MAAM,mBAAA,GAAsB,4BAAA;AAE5B,SAAS,mBAAmB,IAAA,EAAuB;AAEjD,EAAA,MAAM,iBAAA,GAAoB,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,GAAI,CAAA;AAC5C,EAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA;AAEvC,EAAA,IAAI,kBAAkB,QAAA,CAAS,0BAA0B,KAAK,eAAA,CAAgB,QAAA,CAAS,cAAc,CAAA,EAAG;AACtG,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,qBAAA,GAA4C;AACnD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAM,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACzC,IAAA,MAAM,MAAA,GAAS,IAAI,QAAQ,CAAA;AAC3B,IAAA,OAAO,MAAA,CAAO,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACrC,CAAA,CAAA,MAAQ;AAAA,EAER;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M,cAAA,GAAiB,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,CAAE,GAAA,CAAI,CAAA,KAAA,KAAS,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,OAAA,EAAQ,EAAG,KAAK,CAAC,CAAA;AACxF,UAAA,MAAM,OAAO,cAAc,CAAA;AAAA,QAC7B;AAAA,MACF;AAAA,IACF,CAAA,SAAE;AACA,MAAA,oCAAA,EAAqC;AACrC,MAAA,MAAM,yBAAyB,eAAA,EAAgB;AAAA,IACjD;AAAA,EACF;AAEA,EAAA,MAAM,IAAA,GAAO,UAAU,SAAS,CAAA,OAAA,CAAA;AAChC,EAAA,MAAM,aAAA,GACJ,cAAc,MAAA,GACV;AAAA,IACE,MAAA,EAAQ,EAAE,EAAA,EAAI,mBAAA,EAAoB;AAAA,IAClC,OAAA,EAAS;AAAA,GACX,GACA,SAAA;AAEN,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,GAAI,eAAA,GAAkB,EAAE,SAAA,EAAW,aAAA,KAAkB,EAAC;AAAA,IACtD,WAAA;AAAA,IACA,GAAI,OAAA,CAAQ,UAAA,EAAY,OAAA,KAAY,mBAChC,EAAE,cAAA,EAAgB,EAAE,KAAA,EAAO,KAAA,EAAgB,OAAA,EAAS,cAAA,EAAe,KACnE,EAAC;AAAA,IACL;AAAA,GACF;AACF;AAGO,SAAS,kBAAA,CAAmB,WAAA,GAAuB,EAAC,EAAQ;AAGjE,EAAA,OAAO,CAAC,qBAAA,CAAsB,WAAA,EAAa,QAAQ,CAAC,CAAA;AACtD;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/rollup/index.ts"],"sourcesContent":["import type { Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\n getCodeInjectionPosition,\n} from '../core';\nimport type { ComponentAnnotationTransformMeta } from '../core/component-annotation-oxc';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport { finalizeRolldownDebugIds, getDebugIdForChunk, hasExistingDebugID } from './debug-id-injection';\nimport { stampDebugIds, type OutputBundle } from './debug-id-stamping';\n\n// The subset of Rollup's `TransformResult` that this plugin's `transform`\n// hook actually returns. Defined locally instead of imported from `rollup`\n// because `rollup` is an optional dependency.\ntype TransformResult = { code: string; map?: SourceMap | string | { mappings: string } | null } | null | undefined;\n\ntype ViteModule = {\n parseAstAsync?: (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n};\n\ntype ViteParseAstAsync = NonNullable<ViteModule['parseAstAsync']>;\n\nlet viteParseAstAsyncPromise: Promise<ViteParseAstAsync | null> | undefined;\n\n// Rolldown sets `meta.rolldownVersion` on the plugin context.\ntype PluginContext = { meta?: { rolldownVersion?: string } };\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\n\nfunction getRollupMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const rollup = req('rollup') as { VERSION?: string };\n return rollup.VERSION?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nfunction getViteParseAstAsync(): Promise<ViteParseAstAsync | null> {\n if (!viteParseAstAsyncPromise) {\n viteParseAstAsyncPromise = Promise.resolve()\n .then(async () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Vite is an optional runtime peer for this package\n const viteModule = createRequire(import.meta.url)('vite') as ViteModule;\n\n if (typeof viteModule.parseAstAsync !== 'function') {\n return null;\n }\n\n try {\n await viteModule.parseAstAsync('const x = <div />;', { lang: 'tsx' });\n } catch {\n return null;\n }\n\n return viteModule.parseAstAsync;\n })\n .catch(() => null);\n }\n\n return viteParseAstAsyncPromise;\n}\n\n/**\n * @ignore - this is the internal plugin factory function only used for the Vite plugin!\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _rollupPluginInternal(\n userOptions: Options = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,\n buildTool,\n buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n name: 'sentry-noop-plugin',\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n {\n // Vite 8 already loads an oxc-based parser, so reuse it.\n getParseAstAsync: buildTool === 'vite' && buildToolMajorVersion === '8' ? getViteParseAstAsync : undefined,\n logger,\n },\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n const shouldTransform = transformAnnotations || transformReplace;\n\n function buildStart(): void {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n }\n\n async function transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<TransformResult> {\n // Component annotations are only in user code and boolean flag replacements are\n // only in Sentry code. If we successfully add annotations, we can return early.\n if (transformAnnotations) {\n const result = await transformAnnotations.transform(code, id, meta);\n if (result) {\n return result;\n }\n }\n\n if (transformReplace) {\n return replaceBooleanFlagsInCode(code, replacementValues);\n }\n\n return null;\n }\n\n function renderChunk(\n this: PluginContext | undefined,\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null },\n _?: unknown,\n meta?: { magicString?: MagicString },\n ): {\n code: string;\n map?: SourceMap;\n } | null {\n if (!isJsFile(chunk.fileName)) {\n return null; // returning null means not modifying the chunk at all\n }\n\n // Skip empty chunks and HTML facade chunks (Vite MPA)\n if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {\n return null;\n }\n\n const injectCode = staticInjectionCode.clone();\n\n if (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);\n injectCode.append(getDebugIdSnippet(debugId));\n }\n\n if (injectCode.isEmpty()) {\n return null;\n }\n\n const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName });\n const injectionPosition = getCodeInjectionPosition(code);\n const codeToInject = injectionPosition === code.length ? `\\n${injectCode.code()}` : injectCode.code();\n ms.appendLeft(injectionPosition, codeToInject);\n\n // Rolldown can pass a native MagicString instance in meta.magicString\n // https://rolldown.rs/in-depth/native-magic-string#usage-examples\n if (ms?.constructor?.name === 'BindingMagicString') {\n // Rolldown docs say to return the magic string instance directly in this case\n return { code: ms as unknown as string };\n }\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' }),\n };\n }\n\n /**\n * Resolves Rolldown's placeholder debug IDs, then stamps debug IDs into the emitted chunks and\n * source maps.\n *\n * `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted\n * artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the\n * comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final\n * assets afterwards (e.g. subresource integrity) see the stamped content.\n */\n function generateBundle(this: PluginContext | undefined, _outputOptions: unknown, bundle: OutputBundle): void {\n if (this?.meta?.rolldownVersion) {\n finalizeRolldownDebugIds(bundle);\n }\n\n if (options.sourcemaps?.disable !== 'disable-upload') {\n return;\n }\n\n stampDebugIds(bundle, true);\n }\n\n async function writeBundle(\n outputOptions: { dir?: string; file?: string },\n bundle: { [fileName: string]: unknown },\n ): Promise<void> {\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n if (outputOptions.dir) {\n const outputDir = outputOptions.dir;\n const JS_AND_MAP_PATTERNS = [\n '/**/*.js',\n '/**/*.mjs',\n '/**/*.cjs',\n '/**/*.js.map',\n '/**/*.mjs.map',\n '/**/*.cjs.map',\n ].map(q => `${q}?(\\\\?*)?(#*)`); // We want to allow query and hash strings at the end of files\n const buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });\n await upload(buildArtifacts);\n } else if (outputOptions.file) {\n await upload([outputOptions.file]);\n } else {\n const buildArtifacts = Object.keys(bundle).map(asset => path.join(path.resolve(), asset));\n await upload(buildArtifacts);\n }\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n }\n\n const name = `sentry-${buildTool}-plugin`;\n const transformHook =\n buildTool === 'vite'\n ? {\n filter: { id: JS_MODULE_ID_FILTER },\n handler: transform,\n }\n : transform;\n\n return {\n name,\n buildStart,\n ...(shouldTransform ? { transform: transformHook } : {}),\n renderChunk,\n generateBundle: { order: 'pre' as const, handler: generateBundle },\n writeBundle,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-explicit-any\nexport function sentryRollupPlugin(userOptions: Options = {}): any {\n // We return an array here so we don't break backwards compatibility with what\n // unplugin used to return\n return [_rollupPluginInternal(userOptions, 'rollup')];\n}\n\nexport type { Options as SentryRollupPluginOptions } from '../core';\n"],"names":[],"mappings":";;;;;;;;;;;;;AAkCA,IAAI,wBAAA;AAKJ,MAAM,mBAAA,GAAsB,4BAAA;AAE5B,SAAS,qBAAA,GAA4C;AACnD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAM,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACzC,IAAA,MAAM,MAAA,GAAS,IAAI,QAAQ,CAAA;AAC3B,IAAA,OAAO,MAAA,CAAO,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACrC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,oBAAA,GAA0D;AACjE,EAAA,IAAI,CAAC,wBAAA,EAA0B;AAC7B,IAAA,wBAAA,GAA2B,OAAA,CAAQ,OAAA,EAAQ,CACxC,IAAA,CAAK,YAAY;AAGhB,MAAA,MAAM,UAAA,GAAa,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,EAAE,MAAM,CAAA;AAExD,MAAA,IAAI,OAAO,UAAA,CAAW,aAAA,KAAkB,UAAA,EAAY;AAClD,QAAA,OAAO,IAAA;AAAA,MACT;AAEA,MAAA,IAAI;AACF,QAAA,MAAM,WAAW,aAAA,CAAc,oBAAA,EAAsB,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,MACtE,CAAA,CAAA,MAAQ;AACN,QAAA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ebugIds } from '../rollup/debug-id-stamping.js';
3
4
 
4
5
  function getViteMajorVersion() {
5
6
  try {
@@ -11,12 +12,25 @@ function getViteMajorVersion() {
11
12
  return void 0;
12
13
  }
13
14
  const sentryVitePlugin = (options) => {
14
- return [
15
+ const plugins = [
15
16
  {
16
17
  enforce: "pre",
17
18
  ..._rollupPluginInternal(options, "vite", getViteMajorVersion())
18
19
  }
19
20
  ];
21
+ if (!options?.disable && options?.sourcemaps?.disable === "disable-upload") {
22
+ plugins.push({
23
+ name: "sentry-vite-debug-id-sourcemaps",
24
+ enforce: "post",
25
+ generateBundle: {
26
+ order: "post",
27
+ handler(_outputOptions, bundle) {
28
+ stampDebugIds(bundle, false);
29
+ }
30
+ }
31
+ });
32
+ }
33
+ return plugins;
20
34
  };
21
35
 
22
36
  export { sentryVitePlugin };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/vite/index.ts"],"sourcesContent":["import type { SentryRollupPluginOptions } from '../rollup';\nimport { _rollupPluginInternal } from '../rollup';\nimport { createRequire } from 'node:module';\n\ninterface SentryVitePlugin {\n name: string;\n enforce: 'pre';\n}\n\nfunction getViteMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const vite = req('vite') as { version?: string };\n return vite.version?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nexport const sentryVitePlugin = (options?: SentryRollupPluginOptions): SentryVitePlugin[] => {\n return [\n {\n enforce: 'pre',\n ..._rollupPluginInternal(options, 'vite', getViteMajorVersion()),\n },\n ];\n};\n\nexport type { Options as SentryVitePluginOptions } from '../core';\n"],"names":[],"mappings":";;;AASA,SAAS,mBAAA,GAA0C;AACjD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAM,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACzC,IAAA,MAAM,IAAA,GAAO,IAAI,MAAM,CAAA;AACvB,IAAA,OAAO,IAAA,CAAK,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACnC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEO,MAAM,gBAAA,GAAmB,CAAC,OAAA,KAA4D;AAC3F,EAAA,OAAO;AAAA,IACL;AAAA,MACE,OAAA,EAAS,KAAA;AAAA,MACT,GAAG,qBAAA,CAAsB,OAAA,EAAS,MAAA,EAAQ,qBAAqB;AAAA;AACjE,GACF;AACF;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/vite/index.ts"],"sourcesContent":["import type { SentryRollupPluginOptions } from '../rollup';\nimport { _rollupPluginInternal } from '../rollup';\nimport { createRequire } from 'node:module';\nimport { stampDebugIds, type OutputBundle } from '../rollup/debug-id-stamping';\n\ninterface SentryVitePlugin {\n name: string;\n enforce: 'pre' | 'post';\n generateBundle?: {\n order: 'pre' | 'post';\n handler: (_outputOptions: unknown, bundle: OutputBundle) => void;\n };\n}\n\nfunction getViteMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const vite = req('vite') as { version?: string };\n return vite.version?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nexport const sentryVitePlugin = (options?: SentryRollupPluginOptions): SentryVitePlugin[] => {\n const plugins: SentryVitePlugin[] = [\n {\n enforce: 'pre',\n ..._rollupPluginInternal(options, 'vite', getViteMajorVersion()),\n },\n ];\n\n if (!options?.disable && options?.sourcemaps?.disable === 'disable-upload') {\n plugins.push({\n name: 'sentry-vite-debug-id-sourcemaps',\n enforce: 'post',\n generateBundle: {\n order: 'post',\n handler(_outputOptions, bundle) {\n // Vite's module preload rewrite in `generateBundle` regenerates the source map of every\n // chunk with a dynamic import, which drops the debug ID the main plugin stamped in its\n // `pre` hook. Restore it without touching the chunk code, so file hashes stay valid.\n stampDebugIds(bundle, false);\n },\n },\n });\n }\n\n return plugins;\n};\n\nexport type { Options as SentryVitePluginOptions } from '../core';\n"],"names":[],"mappings":";;;;AAcA,SAAS,mBAAA,GAA0C;AACjD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAM,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACzC,IAAA,MAAM,IAAA,GAAO,IAAI,MAAM,CAAA;AACvB,IAAA,OAAO,IAAA,CAAK,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACnC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEO,MAAM,gBAAA,GAAmB,CAAC,OAAA,KAA4D;AAC3F,EAAA,MAAM,OAAA,GAA8B;AAAA,IAClC;AAAA,MACE,OAAA,EAAS,KAAA;AAAA,MACT,GAAG,qBAAA,CAAsB,OAAA,EAAS,MAAA,EAAQ,qBAAqB;AAAA;AACjE,GACF;AAEA,EAAA,IAAI,CAAC,OAAA,EAAS,OAAA,IAAW,OAAA,EAAS,UAAA,EAAY,YAAY,gBAAA,EAAkB;AAC1E,IAAA,OAAA,CAAQ,IAAA,CAAK;AAAA,MACX,IAAA,EAAM,iCAAA;AAAA,MACN,OAAA,EAAS,MAAA;AAAA,MACT,cAAA,EAAgB;AAAA,QACd,KAAA,EAAO,MAAA;AAAA,QACP,OAAA,CAAQ,gBAAgB,MAAA,EAAQ;AAI9B,UAAA,aAAA,CAAc,QAAQ,KAAK,CAAA;AAAA,QAC7B;AAAA;AACF,KACD,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,OAAA;AACT;;;;"}
@@ -1,2 +1,2 @@
1
- export declare const LIB_VERSION = "11.2.0";
1
+ export declare const LIB_VERSION = "11.3.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1,16 @@
1
+ export declare const ROLLDOWN_DEBUG_ID_PLACEHOLDER = "SENTRY_DEBUG_ID_PLACEHOLDER_00000000";
2
+ type GeneratedChunk = {
3
+ type: 'chunk';
4
+ fileName: string;
5
+ code: string;
6
+ };
7
+ type GeneratedAsset = {
8
+ type: 'asset';
9
+ fileName: string;
10
+ };
11
+ export type GeneratedBundle = Record<string, GeneratedChunk | GeneratedAsset>;
12
+ export declare function hasExistingDebugID(code: string): boolean;
13
+ export declare function getDebugIdForChunk(code: string, isRolldown: boolean): string;
14
+ export declare function finalizeRolldownDebugIds(bundle: GeneratedBundle): void;
15
+ export {};
16
+ //# sourceMappingURL=debug-id-injection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-id-injection.d.ts","sourceRoot":"","sources":["../../../src/rollup/debug-id-injection.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,6BAA6B,yCAAyC,CAAC;AAEpF,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAAC,CAAC;AAK9E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKxD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,CAE5E;AAMD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAkCtE"}
@@ -0,0 +1,12 @@
1
+ export type OutputBundle = Record<string, {
2
+ type: 'chunk';
3
+ fileName: string;
4
+ code: string;
5
+ sourcemapFileName?: string | null;
6
+ } | {
7
+ type: 'asset';
8
+ fileName: string;
9
+ source: string | Uint8Array;
10
+ }>;
11
+ export declare function stampDebugIds(bundle: OutputBundle, updateChunkCode: boolean): void;
12
+ //# sourceMappingURL=debug-id-stamping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-id-stamping.d.ts","sourceRoot":"","sources":["../../../src/rollup/debug-id-stamping.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG,MAAM,CAC/B,MAAM,EACJ;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACpF;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CACnE,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI,CAsBlF"}
@@ -2,22 +2,18 @@ import type { Options } from '../core';
2
2
  import type { ComponentAnnotationTransformMeta } from '../core/component-annotation-oxc';
3
3
  import type { SourceMap } from 'magic-string';
4
4
  import MagicString from 'magic-string';
5
+ import { type OutputBundle } from './debug-id-stamping';
5
6
  type TransformResult = {
6
7
  code: string;
7
8
  map?: SourceMap | string | {
8
9
  mappings: string;
9
10
  } | null;
10
11
  } | null | undefined;
11
- type OutputBundle = Record<string, {
12
- type: 'chunk';
13
- fileName: string;
14
- code: string;
15
- sourcemapFileName?: string | null;
16
- } | {
17
- type: 'asset';
18
- fileName: string;
19
- source: string | Uint8Array;
20
- }>;
12
+ type PluginContext = {
13
+ meta?: {
14
+ rolldownVersion?: string;
15
+ };
16
+ };
21
17
  /**
22
18
  * @ignore - this is the internal plugin factory function only used for the Vite plugin!
23
19
  */
@@ -32,7 +28,7 @@ export declare function _rollupPluginInternal(userOptions: Options | undefined,
32
28
  };
33
29
  handler: (code: string, id: string, meta?: ComponentAnnotationTransformMeta) => Promise<TransformResult>;
34
30
  } | undefined;
35
- renderChunk: (code: string, chunk: {
31
+ renderChunk: (this: PluginContext | undefined, code: string, chunk: {
36
32
  fileName: string;
37
33
  facadeModuleId?: string | null;
38
34
  }, _?: unknown, meta?: {
@@ -41,10 +37,10 @@ export declare function _rollupPluginInternal(userOptions: Options | undefined,
41
37
  code: string;
42
38
  map?: SourceMap;
43
39
  } | null;
44
- generateBundle?: {
40
+ generateBundle: {
45
41
  order: 'pre';
46
- handler: (_outputOptions: unknown, bundle: OutputBundle) => void;
47
- } | undefined;
42
+ handler: (this: PluginContext | undefined, _outputOptions: unknown, bundle: OutputBundle) => void;
43
+ };
48
44
  writeBundle: (outputOptions: {
49
45
  dir?: string;
50
46
  file?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rollup/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAiBvC,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,WAAW,MAAM,cAAc,CAAC;AAOvC,KAAK,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAGnH,KAAK,YAAY,GAAG,MAAM,CACxB,MAAM,EACJ;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACpF;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MA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IAAI,yBAAyB,EAAE,MAAM,SAAS,CAAC"}
@@ -1,7 +1,12 @@
1
1
  import type { SentryRollupPluginOptions } from '../rollup';
2
+ import { type OutputBundle } from '../rollup/debug-id-stamping';
2
3
  interface SentryVitePlugin {
3
4
  name: string;
4
- enforce: 'pre';
5
+ enforce: 'pre' | 'post';
6
+ generateBundle?: {
7
+ order: 'pre' | 'post';
8
+ handler: (_outputOptions: unknown, bundle: OutputBundle) => void;
9
+ };
5
10
  }
6
11
  export declare const sentryVitePlugin: (options?: SentryRollupPluginOptions) => SentryVitePlugin[];
7
12
  export type { Options as SentryVitePluginOptions } from '../core';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAI3D,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,KAAK,CAAC;CAChB;AAgBD,eAAO,MAAM,gBAAgB,aAAc,yBAAyB,KAAG,gBAAgB,EAOtF,CAAC;AAEF,YAAY,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAG3D,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE/E,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,KAAK,GAAG,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE;QACf,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;QACtB,OAAO,EAAE,CAAC,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;KAClE,CAAC;CACH;AAgBD,eAAO,MAAM,gBAAgB,aAAc,yBAAyB,KAAG,gBAAgB,EAyBtF,CAAC;AAEF,YAAY,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/bundler-plugins",
3
- "version": "11.2.0",
3
+ "version": "11.3.0",
4
4
  "description": "Sentry Bundler Plugins",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/main/packages/bundler-plugins",
@@ -110,7 +110,7 @@
110
110
  }
111
111
  },
112
112
  "dependencies": {
113
- "@sentry/core": "11.2.0",
113
+ "@sentry/core": "11.3.0",
114
114
  "dotenv": "^17.4.2",
115
115
  "glob": "^13.0.6",
116
116
  "magic-string": "~0.30.8 || ^1.0.0",