diff --git a/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.config.js b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.config.js
new file mode 100644
index 00000000..bb04c9d4
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.config.js
@@ -0,0 +1,13 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
+import { sentryConfig } from "../configs/after-upload-deletion.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/basic.js"],
+ bundle: true,
+ outfile: "./out/after-upload-deletion/basic.js",
+ minify: false,
+ format: "iife",
+ sourcemap: true,
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.test.ts b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.test.ts
new file mode 100644
index 00000000..3fd6de38
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.test.ts
@@ -0,0 +1,41 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
+ runBundler();
+ expect(readOutputFiles()).toMatchInlineSnapshot(`
+ {
+ "basic.js": "(() => {
+ // _sentry-injection-stub
+ !(function() {
+ try {
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {};
+ e.SENTRY_RELEASE = { id: "CURRENT_SHA" };
+ } catch (e2) {
+ }
+ })();
+
+ // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
+ !(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 (e2) {
+ }
+ })();
+
+ // src/basic.js
+ console.log("hello world");
+
+ // src/basic.js?sentryDebugIdProxy=true
+ var basic_default = void 0;
+ })();
+ //# sourceMappingURL=basic.js.map
+ ",
+ }
+ `);
+
+ const output = runFileInNode("basic.js");
+ expect(output).toBe("hello world\n");
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/application-key.config.js b/packages/integration-tests-next/fixtures/esbuild/application-key.config.js
new file mode 100644
index 00000000..fc665c30
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/application-key.config.js
@@ -0,0 +1,12 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
+import { sentryConfig } from "../configs/application-key.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/basic.js"],
+ bundle: true,
+ outfile: "./out/application-key/application-key.js",
+ minify: false,
+ format: "iife",
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/application-key.test.ts b/packages/integration-tests-next/fixtures/esbuild/application-key.test.ts
new file mode 100644
index 00000000..b9c0ae91
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/application-key.test.ts
@@ -0,0 +1,47 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
+ runBundler();
+ expect(readOutputFiles()).toMatchInlineSnapshot(`
+ {
+ "application-key.js": "(() => {
+ // _sentry-injection-stub
+ !(function() {
+ try {
+ 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(e2) {
+ for (var n = 1; n < arguments.length; n++) {
+ var a = arguments[n];
+ if (null != a) for (var t in a) a.hasOwnProperty(t) && (e2[t] = a[t]);
+ }
+ return e2;
+ })({}, e._sentryModuleMetadata[new e.Error().stack], { "_sentryBundlerPluginAppKey:1234567890abcdef": true });
+ } catch (e2) {
+ }
+ })();
+
+ // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
+ !(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 (e2) {
+ }
+ })();
+
+ // src/basic.js
+ console.log("hello world");
+
+ // src/basic.js?sentryDebugIdProxy=true
+ var basic_default = void 0;
+ })();
+ ",
+ }
+ `);
+
+ const output = runFileInNode("application-key.js");
+ expect(output).toBe("hello world\n");
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/basic-release-disabled.config.js b/packages/integration-tests-next/fixtures/esbuild/basic-release-disabled.config.js
new file mode 100644
index 00000000..bb76e29d
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/basic-release-disabled.config.js
@@ -0,0 +1,12 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
+import { sentryConfig } from "../configs/basic-release-disabled.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/basic.js"],
+ bundle: true,
+ outfile: "./out/basic-release-disabled/basic-release-disabled.js",
+ minify: false,
+ format: "iife",
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/basic-release-disabled.test.ts b/packages/integration-tests-next/fixtures/esbuild/basic-release-disabled.test.ts
new file mode 100644
index 00000000..0668bd03
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/basic-release-disabled.test.ts
@@ -0,0 +1,31 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
+ runBundler();
+ expect(readOutputFiles()).toMatchInlineSnapshot(`
+ {
+ "basic-release-disabled.js": "(() => {
+ // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
+ !(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 (e2) {
+ }
+ })();
+
+ // src/basic.js
+ console.log("hello world");
+
+ // src/basic.js?sentryDebugIdProxy=true
+ var basic_default = void 0;
+ })();
+ ",
+ }
+ `);
+
+ const output = runFileInNode("basic-release-disabled.js");
+ expect(output).toBe("hello world\n");
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/basic-sourcemaps.config.js b/packages/integration-tests-next/fixtures/esbuild/basic-sourcemaps.config.js
new file mode 100644
index 00000000..1512be12
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/basic-sourcemaps.config.js
@@ -0,0 +1,13 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
+import { sentryConfig } from "../configs/basic-sourcemaps.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/basic.js"],
+ bundle: true,
+ outfile: "./out/basic-sourcemaps/basic-sourcemaps.js",
+ minify: false,
+ format: "iife",
+ sourcemap: true,
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/basic-sourcemaps.test.ts b/packages/integration-tests-next/fixtures/esbuild/basic-sourcemaps.test.ts
new file mode 100644
index 00000000..23695e5c
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/basic-sourcemaps.test.ts
@@ -0,0 +1,47 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
+ runBundler();
+ expect(readOutputFiles()).toMatchInlineSnapshot(`
+ {
+ "basic-sourcemaps.js": "(() => {
+ // _sentry-injection-stub
+ !(function() {
+ try {
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {};
+ e.SENTRY_RELEASE = { id: "CURRENT_SHA" };
+ } catch (e2) {
+ }
+ })();
+
+ // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
+ !(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 (e2) {
+ }
+ })();
+
+ // src/basic.js
+ console.log("hello world");
+
+ // src/basic.js?sentryDebugIdProxy=true
+ var basic_default = void 0;
+ })();
+ //# sourceMappingURL=basic-sourcemaps.js.map
+ ",
+ "basic-sourcemaps.js.map": "{"version":3,"sources":["../../_sentry-injection-stub","sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000","../../src/basic.js","../../src/basic.js"],"sourcesContent":["!function(){try{var e=\\"undefined\\"!=typeof window?window:\\"undefined\\"!=typeof global?global:\\"undefined\\"!=typeof globalThis?globalThis:\\"undefined\\"!=typeof self?self:{};e.SENTRY_RELEASE={id:\\"CURRENT_SHA\\"};}catch(e){}}();","!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){}}();","// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n","\\n import \\"_sentry-debug-id-injection-stub\\";\\n import * as OriginalModule from \\"./src/basic.js\\";\\n export default OriginalModule.default;\\n export * from \\"./src/basic.js\\";"],"mappings":";;AAAA,IAAC,WAAU;AAAC,QAAG;AAAC,UAAI,IAAE,eAAa,OAAO,SAAO,SAAO,eAAa,OAAO,SAAO,SAAO,eAAa,OAAO,aAAW,aAAW,eAAa,OAAO,OAAK,OAAK,CAAC;AAAE,QAAE,iBAAe,EAAC,IAAG,2CAA0C;AAAA,IAAE,SAAOA,IAAE;AAAA,IAAC;AAAA,EAAC,GAAE;;;ACAnP,IAAC,WAAU;AAAC,QAAG;AAAC,UAAI,IAAE,eAAa,OAAO,SAAO,SAAO,eAAa,OAAO,SAAO,SAAO,eAAa,OAAO,aAAW,aAAW,eAAa,OAAO,OAAK,OAAK,CAAC;AAAE,UAAI,IAAG,IAAI,EAAE,QAAO;AAAM,YAAI,EAAE,kBAAgB,EAAE,mBAAiB,CAAC,GAAE,EAAE,gBAAgB,CAAC,IAAE,wCAAuC,EAAE,2BAAyB;AAAA,IAAoD,SAAOC,IAAE;AAAA,IAAC;AAAA,EAAC,GAAE;;;ACCnY,UAAQ,IAAI,aAAa;;;ACEX,MAAO,gBAAuB;","names":["e","e"]}",
+ "sentry-cli-mock.json": "["releases","new","CURRENT_SHA"],
+ ["releases","set-commits","CURRENT_SHA","--auto","--ignore-missing"],
+ ["releases","finalize","CURRENT_SHA"],
+ ["sourcemaps","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path","--ignore","node_modules","--no-rewrite"],
+ ",
+ }
+ `);
+
+ const output = runFileInNode("basic-sourcemaps.js");
+ expect(output).toBe("hello world\n");
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/basic.config.js b/packages/integration-tests-next/fixtures/esbuild/basic.config.js
new file mode 100644
index 00000000..940d6ba0
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/basic.config.js
@@ -0,0 +1,12 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
+import { sentryConfig } from "../configs/basic.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/basic.js"],
+ bundle: true,
+ outfile: "./out/basic/basic.js",
+ minify: false,
+ format: "iife",
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/basic.test.ts b/packages/integration-tests-next/fixtures/esbuild/basic.test.ts
new file mode 100644
index 00000000..cc4449e1
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/basic.test.ts
@@ -0,0 +1,45 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
+ runBundler();
+ expect(readOutputFiles()).toMatchInlineSnapshot(`
+ {
+ "basic.js": "(() => {
+ // _sentry-injection-stub
+ !(function() {
+ try {
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {};
+ e.SENTRY_RELEASE = { id: "CURRENT_SHA" };
+ } catch (e2) {
+ }
+ })();
+
+ // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
+ !(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 (e2) {
+ }
+ })();
+
+ // src/basic.js
+ console.log("hello world");
+
+ // src/basic.js?sentryDebugIdProxy=true
+ var basic_default = void 0;
+ })();
+ ",
+ "sentry-cli-mock.json": "["releases","new","CURRENT_SHA"],
+ ["releases","set-commits","CURRENT_SHA","--auto","--ignore-missing"],
+ ["releases","finalize","CURRENT_SHA"],
+ ["sourcemaps","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path","--ignore","node_modules","--no-rewrite"],
+ ",
+ }
+ `);
+
+ const output = runFileInNode("basic.js");
+ expect(output).toBe("hello world\n");
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/build-info.config.js b/packages/integration-tests-next/fixtures/esbuild/build-info.config.js
new file mode 100644
index 00000000..9d09ebed
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/build-info.config.js
@@ -0,0 +1,12 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
+import { sentryConfig } from "../configs/build-info.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/basic.js"],
+ bundle: true,
+ outfile: "./out/build-info/build-info.js",
+ minify: false,
+ format: "iife",
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/build-info.test.ts b/packages/integration-tests-next/fixtures/esbuild/build-info.test.ts
new file mode 100644
index 00000000..9d8a3f3e
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/build-info.test.ts
@@ -0,0 +1,41 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
+ runBundler();
+ expect(readOutputFiles()).toMatchInlineSnapshot(`
+ {
+ "build-info.js": "(() => {
+ // _sentry-injection-stub
+ !(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": ["@sentry/esbuild-plugin", "esbuild"], "depsVersions": {}, "nodeVersion":"NODE_VERSION" };
+ } catch (e2) {
+ }
+ })();
+
+ // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
+ !(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 (e2) {
+ }
+ })();
+
+ // src/basic.js
+ console.log("hello world");
+
+ // src/basic.js?sentryDebugIdProxy=true
+ var basic_default = void 0;
+ })();
+ ",
+ }
+ `);
+
+ const output = runFileInNode("build-info.js");
+ expect(output).toBe("hello world\n");
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/bundle-size-optimizations.config.js b/packages/integration-tests-next/fixtures/esbuild/bundle-size-optimizations.config.js
new file mode 100644
index 00000000..6c7d9f77
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/bundle-size-optimizations.config.js
@@ -0,0 +1,12 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
+import { sentryConfig } from "../configs/bundle-size-optimizations.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/bundle.js"],
+ bundle: true,
+ outfile: "./out/bundle-size-optimizations/bundle-size-optimizations.js",
+ minify: false,
+ format: "iife",
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/bundle-size-optimizations.test.ts b/packages/integration-tests-next/fixtures/esbuild/bundle-size-optimizations.test.ts
new file mode 100644
index 00000000..2f472a5a
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/bundle-size-optimizations.test.ts
@@ -0,0 +1,51 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
+ runBundler();
+ expect(readOutputFiles()).toMatchInlineSnapshot(`
+ {
+ "bundle-size-optimizations.js": "(() => {
+ // _sentry-injection-stub
+ !(function() {
+ try {
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {};
+ e.SENTRY_RELEASE = { id: "CURRENT_SHA" };
+ } catch (e2) {
+ }
+ })();
+
+ // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
+ !(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 (e2) {
+ }
+ })();
+
+ // src/bundle.js
+ console.log(
+ JSON.stringify({
+ debug: false ? "a" : "b",
+ trace: false ? "a" : "b",
+ replayCanvas: true ? "a" : "b",
+ replayIframe: true ? "a" : "b",
+ replayShadowDom: true ? "a" : "b",
+ replayWorker: true ? "a" : "b"
+ })
+ );
+
+ // src/bundle.js?sentryDebugIdProxy=true
+ var bundle_default = void 0;
+ })();
+ ",
+ }
+ `);
+
+ const output = runFileInNode("bundle-size-optimizations.js");
+ expect(output).toBe(
+ '{"debug":"b","trace":"b","replayCanvas":"a","replayIframe":"a","replayShadowDom":"a","replayWorker":"a"}\n'
+ );
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/debugid-disabled.config.js b/packages/integration-tests-next/fixtures/esbuild/debugid-disabled.config.js
new file mode 100644
index 00000000..9eff90db
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/debugid-disabled.config.js
@@ -0,0 +1,12 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
+import { sentryConfig } from "../configs/debugid-disabled.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/basic.js"],
+ bundle: true,
+ outfile: "./out/debugid-disabled/debugid-disabled.js",
+ minify: false,
+ format: "iife",
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/debugid-disabled.test.ts b/packages/integration-tests-next/fixtures/esbuild/debugid-disabled.test.ts
new file mode 100644
index 00000000..46615320
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/debugid-disabled.test.ts
@@ -0,0 +1,19 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
+ runBundler();
+ expect(readOutputFiles()).toMatchInlineSnapshot(`
+ {
+ "debugid-disabled.js": ""use strict";
+ (() => {
+ // src/basic.js
+ console.log("hello world");
+ })();
+ ",
+ }
+ `);
+
+ const output = runFileInNode("debugid-disabled.js");
+ expect(output).toBe("hello world\n");
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/module-metadata.config.js b/packages/integration-tests-next/fixtures/esbuild/module-metadata.config.js
new file mode 100644
index 00000000..bbdfe9de
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/module-metadata.config.js
@@ -0,0 +1,12 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
+import { sentryConfig } from "../configs/module-metadata.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/basic.js"],
+ bundle: true,
+ outfile: "./out/module-metadata/module-metadata.js",
+ minify: false,
+ format: "iife",
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/module-metadata.test.ts b/packages/integration-tests-next/fixtures/esbuild/module-metadata.test.ts
new file mode 100644
index 00000000..a09d56d2
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/module-metadata.test.ts
@@ -0,0 +1,47 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
+ runBundler();
+ expect(readOutputFiles()).toMatchInlineSnapshot(`
+ {
+ "module-metadata.js": "(() => {
+ // _sentry-injection-stub
+ !(function() {
+ try {
+ 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(e2) {
+ for (var n = 1; n < arguments.length; n++) {
+ var a = arguments[n];
+ if (null != a) for (var t in a) a.hasOwnProperty(t) && (e2[t] = a[t]);
+ }
+ return e2;
+ })({}, e._sentryModuleMetadata[new e.Error().stack], { "something": "value", "another": 999 });
+ } catch (e2) {
+ }
+ })();
+
+ // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
+ !(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 (e2) {
+ }
+ })();
+
+ // src/basic.js
+ console.log("hello world");
+
+ // src/basic.js?sentryDebugIdProxy=true
+ var basic_default = void 0;
+ })();
+ ",
+ }
+ `);
+
+ const output = runFileInNode("module-metadata.js");
+ expect(output).toBe("hello world\n");
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/multiple-entry-points.config.js b/packages/integration-tests-next/fixtures/esbuild/multiple-entry-points.config.js
new file mode 100644
index 00000000..b80ead2c
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/multiple-entry-points.config.js
@@ -0,0 +1,14 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
+import { sentryConfig } from "../configs/multiple-entry-points.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/entry1.js", "./src/entry2.js"],
+ bundle: true,
+ outdir: "./out/multiple-entry-points",
+ minify: false,
+ format: "esm",
+ splitting: true,
+ chunkNames: "[name]",
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/multiple-entry-points.test.ts b/packages/integration-tests-next/fixtures/esbuild/multiple-entry-points.test.ts
new file mode 100644
index 00000000..6a73daad
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/multiple-entry-points.test.ts
@@ -0,0 +1,76 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
+ runBundler();
+ expect(readOutputFiles()).toMatchInlineSnapshot(`
+ {
+ "chunk.js": "// src/common.js
+ function add(a, b) {
+ return a + b;
+ }
+
+ export {
+ add
+ };
+ ",
+ "entry1.js": "import {
+ add
+ } from "./chunk.js";
+
+ // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
+ !(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 (e2) {
+ }
+ })();
+
+ // src/entry1.js
+ console.log(add(1, 2));
+
+ // src/entry1.js?sentryDebugIdProxy=true
+ var entry1_default = void 0;
+ export {
+ entry1_default as default
+ };
+ ",
+ "entry2.js": "import {
+ add
+ } from "./chunk.js";
+
+ // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
+ !(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 (e2) {
+ }
+ })();
+
+ // src/entry2.js
+ console.log(add(2, 4));
+
+ // src/entry2.js?sentryDebugIdProxy=true
+ var entry2_default = void 0;
+ export {
+ entry2_default as default
+ };
+ ",
+ }
+ `);
+
+ const output1 = runFileInNode("entry1.js");
+ expect(output1).toMatchInlineSnapshot(`
+ "3
+ "
+ `);
+ const output2 = runFileInNode("entry2.js");
+ expect(output2).toMatchInlineSnapshot(`
+ "6
+ "
+ `);
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/package.json b/packages/integration-tests-next/fixtures/esbuild/package.json
new file mode 100644
index 00000000..d10b6e83
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/package.json
@@ -0,0 +1,20 @@
+{
+ "name": "esbuild-integration-tests",
+ "version": "1.0.0",
+ "private": true,
+ "type": "module",
+ "dependencies": {
+ "esbuild": "0.28.0",
+ "@sentry/esbuild-plugin": "5.1.1"
+ },
+ "pnpm": {
+ "overrides": {
+ "@sentry/bundler-plugin-core": "file:../../../bundler-plugin-core/sentry-bundler-plugin-core-5.1.1.tgz",
+ "@sentry/esbuild-plugin": "file:../../../esbuild-plugin/sentry-esbuild-plugin-5.1.1.tgz",
+ "@sentry/babel-plugin-component-annotate": "file:../../../babel-plugin-component-annotate/sentry-babel-plugin-component-annotate-5.1.1.tgz"
+ },
+ "patchedDependencies": {
+ "@sentry/cli": "../patches/@sentry__cli.patch"
+ }
+ }
+}
diff --git a/packages/integration-tests-next/fixtures/esbuild/release-disabled.config.js b/packages/integration-tests-next/fixtures/esbuild/release-disabled.config.js
new file mode 100644
index 00000000..abc57e5f
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/release-disabled.config.js
@@ -0,0 +1,12 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
+import { sentryConfig } from "../configs/release-disabled.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/basic.js"],
+ bundle: true,
+ outfile: "./out/release-disabled/release-disabled.js",
+ minify: false,
+ format: "iife",
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/release-disabled.test.ts b/packages/integration-tests-next/fixtures/esbuild/release-disabled.test.ts
new file mode 100644
index 00000000..214529d8
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/release-disabled.test.ts
@@ -0,0 +1,44 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
+ runBundler();
+ expect(readOutputFiles()).toMatchInlineSnapshot(`
+ {
+ "release-disabled.js": "(() => {
+ // _sentry-injection-stub
+ !(function() {
+ try {
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {};
+ e.SENTRY_RELEASE = { id: "CURRENT_SHA" };
+ } catch (e2) {
+ }
+ })();
+
+ // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
+ !(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 (e2) {
+ }
+ })();
+
+ // src/basic.js
+ console.log("hello world");
+
+ // src/basic.js?sentryDebugIdProxy=true
+ var basic_default = void 0;
+ })();
+ ",
+ "sentry-cli-mock.json": "["releases","set-commits","CURRENT_SHA","--auto","--ignore-missing"],
+ ["releases","finalize","CURRENT_SHA"],
+ ["sourcemaps","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path","--ignore","node_modules","--no-rewrite"],
+ ",
+ }
+ `);
+
+ const output = runFileInNode("release-disabled.js");
+ expect(output).toBe("hello world\n");
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/src/app.jsx b/packages/integration-tests-next/fixtures/esbuild/src/app.jsx
new file mode 100644
index 00000000..614d38c8
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/src/app.jsx
@@ -0,0 +1,9 @@
+import { ComponentA } from "./component-a";
+
+export default function App() {
+ return (
+
+ ;
+
+ );
+}
diff --git a/packages/integration-tests-next/fixtures/esbuild/src/basic.js b/packages/integration-tests-next/fixtures/esbuild/src/basic.js
new file mode 100644
index 00000000..7ef02afb
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/src/basic.js
@@ -0,0 +1,2 @@
+// eslint-disable-next-line no-console
+console.log("hello world");
diff --git a/packages/integration-tests-next/fixtures/esbuild/src/bundle.js b/packages/integration-tests-next/fixtures/esbuild/src/bundle.js
new file mode 100644
index 00000000..0d62e559
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/src/bundle.js
@@ -0,0 +1,10 @@
+console.log(
+ JSON.stringify({
+ debug: __SENTRY_DEBUG__ ? "a" : "b",
+ trace: __SENTRY_TRACING__ ? "a" : "b",
+ replayCanvas: __RRWEB_EXCLUDE_CANVAS__ ? "a" : "b",
+ replayIframe: __RRWEB_EXCLUDE_IFRAME__ ? "a" : "b",
+ replayShadowDom: __RRWEB_EXCLUDE_SHADOW_DOM__ ? "a" : "b",
+ replayWorker: __SENTRY_EXCLUDE_REPLAY_WORKER__ ? "a" : "b",
+ })
+);
diff --git a/packages/integration-tests-next/fixtures/esbuild/src/common.js b/packages/integration-tests-next/fixtures/esbuild/src/common.js
new file mode 100644
index 00000000..7d658310
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/src/common.js
@@ -0,0 +1,3 @@
+export function add(a, b) {
+ return a + b;
+}
diff --git a/packages/integration-tests-next/fixtures/esbuild/src/component-a.jsx b/packages/integration-tests-next/fixtures/esbuild/src/component-a.jsx
new file mode 100644
index 00000000..5d57ab22
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/src/component-a.jsx
@@ -0,0 +1,3 @@
+export function ComponentA() {
+ return Component A;
+}
diff --git a/packages/integration-tests-next/fixtures/esbuild/src/entry1.js b/packages/integration-tests-next/fixtures/esbuild/src/entry1.js
new file mode 100644
index 00000000..48081666
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/src/entry1.js
@@ -0,0 +1,3 @@
+import { add } from "./common";
+
+console.log(add(1, 2));
diff --git a/packages/integration-tests-next/fixtures/esbuild/src/entry2.js b/packages/integration-tests-next/fixtures/esbuild/src/entry2.js
new file mode 100644
index 00000000..f64af1ea
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/src/entry2.js
@@ -0,0 +1,3 @@
+import { add } from "./common";
+
+console.log(add(2, 4));
diff --git a/packages/integration-tests-next/fixtures/esbuild/telemetry.config.js b/packages/integration-tests-next/fixtures/esbuild/telemetry.config.js
new file mode 100644
index 00000000..dd1a93fd
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/telemetry.config.js
@@ -0,0 +1,12 @@
+import * as esbuild from "esbuild";
+import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
+import { sentryConfig } from "../configs/telemetry.config.js";
+
+await esbuild.build({
+ entryPoints: ["./src/basic.js"],
+ bundle: true,
+ outfile: "./out/telemetry/telemetry.js",
+ minify: false,
+ format: "iife",
+ plugins: [sentryEsbuildPlugin(sentryConfig)],
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/telemetry.test.ts b/packages/integration-tests-next/fixtures/esbuild/telemetry.test.ts
new file mode 100644
index 00000000..464d0d47
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/telemetry.test.ts
@@ -0,0 +1,42 @@
+import { expect } from "vitest";
+import { test } from "./utils";
+
+test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
+ runBundler();
+ expect(readOutputFiles()).toMatchInlineSnapshot(`
+ {
+ "sentry-telemetry.json": "[{"sent_at":"TIMESTAMP","sdk":{"name":"sentry.javascript.node","version":"8.30.0"}},[[{"type":"session"},{"sid":"UUID","init":false,"started":"TIMESTAMP","timestamp":"TIMESTAMP","status":"exited","errors":0,"duration":DURATION,"attrs":{"release":"PLUGIN_VERSION","environment":"production"}}]]],
+ ",
+ "telemetry.js": "(() => {
+ // _sentry-injection-stub
+ !(function() {
+ try {
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {};
+ e.SENTRY_RELEASE = { id: "CURRENT_SHA" };
+ } catch (e2) {
+ }
+ })();
+
+ // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
+ !(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 (e2) {
+ }
+ })();
+
+ // src/basic.js
+ console.log("hello world");
+
+ // src/basic.js?sentryDebugIdProxy=true
+ var basic_default = void 0;
+ })();
+ ",
+ }
+ `);
+
+ const output = runFileInNode("telemetry.js");
+ expect(output).toBe("hello world\n");
+});
diff --git a/packages/integration-tests-next/fixtures/esbuild/utils.ts b/packages/integration-tests-next/fixtures/esbuild/utils.ts
new file mode 100644
index 00000000..39ebbe72
--- /dev/null
+++ b/packages/integration-tests-next/fixtures/esbuild/utils.ts
@@ -0,0 +1,64 @@
+import { basename, dirname, join } from "node:path";
+import { createTempDir, readAllFiles, runBundler } from "../utils";
+import { fileURLToPath } from "node:url";
+import { rmSync } from "node:fs";
+import { TestContext, test as vitestTest } from "vitest";
+import { execSync } from "node:child_process";
+
+const cwd = dirname(fileURLToPath(import.meta.url));
+
+type TestCallback = (props: {
+ outDir: string;
+ runBundler: (env?: Record) => void;
+ readOutputFiles: () => Record;
+ runFileInNode: (file: string) => string;
+ createTempDir: () => string;
+ ctx: TestContext;
+}) => void | Promise;
+
+function esbuildReplacer(content: string): string {
+ // esbuild ends up with different debug IDs and UUIDs on different platforms
+ // so we replace them with placeholders to make snapshots deterministic
+ return content.replace(
+ /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/g,
+ "00000000-0000-0000-0000-000000000000"
+ );
+}
+
+export function test(url: string, callback: TestCallback) {
+ const filePath = fileURLToPath(url);
+ const filename = basename(filePath);
+ const testName = filename.replace(/\.test\.ts$/, "");
+ const outDir = join(cwd, "out", testName);
+
+ // Clear the output directory before running the test
+ rmSync(outDir, { recursive: true, force: true });
+
+ vitestTest(`esbuild > ${testName}`, (ctx) =>
+ callback({
+ outDir,
+ runBundler: (env) =>
+ runBundler(
+ `node ${testName}.config.js`,
+ {
+ cwd,
+ env: {
+ ...process.env,
+ ...env,
+ },
+ },
+ outDir
+ ),
+ readOutputFiles: () => readAllFiles(outDir, esbuildReplacer),
+ runFileInNode: (file) => {
+ const fullPath = join(outDir, file);
+ return execSync(`node ${fullPath}`, {
+ cwd,
+ env: { ...process.env, NO_COLOR: "1", FORCE_COLOR: "0" },
+ }).toString();
+ },
+ createTempDir: () => createTempDir(),
+ ctx,
+ })
+ );
+}
diff --git a/packages/integration-tests-next/fixtures/utils.ts b/packages/integration-tests-next/fixtures/utils.ts
index 22fb76b5..e8087563 100644
--- a/packages/integration-tests-next/fixtures/utils.ts
+++ b/packages/integration-tests-next/fixtures/utils.ts
@@ -21,7 +21,10 @@ export function runBundler(command: string, opt: ExecSyncOptions, outDir?: strin
execSync(command, { stdio: DEBUG ? "inherit" : "ignore", ...opt });
}
-export function readAllFiles(directory: string): Record {
+export function readAllFiles(
+ directory: string,
+ customReplacer?: (content: string) => string
+): Record {
const files: Record = {};
const entries = readdirSync(directory);
@@ -39,6 +42,10 @@ export function readAllFiles(directory: string): Record {
.replaceAll(/nodeVersion:\d+/g, `nodeVersion:"NODE_VERSION"`)
.replaceAll(/nodeVersion: \d+/g, `nodeVersion:"NODE_VERSION"`);
+ if (customReplacer) {
+ contents = customReplacer(contents);
+ }
+
// Normalize Windows stuff in .map paths
if (entry.endsWith(".map")) {
const map = JSON.parse(contents) as SourceMap;
diff --git a/packages/integration-tests-next/package.json b/packages/integration-tests-next/package.json
index 6049cd05..3a60457a 100644
--- a/packages/integration-tests-next/package.json
+++ b/packages/integration-tests-next/package.json
@@ -4,7 +4,7 @@
"license": "MIT",
"private": true,
"scripts": {
- "test": "node setup.mjs && vitest run --pool threads",
+ "test": "node setup.mjs && vitest run --pool threads --test-timeout=10000",
"lint": "eslint .",
"check:types": "tsc --project ./tsconfig.json --noEmit",
"clean": "run-s clean:build",