From 8618533c6bc45b19d5c9db99a6ab4c19c0329499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 8 Sep 2026 13:24:35 +0200 Subject: [PATCH 01/25] test(bundler-plugins): Add strict mode injection regression coverage Co-Authored-By: OpenAI Codex --- .../core/get-code-injection-position.test.ts | 36 +++++++ .../test/rollup/public-api.test.ts | 37 +++++++ .../test/vite/public-api.test.ts | 25 +++++ .../test/webpack/webpack4and5.test.ts | 97 +++++++++++++++++++ 4 files changed, 195 insertions(+) create mode 100644 packages/bundler-plugins/test/core/get-code-injection-position.test.ts create mode 100644 packages/bundler-plugins/test/webpack/webpack4and5.test.ts diff --git a/packages/bundler-plugins/test/core/get-code-injection-position.test.ts b/packages/bundler-plugins/test/core/get-code-injection-position.test.ts new file mode 100644 index 000000000000..91ea92211d93 --- /dev/null +++ b/packages/bundler-plugins/test/core/get-code-injection-position.test.ts @@ -0,0 +1,36 @@ +import { getCodeInjectionPosition } from '../../src/core/get-code-injection-position'; +import { describe, expect, it } from 'vitest'; + +describe('getCodeInjectionPosition', () => { + it.each([ + [ + 'multiple directives and a block comment', + `/* license */\n"use client";\n'use strict'\nglobalThis.appStarted = true;`, + `/* license */\n"use client";\n'use strict'\n`, + ], + ['a semicolonless directive before a unary IIFE', '"use strict"\n!function () {}();', '"use strict"\n'], + ['a CRLF line comment', '// license\r\n"use strict";\r\nstartApp();', '// license\r\n"use strict";\r\n'], + ['a CR-only line comment', '// license\r"use strict"\rstartApp();', '// license\r"use strict"\r'], + ['a Unicode line separator', '"use strict"\u2028startApp();', '"use strict"\u2028'], + ['a Unicode paragraph separator', '"use strict"\u2029startApp();', '"use strict"\u2029'], + ['a hashbang', '#!/usr/bin/env node\n"use strict";\nstartApp();', '#!/usr/bin/env node\n"use strict";\n'], + ['an escaped string directive', '"use\\x20strict";\nstartApp();', '"use\\x20strict";\n'], + [ + 'an escaped CRLF in a directive string', + '"not strict\\\r\n";\n"use strict";\nstartApp();', + '"not strict\\\r\n";\n"use strict";\n', + ], + ['an unterminated string', '"use strict', ''], + ['an unterminated block comment', '/* license', '/* license'], + ['leading trivia without directives', '/* license */\nstartApp();', '/* license */\n'], + ['a prefix increment statement', '"use strict"\n++value;', '"use strict"\n'], + ['a prefix decrement statement', '"use strict"\n--value;', '"use strict"\n'], + ['an inequality continuation', '"not a directive"\n!= expectedValue;', ''], + ['an addition continuation', '"not a directive"\n+ otherValue;', ''], + ['an identifier prefixed with in', '"use strict"\nin$foo: ;', '"use strict"\n'], + ['a Unicode identifier prefixed with instanceof', '"use strict"\ninstanceofπ: ;', '"use strict"\n'], + ['an escaped identifier prefixed with in', '"use strict"\nin\\u0066oo: ;', '"use strict"\n'], + ])('returns the injection position for %s', (_description, code, expectedPrefix) => { + expect(code.slice(0, getCodeInjectionPosition(code))).toBe(expectedPrefix); + }); +}); diff --git a/packages/bundler-plugins/test/rollup/public-api.test.ts b/packages/bundler-plugins/test/rollup/public-api.test.ts index b54077fce2bc..6c46a72fe612 100644 --- a/packages/bundler-plugins/test/rollup/public-api.test.ts +++ b/packages/bundler-plugins/test/rollup/public-api.test.ts @@ -1,6 +1,7 @@ import { _rollupPluginInternal, sentryRollupPlugin } from '../../src/rollup'; import { createComponentNameAnnotateHooks } from '../../src/core'; import type { Plugin, SourceMap } from 'rollup'; +import { runInNewContext } from 'node:vm'; import { describe, it, expect, test, beforeEach, vi } from 'vitest'; const { babelCoreImportMock, transformAsyncMock, viteAnnotationModuleImportMock, viteAnnotationTransformMock } = @@ -153,6 +154,42 @@ describe('Hooks', () => { `); }); + it.each([ + ['when the directive has no semicolon', '"use strict"\n'], + ['when another directive precedes it', '"use client";\n"use strict";\n'], + ['after an escaped CRLF in an earlier directive', '"not strict\\\r\n";\n"use strict";\n'], + ['before an identifier prefixed with an operator keyword', '"use strict"\nin$foo: ;\n'], + ])('preserves strict mode %s', (_description, codePrefix) => { + const code = `${codePrefix}globalThis.strictModePreserved = (function () { return this; })() === undefined;`; + const result = renderChunk(code, { fileName: 'bundle.js' }); + const context: { strictModePreserved?: boolean; _sentryDebugIds?: Record } = {}; + + expect(result).not.toBeNull(); + runInNewContext(result?.code ?? '', context); + + expect(context.strictModePreserved).toBe(true); + expect(Object.keys(context._sentryDebugIds ?? {})).toHaveLength(1); + }); + + it.each([ + ['a semicolonless directive', '"use strict"'], + ['trailing whitespace', '"use strict" '], + ['a trailing block comment', '"use strict"/* trailing */'], + ['a trailing line comment', '"use strict" // trailing'], + ])('preserves a directive at EOF with %s', (_description, code) => { + const result = renderChunk(code, { fileName: 'bundle.js' }); + const context: { strictModePreserved?: boolean; _sentryDebugIds?: Record } = {}; + + expect(result).not.toBeNull(); + runInNewContext( + `${result?.code ?? ''}\nglobalThis.strictModePreserved = (function () { return this; })() === undefined;`, + context, + ); + + expect(context.strictModePreserved).toBe(true); + expect(Object.keys(context._sentryDebugIds ?? {})).toHaveLength(1); + }); + it.each([['bundle.js'], ['bundle.mjs'], ['bundle.cjs'], ['bundle.js?foo=bar'], ['bundle.js#hash']])( "should process file '%s'", fileName => { diff --git a/packages/bundler-plugins/test/vite/public-api.test.ts b/packages/bundler-plugins/test/vite/public-api.test.ts index 6f8dd9f84260..cade4da1c67a 100644 --- a/packages/bundler-plugins/test/vite/public-api.test.ts +++ b/packages/bundler-plugins/test/vite/public-api.test.ts @@ -1,4 +1,6 @@ import { sentryVitePlugin } from '../../src/vite'; +import type { Plugin, SourceMap } from 'rollup'; +import { runInNewContext } from 'node:vm'; import { describe, it, expect, test, beforeEach, vi } from 'vitest'; test('Vite plugin should exist', () => { @@ -37,4 +39,27 @@ describe('sentryVitePlugin', () => { expect(plugins.length).toBeGreaterThanOrEqual(1); expect(plugins[0]).toHaveProperty('name'); }); + + it.each([ + ['when the directive has no semicolon', '"use strict"\n'], + ['when another directive precedes it', '"use client";\n"use strict";\n'], + ['after an escaped CRLF in an earlier directive', '"not strict\\\r\n";\n"use strict";\n'], + ['before an identifier prefixed with an operator keyword', '"use strict"\nin$foo: ;\n'], + ])('preserves strict mode %s', (_description, codePrefix) => { + const [plugin] = sentryVitePlugin({ release: { inject: false }, telemetry: false }) as Array; + const renderChunk = plugin?.renderChunk as ( + code: string, + chunkInfo: { fileName: string }, + ) => { code: string; map: SourceMap } | null; + const code = `${codePrefix}globalThis.strictModePreserved = (function () { return this; })() === undefined;`; + + const result = renderChunk(code, { fileName: 'bundle.js' }); + const context: { strictModePreserved?: boolean; _sentryDebugIds?: Record } = {}; + + expect(result).not.toBeNull(); + runInNewContext(result?.code ?? '', context); + + expect(context.strictModePreserved).toBe(true); + expect(Object.keys(context._sentryDebugIds ?? {})).toHaveLength(1); + }); }); diff --git a/packages/bundler-plugins/test/webpack/webpack4and5.test.ts b/packages/bundler-plugins/test/webpack/webpack4and5.test.ts new file mode 100644 index 000000000000..1f014fb3f9b3 --- /dev/null +++ b/packages/bundler-plugins/test/webpack/webpack4and5.test.ts @@ -0,0 +1,97 @@ +import webpack from 'webpack'; +import { runInNewContext } from 'node:vm'; +import { describe, expect, it } from 'vitest'; +import { sentryWebpackPluginFactory } from '../../src/webpack/webpack4and5'; + +function runWebpackInjection(assetName: string, code: string, chunkFiles: string[] = [assetName]): string { + const webpackPlugin = sentryWebpackPluginFactory()({ + release: { inject: false }, + telemetry: false, + }); + let compilationCallback!: (compilation: unknown) => void; + let processAssets!: (assets: Record) => void; + let output: webpack.sources.Source = new webpack.sources.RawSource(code); + const compiler = { + options: { plugins: [] as unknown[] }, + webpack: { + Compilation: { PROCESS_ASSETS_STAGE_ADDITIONS: -100 }, + sources: { ReplaceSource: webpack.sources.ReplaceSource }, + }, + hooks: { + thisCompilation: { + tap: (_name: string, callback: (compilation: unknown) => void) => { + compilationCallback = callback; + }, + }, + afterEmit: { tapAsync: () => undefined }, + done: { tap: () => undefined }, + }, + }; + const compilation = { + chunks: [{ files: chunkFiles }], + compiler: {}, + hooks: { + processAssets: { + tap: (_options: unknown, callback: (assets: Record) => void) => { + processAssets = callback; + }, + }, + }, + updateAsset: (_name: string, source: webpack.sources.Source) => { + output = source; + }, + }; + + webpackPlugin.apply(compiler as never); + compilationCallback(compilation); + processAssets({ [assetName]: new webpack.sources.RawSource(code) }); + + return output.source().toString(); +} + +describe('sentryWebpackPluginFactory', () => { + it('preserves a top-level strict mode directive', () => { + const code = '"use strict";\nglobalThis.strictModePreserved = (function () { return this; })() === undefined;'; + const output = runWebpackInjection('120.js', code); + const context: { strictModePreserved?: boolean; _sentryDebugIds?: Record } = {}; + + runInNewContext(output, context); + + expect(context.strictModePreserved).toBe(true); + expect(Object.keys(context._sentryDebugIds ?? {})).toHaveLength(1); + }); + + it.each([ + ['a semicolonless directive', '"use strict"'], + ['trailing whitespace', '"use strict" '], + ['a trailing block comment', '"use strict"/* trailing */'], + ['a trailing line comment', '"use strict" // trailing'], + ])('preserves a directive at EOF with %s', (_description, code) => { + const output = runWebpackInjection('120.js', code); + const context: { strictModePreserved?: boolean; _sentryDebugIds?: Record } = {}; + + runInNewContext( + `${output}\nglobalThis.strictModePreserved = (function () { return this; })() === undefined;`, + context, + ); + + expect(context.strictModePreserved).toBe(true); + expect(Object.keys(context._sentryDebugIds ?? {})).toHaveLength(1); + }); + + it.each(['.ts', '.tsx', '.jsx'])('injects into a %s asset', extension => { + const output = runWebpackInjection(`bundle${extension}`, 'globalThis.bundleLoaded = true;'); + const context: { _sentryDebugIds?: Record } = {}; + + runInNewContext(output, context); + + expect(Object.keys(context._sentryDebugIds ?? {})).toHaveLength(1); + }); + + it('does not inject into JavaScript assets outside chunks', () => { + const code = 'globalThis.bundleLoaded = true;'; + const output = runWebpackInjection('copied.js', code, []); + + expect(output).toBe(code); + }); +}); From 85379e0fc8e47828259663aad1aba15683f9c6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 8 Sep 2026 13:24:51 +0200 Subject: [PATCH 02/25] fix(bundler-plugins): Preserve directive prologues during bundle injection Co-Authored-By: OpenAI Codex --- .../src/core/get-code-injection-position.ts | 104 ++++++++++++++++ packages/bundler-plugins/src/rollup/index.ts | 12 +- packages/bundler-plugins/src/webpack/index.ts | 19 ++- .../src/webpack/webpack4and5.ts | 115 ++++++++++++------ 4 files changed, 203 insertions(+), 47 deletions(-) create mode 100644 packages/bundler-plugins/src/core/get-code-injection-position.ts diff --git a/packages/bundler-plugins/src/core/get-code-injection-position.ts b/packages/bundler-plugins/src/core/get-code-injection-position.ts new file mode 100644 index 000000000000..8ed7ad3cd19e --- /dev/null +++ b/packages/bundler-plugins/src/core/get-code-injection-position.ts @@ -0,0 +1,104 @@ +function isLineTerminator(character: string | undefined): boolean { + return character === '\n' || character === '\r' || character === '\u2028' || character === '\u2029'; +} + +function skipTrivia(code: string, start: number): { end: number; hasLineBreak: boolean } { + let position = start; + let hasLineBreak = false; + + while (position < code.length) { + const character = code[position]; + + if (/\s/.test(character || '')) { + hasLineBreak ||= isLineTerminator(character); + position++; + } else if (code.startsWith('//', position) || (position === 0 && code.startsWith('#!', position))) { + let lineEnd = position + 2; + while (lineEnd < code.length && !isLineTerminator(code[lineEnd])) { + lineEnd++; + } + if (lineEnd === code.length) { + return { end: code.length, hasLineBreak }; + } + position = lineEnd + 1; + hasLineBreak = true; + } else if (code.startsWith('/*', position)) { + const commentEnd = code.indexOf('*/', position + 2); + if (commentEnd === -1) { + return { end: code.length, hasLineBreak }; + } + const comment = code.slice(position, commentEnd + 2); + hasLineBreak ||= /[\n\r\u2028\u2029]/.test(comment); + position = commentEnd + 2; + } else { + break; + } + } + + return { end: position, hasLineBreak }; +} + +function findStringLiteralEnd(code: string, start: number): number | undefined { + const quote = code[start]; + if (quote !== '"' && quote !== "'") { + return undefined; + } + + for (let position = start + 1; position < code.length; position++) { + const character = code[position]; + if (character === '\\') { + position += code[position + 1] === '\r' && code[position + 2] === '\n' ? 2 : 1; + } else if (character === quote) { + return position + 1; + } else if (isLineTerminator(character)) { + return undefined; + } + } + + return undefined; +} + +function startsWithBinaryOperatorKeyword(remainder: string, keyword: string): boolean { + return remainder.startsWith(keyword) && !/^[$_\\\u200C\u200D\p{ID_Continue}]/u.test(remainder.slice(keyword.length)); +} + +function canContinueStringExpression(code: string, position: number): boolean { + const remainder = code.slice(position); + if (/^(?:\+\+|--|!(?!=))/.test(remainder)) { + return false; + } + + return ( + /^!={1,2}/.test(remainder) || + /^[([.`+\-*/%<>=&|^?,:]/.test(remainder) || + ['in', 'instanceof'].some(keyword => startsWithBinaryOperatorKeyword(remainder, keyword)) + ); +} + +export function getCodeInjectionPosition(code: string): number { + let position = skipTrivia(code, 0).end; + let prologueEnd = position; + + while (position < code.length) { + const stringEnd = findStringLiteralEnd(code, position); + if (stringEnd === undefined) { + break; + } + + const trailingTrivia = skipTrivia(code, stringEnd); + if (code[trailingTrivia.end] === ';') { + position = skipTrivia(code, trailingTrivia.end + 1).end; + } else if ( + trailingTrivia.end === code.length || + (trailingTrivia.hasLineBreak && !canContinueStringExpression(code, trailingTrivia.end)) + ) { + position = trailingTrivia.end; + } else { + break; + } + + prologueEnd = position; + } + + return prologueEnd; +} diff --git a/packages/bundler-plugins/src/rollup/index.ts b/packages/bundler-plugins/src/rollup/index.ts index a1ebcb98769d..4588d7fd9bde 100644 --- a/packages/bundler-plugins/src/rollup/index.ts +++ b/packages/bundler-plugins/src/rollup/index.ts @@ -7,13 +7,13 @@ import { shouldSkipCodeInjection, getDebugIdSnippet, stringToUUID, - COMMENT_USE_STRICT_REGEX, createDebugIdUploadFunction, globFiles, createComponentNameAnnotateHooks, replaceBooleanFlagsInCode, CodeInjection, } from '../core'; +import { getCodeInjectionPosition } from '../core/get-code-injection-position'; import type { ComponentAnnotationTransformMeta, ComponentAnnotationTransformResult, @@ -259,16 +259,16 @@ export function _rollupPluginInternal( } const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName }); - const match = code.match(COMMENT_USE_STRICT_REGEX)?.[0]; + const injectionPosition = getCodeInjectionPosition(code); + const codeToInject = injectionPosition === code.length ? `\n${injectCode.code()}` : injectCode.code(); - if (match) { - // Add injected code after any comments or "use strict" at the beginning of the bundle. - ms.appendLeft(match.length, injectCode.code()); + if (injectionPosition > 0) { + ms.appendLeft(injectionPosition, codeToInject); } else { // ms.replace() doesn't work when there is an empty string match (which happens if // there is neither, a comment, nor a "use strict" at the top of the chunk) so we // need this special case here. - ms.prepend(injectCode.code()); + ms.prepend(codeToInject); } // Rolldown can pass a native MagicString instance in meta.magicString diff --git a/packages/bundler-plugins/src/webpack/index.ts b/packages/bundler-plugins/src/webpack/index.ts index 634f2c1e958f..fa602f2af2ef 100644 --- a/packages/bundler-plugins/src/webpack/index.ts +++ b/packages/bundler-plugins/src/webpack/index.ts @@ -5,9 +5,20 @@ import { createRequire } from 'node:module'; // eslint-disable-next-line @typescript-eslint/no-explicit-any type PluginClass = new (options: any) => unknown; +type WebpackSource = { + source: () => string | Uint8Array; +}; + type WebpackModule = { - BannerPlugin?: PluginClass; DefinePlugin?: PluginClass; + Compilation?: { + PROCESS_ASSETS_STAGE_ADDITIONS: number; + }; + sources?: { + ReplaceSource: new (source: WebpackSource) => WebpackSource & { + insert: (position: number, value: string) => void; + }; + }; default?: WebpackModule; }; @@ -25,13 +36,15 @@ function loadWebpack(): WebpackModule { } const webpack = loadWebpack(); -const BannerPlugin = webpack.BannerPlugin ?? webpack.default?.BannerPlugin; const DefinePlugin = webpack.DefinePlugin ?? webpack.default?.DefinePlugin; +const Compilation = webpack.Compilation ?? webpack.default?.Compilation; +const sources = webpack.sources ?? webpack.default?.sources; // eslint-disable-next-line @typescript-eslint/no-explicit-any export const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any = sentryWebpackPluginFactory({ - BannerPlugin, DefinePlugin, + Compilation, + sources, }); export type { SentryWebpackPluginOptions }; diff --git a/packages/bundler-plugins/src/webpack/webpack4and5.ts b/packages/bundler-plugins/src/webpack/webpack4and5.ts index d58f37aefab8..bddc92a8f4c5 100644 --- a/packages/bundler-plugins/src/webpack/webpack4and5.ts +++ b/packages/bundler-plugins/src/webpack/webpack4and5.ts @@ -9,10 +9,10 @@ import { getDebugIdSnippet, createDebugIdUploadFunction, } from '../core/index'; +import { getCodeInjectionPosition } from '../core/get-code-injection-position'; import * as path from 'node:path'; import { fileURLToPath } from 'node:url'; import { createRequire } from 'node:module'; -import { randomUUID } from 'node:crypto'; const _req = createRequire(import.meta.url); @@ -36,23 +36,17 @@ try { // since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version // https://github.com/webpack/webpack/commit/65eca2e529ce1d79b79200d4bdb1ce1b81141459 -interface BannerPluginCallbackArg { - chunk?: { - hash?: string; - contentHash?: { - javascript?: string; - }; - }; -} - -type UnsafeBannerPlugin = { +type UnsafeDefinePlugin = { // eslint-disable-next-line @typescript-eslint/no-explicit-any new (options: any): unknown; }; -type UnsafeDefinePlugin = { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - new (options: any): unknown; +type WebpackCompilationApi = { + PROCESS_ASSETS_STAGE_ADDITIONS: number; +}; + +type WebpackSources = { + ReplaceSource: new (source: WebpackSource) => WebpackReplaceSource; }; type WebpackModule = { @@ -66,6 +60,7 @@ type WebpackLoaderContext = { }; type WebpackCompilationContext = { + chunks: Iterable<{ files: Iterable }>; compiler: { webpack?: { NormalModule?: { @@ -81,9 +76,26 @@ type WebpackCompilationContext = { normalModuleLoader?: { tap: (name: string, callback: (loaderContext: WebpackLoaderContext, module: WebpackModule) => void) => void; }; + processAssets: { + tap: ( + options: { name: string; stage: number }, + callback: (assets: Record) => void, + ) => void; + }; }; + updateAsset: (name: string, source: WebpackSource) => void; +}; + +type WebpackSource = { + source: () => string | Uint8Array; +}; + +type WebpackReplaceSource = WebpackSource & { + insert: (position: number, value: string) => void; }; +const WEBPACK_JAVASCRIPT_ASSET_REGEX = /\.(?:js|ts|jsx|tsx|mjs|cjs)(?:\?[^?]*)?(?:#[^#]*)?$/; + type WebpackCompiler = { options: { plugins?: unknown[]; @@ -104,8 +116,9 @@ type WebpackCompiler = { }; }; webpack?: { - BannerPlugin?: UnsafeBannerPlugin; DefinePlugin?: UnsafeDefinePlugin; + Compilation?: WebpackCompilationApi; + sources?: WebpackSources; }; }; @@ -137,19 +150,20 @@ function getWebpackMajorVersion(): string | undefined { } /** - * The factory function accepts BannerPlugin and DefinePlugin classes in - * order to avoid direct dependencies on webpack. + * The factory accepts Webpack APIs to avoid a direct dependency on Webpack. * - * This allow us to export version of the plugin for webpack 5.1+ and compatible environments. + * This allows us to export a version of the plugin for Webpack 5.1+ and compatible environments. * * Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version. */ export function sentryWebpackPluginFactory({ - BannerPlugin: UnsafeBannerPlugin, DefinePlugin: UnsafeDefinePlugin, + Compilation: UnsafeCompilation, + sources: unsafeSources, }: { - BannerPlugin?: UnsafeBannerPlugin; DefinePlugin?: UnsafeDefinePlugin; + Compilation?: WebpackCompilationApi; + sources?: WebpackSources; } = {}) { return function sentryWebpackPlugin(userOptions: SentryWebpackPluginOptions = {}) { const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, { @@ -216,32 +230,57 @@ export function sentryWebpackPluginFactory({ }); // Get the correct plugin classes (webpack 5.1+ vs older versions) - const BannerPlugin = compiler?.webpack?.BannerPlugin || UnsafeBannerPlugin; const DefinePlugin = compiler?.webpack?.DefinePlugin || UnsafeDefinePlugin; - // Add BannerPlugin for code injection (release, metadata, debug IDs) + // Injecting through BannerPlugin would place executable code before directive prologues. if (!staticInjectionCode.isEmpty() || sourcemapsEnabled) { - if (!BannerPlugin) { + const ReplaceSource = compiler.webpack?.sources?.ReplaceSource || unsafeSources?.ReplaceSource; + const processAssetsStage = + compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS ?? + UnsafeCompilation?.PROCESS_ASSETS_STAGE_ADDITIONS; + + if (!ReplaceSource || processAssetsStage === undefined) { logger.warn( - 'BannerPlugin is not available. Skipping code injection. This usually means webpack is not properly configured.', + 'Webpack sources are not available. Skipping code injection. This usually means webpack is not properly configured.', ); } else { - compiler.options.plugins = compiler.options.plugins || []; - compiler.options.plugins.push( - new BannerPlugin({ - raw: true, - include: /\.(js|ts|jsx|tsx|mjs|cjs)(\?[^?]*)?(#[^#]*)?$/, - banner: (arg?: BannerPluginCallbackArg) => { - const codeToInject = staticInjectionCode.clone(); - if (sourcemapsEnabled) { - const hash = arg?.chunk?.contentHash?.javascript ?? arg?.chunk?.hash; - const debugId = hash ? stringToUUID(hash) : randomUUID(); - codeToInject.append(getDebugIdSnippet(debugId)); + compiler.hooks.thisCompilation.tap('sentry-webpack-plugin-injection', compilation => { + compilation.hooks.processAssets.tap( + { + name: 'sentry-webpack-plugin-injection', + stage: processAssetsStage, + }, + assets => { + for (const chunk of compilation.chunks) { + for (const assetName of chunk.files) { + if (!WEBPACK_JAVASCRIPT_ASSET_REGEX.test(assetName)) { + continue; + } + + const source = assets[assetName]; + if (!source) { + continue; + } + + const sourceContents = source.source(); + const codeString = + typeof sourceContents === 'string' ? sourceContents : Buffer.from(sourceContents).toString(); + const codeToInject = staticInjectionCode.clone(); + if (sourcemapsEnabled) { + codeToInject.append(getDebugIdSnippet(stringToUUID(codeString))); + } + + const injectionPosition = getCodeInjectionPosition(codeString); + const injection = + injectionPosition === codeString.length ? `\n${codeToInject.code()}` : codeToInject.code(); + const updatedSource = new ReplaceSource(source); + updatedSource.insert(injectionPosition, injection); + compilation.updateAsset(assetName, updatedSource); + } } - return codeToInject.code(); }, - }), - ); + ); + }); } } From 604844ecf8772b44cf71b93e8813e6a4e2d00e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 8 Sep 2026 20:01:21 +0200 Subject: [PATCH 03/25] test(bundler-plugins): Add source map injection coverage Co-Authored-By: OpenAI Codex --- .../test/rollup/public-api.test.ts | 14 ++++++++ .../test/webpack/webpack4and5.test.ts | 34 ++++++++++++++++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/packages/bundler-plugins/test/rollup/public-api.test.ts b/packages/bundler-plugins/test/rollup/public-api.test.ts index 6c46a72fe612..807f923cd6e8 100644 --- a/packages/bundler-plugins/test/rollup/public-api.test.ts +++ b/packages/bundler-plugins/test/rollup/public-api.test.ts @@ -154,6 +154,20 @@ describe('Hooks', () => { `); }); + it('preserves source mappings when injecting after a directive prologue', () => { + const code = '"use strict";\nglobalThis.applicationStarted = true;'; + const result = renderChunk(code, { fileName: 'bundle.js' }); + + expect(result).not.toBeNull(); + expect(JSON.parse(result?.map.toString() ?? '')).toEqual({ + version: 3, + file: 'bundle.js', + sources: ['bundle.js'], + names: [], + mappings: 'AAAA,CAAC,GAAG,CAAC,MAAM,CAAC;qYACZ,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI', + }); + }); + it.each([ ['when the directive has no semicolon', '"use strict"\n'], ['when another directive precedes it', '"use client";\n"use strict";\n'], diff --git a/packages/bundler-plugins/test/webpack/webpack4and5.test.ts b/packages/bundler-plugins/test/webpack/webpack4and5.test.ts index 1f014fb3f9b3..050b25153c43 100644 --- a/packages/bundler-plugins/test/webpack/webpack4and5.test.ts +++ b/packages/bundler-plugins/test/webpack/webpack4and5.test.ts @@ -1,16 +1,21 @@ import webpack from 'webpack'; +import MagicString from 'magic-string'; import { runInNewContext } from 'node:vm'; import { describe, expect, it } from 'vitest'; import { sentryWebpackPluginFactory } from '../../src/webpack/webpack4and5'; -function runWebpackInjection(assetName: string, code: string, chunkFiles: string[] = [assetName]): string { +function runWebpackSourceInjection( + assetName: string, + source: webpack.sources.Source, + chunkFiles: string[] = [assetName], +): webpack.sources.Source { const webpackPlugin = sentryWebpackPluginFactory()({ release: { inject: false }, telemetry: false, }); let compilationCallback!: (compilation: unknown) => void; let processAssets!: (assets: Record) => void; - let output: webpack.sources.Source = new webpack.sources.RawSource(code); + let output = source; const compiler = { options: { plugins: [] as unknown[] }, webpack: { @@ -44,9 +49,13 @@ function runWebpackInjection(assetName: string, code: string, chunkFiles: string webpackPlugin.apply(compiler as never); compilationCallback(compilation); - processAssets({ [assetName]: new webpack.sources.RawSource(code) }); + processAssets({ [assetName]: source }); + + return output; +} - return output.source().toString(); +function runWebpackInjection(assetName: string, code: string, chunkFiles: string[] = [assetName]): string { + return runWebpackSourceInjection(assetName, new webpack.sources.RawSource(code), chunkFiles).source().toString(); } describe('sentryWebpackPluginFactory', () => { @@ -61,6 +70,23 @@ describe('sentryWebpackPluginFactory', () => { expect(Object.keys(context._sentryDebugIds ?? {})).toHaveLength(1); }); + it('preserves source mappings when injecting after a directive prologue', () => { + const code = '"use strict";\nglobalThis.applicationStarted = true;'; + const inputMap = new MagicString(code).generateMap({ + source: 'application.js', + hires: 'boundary' as unknown as undefined, + includeContent: true, + }); + const source = new webpack.sources.SourceMapSource(code, 'bundle.js', inputMap.toString()); + + const output = runWebpackSourceInjection('bundle.js', source); + const outputMap = output.map(); + + expect(outputMap?.sources).toEqual(['application.js']); + expect(outputMap?.sourcesContent).toEqual([code]); + expect(outputMap?.mappings).toBe('AAAA,CAAC,GAAG,CAAC,MAAM,CAAC;AACZ,+YAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI'); + }); + it.each([ ['a semicolonless directive', '"use strict"'], ['trailing whitespace', '"use strict" '], From a04a30b29bba4d6dbdb01f588004690fd3bc917e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 9 Sep 2026 09:45:23 +0200 Subject: [PATCH 04/25] test(bundler-plugins): Cover esbuild directive preservation Co-Authored-By: OpenAI Codex --- .../fixtures/esbuild/cjs-directives.config.js | 33 +++++++++++++++++++ .../fixtures/esbuild/cjs-directives.test.ts | 19 +++++++++++ .../fixtures/esbuild/src/cjs-directives.js | 11 +++++++ .../fixtures/esbuild/src/sloppy-mode.cjs | 4 +++ .../fixtures/esbuild/src/strict-mode.cjs | 6 ++++ 5 files changed, 73 insertions(+) create mode 100644 dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.config.js create mode 100644 dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.test.ts create mode 100644 dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/cjs-directives.js create mode 100644 dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/sloppy-mode.cjs create mode 100644 dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/strict-mode.cjs diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.config.js b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.config.js new file mode 100644 index 000000000000..389f1177121c --- /dev/null +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.config.js @@ -0,0 +1,33 @@ +import * as esbuild from "esbuild"; +import { sentryEsbuildPlugin } from "@sentry/bundler-plugins/esbuild"; + +await esbuild.build({ + entryPoints: ["./src/cjs-directives.js"], + bundle: true, + outfile: "./out/cjs-directives/static-injection.cjs", + minify: false, + format: "cjs", + plugins: [ + sentryEsbuildPlugin({ + telemetry: false, + release: { name: "strict-mode-release", create: false }, + sourcemaps: { disable: true }, + }), + ], +}); + +await esbuild.build({ + entryPoints: ["./src/cjs-directives.js"], + bundle: true, + outfile: "./out/cjs-directives/debug-id-injection.cjs", + minify: false, + format: "cjs", + sourcemap: true, + plugins: [ + sentryEsbuildPlugin({ + telemetry: false, + release: { inject: false }, + sourcemaps: { disable: "disable-upload" }, + }), + ], +}); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.test.ts new file mode 100644 index 000000000000..8dff9d9dec14 --- /dev/null +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.test.ts @@ -0,0 +1,19 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, runFileInNode }) => { + runBundler(); + + expect(JSON.parse(runFileInNode("static-injection.cjs"))).toEqual({ + strictModePreserved: true, + sloppyModePreserved: true, + releaseInjected: true, + debugIdInjected: false, + }); + expect(JSON.parse(runFileInNode("debug-id-injection.cjs"))).toEqual({ + strictModePreserved: true, + sloppyModePreserved: true, + releaseInjected: false, + debugIdInjected: true, + }); +}); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/cjs-directives.js b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/cjs-directives.js new file mode 100644 index 000000000000..60fa2ab2dc5d --- /dev/null +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/cjs-directives.js @@ -0,0 +1,11 @@ +import "./strict-mode.cjs"; +import "./sloppy-mode.cjs"; + +console.log( + JSON.stringify({ + strictModePreserved: globalThis.strictModePreserved, + sloppyModePreserved: globalThis.sloppyModePreserved, + releaseInjected: globalThis.SENTRY_RELEASE?.id === "strict-mode-release", + debugIdInjected: Object.keys(globalThis._sentryDebugIds || {}).length === 1, + }) +); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/sloppy-mode.cjs b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/sloppy-mode.cjs new file mode 100644 index 000000000000..617c6ab75c49 --- /dev/null +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/sloppy-mode.cjs @@ -0,0 +1,4 @@ +globalThis.sloppyModePreserved = + (function () { + return this; + })() === globalThis; diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/strict-mode.cjs b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/strict-mode.cjs new file mode 100644 index 000000000000..249368c18570 --- /dev/null +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/strict-mode.cjs @@ -0,0 +1,6 @@ +"use strict"; + +globalThis.strictModePreserved = + (function () { + return this; + })() === undefined; From 80941665da17736b174cf42ec8498bfae486371e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 9 Sep 2026 10:20:19 +0200 Subject: [PATCH 05/25] fix(bundler-plugins): Recognize mts and cts webpack assets Co-Authored-By: OpenAI Codex --- packages/bundler-plugins/src/webpack/webpack4and5.ts | 2 +- packages/bundler-plugins/test/webpack/webpack4and5.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bundler-plugins/src/webpack/webpack4and5.ts b/packages/bundler-plugins/src/webpack/webpack4and5.ts index bddc92a8f4c5..782cc7ebf887 100644 --- a/packages/bundler-plugins/src/webpack/webpack4and5.ts +++ b/packages/bundler-plugins/src/webpack/webpack4and5.ts @@ -94,7 +94,7 @@ type WebpackReplaceSource = WebpackSource & { insert: (position: number, value: string) => void; }; -const WEBPACK_JAVASCRIPT_ASSET_REGEX = /\.(?:js|ts|jsx|tsx|mjs|cjs)(?:\?[^?]*)?(?:#[^#]*)?$/; +const WEBPACK_JAVASCRIPT_ASSET_REGEX = /\.(?:js|ts|jsx|tsx|mjs|cjs|mts|cts)(?:\?[^?]*)?(?:#[^#]*)?$/; type WebpackCompiler = { options: { diff --git a/packages/bundler-plugins/test/webpack/webpack4and5.test.ts b/packages/bundler-plugins/test/webpack/webpack4and5.test.ts index 050b25153c43..563810cd1e41 100644 --- a/packages/bundler-plugins/test/webpack/webpack4and5.test.ts +++ b/packages/bundler-plugins/test/webpack/webpack4and5.test.ts @@ -105,7 +105,7 @@ describe('sentryWebpackPluginFactory', () => { expect(Object.keys(context._sentryDebugIds ?? {})).toHaveLength(1); }); - it.each(['.ts', '.tsx', '.jsx'])('injects into a %s asset', extension => { + it.each(['.ts', '.tsx', '.jsx', '.mts', '.cts'])('injects into a %s asset', extension => { const output = runWebpackInjection(`bundle${extension}`, 'globalThis.bundleLoaded = true;'); const context: { _sentryDebugIds?: Record } = {}; From 1948f3ba9bd332fb765e014e9124401d66ea985b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 9 Sep 2026 15:34:34 +0200 Subject: [PATCH 06/25] fix(bundler-plugins): Resolve directive injection CI regressions Co-Authored-By: OpenAI Codex --- .../fixtures/esbuild/cjs-directives.config.js | 16 ++++++++++++---- .../fixtures/esbuild/cjs-directives.test.ts | 12 ++++++++++-- .../fixtures/esbuild/src/cjs-directives.js | 11 ----------- .../fixtures/esbuild/src/sloppy-mode.cjs | 8 ++++++++ .../fixtures/esbuild/src/strict-mode.cjs | 8 ++++++++ .../webpack5/after-upload-deletion.test.ts | 4 ++-- .../fixtures/webpack5/application-key.test.ts | 4 ++-- .../fixtures/webpack5/basic-cjs.test.ts | 4 ++-- .../webpack5/basic-release-disabled.test.ts | 4 ++-- .../fixtures/webpack5/basic-sourcemaps.test.ts | 4 ++-- .../fixtures/webpack5/basic.test.ts | 4 ++-- .../fixtures/webpack5/build-info.test.ts | 4 ++-- .../webpack5/bundle-size-optimizations.test.ts | 4 ++-- .../component-annotation-disabled.test.ts | 4 ++-- .../webpack5/component-annotation-next.test.ts | 4 ++-- .../webpack5/component-annotation.test.ts | 4 ++-- .../webpack5/debugids-already-injected.test.ts | 4 ++-- .../fixtures/webpack5/module-metadata.test.ts | 4 ++-- .../webpack5/multiple-entry-points.test.ts | 8 ++++---- .../fixtures/webpack5/release-disabled.test.ts | 4 ++-- .../fixtures/webpack5/telemetry.test.ts | 4 ++-- packages/bundler-plugins/src/rollup/index.ts | 2 +- .../src/webpack/webpack4and5.ts | 14 +++++++++++--- .../test/rollup/public-api.test.ts | 5 +++-- .../test/webpack/webpack4and5.test.ts | 18 ++++++++++++++++-- 25 files changed, 103 insertions(+), 59 deletions(-) delete mode 100644 dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/cjs-directives.js diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.config.js b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.config.js index 389f1177121c..537b3d0abfc9 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.config.js +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.config.js @@ -2,9 +2,13 @@ import * as esbuild from "esbuild"; import { sentryEsbuildPlugin } from "@sentry/bundler-plugins/esbuild"; await esbuild.build({ - entryPoints: ["./src/cjs-directives.js"], + entryPoints: { + strict: "./src/strict-mode.cjs", + sloppy: "./src/sloppy-mode.cjs", + }, bundle: true, - outfile: "./out/cjs-directives/static-injection.cjs", + outdir: "./out/cjs-directives/static-injection", + outExtension: { ".js": ".cjs" }, minify: false, format: "cjs", plugins: [ @@ -17,9 +21,13 @@ await esbuild.build({ }); await esbuild.build({ - entryPoints: ["./src/cjs-directives.js"], + entryPoints: { + strict: "./src/strict-mode.cjs", + sloppy: "./src/sloppy-mode.cjs", + }, bundle: true, - outfile: "./out/cjs-directives/debug-id-injection.cjs", + outdir: "./out/cjs-directives/debug-id-injection", + outExtension: { ".js": ".cjs" }, minify: false, format: "cjs", sourcemap: true, diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.test.ts index 8dff9d9dec14..5cfd748eb78e 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.test.ts @@ -4,14 +4,22 @@ import { test } from "./utils"; test(import.meta.url, ({ runBundler, runFileInNode }) => { runBundler(); - expect(JSON.parse(runFileInNode("static-injection.cjs"))).toEqual({ + expect(JSON.parse(runFileInNode("static-injection/strict.cjs"))).toEqual({ strictModePreserved: true, + releaseInjected: true, + debugIdInjected: false, + }); + expect(JSON.parse(runFileInNode("static-injection/sloppy.cjs"))).toEqual({ sloppyModePreserved: true, releaseInjected: true, debugIdInjected: false, }); - expect(JSON.parse(runFileInNode("debug-id-injection.cjs"))).toEqual({ + expect(JSON.parse(runFileInNode("debug-id-injection/strict.cjs"))).toEqual({ strictModePreserved: true, + releaseInjected: false, + debugIdInjected: true, + }); + expect(JSON.parse(runFileInNode("debug-id-injection/sloppy.cjs"))).toEqual({ sloppyModePreserved: true, releaseInjected: false, debugIdInjected: true, diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/cjs-directives.js b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/cjs-directives.js deleted file mode 100644 index 60fa2ab2dc5d..000000000000 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/cjs-directives.js +++ /dev/null @@ -1,11 +0,0 @@ -import "./strict-mode.cjs"; -import "./sloppy-mode.cjs"; - -console.log( - JSON.stringify({ - strictModePreserved: globalThis.strictModePreserved, - sloppyModePreserved: globalThis.sloppyModePreserved, - releaseInjected: globalThis.SENTRY_RELEASE?.id === "strict-mode-release", - debugIdInjected: Object.keys(globalThis._sentryDebugIds || {}).length === 1, - }) -); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/sloppy-mode.cjs b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/sloppy-mode.cjs index 617c6ab75c49..ce708c7a27de 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/sloppy-mode.cjs +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/sloppy-mode.cjs @@ -2,3 +2,11 @@ globalThis.sloppyModePreserved = (function () { return this; })() === globalThis; + +console.log( + JSON.stringify({ + sloppyModePreserved: globalThis.sloppyModePreserved, + releaseInjected: globalThis.SENTRY_RELEASE?.id === "strict-mode-release", + debugIdInjected: Object.keys(globalThis._sentryDebugIds || {}).length === 1, + }) +); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/strict-mode.cjs b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/strict-mode.cjs index 249368c18570..fa2e93dba59b 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/strict-mode.cjs +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/strict-mode.cjs @@ -4,3 +4,11 @@ globalThis.strictModePreserved = (function () { return this; })() === undefined; + +console.log( + JSON.stringify({ + strictModePreserved: globalThis.strictModePreserved, + releaseInjected: globalThis.SENTRY_RELEASE?.id === "strict-mode-release", + debugIdInjected: Object.keys(globalThis._sentryDebugIds || {}).length === 1, + }) +); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/after-upload-deletion.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/after-upload-deletion.test.ts index a4bcd8a767cb..021d4743e331 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/after-upload-deletion.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/after-upload-deletion.test.ts @@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/application-key.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/application-key.test.ts index 76b6d9adb0e8..71121ac814cb 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/application-key.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/application-key.test.ts @@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-cjs.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-cjs.test.ts index 8095d1ba0754..f12e4b7fc737 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-cjs.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-cjs.test.ts @@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-release-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-release-disabled.test.ts index c7fc5905957a..42134e3f0a58 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-release-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-release-disabled.test.ts @@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-sourcemaps.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-sourcemaps.test.ts index fbcababfd029..b7534c90402f 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-sourcemaps.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-sourcemaps.test.ts @@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic.test.ts index 8095d1ba0754..f12e4b7fc737 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic.test.ts @@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/build-info.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/build-info.test.ts index 4742786c9b76..d29a8157fa40 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/build-info.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/build-info.test.ts @@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"build-information-injection-test"};e.SENTRY_BUILD_INFO={"deps":["@babel/preset-react","@sentry/bundler-plugins","babel-loader","webpack","webpack-cli"],"depsVersions":{"webpack":5},"nodeVersion":"NODE_VERSION"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"build-information-injection-test"};e.SENTRY_BUILD_INFO={"deps":["@babel/preset-react","@sentry/bundler-plugins","babel-loader","webpack","webpack-cli"],"depsVersions":{"webpack":5},"nodeVersion":"NODE_VERSION"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/bundle-size-optimizations.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/bundle-size-optimizations.test.ts index 7313767b10ad..02079036d9c9 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/bundle-size-optimizations.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/bundle-size-optimizations.test.ts @@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "bundle.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "bundle.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; console.log( JSON.stringify({ diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-disabled.test.ts index 39a5b67c4108..78280fc69da0 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-disabled.test.ts @@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "app.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; // UNUSED EXPORTS: default diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-next.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-next.test.ts index 28d9443ae50d..a5556a5624b5 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-next.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-next.test.ts @@ -10,8 +10,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, ctx }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "app.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; // UNUSED EXPORTS: default diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation.test.ts index 1c5f9f8cc6ac..495704896f1e 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation.test.ts @@ -10,8 +10,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, ctx }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "app.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; // UNUSED EXPORTS: default diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/debugids-already-injected.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/debugids-already-injected.test.ts index 3509e3431c86..096b9c89e43b 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/debugids-already-injected.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/debugids-already-injected.test.ts @@ -9,8 +9,8 @@ test(import.meta.url, ({ runBundler, createTempDir }) => { const files = readAllFiles(tempDir); expect(files).toMatchInlineSnapshot(` { - "33730b8e-5b8d-4795-94b2-666cea28fce6-0.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "33730b8e-5b8d-4795-94b2-666cea28fce6-0.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/module-metadata.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/module-metadata.test.ts index 2672e9edf824..3c3b18580a1d 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/module-metadata.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/module-metadata.test.ts @@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/multiple-entry-points.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/multiple-entry-points.test.ts index 5f054a9ba2da..da52345c24e8 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/multiple-entry-points.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/multiple-entry-points.test.ts @@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "entry1.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; ;// ./src/common.js @@ -21,8 +21,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { /******/ })() ;", - "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "entry2.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; ;// ./src/common.js diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/release-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/release-disabled.test.ts index 5288fc48bcba..dda6c9ab8889 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/release-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/release-disabled.test.ts @@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/telemetry.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/telemetry.test.ts index b26f095092af..d2d6f3d77c7e 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/telemetry.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/telemetry.test.ts @@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - /******/ (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + (() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/packages/bundler-plugins/src/rollup/index.ts b/packages/bundler-plugins/src/rollup/index.ts index 4588d7fd9bde..10482a5e30bf 100644 --- a/packages/bundler-plugins/src/rollup/index.ts +++ b/packages/bundler-plugins/src/rollup/index.ts @@ -260,7 +260,7 @@ export function _rollupPluginInternal( const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName }); const injectionPosition = getCodeInjectionPosition(code); - const codeToInject = injectionPosition === code.length ? `\n${injectCode.code()}` : injectCode.code(); + const codeToInject = injectionPosition === code.length ? `\n${injectCode.code()}` : `${injectCode.code()}\n`; if (injectionPosition > 0) { ms.appendLeft(injectionPosition, codeToInject); diff --git a/packages/bundler-plugins/src/webpack/webpack4and5.ts b/packages/bundler-plugins/src/webpack/webpack4and5.ts index 782cc7ebf887..fd2e3d7cf4e5 100644 --- a/packages/bundler-plugins/src/webpack/webpack4and5.ts +++ b/packages/bundler-plugins/src/webpack/webpack4and5.ts @@ -13,6 +13,7 @@ import { getCodeInjectionPosition } from '../core/get-code-injection-position'; import * as path from 'node:path'; import { fileURLToPath } from 'node:url'; import { createRequire } from 'node:module'; +import { randomUUID } from 'node:crypto'; const _req = createRequire(import.meta.url); @@ -60,7 +61,11 @@ type WebpackLoaderContext = { }; type WebpackCompilationContext = { - chunks: Iterable<{ files: Iterable }>; + chunks: Iterable<{ + files: Iterable; + hash?: string; + contentHash?: { javascript?: string }; + }>; compiler: { webpack?: { NormalModule?: { @@ -267,12 +272,15 @@ export function sentryWebpackPluginFactory({ typeof sourceContents === 'string' ? sourceContents : Buffer.from(sourceContents).toString(); const codeToInject = staticInjectionCode.clone(); if (sourcemapsEnabled) { - codeToInject.append(getDebugIdSnippet(stringToUUID(codeString))); + const hash = chunk.contentHash?.javascript ?? chunk.hash; + codeToInject.append(getDebugIdSnippet(hash ? stringToUUID(hash) : randomUUID())); } const injectionPosition = getCodeInjectionPosition(codeString); const injection = - injectionPosition === codeString.length ? `\n${codeToInject.code()}` : codeToInject.code(); + injectionPosition === codeString.length + ? `\n${codeToInject.code()}` + : `${codeToInject.code()}\n`; const updatedSource = new ReplaceSource(source); updatedSource.insert(injectionPosition, injection); compilation.updateAsset(assetName, updatedSource); diff --git a/packages/bundler-plugins/test/rollup/public-api.test.ts b/packages/bundler-plugins/test/rollup/public-api.test.ts index 807f923cd6e8..ce93f0e4d948 100644 --- a/packages/bundler-plugins/test/rollup/public-api.test.ts +++ b/packages/bundler-plugins/test/rollup/public-api.test.ts @@ -149,7 +149,8 @@ describe('Hooks', () => { expect(result).not.toBeNull(); expect(result?.code).toMatchInlineSnapshot(` - ""use strict";!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="79a86c07-8ecc-4367-82b0-88cf822f2d41",e._sentryDebugIdIdentifier="sentry-dbid-79a86c07-8ecc-4367-82b0-88cf822f2d41");}catch(e){}}(); + ""use strict"; + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="79a86c07-8ecc-4367-82b0-88cf822f2d41",e._sentryDebugIdIdentifier="sentry-dbid-79a86c07-8ecc-4367-82b0-88cf822f2d41");}catch(e){}}(); console.log("Hello world");" `); }); @@ -164,7 +165,7 @@ describe('Hooks', () => { file: 'bundle.js', sources: ['bundle.js'], names: [], - mappings: 'AAAA,CAAC,GAAG,CAAC,MAAM,CAAC;qYACZ,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI', + mappings: 'AAAA,CAAC,GAAG,CAAC,MAAM,CAAC;;AACZ,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI', }); }); diff --git a/packages/bundler-plugins/test/webpack/webpack4and5.test.ts b/packages/bundler-plugins/test/webpack/webpack4and5.test.ts index 563810cd1e41..55ed36202f13 100644 --- a/packages/bundler-plugins/test/webpack/webpack4and5.test.ts +++ b/packages/bundler-plugins/test/webpack/webpack4and5.test.ts @@ -8,6 +8,7 @@ function runWebpackSourceInjection( assetName: string, source: webpack.sources.Source, chunkFiles: string[] = [assetName], + chunkHash?: string, ): webpack.sources.Source { const webpackPlugin = sentryWebpackPluginFactory()({ release: { inject: false }, @@ -33,7 +34,7 @@ function runWebpackSourceInjection( }, }; const compilation = { - chunks: [{ files: chunkFiles }], + chunks: [{ files: chunkFiles, hash: chunkHash }], compiler: {}, hooks: { processAssets: { @@ -84,7 +85,20 @@ describe('sentryWebpackPluginFactory', () => { expect(outputMap?.sources).toEqual(['application.js']); expect(outputMap?.sourcesContent).toEqual([code]); - expect(outputMap?.mappings).toBe('AAAA,CAAC,GAAG,CAAC,MAAM,CAAC;AACZ,+YAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI'); + expect(outputMap?.mappings).toBe('AAAA,CAAC,GAAG,CAAC,MAAM,CAAC;AACZ;AAAA,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI'); + }); + + it('derives the debug ID from the Webpack chunk hash', () => { + const output = runWebpackSourceInjection( + 'bundle.js', + new webpack.sources.RawSource('globalThis.bundleLoaded = true;'), + ['bundle.js'], + 'stable-webpack-chunk-hash', + ) + .source() + .toString(); + + expect(output).toContain('sentry-dbid-1924c426-ebb3-47c2-8293-ea326e499bcc'); }); it.each([ From 179dcee7b9bb021489d432c9f270462f392b5e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 9 Sep 2026 20:42:15 +0200 Subject: [PATCH 07/25] Update Rollup injection snapshots Co-Authored-By: OpenAI Codex --- .../rollup3/after-upload-deletion.test.ts | 3 +- .../fixtures/rollup3/application-key.test.ts | 3 +- .../fixtures/rollup3/basic-cjs.test.ts | 3 +- .../rollup3/basic-release-disabled.test.ts | 3 +- .../fixtures/rollup3/basic-sourcemaps.test.ts | 3 +- .../fixtures/rollup3/basic.test.ts | 3 +- .../fixtures/rollup3/build-info.test.ts | 3 +- .../rollup3/bundle-size-optimizations.test.ts | 3 +- .../component-annotation-disabled.test.ts | 3 +- .../rollup3/component-annotation-next.test.ts | 3 +- .../rollup3/component-annotation.test.ts | 3 +- .../rollup3/dont-mess-up-user-code.test.ts | 3 +- .../fixtures/rollup3/module-metadata.test.ts | 3 +- .../rollup3/multiple-entry-points.test.ts | 9 +++-- .../fixtures/rollup3/query-param.test.ts | 9 +++-- .../fixtures/rollup3/release-disabled.test.ts | 3 +- .../fixtures/rollup3/telemetry.test.ts | 3 +- .../rollup4/after-upload-deletion.test.ts | 3 +- .../fixtures/rollup4/application-key.test.ts | 3 +- .../fixtures/rollup4/basic-cjs.test.ts | 3 +- .../rollup4/basic-release-disabled.test.ts | 3 +- .../fixtures/rollup4/basic-sourcemaps.test.ts | 3 +- .../fixtures/rollup4/basic.test.ts | 3 +- .../fixtures/rollup4/build-info.test.ts | 3 +- .../rollup4/bundle-size-optimizations.test.ts | 3 +- .../component-annotation-disabled.test.ts | 3 +- .../rollup4/component-annotation-next.test.ts | 3 +- .../rollup4/component-annotation.test.ts | 3 +- .../rollup4/debugids-already-injected.test.ts | 3 +- .../rollup4/dont-mess-up-user-code.test.ts | 3 +- .../fixtures/rollup4/module-metadata.test.ts | 3 +- .../rollup4/multiple-entry-points.test.ts | 9 +++-- .../fixtures/rollup4/query-param.test.ts | 9 +++-- .../fixtures/rollup4/release-disabled.test.ts | 3 +- .../fixtures/rollup4/telemetry.test.ts | 3 +- .../__snapshots__/public-api.test.ts.snap | 25 +++++++++++--- .../test/rollup/public-api.test.ts | 34 +++++++++++-------- 37 files changed, 126 insertions(+), 62 deletions(-) diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/after-upload-deletion.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/after-upload-deletion.test.ts index a4305945f767..0bce8d75055b 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/after-upload-deletion.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/after-upload-deletion.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); //# sourceMappingURL=basic.js.map ", } diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/application-key.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/application-key.test.ts index 893eb03cfbb1..9281f822cb81 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/application-key.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/application-key.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); ", "sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"], ["release","set-commits","CURRENT_SHA","--auto"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-release-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-release-disabled.test.ts index ebf24e57ed36..afb3e329719b 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-release-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-release-disabled.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); ", } `); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-sourcemaps.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-sourcemaps.test.ts index 1973196d89aa..2a768de2301e 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-sourcemaps.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-sourcemaps.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); //# sourceMappingURL=basic.js.map ", "basic.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;scACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC"}", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic.test.ts index b160e72a864c..8877d0a9eb48 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); ", "sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"], ["release","set-commits","CURRENT_SHA","--auto"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/build-info.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/build-info.test.ts index e9b8e53ac2e3..d9dc4b1f6de6 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/build-info.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/build-info.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"build-information-injection-test"};e.SENTRY_BUILD_INFO={"deps":["@rollup/plugin-babel","@rollup/plugin-node-resolve","@sentry/bundler-plugins","react","rollup"],"depsVersions":{"react":19,"rollup":3},"nodeVersion":"NODE_VERSION"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"build-information-injection-test"};e.SENTRY_BUILD_INFO={"deps":["@rollup/plugin-babel","@rollup/plugin-node-resolve","@sentry/bundler-plugins","react","rollup"],"depsVersions":{"react":19,"rollup":3},"nodeVersion":"NODE_VERSION"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); ", } `); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/bundle-size-optimizations.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/bundle-size-optimizations.test.ts index c685a2b794e2..05c36ad3b9cf 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/bundle-size-optimizations.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/bundle-size-optimizations.test.ts @@ -5,7 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "bundle.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log( + "bundle.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log( JSON.stringify({ debug: "b", trace: "b", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-disabled.test.ts index 054e90c0e827..82c4d4c2277a 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-disabled.test.ts @@ -5,7 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { jsx, jsxs } from 'react/jsx-runtime'; + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-next.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-next.test.ts index 62cfe0816cc5..565279b0b40e 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-next.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-next.test.ts @@ -5,7 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { jsx, jsxs } from 'react/jsx-runtime'; + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation.test.ts index 387beb7fda07..b1ed2fb54e56 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation.test.ts @@ -5,7 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { jsx, jsxs } from 'react/jsx-runtime'; + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/dont-mess-up-user-code.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/dont-mess-up-user-code.test.ts index 42d6d3679b9c..fabf4c4422a0 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/dont-mess-up-user-code.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/dont-mess-up-user-code.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "index.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"I am release!"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("I am import!"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"I am release!"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("I am import!"); // eslint-disable-next-line no-console console.log("I am index!"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/module-metadata.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/module-metadata.test.ts index b4acc59902a5..cd934b859408 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/module-metadata.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/module-metadata.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "common.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();function add(a, b) { + "common.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + function add(a, b) { return a + b; } export { add as a }; ", - "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js'; + "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { a as add } from './common.js'; console.log(add(1, 2)); ", - "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js'; + "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { a as add } from './common.js'; console.log(add(2, 4)); ", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/query-param.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/query-param.test.ts index d65cb2e349da..0aa3e70b61eb 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/query-param.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/query-param.test.ts @@ -10,17 +10,20 @@ test(import.meta.url, ({ runBundler, readOutputFiles, ctx }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "common.js?seP58q4g": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();function add(a, b) { + "common.js?seP58q4g": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + function add(a, b) { return a + b; } export { add as a }; ", - "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js?seP58q4g'; + "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { a as add } from './common.js?seP58q4g'; console.log(add(1, 2)); ", - "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js?seP58q4g'; + "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { a as add } from './common.js?seP58q4g'; console.log(add(2, 4)); ", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/release-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/release-disabled.test.ts index 39c7da1959d9..c2a17292386d 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/release-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/release-disabled.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); ", "sentry-cli-mock.json": "["release","set-commits","CURRENT_SHA","--auto"], ["release","finalize","CURRENT_SHA"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/telemetry.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/telemetry.test.ts index 970ebdaefd1d..4889fa9c3031 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/telemetry.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/telemetry.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); ", "sentry-telemetry.json": "[{"sent_at":"TIMESTAMP","sdk":{"name":"sentry.javascript.node","version":"SDK_VERSION"}},[[{"type":"session"},{"sid":"UUID","init":true,"started":"TIMESTAMP","timestamp":"TIMESTAMP","status":"ok","errors":0,"duration":DURATION,"attrs":{"release":"PLUGIN_VERSION","environment":"production"}}]]], [{"event_id":"UUID","sent_at":"TIMESTAMP","sdk":{"name":"sentry.javascript.node","version":"SDK_VERSION"},"trace":{"environment":"production","release":"PLUGIN_VERSION","public_key":"UUID","trace_id":"UUID","org_id":"1","transaction":"Sentry Bundler Plugin execution","sampled":"true","sample_rand":"SAMPLE_RAND","sample_rate":"1"}},[[{"type":"transaction"},{"contexts":{"trace":{"span_id":"SHORT_UUID","trace_id":"UUID","data":{"sentry.origin":"manual","sentry.segment.name.source":"custom","sentry.sample_rate":1},"status":"ok","origin":"manual"},"runtime":{"name":"node","version":"NODE_VERSION"}},"spans":[],"start_timestamp":START_TIMESTAMP,"timestamp":TIMESTAMP,"transaction":"Sentry Bundler Plugin execution","type":"transaction","transaction_info":{"source":"custom"},"platform":"PLATFORM","event_id":"UUID","environment":"production","release":"PLUGIN_VERSION","tags":{"upload-legacy-sourcemaps":false,"module-metadata":false,"inject-build-information":false,"set-commits":"auto","finalize-release":true,"deploy-options":false,"custom-error-handler":false,"sourcemaps-assets":false,"delete-after-upload":false,"sourcemaps-disabled":false,"react-annotate":false,"node":"NODE_VERSION","platform":"PLATFORM","meta-framework":"none","application-key-set":false,"ci":true,"project":"undefined","bundler":"rollup","bundler-major-version":"3"},"user":{},"sdk":{"name":"sentry.javascript.node","version":"SDK_VERSION","integrations":[],"packages":[{"name":"npm:@sentry/node","version":"SDK_VERSION"}]}}]]], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/after-upload-deletion.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/after-upload-deletion.test.ts index a4305945f767..0bce8d75055b 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/after-upload-deletion.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/after-upload-deletion.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); //# sourceMappingURL=basic.js.map ", } diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/application-key.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/application-key.test.ts index 893eb03cfbb1..9281f822cb81 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/application-key.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/application-key.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); ", "sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"], ["release","set-commits","CURRENT_SHA","--auto"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-release-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-release-disabled.test.ts index ebf24e57ed36..afb3e329719b 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-release-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-release-disabled.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); ", } `); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-sourcemaps.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-sourcemaps.test.ts index 1973196d89aa..2a768de2301e 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-sourcemaps.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-sourcemaps.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); //# sourceMappingURL=basic.js.map ", "basic.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;scACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC"}", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic.test.ts index b160e72a864c..8877d0a9eb48 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); ", "sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"], ["release","set-commits","CURRENT_SHA","--auto"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/build-info.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/build-info.test.ts index 3dca9559e716..eab4c35fc0b3 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/build-info.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/build-info.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"build-information-injection-test"};e.SENTRY_BUILD_INFO={"deps":["@rollup/plugin-babel","@rollup/plugin-node-resolve","@sentry/bundler-plugins","react","rollup"],"depsVersions":{"react":19,"rollup":4},"nodeVersion":"NODE_VERSION"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"build-information-injection-test"};e.SENTRY_BUILD_INFO={"deps":["@rollup/plugin-babel","@rollup/plugin-node-resolve","@sentry/bundler-plugins","react","rollup"],"depsVersions":{"react":19,"rollup":4},"nodeVersion":"NODE_VERSION"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); ", } `); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/bundle-size-optimizations.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/bundle-size-optimizations.test.ts index c685a2b794e2..05c36ad3b9cf 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/bundle-size-optimizations.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/bundle-size-optimizations.test.ts @@ -5,7 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "bundle.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log( + "bundle.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log( JSON.stringify({ debug: "b", trace: "b", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-disabled.test.ts index 054e90c0e827..82c4d4c2277a 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-disabled.test.ts @@ -5,7 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { jsx, jsxs } from 'react/jsx-runtime'; + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-next.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-next.test.ts index 62cfe0816cc5..565279b0b40e 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-next.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-next.test.ts @@ -5,7 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { jsx, jsxs } from 'react/jsx-runtime'; + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation.test.ts index 387beb7fda07..b1ed2fb54e56 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation.test.ts @@ -5,7 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { jsx, jsxs } from 'react/jsx-runtime'; + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/debugids-already-injected.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/debugids-already-injected.test.ts index de92ed454402..15912eaa322a 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/debugids-already-injected.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/debugids-already-injected.test.ts @@ -10,7 +10,8 @@ test(import.meta.url, ({ runBundler, createTempDir }) => { expect(files).toMatchInlineSnapshot(` { "252e0338-8927-4f52-bd57-188131defd0f-0.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); //# debugId=00000000-0000-0000-0000-000000000000 //# sourceMappingURL=basic.js.map ", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/dont-mess-up-user-code.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/dont-mess-up-user-code.test.ts index 42d6d3679b9c..fabf4c4422a0 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/dont-mess-up-user-code.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/dont-mess-up-user-code.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "index.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"I am release!"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("I am import!"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"I am release!"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("I am import!"); // eslint-disable-next-line no-console console.log("I am index!"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/module-metadata.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/module-metadata.test.ts index b4acc59902a5..cd934b859408 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/module-metadata.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/module-metadata.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "common.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();function add(a, b) { + "common.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + function add(a, b) { return a + b; } export { add as a }; ", - "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js'; + "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { a as add } from './common.js'; console.log(add(1, 2)); ", - "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js'; + "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { a as add } from './common.js'; console.log(add(2, 4)); ", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/query-param.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/query-param.test.ts index d65cb2e349da..0aa3e70b61eb 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/query-param.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/query-param.test.ts @@ -10,17 +10,20 @@ test(import.meta.url, ({ runBundler, readOutputFiles, ctx }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "common.js?seP58q4g": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();function add(a, b) { + "common.js?seP58q4g": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + function add(a, b) { return a + b; } export { add as a }; ", - "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js?seP58q4g'; + "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { a as add } from './common.js?seP58q4g'; console.log(add(1, 2)); ", - "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js?seP58q4g'; + "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + import { a as add } from './common.js?seP58q4g'; console.log(add(2, 4)); ", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/release-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/release-disabled.test.ts index 39c7da1959d9..c2a17292386d 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/release-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/release-disabled.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); ", "sentry-cli-mock.json": "["release","set-commits","CURRENT_SHA","--auto"], ["release","finalize","CURRENT_SHA"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/telemetry.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/telemetry.test.ts index cfb27aee5b5e..6a979c32c9cc 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/telemetry.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/telemetry.test.ts @@ -6,7 +6,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + console.log("hello world"); ", "sentry-telemetry.json": "[{"sent_at":"TIMESTAMP","sdk":{"name":"sentry.javascript.node","version":"SDK_VERSION"}},[[{"type":"session"},{"sid":"UUID","init":true,"started":"TIMESTAMP","timestamp":"TIMESTAMP","status":"ok","errors":0,"duration":DURATION,"attrs":{"release":"PLUGIN_VERSION","environment":"production"}}]]], [{"event_id":"UUID","sent_at":"TIMESTAMP","sdk":{"name":"sentry.javascript.node","version":"SDK_VERSION"},"trace":{"environment":"production","release":"PLUGIN_VERSION","public_key":"UUID","trace_id":"UUID","org_id":"1","transaction":"Sentry Bundler Plugin execution","sampled":"true","sample_rand":"SAMPLE_RAND","sample_rate":"1"}},[[{"type":"transaction"},{"contexts":{"trace":{"span_id":"SHORT_UUID","trace_id":"UUID","data":{"sentry.origin":"manual","sentry.segment.name.source":"custom","sentry.sample_rate":1},"status":"ok","origin":"manual"},"runtime":{"name":"node","version":"NODE_VERSION"}},"spans":[],"start_timestamp":START_TIMESTAMP,"timestamp":TIMESTAMP,"transaction":"Sentry Bundler Plugin execution","type":"transaction","transaction_info":{"source":"custom"},"platform":"PLATFORM","event_id":"UUID","environment":"production","release":"PLUGIN_VERSION","tags":{"upload-legacy-sourcemaps":false,"module-metadata":false,"inject-build-information":false,"set-commits":"auto","finalize-release":true,"deploy-options":false,"custom-error-handler":false,"sourcemaps-assets":false,"delete-after-upload":false,"sourcemaps-disabled":false,"react-annotate":false,"node":"NODE_VERSION","platform":"PLATFORM","meta-framework":"none","application-key-set":false,"ci":true,"project":"undefined","bundler":"rollup","bundler-major-version":"4"},"user":{},"sdk":{"name":"sentry.javascript.node","version":"SDK_VERSION","integrations":[],"packages":[{"name":"npm:@sentry/node","version":"SDK_VERSION"}]}}]]], diff --git a/packages/bundler-plugins/test/rollup/__snapshots__/public-api.test.ts.snap b/packages/bundler-plugins/test/rollup/__snapshots__/public-api.test.ts.snap index cd0ad570649f..efd140af38e6 100644 --- a/packages/bundler-plugins/test/rollup/__snapshots__/public-api.test.ts.snap +++ b/packages/bundler-plugins/test/rollup/__snapshots__/public-api.test.ts.snap @@ -1,11 +1,26 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Hooks > renderChunk > should process file 'bundle.cjs' 1`] = `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}();console.log("test");"`; +exports[`Hooks > renderChunk > should process file 'bundle.cjs' 1`] = ` +"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}(); +console.log("test");" +`; -exports[`Hooks > renderChunk > should process file 'bundle.js#hash' 1`] = `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}();console.log("test");"`; +exports[`Hooks > renderChunk > should process file 'bundle.js#hash' 1`] = ` +"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}(); +console.log("test");" +`; -exports[`Hooks > renderChunk > should process file 'bundle.js' 1`] = `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}();console.log("test");"`; +exports[`Hooks > renderChunk > should process file 'bundle.js' 1`] = ` +"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}(); +console.log("test");" +`; -exports[`Hooks > renderChunk > should process file 'bundle.js?foo=bar' 1`] = `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}();console.log("test");"`; +exports[`Hooks > renderChunk > should process file 'bundle.js?foo=bar' 1`] = ` +"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}(); +console.log("test");" +`; -exports[`Hooks > renderChunk > should process file 'bundle.mjs' 1`] = `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}();console.log("test");"`; +exports[`Hooks > renderChunk > should process file 'bundle.mjs' 1`] = ` +"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}(); +console.log("test");" +`; diff --git a/packages/bundler-plugins/test/rollup/public-api.test.ts b/packages/bundler-plugins/test/rollup/public-api.test.ts index ce93f0e4d948..296d4416f399 100644 --- a/packages/bundler-plugins/test/rollup/public-api.test.ts +++ b/packages/bundler-plugins/test/rollup/public-api.test.ts @@ -138,9 +138,10 @@ describe('Hooks', () => { const result = renderChunk(code, { fileName: 'bundle.js' }); expect(result).not.toBeNull(); - expect(result?.code).toMatchInlineSnapshot( - `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d4309f93-5358-4ae1-bcf0-3813aa590eb5",e._sentryDebugIdIdentifier="sentry-dbid-d4309f93-5358-4ae1-bcf0-3813aa590eb5");}catch(e){}}();console.log("Hello world");"`, - ); + expect(result?.code).toMatchInlineSnapshot(` + "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d4309f93-5358-4ae1-bcf0-3813aa590eb5",e._sentryDebugIdIdentifier="sentry-dbid-d4309f93-5358-4ae1-bcf0-3813aa590eb5");}catch(e){}}(); + console.log("Hello world");" + `); }); it("should inject debug ID after 'use strict'", () => { @@ -287,9 +288,10 @@ export * from './moduleC.js';`, facadeModuleId: '/path/to/index.html', }); expect(result).not.toBeNull(); - expect(result?.code).toMatchInlineSnapshot( - `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c4c89e04-3658-4874-b25b-07e638185091",e._sentryDebugIdIdentifier="sentry-dbid-c4c89e04-3658-4874-b25b-07e638185091");}catch(e){}}();function main() { console.log("hello"); }"`, - ); + expect(result?.code).toMatchInlineSnapshot(` + "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c4c89e04-3658-4874-b25b-07e638185091",e._sentryDebugIdIdentifier="sentry-dbid-c4c89e04-3658-4874-b25b-07e638185091");}catch(e){}}(); + function main() { console.log("hello"); }" + `); }); it('should inject into HTML facade with variable declarations', () => { @@ -298,9 +300,10 @@ export * from './moduleC.js';`, facadeModuleId: '/path/to/index.html', }); expect(result).not.toBeNull(); - expect(result?.code).toMatchInlineSnapshot( - `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="43e69766-1963-49f2-a291-ff8de60cc652",e._sentryDebugIdIdentifier="sentry-dbid-43e69766-1963-49f2-a291-ff8de60cc652");}catch(e){}}();const x = 42;"`, - ); + expect(result?.code).toMatchInlineSnapshot(` + "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="43e69766-1963-49f2-a291-ff8de60cc652",e._sentryDebugIdIdentifier="sentry-dbid-43e69766-1963-49f2-a291-ff8de60cc652");}catch(e){}}(); + const x = 42;" + `); }); it('should inject into HTML facade with substantial code (SPA main bundle)', () => { @@ -319,7 +322,8 @@ bootstrap();`; }); expect(result).not.toBeNull(); expect(result?.code).toMatchInlineSnapshot(` - "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d0c4524b-496e-45a4-9852-7558d043ba3c",e._sentryDebugIdIdentifier="sentry-dbid-d0c4524b-496e-45a4-9852-7558d043ba3c");}catch(e){}}();import { initApp } from './app.js'; + "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d0c4524b-496e-45a4-9852-7558d043ba3c",e._sentryDebugIdIdentifier="sentry-dbid-d0c4524b-496e-45a4-9852-7558d043ba3c");}catch(e){}}(); + import { initApp } from './app.js'; const config = { debug: true }; @@ -338,7 +342,8 @@ bootstrap();`; }); expect(result).not.toBeNull(); expect(result?.code).toMatchInlineSnapshot(` - "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="28f0bbaa-9aeb-40c4-98c9-4e44f1d4e175",e._sentryDebugIdIdentifier="sentry-dbid-28f0bbaa-9aeb-40c4-98c9-4e44f1d4e175");}catch(e){}}();import './polyfills.js'; + "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="28f0bbaa-9aeb-40c4-98c9-4e44f1d4e175",e._sentryDebugIdIdentifier="sentry-dbid-28f0bbaa-9aeb-40c4-98c9-4e44f1d4e175");}catch(e){}}(); + import './polyfills.js'; import { init } from './app.js'; init();" @@ -348,9 +353,10 @@ bootstrap();`; it('should inject into regular JS chunks (no HTML facade)', () => { const result = renderChunk(`console.log("Hello");`, { fileName: 'bundle.js' }); expect(result).not.toBeNull(); - expect(result?.code).toMatchInlineSnapshot( - `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="79f18a7f-ca16-4168-9797-906c82058367",e._sentryDebugIdIdentifier="sentry-dbid-79f18a7f-ca16-4168-9797-906c82058367");}catch(e){}}();console.log("Hello");"`, - ); + expect(result?.code).toMatchInlineSnapshot(` + "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="79f18a7f-ca16-4168-9797-906c82058367",e._sentryDebugIdIdentifier="sentry-dbid-79f18a7f-ca16-4168-9797-906c82058367");}catch(e){}}(); + console.log("Hello");" + `); }); }); }); From 3429dda7fab3cab3f635722cd82947ff96c2d6b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 9 Sep 2026 21:58:26 +0200 Subject: [PATCH 08/25] fix(bundler-plugins): Resolve remaining integration failures Co-Authored-By: OpenAI Codex --- .../fixtures/rollup3/basic-sourcemaps.test.ts | 2 +- .../fixtures/rollup3/bundle-size-optimizations.test.ts | 2 +- .../fixtures/rollup3/component-annotation-disabled.test.ts | 2 +- .../fixtures/rollup3/component-annotation-next.test.ts | 2 +- .../fixtures/rollup3/component-annotation.test.ts | 2 +- .../fixtures/rollup3/dont-mess-up-user-code.test.ts | 2 +- .../fixtures/rollup3/multiple-entry-points.test.ts | 6 +++--- .../fixtures/rollup3/query-param.test.ts | 6 +++--- .../fixtures/rollup4/basic-sourcemaps.test.ts | 2 +- .../fixtures/rollup4/bundle-size-optimizations.test.ts | 2 +- .../fixtures/rollup4/component-annotation-disabled.test.ts | 2 +- .../fixtures/rollup4/component-annotation-next.test.ts | 2 +- .../fixtures/rollup4/component-annotation.test.ts | 2 +- .../fixtures/rollup4/debugids-already-injected.test.ts | 2 +- .../fixtures/rollup4/dont-mess-up-user-code.test.ts | 2 +- .../fixtures/rollup4/multiple-entry-points.test.ts | 6 +++--- .../fixtures/rollup4/query-param.test.ts | 6 +++--- packages/bundler-plugins/src/esbuild/index.ts | 3 ++- 18 files changed, 27 insertions(+), 26 deletions(-) diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-sourcemaps.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-sourcemaps.test.ts index 2a768de2301e..c4f4c0618a3c 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-sourcemaps.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-sourcemaps.test.ts @@ -10,7 +10,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { console.log("hello world"); //# sourceMappingURL=basic.js.map ", - "basic.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;scACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC"}", + "basic.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC"}", "sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"], ["release","set-commits","CURRENT_SHA","--auto"], ["release","finalize","CURRENT_SHA"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/bundle-size-optimizations.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/bundle-size-optimizations.test.ts index 05c36ad3b9cf..0bf9ac671a0b 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/bundle-size-optimizations.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/bundle-size-optimizations.test.ts @@ -6,7 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "bundle.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log( + console.log( JSON.stringify({ debug: "b", trace: "b", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-disabled.test.ts index 82c4d4c2277a..fe72a52582ca 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-disabled.test.ts @@ -6,7 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { jsx, jsxs } from 'react/jsx-runtime'; + import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-next.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-next.test.ts index 565279b0b40e..736ee15f00cc 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-next.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-next.test.ts @@ -6,7 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { jsx, jsxs } from 'react/jsx-runtime'; + import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation.test.ts index b1ed2fb54e56..e26693d043bc 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation.test.ts @@ -6,7 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { jsx, jsxs } from 'react/jsx-runtime'; + import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/dont-mess-up-user-code.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/dont-mess-up-user-code.test.ts index fabf4c4422a0..87edc97eee9c 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/dont-mess-up-user-code.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/dont-mess-up-user-code.test.ts @@ -13,7 +13,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { console.log("I am index!"); //# sourceMappingURL=index.js.map ", - "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;2aACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAc,CAAC;;ACC3B,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,KAAA,CAAA,CAAa,CAAC"}", + "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAc,CAAC;;ACC3B,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,KAAA,CAAA,CAAa,CAAC"}", } `); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/multiple-entry-points.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/multiple-entry-points.test.ts index 898a5282c22e..d6088988821c 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/multiple-entry-points.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/multiple-entry-points.test.ts @@ -6,19 +6,19 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "common.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - function add(a, b) { + function add(a, b) { return a + b; } export { add as a }; ", "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js'; + import { a as add } from './common.js'; console.log(add(1, 2)); ", "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js'; + import { a as add } from './common.js'; console.log(add(2, 4)); ", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/query-param.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/query-param.test.ts index 0aa3e70b61eb..8200af8ddcf4 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/query-param.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/query-param.test.ts @@ -11,19 +11,19 @@ test(import.meta.url, ({ runBundler, readOutputFiles, ctx }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "common.js?seP58q4g": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - function add(a, b) { + function add(a, b) { return a + b; } export { add as a }; ", "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js?seP58q4g'; + import { a as add } from './common.js?seP58q4g'; console.log(add(1, 2)); ", "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js?seP58q4g'; + import { a as add } from './common.js?seP58q4g'; console.log(add(2, 4)); ", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-sourcemaps.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-sourcemaps.test.ts index 2a768de2301e..c4f4c0618a3c 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-sourcemaps.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-sourcemaps.test.ts @@ -10,7 +10,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { console.log("hello world"); //# sourceMappingURL=basic.js.map ", - "basic.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;scACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC"}", + "basic.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC"}", "sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"], ["release","set-commits","CURRENT_SHA","--auto"], ["release","finalize","CURRENT_SHA"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/bundle-size-optimizations.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/bundle-size-optimizations.test.ts index 05c36ad3b9cf..0bf9ac671a0b 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/bundle-size-optimizations.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/bundle-size-optimizations.test.ts @@ -6,7 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "bundle.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log( + console.log( JSON.stringify({ debug: "b", trace: "b", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-disabled.test.ts index 82c4d4c2277a..fe72a52582ca 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-disabled.test.ts @@ -6,7 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { jsx, jsxs } from 'react/jsx-runtime'; + import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-next.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-next.test.ts index 565279b0b40e..736ee15f00cc 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-next.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-next.test.ts @@ -6,7 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { jsx, jsxs } from 'react/jsx-runtime'; + import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation.test.ts index b1ed2fb54e56..e26693d043bc 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation.test.ts @@ -6,7 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { jsx, jsxs } from 'react/jsx-runtime'; + import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/debugids-already-injected.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/debugids-already-injected.test.ts index 15912eaa322a..8242f692f0b7 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/debugids-already-injected.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/debugids-already-injected.test.ts @@ -15,7 +15,7 @@ test(import.meta.url, ({ runBundler, createTempDir }) => { //# debugId=00000000-0000-0000-0000-000000000000 //# sourceMappingURL=basic.js.map ", - "252e0338-8927-4f52-bd57-188131defd0f-0.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;scACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC","debugId":"252e0338-8927-4f52-bd57-188131defd0f","debug_id":"252e0338-8927-4f52-bd57-188131defd0f"}", + "252e0338-8927-4f52-bd57-188131defd0f-0.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC","debugId":"252e0338-8927-4f52-bd57-188131defd0f","debug_id":"252e0338-8927-4f52-bd57-188131defd0f"}", } `); }); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/dont-mess-up-user-code.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/dont-mess-up-user-code.test.ts index fabf4c4422a0..87edc97eee9c 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/dont-mess-up-user-code.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/dont-mess-up-user-code.test.ts @@ -13,7 +13,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { console.log("I am index!"); //# sourceMappingURL=index.js.map ", - "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;2aACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAc,CAAC;;ACC3B,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,KAAA,CAAA,CAAa,CAAC"}", + "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAc,CAAC;;ACC3B,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,KAAA,CAAA,CAAa,CAAC"}", } `); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/multiple-entry-points.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/multiple-entry-points.test.ts index 898a5282c22e..d6088988821c 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/multiple-entry-points.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/multiple-entry-points.test.ts @@ -6,19 +6,19 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "common.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - function add(a, b) { + function add(a, b) { return a + b; } export { add as a }; ", "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js'; + import { a as add } from './common.js'; console.log(add(1, 2)); ", "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js'; + import { a as add } from './common.js'; console.log(add(2, 4)); ", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/query-param.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/query-param.test.ts index 0aa3e70b61eb..8200af8ddcf4 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/query-param.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/query-param.test.ts @@ -11,19 +11,19 @@ test(import.meta.url, ({ runBundler, readOutputFiles, ctx }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "common.js?seP58q4g": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - function add(a, b) { + function add(a, b) { return a + b; } export { add as a }; ", "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js?seP58q4g'; + import { a as add } from './common.js?seP58q4g'; console.log(add(1, 2)); ", "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js?seP58q4g'; + import { a as add } from './common.js?seP58q4g'; console.log(add(2, 4)); ", diff --git a/packages/bundler-plugins/src/esbuild/index.ts b/packages/bundler-plugins/src/esbuild/index.ts index e4b1374729e3..ebbc318a280a 100644 --- a/packages/bundler-plugins/src/esbuild/index.ts +++ b/packages/bundler-plugins/src/esbuild/index.ts @@ -171,7 +171,8 @@ export function sentryEsbuildPlugin(userOptions: Options = {}): any { return { loader: 'js', pluginName, - contents: staticInjectionCode.code(), + // Force the injected module to be CommonJS so it cannot make a CommonJS entry point strict. + contents: `${staticInjectionCode.code()}\nmodule.exports;`, }; }); } From 236e1fc57ed23fc486b72810576c92ce73ba2225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 9 Sep 2026 22:29:21 +0200 Subject: [PATCH 09/25] fix(bundler-plugins): Preserve esbuild module semantics Co-Authored-By: OpenAI Codex --- packages/bundler-plugins/src/esbuild/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bundler-plugins/src/esbuild/index.ts b/packages/bundler-plugins/src/esbuild/index.ts index ebbc318a280a..8508278ad13a 100644 --- a/packages/bundler-plugins/src/esbuild/index.ts +++ b/packages/bundler-plugins/src/esbuild/index.ts @@ -171,8 +171,8 @@ export function sentryEsbuildPlugin(userOptions: Options = {}): any { return { loader: 'js', pluginName, - // Force the injected module to be CommonJS so it cannot make a CommonJS entry point strict. - contents: `${staticInjectionCode.code()}\nmodule.exports;`, + // Keep the side-effect-only stub in its own ESM scope so it cannot change an entry point's strictness. + contents: `${staticInjectionCode.code()}\nexport {};`, }; }); } From cdd6e739af8ed63b4c626ba118381d4b398e14e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 10 Sep 2026 00:18:51 +0200 Subject: [PATCH 10/25] fix(bundler-plugins): Restore format-neutral esbuild injection Co-Authored-By: OpenAI Codex --- packages/bundler-plugins/src/esbuild/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/bundler-plugins/src/esbuild/index.ts b/packages/bundler-plugins/src/esbuild/index.ts index 8508278ad13a..e4b1374729e3 100644 --- a/packages/bundler-plugins/src/esbuild/index.ts +++ b/packages/bundler-plugins/src/esbuild/index.ts @@ -171,8 +171,7 @@ export function sentryEsbuildPlugin(userOptions: Options = {}): any { return { loader: 'js', pluginName, - // Keep the side-effect-only stub in its own ESM scope so it cannot change an entry point's strictness. - contents: `${staticInjectionCode.code()}\nexport {};`, + contents: staticInjectionCode.code(), }; }); } From 24071161e358930dba533de303d510251f751974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 10 Sep 2026 09:00:50 +0200 Subject: [PATCH 11/25] test(bundler-plugins): Isolate esbuild strictness behavior Co-Authored-By: OpenAI Codex --- .../fixtures/esbuild/cjs-directives.config.js | 14 ++++++++++++++ .../fixtures/esbuild/cjs-directives.test.ts | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.config.js b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.config.js index 537b3d0abfc9..30a9bf23f2b1 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.config.js +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.config.js @@ -1,6 +1,18 @@ import * as esbuild from "esbuild"; import { sentryEsbuildPlugin } from "@sentry/bundler-plugins/esbuild"; +await esbuild.build({ + entryPoints: { + sloppy: "./src/sloppy-mode.cjs", + }, + bundle: true, + outdir: "./out/cjs-directives/without-plugin", + outExtension: { ".js": ".cjs" }, + minify: false, + format: "cjs", + tsconfigRaw: { compilerOptions: { alwaysStrict: false } }, +}); + await esbuild.build({ entryPoints: { strict: "./src/strict-mode.cjs", @@ -11,6 +23,7 @@ await esbuild.build({ outExtension: { ".js": ".cjs" }, minify: false, format: "cjs", + tsconfigRaw: { compilerOptions: { alwaysStrict: false } }, plugins: [ sentryEsbuildPlugin({ telemetry: false, @@ -31,6 +44,7 @@ await esbuild.build({ minify: false, format: "cjs", sourcemap: true, + tsconfigRaw: { compilerOptions: { alwaysStrict: false } }, plugins: [ sentryEsbuildPlugin({ telemetry: false, diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.test.ts index 5cfd748eb78e..cfb43ef05ae8 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.test.ts @@ -4,6 +4,11 @@ import { test } from "./utils"; test(import.meta.url, ({ runBundler, runFileInNode }) => { runBundler(); + expect(JSON.parse(runFileInNode("without-plugin/sloppy.cjs"))).toEqual({ + sloppyModePreserved: true, + releaseInjected: false, + debugIdInjected: false, + }); expect(JSON.parse(runFileInNode("static-injection/strict.cjs"))).toEqual({ strictModePreserved: true, releaseInjected: true, From 4485fc14a11282d46e44c51ce35625a30ad97675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 14 Sep 2026 10:07:11 +0200 Subject: [PATCH 12/25] test(bundler-plugins): Cover child compiler injection Co-Authored-By: OpenAI Codex --- .../test/webpack/child-compiler.test.ts | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 packages/bundler-plugins/test/webpack/child-compiler.test.ts diff --git a/packages/bundler-plugins/test/webpack/child-compiler.test.ts b/packages/bundler-plugins/test/webpack/child-compiler.test.ts new file mode 100644 index 000000000000..04edf0b82b9f --- /dev/null +++ b/packages/bundler-plugins/test/webpack/child-compiler.test.ts @@ -0,0 +1,78 @@ +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; +import { EntryPlugin, webpack } from 'webpack'; +import type { Compiler, Configuration, Stats } from 'webpack'; +import { afterEach, beforeEach, describe, expect, it } from 'vitest'; +import { sentryWebpackPlugin } from '../../src/webpack/index'; + +function build(config: Configuration): Promise { + return new Promise((resolve, reject) => { + webpack(config, (err, stats) => { + if (err) { + return reject(err); + } + if (!stats || stats.hasErrors()) { + return reject(new Error(stats?.toString() ?? 'no stats')); + } + resolve(stats); + }); + }); +} + +function createChildCompilerPlugin(context: string): { apply(compiler: Compiler): void } { + return { + apply(compiler) { + compiler.hooks.make.tapAsync('test-child-compiler', (compilation, callback) => { + const childCompiler = compilation.createChildCompiler('test-child-compiler', { filename: 'worker.js' }, [ + new EntryPlugin(context, './worker.js', { name: 'worker' }), + ]); + + childCompiler.runAsChild(error => { + if (error) { + callback(error); + } else { + callback(); + } + }); + }); + }, + }; +} + +describe('child compiler injection', () => { + let tmpDir: string; + + beforeEach(() => { + tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sentry-webpack-child-compiler-')); + fs.writeFileSync(path.join(tmpDir, 'entry.js'), 'globalThis.applicationLoaded = true;\n'); + fs.writeFileSync(path.join(tmpDir, 'worker.js'), 'globalThis.workerLoaded = true;\n'); + }); + + afterEach(() => { + fs.rmSync(tmpDir, { recursive: true, force: true }); + }); + + it('injects release information into child-compiler bundles', async () => { + const outDir = path.join(tmpDir, 'dist'); + + await build({ + mode: 'production', + context: tmpDir, + entry: './entry.js', + output: { path: outDir, filename: 'bundle.js' }, + plugins: [ + sentryWebpackPlugin({ + release: { name: 'child-compiler-release' }, + sourcemaps: { disable: true }, + telemetry: false, + }), + createChildCompilerPlugin(tmpDir), + ], + }); + + const workerBundle = fs.readFileSync(path.join(outDir, 'worker.js'), 'utf8'); + + expect(workerBundle).toContain('child-compiler-release'); + }); +}); From a711a31c8f2e8473e7f8f97a7f713c4d744003d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 14 Sep 2026 10:23:10 +0200 Subject: [PATCH 13/25] fix(bundler-plugins): Inject into Webpack child compilers Co-Authored-By: OpenAI Codex --- .../src/webpack/webpack4and5.ts | 141 ++++++++---------- .../test/webpack/webpack4and5.test.ts | 2 +- 2 files changed, 65 insertions(+), 78 deletions(-) diff --git a/packages/bundler-plugins/src/webpack/webpack4and5.ts b/packages/bundler-plugins/src/webpack/webpack4and5.ts index 4cfad2b4f16c..c41a3e238577 100644 --- a/packages/bundler-plugins/src/webpack/webpack4and5.ts +++ b/packages/bundler-plugins/src/webpack/webpack4and5.ts @@ -1,3 +1,6 @@ +// Webpack 4 and 5 share this implementation so their behavior cannot drift apart. +/* oxlint-disable max-lines */ + import type { Options } from '../core/index'; import { createSentryBuildPluginManager, @@ -54,37 +57,13 @@ type WebpackSources = { RawSource?: WebpackRawSource; }; -type WebpackModule = { - resource?: string; -}; - -type WebpackLoaderCallback = (err: Error | null, content?: string, sourceMap?: unknown) => void; - -type WebpackLoaderContext = { - callback: WebpackLoaderCallback; -}; - type WebpackCompilationContext = { chunks: Iterable<{ files: Iterable; hash?: string; contentHash?: { javascript?: string }; }>; - compiler: { - webpack?: { - NormalModule?: { - getCompilationHooks: (compilation: WebpackCompilationContext) => { - loader: { - tap: (name: string, callback: (loaderContext: WebpackLoaderContext, module: WebpackModule) => void) => void; - }; - }; - }; - }; - }; hooks: { - normalModuleLoader?: { - tap: (name: string, callback: (loaderContext: WebpackLoaderContext, module: WebpackModule) => void) => void; - }; processAssets: { tap: ( options: { name: string; stage: number }, @@ -128,6 +107,9 @@ type WebpackCompiler = { }; }; hooks: { + compilation: { + tap: (name: string, callback: (compilation: WebpackCompilationContext) => void) => void; + }; thisCompilation: { tap: (name: string, callback: (compilation: WebpackCompilation) => void) => void; }; @@ -272,6 +254,63 @@ export function sentryWebpackPluginFactory({ const transformReplace = Object.keys(replacementValues).length > 0; + function addCodeInjection(compiler: WebpackCompiler): void { + if (staticInjectionCode.isEmpty() && !sourcemapsEnabled) { + return; + } + + const ReplaceSource = compiler.webpack?.sources?.ReplaceSource || unsafeSources?.ReplaceSource; + const processAssetsStage = + compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS ?? + UnsafeCompilation?.PROCESS_ASSETS_STAGE_ADDITIONS; + + if (!ReplaceSource || processAssetsStage === undefined) { + logger.warn( + 'Webpack sources are not available. Skipping code injection. This usually means webpack is not properly configured.', + ); + return; + } + + compiler.hooks.compilation.tap('sentry-webpack-plugin-injection', compilation => { + compilation.hooks.processAssets.tap( + { + name: 'sentry-webpack-plugin-injection', + stage: processAssetsStage, + }, + assets => { + for (const chunk of compilation.chunks) { + for (const assetName of chunk.files) { + if (!WEBPACK_JAVASCRIPT_ASSET_REGEX.test(assetName)) { + continue; + } + + const source = assets[assetName]; + if (!source) { + continue; + } + + const sourceContents = source.source(); + const codeString = + typeof sourceContents === 'string' ? sourceContents : Buffer.from(sourceContents).toString(); + const codeToInject = staticInjectionCode.clone(); + if (sourcemapsEnabled) { + const hash = chunk.contentHash?.javascript ?? chunk.hash; + codeToInject.append(getDebugIdSnippet(hash ? stringToUUID(hash) : randomUUID())); + } + + const injectionPosition = getCodeInjectionPosition(codeString); + const injection = + injectionPosition === codeString.length ? `\n${codeToInject.code()}` : `${codeToInject.code()}\n`; + const updatedSource = new ReplaceSource(source); + updatedSource.insert(injectionPosition, injection); + compilation.updateAsset(assetName, updatedSource); + } + } + }, + ); + }); + } + return { apply(compiler: WebpackCompiler) { void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => { @@ -282,59 +321,7 @@ export function sentryWebpackPluginFactory({ const DefinePlugin = compiler?.webpack?.DefinePlugin || UnsafeDefinePlugin; // Injecting through BannerPlugin would place executable code before directive prologues. - if (!staticInjectionCode.isEmpty() || sourcemapsEnabled) { - const ReplaceSource = compiler.webpack?.sources?.ReplaceSource || unsafeSources?.ReplaceSource; - const processAssetsStage = - compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS ?? - UnsafeCompilation?.PROCESS_ASSETS_STAGE_ADDITIONS; - - if (!ReplaceSource || processAssetsStage === undefined) { - logger.warn( - 'Webpack sources are not available. Skipping code injection. This usually means webpack is not properly configured.', - ); - } else { - compiler.hooks.thisCompilation.tap('sentry-webpack-plugin-injection', compilation => { - compilation.hooks.processAssets.tap( - { - name: 'sentry-webpack-plugin-injection', - stage: processAssetsStage, - }, - assets => { - for (const chunk of compilation.chunks) { - for (const assetName of chunk.files) { - if (!WEBPACK_JAVASCRIPT_ASSET_REGEX.test(assetName)) { - continue; - } - - const source = assets[assetName]; - if (!source) { - continue; - } - - const sourceContents = source.source(); - const codeString = - typeof sourceContents === 'string' ? sourceContents : Buffer.from(sourceContents).toString(); - const codeToInject = staticInjectionCode.clone(); - if (sourcemapsEnabled) { - const hash = chunk.contentHash?.javascript ?? chunk.hash; - codeToInject.append(getDebugIdSnippet(hash ? stringToUUID(hash) : randomUUID())); - } - - const injectionPosition = getCodeInjectionPosition(codeString); - const injection = - injectionPosition === codeString.length - ? `\n${codeToInject.code()}` - : `${codeToInject.code()}\n`; - const updatedSource = new ReplaceSource(source); - updatedSource.insert(injectionPosition, injection); - compilation.updateAsset(assetName, updatedSource); - } - } - }, - ); - }); - } - } + addCodeInjection(compiler); // The upload routine (which stamps debug IDs into temp copies of the artifacts) is skipped // with `disable-upload`, so the emitted artifacts get stamped in the asset pipeline instead. diff --git a/packages/bundler-plugins/test/webpack/webpack4and5.test.ts b/packages/bundler-plugins/test/webpack/webpack4and5.test.ts index 55ed36202f13..ace341c26cdb 100644 --- a/packages/bundler-plugins/test/webpack/webpack4and5.test.ts +++ b/packages/bundler-plugins/test/webpack/webpack4and5.test.ts @@ -24,7 +24,7 @@ function runWebpackSourceInjection( sources: { ReplaceSource: webpack.sources.ReplaceSource }, }, hooks: { - thisCompilation: { + compilation: { tap: (_name: string, callback: (compilation: unknown) => void) => { compilationCallback = callback; }, From 1ef1626bf2c365fc722656edd1b578fc48380dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 17 Sep 2026 16:12:21 +0200 Subject: [PATCH 14/25] docs(bundler-plugins): Explain esbuild injection placement Co-Authored-By: OpenAI Codex --- packages/bundler-plugins/src/esbuild/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/bundler-plugins/src/esbuild/index.ts b/packages/bundler-plugins/src/esbuild/index.ts index f3bc0fc8c01e..fc17904624be 100644 --- a/packages/bundler-plugins/src/esbuild/index.ts +++ b/packages/bundler-plugins/src/esbuild/index.ts @@ -161,6 +161,8 @@ export function sentryEsbuildPlugin(userOptions: Options = {}): any { if (!staticInjectionCode.isEmpty()) { const virtualInjectionFilePath = path.resolve('_sentry-injection-stub'); initialOptions.inject = initialOptions.inject || []; + // esbuild emits injected files after an entry's directive prologue. A banner would precede + // "use strict" and turn it into an ordinary string expression. initialOptions.inject.push(virtualInjectionFilePath); onResolve({ filter: /_sentry-injection-stub/ }, args => { From 1679219351cc593d028b0c293ffbd15eb0391f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 17 Sep 2026 16:13:49 +0200 Subject: [PATCH 15/25] ref(bundler-plugins): Reuse directive scanner in Next.js Co-Authored-By: OpenAI Codex --- .../src/core/get-code-injection-position.ts | 2 +- packages/bundler-plugins/src/core/index.ts | 1 + .../loaders/moduleMetadataInjectionLoader.ts | 4 +- .../config/loaders/valueInjectionLoader.ts | 144 +----------------- .../test/config/valueInjectionLoader.test.ts | 46 +----- 5 files changed, 11 insertions(+), 186 deletions(-) diff --git a/packages/bundler-plugins/src/core/get-code-injection-position.ts b/packages/bundler-plugins/src/core/get-code-injection-position.ts index 8ed7ad3cd19e..a7299685a4db 100644 --- a/packages/bundler-plugins/src/core/get-code-injection-position.ts +++ b/packages/bundler-plugins/src/core/get-code-injection-position.ts @@ -63,7 +63,7 @@ function startsWithBinaryOperatorKeyword(remainder: string, keyword: string): bo } function canContinueStringExpression(code: string, position: number): boolean { - const remainder = code.slice(position); + const remainder = code.slice(position, position + 'instanceof'.length + 1); if (/^(?:\+\+|--|!(?!=))/.test(remainder)) { return false; } diff --git a/packages/bundler-plugins/src/core/index.ts b/packages/bundler-plugins/src/core/index.ts index 0386bf3e86ac..506d965a083e 100644 --- a/packages/bundler-plugins/src/core/index.ts +++ b/packages/bundler-plugins/src/core/index.ts @@ -74,6 +74,7 @@ export function shouldSkipCodeInjection(code: string, facadeModuleId: string | n } export { globFiles } from './glob'; +export { getCodeInjectionPosition } from './get-code-injection-position'; // eslint-disable-next-line @typescript-eslint/explicit-function-return-type export function createComponentNameAnnotateHooks(ignoredComponents: string[], injectIntoHtml: boolean) { diff --git a/packages/nextjs/src/config/loaders/moduleMetadataInjectionLoader.ts b/packages/nextjs/src/config/loaders/moduleMetadataInjectionLoader.ts index 7e8315b51831..5ff5d9ac2bf2 100644 --- a/packages/nextjs/src/config/loaders/moduleMetadataInjectionLoader.ts +++ b/packages/nextjs/src/config/loaders/moduleMetadataInjectionLoader.ts @@ -1,5 +1,5 @@ +import { getCodeInjectionPosition } from '@sentry/bundler-plugins/core'; import type { LoaderThis } from './types'; -import { findInjectionIndexAfterDirectives } from './valueInjectionLoader'; export type ModuleMetadataInjectionLoaderOptions = { applicationKey: string; @@ -39,6 +39,6 @@ export default function moduleMetadataInjectionLoader( `e._sentryModuleMetadata[(new e.Error).stack]=Object.assign({},e._sentryModuleMetadata[(new e.Error).stack],${metadata});` + '}catch(e){}}();'; - const injectionIndex = findInjectionIndexAfterDirectives(userCode); + const injectionIndex = getCodeInjectionPosition(userCode); return `${userCode.slice(0, injectionIndex)}${injectedCode}${userCode.slice(injectionIndex)}`; } diff --git a/packages/nextjs/src/config/loaders/valueInjectionLoader.ts b/packages/nextjs/src/config/loaders/valueInjectionLoader.ts index 0040e9f4543d..a8da78c90850 100644 --- a/packages/nextjs/src/config/loaders/valueInjectionLoader.ts +++ b/packages/nextjs/src/config/loaders/valueInjectionLoader.ts @@ -1,150 +1,10 @@ +import { getCodeInjectionPosition } from '@sentry/bundler-plugins/core'; import type { LoaderThis } from './types'; export type ValueInjectionLoaderOptions = { values: Record; }; -/** - * Finds the index in user code at which to inject statements. - * - * The injection must come AFTER all prologue directives ("use strict", "use client", etc.) - * and any surrounding whitespace/comments, but before any actual statements. - * - * Handles multiple directives, comments between directives, directives without semicolons, - * escape sequences in strings, and strings followed by operators (which are not directives). - */ -export function findInjectionIndexAfterDirectives(userCode: string): number { - let index = 0; - let afterLastDirective: number | undefined; - - while (index < userCode.length) { - const char = userCode[index]; - - if (char && /\s/.test(char)) { - index++; - continue; - } - - if (userCode.startsWith('//', index)) { - const newlineIndex = userCode.indexOf('\n', index + 2); - index = newlineIndex === -1 ? userCode.length : newlineIndex + 1; - continue; - } - - if (userCode.startsWith('/*', index)) { - const commentEndIndex = userCode.indexOf('*/', index + 2); - if (commentEndIndex === -1) { - return afterLastDirective ?? 0; - } - - index = commentEndIndex + 2; - continue; - } - - if (char === '"' || char === "'") { - const stringEnd = findStringLiteralEnd(userCode, index); - if (stringEnd === null) { - return afterLastDirective ?? index; - } - - const terminatorEnd = findDirectiveTerminator(userCode, stringEnd); - if (terminatorEnd === null) { - return afterLastDirective ?? index; - } - - afterLastDirective = terminatorEnd; - index = terminatorEnd; - continue; - } - - return afterLastDirective ?? index; - } - - return afterLastDirective ?? index; -} - -/** - * Scans a string literal starting at `start` (which must be a quote character), - * correctly handling escape sequences and rejecting unterminated/multiline strings. - * Returns the index after the closing quote, or null if the string is unterminated. - */ -function findStringLiteralEnd(userCode: string, startIndex: number): number | null { - const quote = userCode[startIndex]; - let index = startIndex + 1; - - while (index < userCode.length) { - const char = userCode[index]; - - if (char === '\\') { - // skip escaped character - index += 2; - continue; - } - - if (char === quote) { - return index + 1; // found closing quote - } - - if (char === '\n' || char === '\r') { - return null; // unterminated - } - - index++; - } - - return null; // unterminated -} - -/** - * Starting at `i`, skips horizontal whitespace and single-line block comments, - * then checks for a valid directive terminator: `;`, newline, `//`, or EOF. - * Returns the index after the terminator, or null if no valid terminator is found - * (meaning the preceding string literal is not a directive). - */ -function findDirectiveTerminator(userCode: string, startIndex: number): number | null { - let index = startIndex; - - while (index < userCode.length) { - const char = userCode[index]; - - if (char === ';') { - return index + 1; - } - - if (char === '\n' || char === '\r' || char === '}') { - return index; - } - - if (char && /\s/.test(char)) { - index++; - continue; - } - - if (userCode.startsWith('//', index)) { - return index; - } - - if (userCode.startsWith('/*', index)) { - const commentEndIndex = userCode.indexOf('*/', index + 2); - if (commentEndIndex === -1) { - return null; - } - - const comment = userCode.slice(index + 2, commentEndIndex); - if (comment.includes('\n') || comment.includes('\r')) { - return index; - } - - index = commentEndIndex + 2; - continue; - } - - return null; // operator or any other token → not a directive - } - - return index; // EOF is a valid terminator -} - /** * Set values on the global/window object at the start of a module. * @@ -167,6 +27,6 @@ export default function valueInjectionLoader(this: LoaderThis `globalThis["${key}"] = ${JSON.stringify(value)};`) .join(''); - const injectionIndex = findInjectionIndexAfterDirectives(userCode); + const injectionIndex = getCodeInjectionPosition(userCode); return `${userCode.slice(0, injectionIndex)}${injectedCode}${userCode.slice(injectionIndex)}`; } diff --git a/packages/nextjs/test/config/valueInjectionLoader.test.ts b/packages/nextjs/test/config/valueInjectionLoader.test.ts index 83c0c1d5e0f9..a01d9c309fe6 100644 --- a/packages/nextjs/test/config/valueInjectionLoader.test.ts +++ b/packages/nextjs/test/config/valueInjectionLoader.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; import type { LoaderThis } from '../../src/config/loaders/types'; import type { ValueInjectionLoaderOptions } from '../../src/config/loaders/valueInjectionLoader'; -import valueInjectionLoader, { findInjectionIndexAfterDirectives } from '../../src/config/loaders/valueInjectionLoader'; +import valueInjectionLoader from '../../src/config/loaders/valueInjectionLoader'; const defaultLoaderThis = { addDependency: () => undefined, @@ -217,48 +217,12 @@ describe.each([[clientConfigLoaderThis], [instrumentationLoaderThis]])('valueInj expect(injectionIndex).toBeGreaterThan(clientDirectiveIndex); }); -}); - -describe('findInjectionIndexAfterDirectives', () => { - it('returns the position immediately after the last directive', () => { - const userCode = '"use strict";\n"use client";\nimport React from \'react\';'; - - expect(userCode.slice(findInjectionIndexAfterDirectives(userCode))).toBe("\nimport React from 'react';"); - }); - - it('returns the end of the input when the last directive reaches EOF', () => { - const userCode = '"use strict";\n"use client";'; - - expect(findInjectionIndexAfterDirectives(userCode)).toBe(userCode.length); - }); - - it('does not skip a string literal that is not a directive', () => { - const userCode = '"use client" + suffix;'; - - expect(findInjectionIndexAfterDirectives(userCode)).toBe(0); - }); - it('does not treat an escaped quote at EOF as a closed directive', () => { - const userCode = '"use client\\"'; + it('inserts values after a directive with a Unicode line separator', () => { + const userCode = '"use client"\u2028startApp();'; - expect(findInjectionIndexAfterDirectives(userCode)).toBe(0); - }); - - it('returns 0 for an unterminated leading block comment', () => { - const userCode = '/* unterminated'; - - expect(findInjectionIndexAfterDirectives(userCode)).toBe(0); - }); - - it('returns the last complete directive when followed by an unterminated block comment', () => { - const userCode = '"use client"; /* unterminated'; - - expect(findInjectionIndexAfterDirectives(userCode)).toBe('"use client";'.length); - }); - - it('treats a block comment without a line break as part of the same statement', () => { - const userCode = '"use client" /* comment */ + suffix;'; + const result = valueInjectionLoader.call(loaderThis, userCode); - expect(findInjectionIndexAfterDirectives(userCode)).toBe(0); + expect(result).toBe('"use client"\u2028;globalThis["foo"] = "bar";startApp();'); }); }); From 3aa5dd5b0701e8524287ecf8f28aa6ddea01f58e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 17 Sep 2026 16:18:21 +0200 Subject: [PATCH 16/25] fix(bundler-plugins): Avoid extra Rollup injection line Co-Authored-By: OpenAI Codex --- .../rollup3/after-upload-deletion.test.ts | 3 +- .../fixtures/rollup3/application-key.test.ts | 3 +- .../fixtures/rollup3/basic-cjs.test.ts | 3 +- .../rollup3/basic-release-disabled.test.ts | 3 +- .../fixtures/rollup3/basic-sourcemaps.test.ts | 5 +-- .../fixtures/rollup3/basic.test.ts | 3 +- .../fixtures/rollup3/build-info.test.ts | 3 +- .../rollup3/bundle-size-optimizations.test.ts | 3 +- .../component-annotation-disabled.test.ts | 3 +- .../rollup3/component-annotation-next.test.ts | 3 +- .../rollup3/component-annotation.test.ts | 3 +- .../rollup3/dont-mess-up-user-code.test.ts | 5 +-- .../fixtures/rollup3/module-metadata.test.ts | 3 +- .../rollup3/multiple-entry-points.test.ts | 9 ++--- .../fixtures/rollup3/query-param.test.ts | 9 ++--- .../fixtures/rollup3/release-disabled.test.ts | 3 +- .../fixtures/rollup3/telemetry.test.ts | 3 +- .../rollup4/after-upload-deletion.test.ts | 3 +- .../fixtures/rollup4/application-key.test.ts | 3 +- .../fixtures/rollup4/basic-cjs.test.ts | 3 +- .../rollup4/basic-release-disabled.test.ts | 3 +- .../fixtures/rollup4/basic-sourcemaps.test.ts | 5 +-- .../fixtures/rollup4/basic.test.ts | 3 +- .../fixtures/rollup4/build-info.test.ts | 3 +- .../rollup4/bundle-size-optimizations.test.ts | 3 +- .../component-annotation-disabled.test.ts | 3 +- .../rollup4/component-annotation-next.test.ts | 3 +- .../rollup4/component-annotation.test.ts | 3 +- .../rollup4/debugids-already-injected.test.ts | 5 +-- .../rollup4/dont-mess-up-user-code.test.ts | 5 +-- .../fixtures/rollup4/module-metadata.test.ts | 3 +- .../rollup4/multiple-entry-points.test.ts | 9 ++--- .../fixtures/rollup4/query-param.test.ts | 9 ++--- .../fixtures/rollup4/release-disabled.test.ts | 3 +- .../fixtures/rollup4/telemetry.test.ts | 3 +- packages/bundler-plugins/src/rollup/index.ts | 16 ++------ .../__snapshots__/public-api.test.ts.snap | 25 +++--------- .../test/rollup/public-api.test.ts | 39 ++++++++----------- 38 files changed, 73 insertions(+), 146 deletions(-) diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/after-upload-deletion.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/after-upload-deletion.test.ts index 0bce8d75055b..a4305945f767 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/after-upload-deletion.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/after-upload-deletion.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); //# sourceMappingURL=basic.js.map ", } diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/application-key.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/application-key.test.ts index 9281f822cb81..893eb03cfbb1 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/application-key.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/application-key.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); ", "sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"], ["release","set-commits","CURRENT_SHA","--auto"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-release-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-release-disabled.test.ts index afb3e329719b..ebf24e57ed36 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-release-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-release-disabled.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); ", } `); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-sourcemaps.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-sourcemaps.test.ts index c4f4c0618a3c..1973196d89aa 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-sourcemaps.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic-sourcemaps.test.ts @@ -6,11 +6,10 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); //# sourceMappingURL=basic.js.map ", - "basic.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC"}", + "basic.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;scACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC"}", "sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"], ["release","set-commits","CURRENT_SHA","--auto"], ["release","finalize","CURRENT_SHA"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic.test.ts index 8877d0a9eb48..b160e72a864c 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/basic.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); ", "sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"], ["release","set-commits","CURRENT_SHA","--auto"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/build-info.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/build-info.test.ts index d9dc4b1f6de6..e9b8e53ac2e3 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/build-info.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/build-info.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"build-information-injection-test"};e.SENTRY_BUILD_INFO={"deps":["@rollup/plugin-babel","@rollup/plugin-node-resolve","@sentry/bundler-plugins","react","rollup"],"depsVersions":{"react":19,"rollup":3},"nodeVersion":"NODE_VERSION"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"build-information-injection-test"};e.SENTRY_BUILD_INFO={"deps":["@rollup/plugin-babel","@rollup/plugin-node-resolve","@sentry/bundler-plugins","react","rollup"],"depsVersions":{"react":19,"rollup":3},"nodeVersion":"NODE_VERSION"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); ", } `); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/bundle-size-optimizations.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/bundle-size-optimizations.test.ts index 0bf9ac671a0b..c685a2b794e2 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/bundle-size-optimizations.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/bundle-size-optimizations.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "bundle.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log( + "bundle.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log( JSON.stringify({ debug: "b", trace: "b", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-disabled.test.ts index fe72a52582ca..054e90c0e827 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-disabled.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { jsx, jsxs } from 'react/jsx-runtime'; + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-next.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-next.test.ts index 736ee15f00cc..62cfe0816cc5 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-next.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation-next.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { jsx, jsxs } from 'react/jsx-runtime'; + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation.test.ts index e26693d043bc..387beb7fda07 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/component-annotation.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { jsx, jsxs } from 'react/jsx-runtime'; + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/dont-mess-up-user-code.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/dont-mess-up-user-code.test.ts index 87edc97eee9c..42d6d3679b9c 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/dont-mess-up-user-code.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/dont-mess-up-user-code.test.ts @@ -6,14 +6,13 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "index.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"I am release!"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("I am import!"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"I am release!"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("I am import!"); // eslint-disable-next-line no-console console.log("I am index!"); //# sourceMappingURL=index.js.map ", - "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAc,CAAC;;ACC3B,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,KAAA,CAAA,CAAa,CAAC"}", + "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;2aACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAc,CAAC;;ACC3B,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,KAAA,CAAA,CAAa,CAAC"}", } `); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/module-metadata.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/module-metadata.test.ts index cd934b859408..b4acc59902a5 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/module-metadata.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/module-metadata.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "common.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - function add(a, b) { + "common.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();function add(a, b) { return a + b; } export { add as a }; ", - "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js'; + "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js'; console.log(add(1, 2)); ", - "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js'; + "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js'; console.log(add(2, 4)); ", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/query-param.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/query-param.test.ts index 8200af8ddcf4..d65cb2e349da 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/query-param.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/query-param.test.ts @@ -10,20 +10,17 @@ test(import.meta.url, ({ runBundler, readOutputFiles, ctx }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "common.js?seP58q4g": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - function add(a, b) { + "common.js?seP58q4g": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();function add(a, b) { return a + b; } export { add as a }; ", - "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js?seP58q4g'; + "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js?seP58q4g'; console.log(add(1, 2)); ", - "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js?seP58q4g'; + "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js?seP58q4g'; console.log(add(2, 4)); ", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/release-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/release-disabled.test.ts index c2a17292386d..39c7da1959d9 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/release-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/release-disabled.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); ", "sentry-cli-mock.json": "["release","set-commits","CURRENT_SHA","--auto"], ["release","finalize","CURRENT_SHA"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/telemetry.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/telemetry.test.ts index 4889fa9c3031..970ebdaefd1d 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/telemetry.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup3/telemetry.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); ", "sentry-telemetry.json": "[{"sent_at":"TIMESTAMP","sdk":{"name":"sentry.javascript.node","version":"SDK_VERSION"}},[[{"type":"session"},{"sid":"UUID","init":true,"started":"TIMESTAMP","timestamp":"TIMESTAMP","status":"ok","errors":0,"duration":DURATION,"attrs":{"release":"PLUGIN_VERSION","environment":"production"}}]]], [{"event_id":"UUID","sent_at":"TIMESTAMP","sdk":{"name":"sentry.javascript.node","version":"SDK_VERSION"},"trace":{"environment":"production","release":"PLUGIN_VERSION","public_key":"UUID","trace_id":"UUID","org_id":"1","transaction":"Sentry Bundler Plugin execution","sampled":"true","sample_rand":"SAMPLE_RAND","sample_rate":"1"}},[[{"type":"transaction"},{"contexts":{"trace":{"span_id":"SHORT_UUID","trace_id":"UUID","data":{"sentry.origin":"manual","sentry.segment.name.source":"custom","sentry.sample_rate":1},"status":"ok","origin":"manual"},"runtime":{"name":"node","version":"NODE_VERSION"}},"spans":[],"start_timestamp":START_TIMESTAMP,"timestamp":TIMESTAMP,"transaction":"Sentry Bundler Plugin execution","type":"transaction","transaction_info":{"source":"custom"},"platform":"PLATFORM","event_id":"UUID","environment":"production","release":"PLUGIN_VERSION","tags":{"upload-legacy-sourcemaps":false,"module-metadata":false,"inject-build-information":false,"set-commits":"auto","finalize-release":true,"deploy-options":false,"custom-error-handler":false,"sourcemaps-assets":false,"delete-after-upload":false,"sourcemaps-disabled":false,"react-annotate":false,"node":"NODE_VERSION","platform":"PLATFORM","meta-framework":"none","application-key-set":false,"ci":true,"project":"undefined","bundler":"rollup","bundler-major-version":"3"},"user":{},"sdk":{"name":"sentry.javascript.node","version":"SDK_VERSION","integrations":[],"packages":[{"name":"npm:@sentry/node","version":"SDK_VERSION"}]}}]]], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/after-upload-deletion.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/after-upload-deletion.test.ts index 0bce8d75055b..a4305945f767 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/after-upload-deletion.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/after-upload-deletion.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); //# sourceMappingURL=basic.js.map ", } diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/application-key.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/application-key.test.ts index 9281f822cb81..893eb03cfbb1 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/application-key.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/application-key.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); ", "sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"], ["release","set-commits","CURRENT_SHA","--auto"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-release-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-release-disabled.test.ts index afb3e329719b..ebf24e57ed36 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-release-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-release-disabled.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); ", } `); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-sourcemaps.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-sourcemaps.test.ts index c4f4c0618a3c..1973196d89aa 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-sourcemaps.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic-sourcemaps.test.ts @@ -6,11 +6,10 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); //# sourceMappingURL=basic.js.map ", - "basic.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC"}", + "basic.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;scACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC"}", "sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"], ["release","set-commits","CURRENT_SHA","--auto"], ["release","finalize","CURRENT_SHA"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic.test.ts index 8877d0a9eb48..b160e72a864c 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/basic.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); ", "sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"], ["release","set-commits","CURRENT_SHA","--auto"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/build-info.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/build-info.test.ts index eab4c35fc0b3..3dca9559e716 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/build-info.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/build-info.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"build-information-injection-test"};e.SENTRY_BUILD_INFO={"deps":["@rollup/plugin-babel","@rollup/plugin-node-resolve","@sentry/bundler-plugins","react","rollup"],"depsVersions":{"react":19,"rollup":4},"nodeVersion":"NODE_VERSION"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"build-information-injection-test"};e.SENTRY_BUILD_INFO={"deps":["@rollup/plugin-babel","@rollup/plugin-node-resolve","@sentry/bundler-plugins","react","rollup"],"depsVersions":{"react":19,"rollup":4},"nodeVersion":"NODE_VERSION"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); ", } `); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/bundle-size-optimizations.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/bundle-size-optimizations.test.ts index 0bf9ac671a0b..c685a2b794e2 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/bundle-size-optimizations.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/bundle-size-optimizations.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "bundle.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log( + "bundle.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log( JSON.stringify({ debug: "b", trace: "b", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-disabled.test.ts index fe72a52582ca..054e90c0e827 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-disabled.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { jsx, jsxs } from 'react/jsx-runtime'; + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-next.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-next.test.ts index 736ee15f00cc..62cfe0816cc5 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-next.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation-next.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { jsx, jsxs } from 'react/jsx-runtime'; + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation.test.ts index e26693d043bc..387beb7fda07 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/component-annotation.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { jsx, jsxs } from 'react/jsx-runtime'; + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { jsx, jsxs } from 'react/jsx-runtime'; function ComponentA() { return /*#__PURE__*/jsx("span", { diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/debugids-already-injected.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/debugids-already-injected.test.ts index 8242f692f0b7..de92ed454402 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/debugids-already-injected.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/debugids-already-injected.test.ts @@ -10,12 +10,11 @@ test(import.meta.url, ({ runBundler, createTempDir }) => { expect(files).toMatchInlineSnapshot(` { "252e0338-8927-4f52-bd57-188131defd0f-0.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); //# debugId=00000000-0000-0000-0000-000000000000 //# sourceMappingURL=basic.js.map ", - "252e0338-8927-4f52-bd57-188131defd0f-0.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC","debugId":"252e0338-8927-4f52-bd57-188131defd0f","debug_id":"252e0338-8927-4f52-bd57-188131defd0f"}", + "252e0338-8927-4f52-bd57-188131defd0f-0.js.map": "{"version":3,"file":"basic.js","sources":["../../src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;scACA,OAAO,CAAC,GAAG,CAAC,CAAA,KAAA,CAAA,KAAA,CAAa,CAAC","debugId":"252e0338-8927-4f52-bd57-188131defd0f","debug_id":"252e0338-8927-4f52-bd57-188131defd0f"}", } `); }); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/dont-mess-up-user-code.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/dont-mess-up-user-code.test.ts index 87edc97eee9c..42d6d3679b9c 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/dont-mess-up-user-code.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/dont-mess-up-user-code.test.ts @@ -6,14 +6,13 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "index.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"I am release!"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("I am import!"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"I am release!"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("I am import!"); // eslint-disable-next-line no-console console.log("I am index!"); //# sourceMappingURL=index.js.map ", - "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAc,CAAC;;ACC3B,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,KAAA,CAAA,CAAa,CAAC"}", + "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;2aACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAc,CAAC;;ACC3B,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,KAAA,CAAA,CAAa,CAAC"}", } `); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/module-metadata.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/module-metadata.test.ts index cd934b859408..b4acc59902a5 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/module-metadata.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/module-metadata.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "common.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - function add(a, b) { + "common.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();function add(a, b) { return a + b; } export { add as a }; ", - "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js'; + "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js'; console.log(add(1, 2)); ", - "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js'; + "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js'; console.log(add(2, 4)); ", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/query-param.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/query-param.test.ts index 8200af8ddcf4..d65cb2e349da 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/query-param.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/query-param.test.ts @@ -10,20 +10,17 @@ test(import.meta.url, ({ runBundler, readOutputFiles, ctx }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "common.js?seP58q4g": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - function add(a, b) { + "common.js?seP58q4g": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();function add(a, b) { return a + b; } export { add as a }; ", - "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js?seP58q4g'; + "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js?seP58q4g'; console.log(add(1, 2)); ", - "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - import { a as add } from './common.js?seP58q4g'; + "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();import { a as add } from './common.js?seP58q4g'; console.log(add(2, 4)); ", diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/release-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/release-disabled.test.ts index c2a17292386d..39c7da1959d9 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/release-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/release-disabled.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); ", "sentry-cli-mock.json": "["release","set-commits","CURRENT_SHA","--auto"], ["release","finalize","CURRENT_SHA"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/telemetry.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/telemetry.test.ts index 6a979c32c9cc..cfb27aee5b5e 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/telemetry.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/rollup4/telemetry.test.ts @@ -6,8 +6,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic.js": "// eslint-disable-next-line no-console - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - console.log("hello world"); + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); ", "sentry-telemetry.json": "[{"sent_at":"TIMESTAMP","sdk":{"name":"sentry.javascript.node","version":"SDK_VERSION"}},[[{"type":"session"},{"sid":"UUID","init":true,"started":"TIMESTAMP","timestamp":"TIMESTAMP","status":"ok","errors":0,"duration":DURATION,"attrs":{"release":"PLUGIN_VERSION","environment":"production"}}]]], [{"event_id":"UUID","sent_at":"TIMESTAMP","sdk":{"name":"sentry.javascript.node","version":"SDK_VERSION"},"trace":{"environment":"production","release":"PLUGIN_VERSION","public_key":"UUID","trace_id":"UUID","org_id":"1","transaction":"Sentry Bundler Plugin execution","sampled":"true","sample_rand":"SAMPLE_RAND","sample_rate":"1"}},[[{"type":"transaction"},{"contexts":{"trace":{"span_id":"SHORT_UUID","trace_id":"UUID","data":{"sentry.origin":"manual","sentry.segment.name.source":"custom","sentry.sample_rate":1},"status":"ok","origin":"manual"},"runtime":{"name":"node","version":"NODE_VERSION"}},"spans":[],"start_timestamp":START_TIMESTAMP,"timestamp":TIMESTAMP,"transaction":"Sentry Bundler Plugin execution","type":"transaction","transaction_info":{"source":"custom"},"platform":"PLATFORM","event_id":"UUID","environment":"production","release":"PLUGIN_VERSION","tags":{"upload-legacy-sourcemaps":false,"module-metadata":false,"inject-build-information":false,"set-commits":"auto","finalize-release":true,"deploy-options":false,"custom-error-handler":false,"sourcemaps-assets":false,"delete-after-upload":false,"sourcemaps-disabled":false,"react-annotate":false,"node":"NODE_VERSION","platform":"PLATFORM","meta-framework":"none","application-key-set":false,"ci":true,"project":"undefined","bundler":"rollup","bundler-major-version":"4"},"user":{},"sdk":{"name":"sentry.javascript.node","version":"SDK_VERSION","integrations":[],"packages":[{"name":"npm:@sentry/node","version":"SDK_VERSION"}]}}]]], diff --git a/packages/bundler-plugins/src/rollup/index.ts b/packages/bundler-plugins/src/rollup/index.ts index 73694cc9b4eb..fb3eae756ac0 100644 --- a/packages/bundler-plugins/src/rollup/index.ts +++ b/packages/bundler-plugins/src/rollup/index.ts @@ -13,8 +13,8 @@ import { replaceBooleanFlagsInCode, CodeInjection, stampDebugId, + getCodeInjectionPosition, } from '../core'; -import { getCodeInjectionPosition } from '../core/get-code-injection-position'; import type { ComponentAnnotationTransformMeta, ComponentAnnotationTransformResult, @@ -268,16 +268,8 @@ export function _rollupPluginInternal( const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName }); const injectionPosition = getCodeInjectionPosition(code); - const codeToInject = injectionPosition === code.length ? `\n${injectCode.code()}` : `${injectCode.code()}\n`; - - if (injectionPosition > 0) { - ms.appendLeft(injectionPosition, codeToInject); - } else { - // ms.replace() doesn't work when there is an empty string match (which happens if - // there is neither, a comment, nor a "use strict" at the top of the chunk) so we - // need this special case here. - ms.prepend(codeToInject); - } + const codeToInject = injectionPosition === code.length ? `\n${injectCode.code()}` : injectCode.code(); + ms.appendLeft(injectionPosition, codeToInject); // Rolldown can pass a native MagicString instance in meta.magicString // https://rolldown.rs/in-depth/native-magic-string#usage-examples @@ -288,7 +280,7 @@ export function _rollupPluginInternal( return { code: ms.toString(), - map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' as unknown as undefined }), + map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' }), }; } diff --git a/packages/bundler-plugins/test/rollup/__snapshots__/public-api.test.ts.snap b/packages/bundler-plugins/test/rollup/__snapshots__/public-api.test.ts.snap index efd140af38e6..cd0ad570649f 100644 --- a/packages/bundler-plugins/test/rollup/__snapshots__/public-api.test.ts.snap +++ b/packages/bundler-plugins/test/rollup/__snapshots__/public-api.test.ts.snap @@ -1,26 +1,11 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Hooks > renderChunk > should process file 'bundle.cjs' 1`] = ` -"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}(); -console.log("test");" -`; +exports[`Hooks > renderChunk > should process file 'bundle.cjs' 1`] = `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}();console.log("test");"`; -exports[`Hooks > renderChunk > should process file 'bundle.js#hash' 1`] = ` -"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}(); -console.log("test");" -`; +exports[`Hooks > renderChunk > should process file 'bundle.js#hash' 1`] = `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}();console.log("test");"`; -exports[`Hooks > renderChunk > should process file 'bundle.js' 1`] = ` -"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}(); -console.log("test");" -`; +exports[`Hooks > renderChunk > should process file 'bundle.js' 1`] = `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}();console.log("test");"`; -exports[`Hooks > renderChunk > should process file 'bundle.js?foo=bar' 1`] = ` -"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}(); -console.log("test");" -`; +exports[`Hooks > renderChunk > should process file 'bundle.js?foo=bar' 1`] = `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}();console.log("test");"`; -exports[`Hooks > renderChunk > should process file 'bundle.mjs' 1`] = ` -"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}(); -console.log("test");" -`; +exports[`Hooks > renderChunk > should process file 'bundle.mjs' 1`] = `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b80112c0-6818-486d-96f0-185c023439b4",e._sentryDebugIdIdentifier="sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4");}catch(e){}}();console.log("test");"`; diff --git a/packages/bundler-plugins/test/rollup/public-api.test.ts b/packages/bundler-plugins/test/rollup/public-api.test.ts index 296d4416f399..11eb151f9072 100644 --- a/packages/bundler-plugins/test/rollup/public-api.test.ts +++ b/packages/bundler-plugins/test/rollup/public-api.test.ts @@ -138,10 +138,9 @@ describe('Hooks', () => { const result = renderChunk(code, { fileName: 'bundle.js' }); expect(result).not.toBeNull(); - expect(result?.code).toMatchInlineSnapshot(` - "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d4309f93-5358-4ae1-bcf0-3813aa590eb5",e._sentryDebugIdIdentifier="sentry-dbid-d4309f93-5358-4ae1-bcf0-3813aa590eb5");}catch(e){}}(); - console.log("Hello world");" - `); + expect(result?.code).toMatchInlineSnapshot( + `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d4309f93-5358-4ae1-bcf0-3813aa590eb5",e._sentryDebugIdIdentifier="sentry-dbid-d4309f93-5358-4ae1-bcf0-3813aa590eb5");}catch(e){}}();console.log("Hello world");"`, + ); }); it("should inject debug ID after 'use strict'", () => { @@ -151,8 +150,7 @@ describe('Hooks', () => { expect(result).not.toBeNull(); expect(result?.code).toMatchInlineSnapshot(` ""use strict"; - !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="79a86c07-8ecc-4367-82b0-88cf822f2d41",e._sentryDebugIdIdentifier="sentry-dbid-79a86c07-8ecc-4367-82b0-88cf822f2d41");}catch(e){}}(); - console.log("Hello world");" + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="79a86c07-8ecc-4367-82b0-88cf822f2d41",e._sentryDebugIdIdentifier="sentry-dbid-79a86c07-8ecc-4367-82b0-88cf822f2d41");}catch(e){}}();console.log("Hello world");" `); }); @@ -166,7 +164,7 @@ describe('Hooks', () => { file: 'bundle.js', sources: ['bundle.js'], names: [], - mappings: 'AAAA,CAAC,GAAG,CAAC,MAAM,CAAC;;AACZ,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI', + mappings: 'AAAA,CAAC,GAAG,CAAC,MAAM,CAAC;qYACZ,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI', }); }); @@ -288,10 +286,9 @@ export * from './moduleC.js';`, facadeModuleId: '/path/to/index.html', }); expect(result).not.toBeNull(); - expect(result?.code).toMatchInlineSnapshot(` - "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c4c89e04-3658-4874-b25b-07e638185091",e._sentryDebugIdIdentifier="sentry-dbid-c4c89e04-3658-4874-b25b-07e638185091");}catch(e){}}(); - function main() { console.log("hello"); }" - `); + expect(result?.code).toMatchInlineSnapshot( + `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c4c89e04-3658-4874-b25b-07e638185091",e._sentryDebugIdIdentifier="sentry-dbid-c4c89e04-3658-4874-b25b-07e638185091");}catch(e){}}();function main() { console.log("hello"); }"`, + ); }); it('should inject into HTML facade with variable declarations', () => { @@ -300,10 +297,9 @@ export * from './moduleC.js';`, facadeModuleId: '/path/to/index.html', }); expect(result).not.toBeNull(); - expect(result?.code).toMatchInlineSnapshot(` - "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="43e69766-1963-49f2-a291-ff8de60cc652",e._sentryDebugIdIdentifier="sentry-dbid-43e69766-1963-49f2-a291-ff8de60cc652");}catch(e){}}(); - const x = 42;" - `); + expect(result?.code).toMatchInlineSnapshot( + `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="43e69766-1963-49f2-a291-ff8de60cc652",e._sentryDebugIdIdentifier="sentry-dbid-43e69766-1963-49f2-a291-ff8de60cc652");}catch(e){}}();const x = 42;"`, + ); }); it('should inject into HTML facade with substantial code (SPA main bundle)', () => { @@ -322,8 +318,7 @@ bootstrap();`; }); expect(result).not.toBeNull(); expect(result?.code).toMatchInlineSnapshot(` - "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d0c4524b-496e-45a4-9852-7558d043ba3c",e._sentryDebugIdIdentifier="sentry-dbid-d0c4524b-496e-45a4-9852-7558d043ba3c");}catch(e){}}(); - import { initApp } from './app.js'; + "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d0c4524b-496e-45a4-9852-7558d043ba3c",e._sentryDebugIdIdentifier="sentry-dbid-d0c4524b-496e-45a4-9852-7558d043ba3c");}catch(e){}}();import { initApp } from './app.js'; const config = { debug: true }; @@ -342,8 +337,7 @@ bootstrap();`; }); expect(result).not.toBeNull(); expect(result?.code).toMatchInlineSnapshot(` - "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="28f0bbaa-9aeb-40c4-98c9-4e44f1d4e175",e._sentryDebugIdIdentifier="sentry-dbid-28f0bbaa-9aeb-40c4-98c9-4e44f1d4e175");}catch(e){}}(); - import './polyfills.js'; + "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="28f0bbaa-9aeb-40c4-98c9-4e44f1d4e175",e._sentryDebugIdIdentifier="sentry-dbid-28f0bbaa-9aeb-40c4-98c9-4e44f1d4e175");}catch(e){}}();import './polyfills.js'; import { init } from './app.js'; init();" @@ -353,10 +347,9 @@ bootstrap();`; it('should inject into regular JS chunks (no HTML facade)', () => { const result = renderChunk(`console.log("Hello");`, { fileName: 'bundle.js' }); expect(result).not.toBeNull(); - expect(result?.code).toMatchInlineSnapshot(` - "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="79f18a7f-ca16-4168-9797-906c82058367",e._sentryDebugIdIdentifier="sentry-dbid-79f18a7f-ca16-4168-9797-906c82058367");}catch(e){}}(); - console.log("Hello");" - `); + expect(result?.code).toMatchInlineSnapshot( + `"!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="79f18a7f-ca16-4168-9797-906c82058367",e._sentryDebugIdIdentifier="sentry-dbid-79f18a7f-ca16-4168-9797-906c82058367");}catch(e){}}();console.log("Hello");"`, + ); }); }); }); From 2591a3211344afd70840ad2068e288c1285976c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 17 Sep 2026 16:20:21 +0200 Subject: [PATCH 17/25] fix(bundler-plugins): Avoid extra Webpack injection line Co-Authored-By: OpenAI Codex --- .../webpack5/after-upload-deletion.test.ts | 3 +-- .../fixtures/webpack5/application-key.test.ts | 3 +-- .../fixtures/webpack5/basic-cjs.test.ts | 3 +-- .../webpack5/basic-release-disabled.test.ts | 3 +-- .../fixtures/webpack5/basic-sourcemaps.test.ts | 3 +-- .../fixtures/webpack5/basic.test.ts | 3 +-- .../fixtures/webpack5/build-info.test.ts | 3 +-- .../webpack5/bundle-size-optimizations.test.ts | 3 +-- .../component-annotation-disabled.test.ts | 3 +-- .../webpack5/component-annotation-next.test.ts | 3 +-- .../webpack5/component-annotation.test.ts | 3 +-- .../webpack5/debugids-already-injected.test.ts | 3 +-- .../fixtures/webpack5/module-metadata.test.ts | 3 +-- .../webpack5/multiple-entry-points.test.ts | 6 ++---- .../fixtures/webpack5/release-disabled.test.ts | 3 +-- .../fixtures/webpack5/telemetry.test.ts | 3 +-- packages/bundler-plugins/src/webpack/index.ts | 18 +++--------------- .../src/webpack/webpack4and5.ts | 8 ++++---- .../test/webpack/webpack4and5.test.ts | 4 ++-- 19 files changed, 26 insertions(+), 55 deletions(-) diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/after-upload-deletion.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/after-upload-deletion.test.ts index 021d4743e331..b82433103407 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/after-upload-deletion.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/after-upload-deletion.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/application-key.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/application-key.test.ts index 71121ac814cb..1b7b4b354b7c 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/application-key.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/application-key.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-cjs.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-cjs.test.ts index f12e4b7fc737..c0a5365c61fd 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-cjs.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-cjs.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-release-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-release-disabled.test.ts index 42134e3f0a58..0f0ac8d0feff 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-release-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-release-disabled.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-sourcemaps.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-sourcemaps.test.ts index b7534c90402f..ef853b005d16 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-sourcemaps.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-sourcemaps.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic.test.ts index f12e4b7fc737..c0a5365c61fd 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/build-info.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/build-info.test.ts index d29a8157fa40..1f5107e559ef 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/build-info.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/build-info.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"build-information-injection-test"};e.SENTRY_BUILD_INFO={"deps":["@babel/preset-react","@sentry/bundler-plugins","babel-loader","webpack","webpack-cli"],"depsVersions":{"webpack":5},"nodeVersion":"NODE_VERSION"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"build-information-injection-test"};e.SENTRY_BUILD_INFO={"deps":["@babel/preset-react","@sentry/bundler-plugins","babel-loader","webpack","webpack-cli"],"depsVersions":{"webpack":5},"nodeVersion":"NODE_VERSION"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/bundle-size-optimizations.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/bundle-size-optimizations.test.ts index 02079036d9c9..dacf1bc67701 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/bundle-size-optimizations.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/bundle-size-optimizations.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "bundle.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "bundle.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; console.log( JSON.stringify({ diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-disabled.test.ts index 78280fc69da0..d3a532ff0ba3 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-disabled.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "app.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; // UNUSED EXPORTS: default diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-next.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-next.test.ts index a5556a5624b5..ae93c38a8bc3 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-next.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation-next.test.ts @@ -10,8 +10,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, ctx }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "app.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; // UNUSED EXPORTS: default diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation.test.ts index 495704896f1e..750c7fbdaebe 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/component-annotation.test.ts @@ -10,8 +10,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, ctx }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "app.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "app.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; // UNUSED EXPORTS: default diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/debugids-already-injected.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/debugids-already-injected.test.ts index 096b9c89e43b..ee292c884def 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/debugids-already-injected.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/debugids-already-injected.test.ts @@ -9,8 +9,7 @@ test(import.meta.url, ({ runBundler, createTempDir }) => { const files = readAllFiles(tempDir); expect(files).toMatchInlineSnapshot(` { - "33730b8e-5b8d-4795-94b2-666cea28fce6-0.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "33730b8e-5b8d-4795-94b2-666cea28fce6-0.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/module-metadata.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/module-metadata.test.ts index 3c3b18580a1d..a6830a1f55b4 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/module-metadata.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/module-metadata.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/multiple-entry-points.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/multiple-entry-points.test.ts index da52345c24e8..2683bd1001e3 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/multiple-entry-points.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/multiple-entry-points.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "entry1.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "entry1.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; ;// ./src/common.js @@ -21,8 +20,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { /******/ })() ;", - "entry2.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "entry2.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; ;// ./src/common.js diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/release-disabled.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/release-disabled.test.ts index dda6c9ab8889..9982a5b85bf9 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/release-disabled.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/release-disabled.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/telemetry.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/telemetry.test.ts index d2d6f3d77c7e..cf37af1dcc2e 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/telemetry.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/telemetry.test.ts @@ -5,8 +5,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); - (() => { // webpackBootstrap + "basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();(() => { // webpackBootstrap /******/ "use strict"; // eslint-disable-next-line no-console console.log("hello world"); diff --git a/packages/bundler-plugins/src/webpack/index.ts b/packages/bundler-plugins/src/webpack/index.ts index 9a4140570691..72c43676ecfc 100644 --- a/packages/bundler-plugins/src/webpack/index.ts +++ b/packages/bundler-plugins/src/webpack/index.ts @@ -1,26 +1,14 @@ -import type { SentryWebpackPluginOptions } from './webpack4and5'; +import type { SentryWebpackPluginOptions, WebpackCompilationApi, WebpackSources } from './webpack4and5'; import { sentryWebpackPluginFactory } from './webpack4and5'; import { createRequire } from 'node:module'; // eslint-disable-next-line @typescript-eslint/no-explicit-any type PluginClass = new (options: any) => unknown; -type WebpackSource = { - source: () => string | Uint8Array; -}; - type WebpackModule = { DefinePlugin?: PluginClass; - Compilation?: { - PROCESS_ASSETS_STAGE_ADDITIONS: number; - PROCESS_ASSETS_STAGE_DEV_TOOLING?: number; - }; - sources?: { - ReplaceSource: new (source: WebpackSource) => WebpackSource & { - insert: (position: number, value: string) => void; - }; - RawSource?: new (source: string) => WebpackSource; - }; + Compilation?: WebpackCompilationApi; + sources?: WebpackSources; default?: WebpackModule; }; diff --git a/packages/bundler-plugins/src/webpack/webpack4and5.ts b/packages/bundler-plugins/src/webpack/webpack4and5.ts index c41a3e238577..2fcd92b96c9f 100644 --- a/packages/bundler-plugins/src/webpack/webpack4and5.ts +++ b/packages/bundler-plugins/src/webpack/webpack4and5.ts @@ -13,8 +13,8 @@ import { createDebugIdUploadFunction, isJsFile, stampDebugId, + getCodeInjectionPosition, } from '../core/index'; -import { getCodeInjectionPosition } from '../core/get-code-injection-position'; import * as path from 'node:path'; import { fileURLToPath } from 'node:url'; import { createRequire } from 'node:module'; @@ -47,12 +47,12 @@ type UnsafeDefinePlugin = { new (options: any): unknown; }; -type WebpackCompilationApi = { +export type WebpackCompilationApi = { PROCESS_ASSETS_STAGE_ADDITIONS: number; PROCESS_ASSETS_STAGE_DEV_TOOLING?: number; }; -type WebpackSources = { +export type WebpackSources = { ReplaceSource: new (source: WebpackSource) => WebpackReplaceSource; RawSource?: WebpackRawSource; }; @@ -300,7 +300,7 @@ export function sentryWebpackPluginFactory({ const injectionPosition = getCodeInjectionPosition(codeString); const injection = - injectionPosition === codeString.length ? `\n${codeToInject.code()}` : `${codeToInject.code()}\n`; + injectionPosition === codeString.length ? `\n${codeToInject.code()}` : codeToInject.code(); const updatedSource = new ReplaceSource(source); updatedSource.insert(injectionPosition, injection); compilation.updateAsset(assetName, updatedSource); diff --git a/packages/bundler-plugins/test/webpack/webpack4and5.test.ts b/packages/bundler-plugins/test/webpack/webpack4and5.test.ts index ace341c26cdb..d9621d70a710 100644 --- a/packages/bundler-plugins/test/webpack/webpack4and5.test.ts +++ b/packages/bundler-plugins/test/webpack/webpack4and5.test.ts @@ -75,7 +75,7 @@ describe('sentryWebpackPluginFactory', () => { const code = '"use strict";\nglobalThis.applicationStarted = true;'; const inputMap = new MagicString(code).generateMap({ source: 'application.js', - hires: 'boundary' as unknown as undefined, + hires: 'boundary', includeContent: true, }); const source = new webpack.sources.SourceMapSource(code, 'bundle.js', inputMap.toString()); @@ -85,7 +85,7 @@ describe('sentryWebpackPluginFactory', () => { expect(outputMap?.sources).toEqual(['application.js']); expect(outputMap?.sourcesContent).toEqual([code]); - expect(outputMap?.mappings).toBe('AAAA,CAAC,GAAG,CAAC,MAAM,CAAC;AACZ;AAAA,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI'); + expect(outputMap?.mappings).toBe('AAAA,CAAC,GAAG,CAAC,MAAM,CAAC;AACZ,+YAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI'); }); it('derives the debug ID from the Webpack chunk hash', () => { From cf06dfbf589ff7536151531416b559f7a2903463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 17 Sep 2026 16:21:49 +0200 Subject: [PATCH 18/25] fix(nextjs): Separate EOF loader injections Co-Authored-By: OpenAI Codex --- .../src/config/loaders/moduleMetadataInjectionLoader.ts | 3 ++- .../nextjs/src/config/loaders/valueInjectionLoader.ts | 3 ++- .../test/config/moduleMetadataInjectionLoader.test.ts | 9 +++++++++ packages/nextjs/test/config/valueInjectionLoader.test.ts | 8 ++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/nextjs/src/config/loaders/moduleMetadataInjectionLoader.ts b/packages/nextjs/src/config/loaders/moduleMetadataInjectionLoader.ts index 5ff5d9ac2bf2..0c44bac71db5 100644 --- a/packages/nextjs/src/config/loaders/moduleMetadataInjectionLoader.ts +++ b/packages/nextjs/src/config/loaders/moduleMetadataInjectionLoader.ts @@ -40,5 +40,6 @@ export default function moduleMetadataInjectionLoader( '}catch(e){}}();'; const injectionIndex = getCodeInjectionPosition(userCode); - return `${userCode.slice(0, injectionIndex)}${injectedCode}${userCode.slice(injectionIndex)}`; + const codeToInject = injectionIndex === userCode.length ? `\n${injectedCode}` : injectedCode; + return `${userCode.slice(0, injectionIndex)}${codeToInject}${userCode.slice(injectionIndex)}`; } diff --git a/packages/nextjs/src/config/loaders/valueInjectionLoader.ts b/packages/nextjs/src/config/loaders/valueInjectionLoader.ts index a8da78c90850..8937b4e435e1 100644 --- a/packages/nextjs/src/config/loaders/valueInjectionLoader.ts +++ b/packages/nextjs/src/config/loaders/valueInjectionLoader.ts @@ -28,5 +28,6 @@ export default function valueInjectionLoader(this: LoaderThis { expect(metadataIndex).toBeGreaterThan(clientDirectiveIndex); }); + + it('separates an EOF injection from a trailing line comment', () => { + const loaderThis = createLoaderThis('my-app'); + const userCode = '"use client" // trailing'; + + const result = moduleMetadataInjectionLoader.call(loaderThis, userCode); + + expect(result).toContain('// trailing\n;!function(){try{'); + }); }); diff --git a/packages/nextjs/test/config/valueInjectionLoader.test.ts b/packages/nextjs/test/config/valueInjectionLoader.test.ts index a01d9c309fe6..bc6a730d1c69 100644 --- a/packages/nextjs/test/config/valueInjectionLoader.test.ts +++ b/packages/nextjs/test/config/valueInjectionLoader.test.ts @@ -225,4 +225,12 @@ describe.each([[clientConfigLoaderThis], [instrumentationLoaderThis]])('valueInj expect(result).toBe('"use client"\u2028;globalThis["foo"] = "bar";startApp();'); }); + + it('separates an EOF injection from a trailing line comment', () => { + const userCode = '"use client" // trailing'; + + const result = valueInjectionLoader.call(loaderThis, userCode); + + expect(result).toBe('"use client" // trailing\n;globalThis["foo"] = "bar";'); + }); }); From e4ac1ba9958650c9e72d9f58bcf741b644c4049d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 17 Sep 2026 16:24:36 +0200 Subject: [PATCH 19/25] test(nextjs): Update directive injection snapshots Co-Authored-By: OpenAI Codex --- .../valueInjectionLoader.test.ts.snap | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/nextjs/test/config/__snapshots__/valueInjectionLoader.test.ts.snap b/packages/nextjs/test/config/__snapshots__/valueInjectionLoader.test.ts.snap index 8853a6c160b0..3c75e31c2e44 100644 --- a/packages/nextjs/test/config/__snapshots__/valueInjectionLoader.test.ts.snap +++ b/packages/nextjs/test/config/__snapshots__/valueInjectionLoader.test.ts.snap @@ -40,16 +40,16 @@ exports[`valueInjectionLoader > should correctly insert values with a misplaced exports[`valueInjectionLoader > should correctly insert values with directive 1`] = ` " - "use client";globalThis["foo"] = "bar"; - import * as Sentry from '@sentry/nextjs'; + "use client" + ;globalThis["foo"] = "bar";import * as Sentry from '@sentry/nextjs'; Sentry.init(); " `; exports[`valueInjectionLoader > should correctly insert values with directive 2`] = ` " - "use client";globalThis["foo"] = "bar"; - import * as Sentry from '@sentry/nextjs'; + "use client" + ;globalThis["foo"] = "bar";import * as Sentry from '@sentry/nextjs'; Sentry.init(); " `; @@ -57,8 +57,8 @@ exports[`valueInjectionLoader > should correctly insert values with directive 2` exports[`valueInjectionLoader > should correctly insert values with directive and block comments 1`] = ` " /* test */ - "use client";;globalThis["foo"] = "bar"; - import * as Sentry from '@sentry/nextjs'; + "use client"; + ;globalThis["foo"] = "bar";import * as Sentry from '@sentry/nextjs'; Sentry.init(); " `; @@ -66,8 +66,8 @@ exports[`valueInjectionLoader > should correctly insert values with directive an exports[`valueInjectionLoader > should correctly insert values with directive and block comments 2`] = ` " /* test */ - "use client";;globalThis["foo"] = "bar"; - import * as Sentry from '@sentry/nextjs'; + "use client"; + ;globalThis["foo"] = "bar";import * as Sentry from '@sentry/nextjs'; Sentry.init(); " `; @@ -75,8 +75,8 @@ exports[`valueInjectionLoader > should correctly insert values with directive an exports[`valueInjectionLoader > should correctly insert values with directive and inline comments 1`] = ` " // test - "use client";;globalThis["foo"] = "bar"; - import * as Sentry from '@sentry/nextjs'; + "use client"; + ;globalThis["foo"] = "bar";import * as Sentry from '@sentry/nextjs'; Sentry.init(); " `; @@ -84,8 +84,8 @@ exports[`valueInjectionLoader > should correctly insert values with directive an exports[`valueInjectionLoader > should correctly insert values with directive and inline comments 2`] = ` " // test - "use client";;globalThis["foo"] = "bar"; - import * as Sentry from '@sentry/nextjs'; + "use client"; + ;globalThis["foo"] = "bar";import * as Sentry from '@sentry/nextjs'; Sentry.init(); " `; @@ -95,8 +95,8 @@ exports[`valueInjectionLoader > should correctly insert values with directive an /* test */ - "use client";;globalThis["foo"] = "bar"; - import * as Sentry from '@sentry/nextjs'; + "use client"; + ;globalThis["foo"] = "bar";import * as Sentry from '@sentry/nextjs'; Sentry.init(); " `; @@ -106,8 +106,8 @@ exports[`valueInjectionLoader > should correctly insert values with directive an /* test */ - "use client";;globalThis["foo"] = "bar"; - import * as Sentry from '@sentry/nextjs'; + "use client"; + ;globalThis["foo"] = "bar";import * as Sentry from '@sentry/nextjs'; Sentry.init(); " `; @@ -121,11 +121,11 @@ exports[`valueInjectionLoader > should correctly insert values with directive an - "use client";;globalThis["foo"] = "bar"; + "use client"; - import * as Sentry from '@sentry/nextjs'; + ;globalThis["foo"] = "bar";import * as Sentry from '@sentry/nextjs'; Sentry.init(); " `; @@ -139,27 +139,27 @@ exports[`valueInjectionLoader > should correctly insert values with directive an - "use client";;globalThis["foo"] = "bar"; + "use client"; - import * as Sentry from '@sentry/nextjs'; + ;globalThis["foo"] = "bar";import * as Sentry from '@sentry/nextjs'; Sentry.init(); " `; exports[`valueInjectionLoader > should correctly insert values with directive and semicolon 1`] = ` " - "use client";;globalThis["foo"] = "bar"; - import * as Sentry from '@sentry/nextjs'; + "use client"; + ;globalThis["foo"] = "bar";import * as Sentry from '@sentry/nextjs'; Sentry.init(); " `; exports[`valueInjectionLoader > should correctly insert values with directive and semicolon 2`] = ` " - "use client";;globalThis["foo"] = "bar"; - import * as Sentry from '@sentry/nextjs'; + "use client"; + ;globalThis["foo"] = "bar";import * as Sentry from '@sentry/nextjs'; Sentry.init(); " `; From 4627deddab640aaa2f8f555c13af1645b9c8ba6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 17 Sep 2026 17:50:08 +0200 Subject: [PATCH 20/25] test(bundler-plugins): Update Webpack sourcemap snapshots Co-Authored-By: OpenAI Codex --- .../fixtures/webpack5/basic-sourcemaps.test.ts | 2 +- .../fixtures/webpack5/debugids-already-injected.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-sourcemaps.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-sourcemaps.test.ts index ef853b005d16..575d00dc1ee9 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-sourcemaps.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-sourcemaps.test.ts @@ -13,7 +13,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { /******/ })() ; //# sourceMappingURL=basic.js.map", - "basic.js.map": "{"version":3,"file":"basic.js","mappings":";;;AAAA;AACA","sources":["webpack://webpack5-integration-tests/./src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"sourceRoot":""}", + "basic.js.map": "{"version":3,"file":"basic.js","mappings":";;AAAA;AACA","sources":["webpack://webpack5-integration-tests/./src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"sourceRoot":""}", "sentry-cli-mock.json": "["release","create","CURRENT_SHA","--project","fake-project"], ["release","set-commits","CURRENT_SHA","--auto"], ["release","finalize","CURRENT_SHA"], diff --git a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/debugids-already-injected.test.ts b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/debugids-already-injected.test.ts index ee292c884def..cf466e381a46 100644 --- a/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/debugids-already-injected.test.ts +++ b/dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/debugids-already-injected.test.ts @@ -18,7 +18,7 @@ test(import.meta.url, ({ runBundler, createTempDir }) => { ; //# sourceMappingURL=basic.js.map //# debugId=00000000-0000-0000-0000-000000000000", - "33730b8e-5b8d-4795-94b2-666cea28fce6-0.js.map": "{"version":3,"file":"basic.js","mappings":";;;AAAA;AACA","sources":["webpack5-integration-tests/./src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"sourceRoot":"","debug_id":"33730b8e-5b8d-4795-94b2-666cea28fce6","debugId":"33730b8e-5b8d-4795-94b2-666cea28fce6"}", + "33730b8e-5b8d-4795-94b2-666cea28fce6-0.js.map": "{"version":3,"file":"basic.js","mappings":";;AAAA;AACA","sources":["webpack5-integration-tests/./src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"sourceRoot":"","debug_id":"33730b8e-5b8d-4795-94b2-666cea28fce6","debugId":"33730b8e-5b8d-4795-94b2-666cea28fce6"}", } `); }); From c6e43f8f09237e5702c2ed352e0ec67190d77af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 21 Sep 2026 12:47:01 +0200 Subject: [PATCH 21/25] fix(bundler-plugins): Format Webpack injection Co-Authored-By: OpenAI Codex --- packages/bundler-plugins/src/webpack/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/bundler-plugins/src/webpack/index.ts b/packages/bundler-plugins/src/webpack/index.ts index 9eba5efee2c0..e6b6d4a48705 100644 --- a/packages/bundler-plugins/src/webpack/index.ts +++ b/packages/bundler-plugins/src/webpack/index.ts @@ -260,8 +260,7 @@ function createSentryWebpackPlugin(userOptions: SentryWebpackPluginOptions = {}) } const sourceContents = source.source(); - const code = - typeof sourceContents === 'string' ? sourceContents : Buffer.from(sourceContents).toString(); + const code = typeof sourceContents === 'string' ? sourceContents : Buffer.from(sourceContents).toString(); const codeToInject = staticInjectionCode.clone(); if (sourcemapsEnabled) { const hash = chunk.contentHash?.javascript ?? chunk.hash; From d139e1620eca5504d0e667c7ddf42b110ea90b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 21 Sep 2026 12:48:14 +0200 Subject: [PATCH 22/25] fix(bundler-plugins): Restore Webpack lint exception Co-Authored-By: OpenAI Codex --- packages/bundler-plugins/src/webpack/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/bundler-plugins/src/webpack/index.ts b/packages/bundler-plugins/src/webpack/index.ts index e6b6d4a48705..d492800dfee7 100644 --- a/packages/bundler-plugins/src/webpack/index.ts +++ b/packages/bundler-plugins/src/webpack/index.ts @@ -1,3 +1,5 @@ +/* oxlint-disable max-lines */ + import type { Options } from '../core/index'; import { createSentryBuildPluginManager, From c9f40a495dc7f43b96186a7393103b3eeb35a5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 21 Sep 2026 13:18:48 +0200 Subject: [PATCH 23/25] test(bundler-plugins): Cover shared Webpack assets Co-Authored-By: OpenAI Codex --- .../test/webpack/injection.test.ts | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/packages/bundler-plugins/test/webpack/injection.test.ts b/packages/bundler-plugins/test/webpack/injection.test.ts index 6072dc1f7a0c..baf74dc6b7db 100644 --- a/packages/bundler-plugins/test/webpack/injection.test.ts +++ b/packages/bundler-plugins/test/webpack/injection.test.ts @@ -4,11 +4,15 @@ import { runInNewContext } from 'node:vm'; import { describe, expect, it } from 'vitest'; import { sentryWebpackPlugin } from '../../src/webpack'; +interface TestChunk { + files: string[]; + hash?: string; +} + function runWebpackSourceInjection( assetName: string, source: webpack.sources.Source, - chunkFiles: string[] = [assetName], - chunkHash?: string, + chunks: TestChunk[] = [{ files: [assetName] }], ): webpack.sources.Source { const webpackPlugin = sentryWebpackPlugin({ release: { inject: false }, @@ -16,7 +20,7 @@ function runWebpackSourceInjection( }); let compilationCallback!: (compilation: unknown) => void; let processAssets!: (assets: Record) => void; - let output = source; + const assets = { [assetName]: source }; const compiler = { options: { plugins: [] as unknown[] }, webpack: { @@ -34,7 +38,7 @@ function runWebpackSourceInjection( }, }; const compilation = { - chunks: [{ files: chunkFiles, hash: chunkHash }], + chunks, compiler: {}, hooks: { processAssets: { @@ -43,20 +47,20 @@ function runWebpackSourceInjection( }, }, }, - updateAsset: (_name: string, source: webpack.sources.Source) => { - output = source; + updateAsset: (name: string, updatedSource: webpack.sources.Source) => { + assets[name] = updatedSource; }, }; webpackPlugin.apply(compiler as never); compilationCallback(compilation); - processAssets({ [assetName]: source }); + processAssets(assets); - return output; + return assets[assetName]; } -function runWebpackInjection(assetName: string, code: string, chunkFiles: string[] = [assetName]): string { - return runWebpackSourceInjection(assetName, new webpack.sources.RawSource(code), chunkFiles).source().toString(); +function runWebpackInjection(assetName: string, code: string, chunks?: TestChunk[]): string { + return runWebpackSourceInjection(assetName, new webpack.sources.RawSource(code), chunks).source().toString(); } describe('sentryWebpackPlugin', () => { @@ -92,8 +96,7 @@ describe('sentryWebpackPlugin', () => { const output = runWebpackSourceInjection( 'bundle.js', new webpack.sources.RawSource('globalThis.bundleLoaded = true;'), - ['bundle.js'], - 'stable-webpack-chunk-hash', + [{ files: ['bundle.js'], hash: 'stable-webpack-chunk-hash' }], ) .source() .toString(); @@ -134,4 +137,13 @@ describe('sentryWebpackPlugin', () => { expect(output).toBe(code); }); + + it('injects into an asset shared by multiple chunks once', () => { + const output = runWebpackInjection('shared.js', 'globalThis.bundleLoaded = true;', [ + { files: ['shared.js'], hash: 'first-chunk-hash' }, + { files: ['shared.js'], hash: 'second-chunk-hash' }, + ]); + + expect(output.match(/_sentryDebugIdIdentifier/g)).toHaveLength(1); + }); }); From 4dd2a3181ba6f0e55317a054fb4286ba7a3474fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 21 Sep 2026 13:19:12 +0200 Subject: [PATCH 24/25] fix(bundler-plugins): Avoid duplicate Webpack injection Co-Authored-By: OpenAI Codex --- packages/bundler-plugins/src/webpack/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/bundler-plugins/src/webpack/index.ts b/packages/bundler-plugins/src/webpack/index.ts index d492800dfee7..2adcd4ddc0b6 100644 --- a/packages/bundler-plugins/src/webpack/index.ts +++ b/packages/bundler-plugins/src/webpack/index.ts @@ -250,9 +250,11 @@ function createSentryWebpackPlugin(userOptions: SentryWebpackPluginOptions = {}) stage: processAssetsStage, }, assets => { + const injectedAssets = new Set(); + for (const chunk of compilation.chunks) { for (const assetName of chunk.files) { - if (!WEBPACK_JAVASCRIPT_ASSET_REGEX.test(assetName)) { + if (injectedAssets.has(assetName) || !WEBPACK_JAVASCRIPT_ASSET_REGEX.test(assetName)) { continue; } @@ -260,6 +262,7 @@ function createSentryWebpackPlugin(userOptions: SentryWebpackPluginOptions = {}) if (!source) { continue; } + injectedAssets.add(assetName); const sourceContents = source.source(); const code = typeof sourceContents === 'string' ? sourceContents : Buffer.from(sourceContents).toString(); From 233abc21a04c6c6a9dd951372b246b8d21868acc Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 22 Sep 2026 20:53:02 +0200 Subject: [PATCH 25/25] Remove unused regex --- packages/bundler-plugins/src/core/index.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/bundler-plugins/src/core/index.ts b/packages/bundler-plugins/src/core/index.ts index 506d965a083e..9c5008bf8587 100644 --- a/packages/bundler-plugins/src/core/index.ts +++ b/packages/bundler-plugins/src/core/index.ts @@ -30,12 +30,6 @@ function loadBabelAnnotationRuntime(): Promise { return babelAnnotationRuntimePromise; } -// We need to be careful not to inject the snippet before any `"use strict";`s. -// As an additional complication `"use strict";`s may come after any number of comments. -export const COMMENT_USE_STRICT_REGEX = - // Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files. - /^(?:\s*|\/\*(?:.|\r|\n)*?\*\/|\/\/.*[\n\r])*(?:"[^"]*";|'[^']*';)?/; - /** * Checks if a file is a JavaScript file based on its extension. * Handles query strings and hashes in the filename.