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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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/11] 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,