From 0d2cde8f1fd89cdb6e5db6b13efddead79c262e4 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Sun, 5 Apr 2026 22:09:00 +0200 Subject: [PATCH 1/5] test: Add esbuild integration tests --- .../esbuild/after-upload-deletion.config.js | 12 +++ .../esbuild/after-upload-deletion.test.ts | 42 ++++++++++ .../esbuild/application-key.config.js | 12 +++ .../fixtures/esbuild/application-key.test.ts | 47 ++++++++++++ .../esbuild/basic-release-disabled.config.js | 12 +++ .../esbuild/basic-release-disabled.test.ts | 31 ++++++++ .../esbuild/basic-sourcemaps.config.js | 13 ++++ .../fixtures/esbuild/basic-sourcemaps.test.ts | 47 ++++++++++++ .../fixtures/esbuild/basic.config.js | 12 +++ .../fixtures/esbuild/basic.test.ts | 45 +++++++++++ .../fixtures/esbuild/build-info.config.js | 12 +++ .../fixtures/esbuild/build-info.test.ts | 41 ++++++++++ .../bundle-size-optimizations.config.js | 12 +++ .../esbuild/bundle-size-optimizations.test.ts | 51 +++++++++++++ .../esbuild/debugid-disabled.config.js | 12 +++ .../fixtures/esbuild/debugid-disabled.test.ts | 19 +++++ .../esbuild/module-metadata.config.js | 12 +++ .../fixtures/esbuild/module-metadata.test.ts | 47 ++++++++++++ .../esbuild/multiple-entry-points.config.js | 14 ++++ .../esbuild/multiple-entry-points.test.ts | 76 +++++++++++++++++++ .../fixtures/esbuild/package.json | 20 +++++ .../esbuild/release-disabled.config.js | 12 +++ .../fixtures/esbuild/release-disabled.test.ts | 44 +++++++++++ .../fixtures/esbuild/src/app.jsx | 9 +++ .../fixtures/esbuild/src/basic.js | 2 + .../fixtures/esbuild/src/bundle.js | 10 +++ .../fixtures/esbuild/src/common.js | 3 + .../fixtures/esbuild/src/component-a.jsx | 3 + .../fixtures/esbuild/src/entry1.js | 3 + .../fixtures/esbuild/src/entry2.js | 3 + .../fixtures/esbuild/telemetry.config.js | 12 +++ .../fixtures/esbuild/telemetry.test.ts | 42 ++++++++++ .../fixtures/esbuild/utils.ts | 55 ++++++++++++++ 33 files changed, 787 insertions(+) create mode 100644 packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/application-key.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/application-key.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/basic-release-disabled.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/basic-release-disabled.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/basic-sourcemaps.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/basic-sourcemaps.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/basic.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/basic.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/build-info.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/build-info.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/bundle-size-optimizations.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/bundle-size-optimizations.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/debugid-disabled.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/debugid-disabled.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/module-metadata.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/module-metadata.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/multiple-entry-points.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/multiple-entry-points.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/package.json create mode 100644 packages/integration-tests-next/fixtures/esbuild/release-disabled.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/release-disabled.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/src/app.jsx create mode 100644 packages/integration-tests-next/fixtures/esbuild/src/basic.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/src/bundle.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/src/common.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/src/component-a.jsx create mode 100644 packages/integration-tests-next/fixtures/esbuild/src/entry1.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/src/entry2.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/telemetry.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/telemetry.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/utils.ts 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..e019f278 --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.config.js @@ -0,0 +1,12 @@ +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/after-upload-deletion.js", + minify: false, + format: "iife", + 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..71a7255b --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.test.ts @@ -0,0 +1,42 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode, createTempDir }) => { + const tempUploadDir = createTempDir(); + + runBundler({ SENTRY_UPLOAD_DIR: tempUploadDir }); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "after-upload-deletion.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=0b47a7df-9bd6-49af-b000-120af50210e7 + !(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] = "22bc3889-65fe-4261-864b-14743cb882fc", e._sentryDebugIdIdentifier = "sentry-dbid-22bc3889-65fe-4261-864b-14743cb882fc"); + } catch (e2) { + } + })(); + + // src/basic.js + console.log("hello world"); + + // src/basic.js?sentryDebugIdProxy=true + var basic_default = void 0; + })(); + ", + } + `); + + const output = runFileInNode("after-upload-deletion.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..daa79b04 --- /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=36ab4956-8bc7-41fe-ae11-ff1b128e260c + !(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] = "64bc859a-c7c1-4c92-a0e8-426b986498f6", e._sentryDebugIdIdentifier = "sentry-dbid-64bc859a-c7c1-4c92-a0e8-426b986498f6"); + } 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..fd988850 --- /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=67d855c1-c1ce-4878-b7df-5e1d3a845acd + !(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] = "6127d709-823a-434f-a0b5-84ffddc24a46", e._sentryDebugIdIdentifier = "sentry-dbid-6127d709-823a-434f-a0b5-84ffddc24a46"); + } 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..95f5fa9f --- /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=a0ace079-bed9-42d5-843c-9a9e9069b050 + !(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] = "f0a38e67-9616-41ca-8594-2c05add42ced", e._sentryDebugIdIdentifier = "sentry-dbid-f0a38e67-9616-41ca-8594-2c05add42ced"); + } 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=a0ace079-bed9-42d5-843c-9a9e9069b050","../../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]=\\"f0a38e67-9616-41ca-8594-2c05add42ced\\",e._sentryDebugIdIdentifier=\\"sentry-dbid-f0a38e67-9616-41ca-8594-2c05add42ced\\");}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..91c5bd7d --- /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=c8279241-c5a1-4eac-a18d-a76dafa5eebb + !(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] = "18c35f84-a9e2-4ff3-8f86-03b6125dfff4", e._sentryDebugIdIdentifier = "sentry-dbid-18c35f84-a9e2-4ff3-8f86-03b6125dfff4"); + } 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..632b9e5c --- /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=b34f472c-7395-44f4-a7a5-a91fbc7269a7 + !(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] = "219a2a5a-1d62-46d9-a348-be5dfc114571", e._sentryDebugIdIdentifier = "sentry-dbid-219a2a5a-1d62-46d9-a348-be5dfc114571"); + } 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..bc02aee4 --- /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=f831ef62-0aba-4f21-9c68-1e7534d72124 + !(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] = "9d04d57b-c444-4e10-904f-9a1eca8c239a", e._sentryDebugIdIdentifier = "sentry-dbid-9d04d57b-c444-4e10-904f-9a1eca8c239a"); + } 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..62cee9e3 --- /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=d4b45b77-7d29-45fb-a273-8f00c7c3dbb5 + !(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] = "7bf670da-9136-4d98-a733-20a6065df996", e._sentryDebugIdIdentifier = "sentry-dbid-7bf670da-9136-4d98-a733-20a6065df996"); + } 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..8f79b2da --- /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=24dd1f0c-68a8-4235-8490-299463364fe5 + !(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] = "faec67e2-efc7-4a35-a05b-52f899f5a81c", e._sentryDebugIdIdentifier = "sentry-dbid-faec67e2-efc7-4a35-a05b-52f899f5a81c"); + } 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=2c350a5f-13d4-4a2a-a0fd-b478b231fe0c + !(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] = "3673342a-03c7-4fd3-9248-302bc3cc793f", e._sentryDebugIdIdentifier = "sentry-dbid-3673342a-03c7-4fd3-9248-302bc3cc793f"); + } 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..c605030c --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/package.json @@ -0,0 +1,20 @@ +{ + "name": "esbuild0-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..226af0ac --- /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=15236f17-432b-4e0e-a008-20caa766b76b + !(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] = "58f39824-6715-486e-9f39-3fbdb9e2bcff", e._sentryDebugIdIdentifier = "sentry-dbid-58f39824-6715-486e-9f39-3fbdb9e2bcff"); + } 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..be4c04fd --- /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=35772989-29a2-4a00-ab11-2dde789c23b5 + !(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] = "b2f058af-3fdd-4cca-8393-3a34c992a9f8", e._sentryDebugIdIdentifier = "sentry-dbid-b2f058af-3fdd-4cca-8393-3a34c992a9f8"); + } 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..51446063 --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/utils.ts @@ -0,0 +1,55 @@ +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; + +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), + 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, + }) + ); +} From efbb76019a3b90bf07bb09d9d9ec12a846977211 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Sun, 5 Apr 2026 23:27:09 +0200 Subject: [PATCH 2/5] Replace uuids with placeholders --- .../fixtures/esbuild/after-upload-deletion.test.ts | 4 ++-- .../fixtures/esbuild/application-key.test.ts | 4 ++-- .../fixtures/esbuild/basic-release-disabled.test.ts | 4 ++-- .../fixtures/esbuild/basic-sourcemaps.test.ts | 6 +++--- .../fixtures/esbuild/basic.test.ts | 4 ++-- .../fixtures/esbuild/build-info.test.ts | 4 ++-- .../esbuild/bundle-size-optimizations.test.ts | 4 ++-- .../fixtures/esbuild/module-metadata.test.ts | 4 ++-- .../fixtures/esbuild/multiple-entry-points.test.ts | 8 ++++---- .../fixtures/esbuild/release-disabled.test.ts | 4 ++-- .../fixtures/esbuild/telemetry.test.ts | 4 ++-- .../integration-tests-next/fixtures/esbuild/utils.ts | 11 ++++++++++- packages/integration-tests-next/fixtures/utils.ts | 9 ++++++++- 13 files changed, 43 insertions(+), 27 deletions(-) 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 index 71a7255b..37d47b14 100644 --- a/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.test.ts @@ -17,12 +17,12 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode, createTempD } })(); - // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=0b47a7df-9bd6-49af-b000-120af50210e7 + // 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] = "22bc3889-65fe-4261-864b-14743cb882fc", e._sentryDebugIdIdentifier = "sentry-dbid-22bc3889-65fe-4261-864b-14743cb882fc"); + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); } catch (e2) { } })(); diff --git a/packages/integration-tests-next/fixtures/esbuild/application-key.test.ts b/packages/integration-tests-next/fixtures/esbuild/application-key.test.ts index daa79b04..b9c0ae91 100644 --- a/packages/integration-tests-next/fixtures/esbuild/application-key.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/application-key.test.ts @@ -22,12 +22,12 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { } })(); - // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=36ab4956-8bc7-41fe-ae11-ff1b128e260c + // 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] = "64bc859a-c7c1-4c92-a0e8-426b986498f6", e._sentryDebugIdIdentifier = "sentry-dbid-64bc859a-c7c1-4c92-a0e8-426b986498f6"); + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); } catch (e2) { } })(); 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 index fd988850..0668bd03 100644 --- a/packages/integration-tests-next/fixtures/esbuild/basic-release-disabled.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/basic-release-disabled.test.ts @@ -6,12 +6,12 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { expect(readOutputFiles()).toMatchInlineSnapshot(` { "basic-release-disabled.js": "(() => { - // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=67d855c1-c1ce-4878-b7df-5e1d3a845acd + // 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] = "6127d709-823a-434f-a0b5-84ffddc24a46", e._sentryDebugIdIdentifier = "sentry-dbid-6127d709-823a-434f-a0b5-84ffddc24a46"); + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); } catch (e2) { } })(); diff --git a/packages/integration-tests-next/fixtures/esbuild/basic-sourcemaps.test.ts b/packages/integration-tests-next/fixtures/esbuild/basic-sourcemaps.test.ts index 95f5fa9f..23695e5c 100644 --- a/packages/integration-tests-next/fixtures/esbuild/basic-sourcemaps.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/basic-sourcemaps.test.ts @@ -15,12 +15,12 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { } })(); - // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=a0ace079-bed9-42d5-843c-9a9e9069b050 + // 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] = "f0a38e67-9616-41ca-8594-2c05add42ced", e._sentryDebugIdIdentifier = "sentry-dbid-f0a38e67-9616-41ca-8594-2c05add42ced"); + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); } catch (e2) { } })(); @@ -33,7 +33,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { })(); //# 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=a0ace079-bed9-42d5-843c-9a9e9069b050","../../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]=\\"f0a38e67-9616-41ca-8594-2c05add42ced\\",e._sentryDebugIdIdentifier=\\"sentry-dbid-f0a38e67-9616-41ca-8594-2c05add42ced\\");}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"]}", + "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"], diff --git a/packages/integration-tests-next/fixtures/esbuild/basic.test.ts b/packages/integration-tests-next/fixtures/esbuild/basic.test.ts index 91c5bd7d..cc4449e1 100644 --- a/packages/integration-tests-next/fixtures/esbuild/basic.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/basic.test.ts @@ -15,12 +15,12 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { } })(); - // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=c8279241-c5a1-4eac-a18d-a76dafa5eebb + // 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] = "18c35f84-a9e2-4ff3-8f86-03b6125dfff4", e._sentryDebugIdIdentifier = "sentry-dbid-18c35f84-a9e2-4ff3-8f86-03b6125dfff4"); + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); } catch (e2) { } })(); diff --git a/packages/integration-tests-next/fixtures/esbuild/build-info.test.ts b/packages/integration-tests-next/fixtures/esbuild/build-info.test.ts index 632b9e5c..9d8a3f3e 100644 --- a/packages/integration-tests-next/fixtures/esbuild/build-info.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/build-info.test.ts @@ -16,12 +16,12 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { } })(); - // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=b34f472c-7395-44f4-a7a5-a91fbc7269a7 + // 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] = "219a2a5a-1d62-46d9-a348-be5dfc114571", e._sentryDebugIdIdentifier = "sentry-dbid-219a2a5a-1d62-46d9-a348-be5dfc114571"); + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); } catch (e2) { } })(); 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 index bc02aee4..2f472a5a 100644 --- a/packages/integration-tests-next/fixtures/esbuild/bundle-size-optimizations.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/bundle-size-optimizations.test.ts @@ -15,12 +15,12 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { } })(); - // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=f831ef62-0aba-4f21-9c68-1e7534d72124 + // 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] = "9d04d57b-c444-4e10-904f-9a1eca8c239a", e._sentryDebugIdIdentifier = "sentry-dbid-9d04d57b-c444-4e10-904f-9a1eca8c239a"); + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); } catch (e2) { } })(); diff --git a/packages/integration-tests-next/fixtures/esbuild/module-metadata.test.ts b/packages/integration-tests-next/fixtures/esbuild/module-metadata.test.ts index 62cee9e3..a09d56d2 100644 --- a/packages/integration-tests-next/fixtures/esbuild/module-metadata.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/module-metadata.test.ts @@ -22,12 +22,12 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { } })(); - // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=d4b45b77-7d29-45fb-a273-8f00c7c3dbb5 + // 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] = "7bf670da-9136-4d98-a733-20a6065df996", e._sentryDebugIdIdentifier = "sentry-dbid-7bf670da-9136-4d98-a733-20a6065df996"); + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); } catch (e2) { } })(); 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 index 8f79b2da..6a73daad 100644 --- a/packages/integration-tests-next/fixtures/esbuild/multiple-entry-points.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/multiple-entry-points.test.ts @@ -18,12 +18,12 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { add } from "./chunk.js"; - // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=24dd1f0c-68a8-4235-8490-299463364fe5 + // 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] = "faec67e2-efc7-4a35-a05b-52f899f5a81c", e._sentryDebugIdIdentifier = "sentry-dbid-faec67e2-efc7-4a35-a05b-52f899f5a81c"); + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); } catch (e2) { } })(); @@ -41,12 +41,12 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { add } from "./chunk.js"; - // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=2c350a5f-13d4-4a2a-a0fd-b478b231fe0c + // 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] = "3673342a-03c7-4fd3-9248-302bc3cc793f", e._sentryDebugIdIdentifier = "sentry-dbid-3673342a-03c7-4fd3-9248-302bc3cc793f"); + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); } catch (e2) { } })(); diff --git a/packages/integration-tests-next/fixtures/esbuild/release-disabled.test.ts b/packages/integration-tests-next/fixtures/esbuild/release-disabled.test.ts index 226af0ac..214529d8 100644 --- a/packages/integration-tests-next/fixtures/esbuild/release-disabled.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/release-disabled.test.ts @@ -15,12 +15,12 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { } })(); - // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=15236f17-432b-4e0e-a008-20caa766b76b + // 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] = "58f39824-6715-486e-9f39-3fbdb9e2bcff", e._sentryDebugIdIdentifier = "sentry-dbid-58f39824-6715-486e-9f39-3fbdb9e2bcff"); + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); } catch (e2) { } })(); diff --git a/packages/integration-tests-next/fixtures/esbuild/telemetry.test.ts b/packages/integration-tests-next/fixtures/esbuild/telemetry.test.ts index be4c04fd..464d0d47 100644 --- a/packages/integration-tests-next/fixtures/esbuild/telemetry.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/telemetry.test.ts @@ -17,12 +17,12 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { } })(); - // sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=35772989-29a2-4a00-ab11-2dde789c23b5 + // 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] = "b2f058af-3fdd-4cca-8393-3a34c992a9f8", e._sentryDebugIdIdentifier = "sentry-dbid-b2f058af-3fdd-4cca-8393-3a34c992a9f8"); + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); } catch (e2) { } })(); diff --git a/packages/integration-tests-next/fixtures/esbuild/utils.ts b/packages/integration-tests-next/fixtures/esbuild/utils.ts index 51446063..39ebbe72 100644 --- a/packages/integration-tests-next/fixtures/esbuild/utils.ts +++ b/packages/integration-tests-next/fixtures/esbuild/utils.ts @@ -16,6 +16,15 @@ type TestCallback = (props: { 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); @@ -40,7 +49,7 @@ export function test(url: string, callback: TestCallback) { }, outDir ), - readOutputFiles: () => readAllFiles(outDir), + readOutputFiles: () => readAllFiles(outDir, esbuildReplacer), runFileInNode: (file) => { const fullPath = join(outDir, file); return execSync(`node ${fullPath}`, { 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; From dc58c4af64d959dd14866ca430e63cf8788d21ed Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Sun, 5 Apr 2026 23:49:44 +0200 Subject: [PATCH 3/5] Fix sourcemap delete test --- .../fixtures/esbuild/after-upload-deletion.config.js | 3 ++- .../fixtures/esbuild/after-upload-deletion.test.ts | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) 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 index e019f278..bb04c9d4 100644 --- a/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.config.js +++ b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.config.js @@ -5,8 +5,9 @@ import { sentryConfig } from "../configs/after-upload-deletion.config.js"; await esbuild.build({ entryPoints: ["./src/basic.js"], bundle: true, - outfile: "./out/after-upload-deletion/after-upload-deletion.js", + 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 index 37d47b14..3fd6de38 100644 --- a/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion.test.ts @@ -1,13 +1,11 @@ import { expect } from "vitest"; import { test } from "./utils"; -test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode, createTempDir }) => { - const tempUploadDir = createTempDir(); - - runBundler({ SENTRY_UPLOAD_DIR: tempUploadDir }); +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); expect(readOutputFiles()).toMatchInlineSnapshot(` { - "after-upload-deletion.js": "(() => { + "basic.js": "(() => { // _sentry-injection-stub !(function() { try { @@ -33,10 +31,11 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode, createTempD // src/basic.js?sentryDebugIdProxy=true var basic_default = void 0; })(); + //# sourceMappingURL=basic.js.map ", } `); - const output = runFileInNode("after-upload-deletion.js"); + const output = runFileInNode("basic.js"); expect(output).toBe("hello world\n"); }); From 0d052444786814547f01ab86a073dc67d16a7fad Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Sun, 5 Apr 2026 23:59:03 +0200 Subject: [PATCH 4/5] increase test timeout for Windows --- packages/integration-tests-next/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From a04f693940c312eba0db4995534736b554875418 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Mon, 6 Apr 2026 00:11:01 +0200 Subject: [PATCH 5/5] rename package --- packages/integration-tests-next/fixtures/esbuild/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integration-tests-next/fixtures/esbuild/package.json b/packages/integration-tests-next/fixtures/esbuild/package.json index c605030c..d10b6e83 100644 --- a/packages/integration-tests-next/fixtures/esbuild/package.json +++ b/packages/integration-tests-next/fixtures/esbuild/package.json @@ -1,5 +1,5 @@ { - "name": "esbuild0-integration-tests", + "name": "esbuild-integration-tests", "version": "1.0.0", "private": true, "type": "module",