From efe8d20afbee1dd5ef3714771625fdbc982210dc Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 14 Apr 2026 14:40:50 +0100 Subject: [PATCH 01/11] Add CJS tests --- .../fixtures/esbuild/basic-cjs.config.cjs | 12 +++++ .../fixtures/esbuild/basic-cjs.test.ts | 45 +++++++++++++++++++ .../fixtures/esbuild/utils.ts | 5 ++- .../fixtures/rolldown/basic-cjs.config.cjs | 11 +++++ .../fixtures/rolldown/basic-cjs.test.ts | 30 +++++++++++++ .../fixtures/rolldown/utils.ts | 5 ++- .../fixtures/rollup3/basic-cjs.config.cjs | 11 +++++ .../fixtures/rollup3/basic-cjs.test.ts | 21 +++++++++ .../fixtures/rollup3/utils.ts | 5 ++- .../fixtures/rollup4/basic-cjs.config.cjs | 11 +++++ .../fixtures/rollup4/basic-cjs.test.ts | 21 +++++++++ .../fixtures/rollup4/utils.ts | 5 ++- .../fixtures/vite4/basic-cjs.config.cjs | 17 +++++++ .../fixtures/vite4/basic-cjs.test.ts | 29 ++++++++++++ .../fixtures/vite4/utils.ts | 5 ++- .../fixtures/vite7/basic-cjs.config.cjs | 17 +++++++ .../fixtures/vite7/basic-cjs.test.ts | 29 ++++++++++++ .../fixtures/vite7/utils.ts | 5 ++- .../fixtures/vite8/basic-cjs.config.cjs | 17 +++++++ .../fixtures/vite8/basic-cjs.test.ts | 29 ++++++++++++ .../fixtures/vite8/utils.ts | 5 ++- .../fixtures/webpack5/basic-cjs.config.cjs | 17 +++++++ .../fixtures/webpack5/basic-cjs.test.ts | 26 +++++++++++ .../fixtures/webpack5/utils.ts | 5 ++- 24 files changed, 375 insertions(+), 8 deletions(-) create mode 100644 packages/integration-tests-next/fixtures/esbuild/basic-cjs.config.cjs create mode 100644 packages/integration-tests-next/fixtures/esbuild/basic-cjs.test.ts create mode 100644 packages/integration-tests-next/fixtures/rolldown/basic-cjs.config.cjs create mode 100644 packages/integration-tests-next/fixtures/rolldown/basic-cjs.test.ts create mode 100644 packages/integration-tests-next/fixtures/rollup3/basic-cjs.config.cjs create mode 100644 packages/integration-tests-next/fixtures/rollup3/basic-cjs.test.ts create mode 100644 packages/integration-tests-next/fixtures/rollup4/basic-cjs.config.cjs create mode 100644 packages/integration-tests-next/fixtures/rollup4/basic-cjs.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite4/basic-cjs.config.cjs create mode 100644 packages/integration-tests-next/fixtures/vite4/basic-cjs.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite7/basic-cjs.config.cjs create mode 100644 packages/integration-tests-next/fixtures/vite7/basic-cjs.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite8/basic-cjs.config.cjs create mode 100644 packages/integration-tests-next/fixtures/vite8/basic-cjs.test.ts create mode 100644 packages/integration-tests-next/fixtures/webpack5/basic-cjs.config.cjs create mode 100644 packages/integration-tests-next/fixtures/webpack5/basic-cjs.test.ts diff --git a/packages/integration-tests-next/fixtures/esbuild/basic-cjs.config.cjs b/packages/integration-tests-next/fixtures/esbuild/basic-cjs.config.cjs new file mode 100644 index 00000000..5187390a --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/basic-cjs.config.cjs @@ -0,0 +1,12 @@ +const esbuild = require("esbuild"); +const { sentryEsbuildPlugin } = require("@sentry/esbuild-plugin"); +const { sentryConfig } = require("../configs/basic.config.js"); + +esbuild.build({ + entryPoints: ["./src/basic.js"], + bundle: true, + outfile: "./out/basic-cjs/basic.js", + minify: false, + format: "iife", + plugins: [sentryEsbuildPlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/esbuild/basic-cjs.test.ts b/packages/integration-tests-next/fixtures/esbuild/basic-cjs.test.ts new file mode 100644 index 00000000..cc4449e1 --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/basic-cjs.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/utils.ts b/packages/integration-tests-next/fixtures/esbuild/utils.ts index 39ebbe72..73479a8a 100644 --- a/packages/integration-tests-next/fixtures/esbuild/utils.ts +++ b/packages/integration-tests-next/fixtures/esbuild/utils.ts @@ -34,12 +34,15 @@ export function test(url: string, callback: TestCallback) { // Clear the output directory before running the test rmSync(outDir, { recursive: true, force: true }); + // Detect CJS config files by test name suffix + const configExt = testName.endsWith("-cjs") ? ".config.cjs" : ".config.js"; + vitestTest(`esbuild > ${testName}`, (ctx) => callback({ outDir, runBundler: (env) => runBundler( - `node ${testName}.config.js`, + `node ${testName}${configExt}`, { cwd, env: { diff --git a/packages/integration-tests-next/fixtures/rolldown/basic-cjs.config.cjs b/packages/integration-tests-next/fixtures/rolldown/basic-cjs.config.cjs new file mode 100644 index 00000000..18bef785 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rolldown/basic-cjs.config.cjs @@ -0,0 +1,11 @@ +const { sentryRollupPlugin } = require("@sentry/rollup-plugin"); +const { defineConfig } = require("rolldown"); +const { sentryConfig } = require("../configs/basic.config.js"); + +module.exports = defineConfig({ + input: "src/basic.js", + output: { + file: "out/basic-cjs/basic.js", + }, + plugins: [sentryRollupPlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/rolldown/basic-cjs.test.ts b/packages/integration-tests-next/fixtures/rolldown/basic-cjs.test.ts new file mode 100644 index 00000000..ef26f379 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rolldown/basic-cjs.test.ts @@ -0,0 +1,30 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "basic.js": "//#region src/basic.js + (function() { + try { + var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}; + e.SENTRY_RELEASE = { id: "CURRENT_SHA" }; + var n = new e.Error().stack; + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); + } catch (e) {} + })(); + console.log("hello world"); + //#endregion + ", + "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/rolldown/utils.ts b/packages/integration-tests-next/fixtures/rolldown/utils.ts index d858292e..6de2f9e6 100644 --- a/packages/integration-tests-next/fixtures/rolldown/utils.ts +++ b/packages/integration-tests-next/fixtures/rolldown/utils.ts @@ -26,6 +26,9 @@ export function test(url: string, callback: TestCallback) { // Clear the output directory before running the test rmSync(outDir, { recursive: true, force: true }); + // Detect CJS config files by test name suffix + const configExt = testName.endsWith("-cjs") ? ".config.cjs" : ".config.ts"; + // Rolldown requires Node 20+ if (NODE_MAJOR_VERSION < 20) { // eslint-disable-next-line @typescript-eslint/no-empty-function @@ -36,7 +39,7 @@ export function test(url: string, callback: TestCallback) { outDir, runBundler: (env) => runBundler( - `rolldown --config ${testName}.config.ts`, + `rolldown --config ${testName}${configExt}`, { cwd, env: { diff --git a/packages/integration-tests-next/fixtures/rollup3/basic-cjs.config.cjs b/packages/integration-tests-next/fixtures/rollup3/basic-cjs.config.cjs new file mode 100644 index 00000000..275ef5bb --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup3/basic-cjs.config.cjs @@ -0,0 +1,11 @@ +const { sentryRollupPlugin } = require("@sentry/rollup-plugin"); +const { defineConfig } = require("rollup"); +const { sentryConfig } = require("../configs/basic.config.js"); + +module.exports = defineConfig({ + input: "src/basic.js", + output: { + file: "out/basic-cjs/basic.js", + }, + plugins: [sentryRollupPlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/rollup3/basic-cjs.test.ts b/packages/integration-tests-next/fixtures/rollup3/basic-cjs.test.ts new file mode 100644 index 00000000..1d68d310 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup3/basic-cjs.test.ts @@ -0,0 +1,21 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "basic.js": "// eslint-disable-next-line no-console + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + ", + "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/rollup3/utils.ts b/packages/integration-tests-next/fixtures/rollup3/utils.ts index 6da0009d..0893f70e 100644 --- a/packages/integration-tests-next/fixtures/rollup3/utils.ts +++ b/packages/integration-tests-next/fixtures/rollup3/utils.ts @@ -25,12 +25,15 @@ export function test(url: string, callback: TestCallback) { // Clear the output directory before running the test rmSync(outDir, { recursive: true, force: true }); + // Detect CJS config files by test name suffix + const configExt = testName.endsWith("-cjs") ? ".config.cjs" : ".config.js"; + vitestTest(`rollup v3 > ${testName}`, (ctx) => callback({ outDir, runBundler: (env) => runBundler( - `rollup --config ${testName}.config.js`, + `rollup --config ${testName}${configExt}`, { cwd, env: { diff --git a/packages/integration-tests-next/fixtures/rollup4/basic-cjs.config.cjs b/packages/integration-tests-next/fixtures/rollup4/basic-cjs.config.cjs new file mode 100644 index 00000000..275ef5bb --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup4/basic-cjs.config.cjs @@ -0,0 +1,11 @@ +const { sentryRollupPlugin } = require("@sentry/rollup-plugin"); +const { defineConfig } = require("rollup"); +const { sentryConfig } = require("../configs/basic.config.js"); + +module.exports = defineConfig({ + input: "src/basic.js", + output: { + file: "out/basic-cjs/basic.js", + }, + plugins: [sentryRollupPlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/rollup4/basic-cjs.test.ts b/packages/integration-tests-next/fixtures/rollup4/basic-cjs.test.ts new file mode 100644 index 00000000..1d68d310 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup4/basic-cjs.test.ts @@ -0,0 +1,21 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "basic.js": "// eslint-disable-next-line no-console + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("hello world"); + ", + "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/rollup4/utils.ts b/packages/integration-tests-next/fixtures/rollup4/utils.ts index 2ad6dd0d..101a278f 100644 --- a/packages/integration-tests-next/fixtures/rollup4/utils.ts +++ b/packages/integration-tests-next/fixtures/rollup4/utils.ts @@ -25,12 +25,15 @@ export function test(url: string, callback: TestCallback) { // Clear the output directory before running the test rmSync(outDir, { recursive: true, force: true }); + // Detect CJS config files by test name suffix + const configExt = testName.endsWith("-cjs") ? ".config.cjs" : ".config.js"; + vitestTest(`rollup v4 > ${testName}`, (ctx) => callback({ outDir, runBundler: (env) => runBundler( - `rollup --config ${testName}.config.js`, + `rollup --config ${testName}${configExt}`, { cwd, env: { diff --git a/packages/integration-tests-next/fixtures/vite4/basic-cjs.config.cjs b/packages/integration-tests-next/fixtures/vite4/basic-cjs.config.cjs new file mode 100644 index 00000000..c3b54af7 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/basic-cjs.config.cjs @@ -0,0 +1,17 @@ +const { sentryVitePlugin } = require("@sentry/vite-plugin"); +const { defineConfig } = require("vite"); +const { sentryConfig } = require("../configs/basic.config.js"); + +module.exports = defineConfig({ + build: { + minify: false, + rollupOptions: { + input: "src/basic.js", + output: { + dir: "out/basic-cjs", + entryFileNames: "[name].js", + }, + }, + }, + plugins: [sentryVitePlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/vite4/basic-cjs.test.ts b/packages/integration-tests-next/fixtures/vite4/basic-cjs.test.ts new file mode 100644 index 00000000..4b334c16 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/basic-cjs.test.ts @@ -0,0 +1,29 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "basic.js": "!(function() { + try { + var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}; + e.SENTRY_RELEASE = { id: "CURRENT_SHA" }; + var n = new e.Error().stack; + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); + } catch (e2) { + } + })(); + console.log("hello world"); + ", + "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/vite4/utils.ts b/packages/integration-tests-next/fixtures/vite4/utils.ts index 89f7a2a6..fd0b4467 100644 --- a/packages/integration-tests-next/fixtures/vite4/utils.ts +++ b/packages/integration-tests-next/fixtures/vite4/utils.ts @@ -25,12 +25,15 @@ export function test(url: string, callback: TestCallback) { // Clear the output directory before running the test rmSync(outDir, { recursive: true, force: true }); + // Detect CJS config files by test name suffix + const configExt = testName.endsWith("-cjs") ? ".config.cjs" : ".config.ts"; + vitestTest(`Vite v4 > ${testName}`, (ctx) => callback({ outDir, runBundler: (env) => runBundler( - `vite build --config ${testName}.config.ts`, + `vite build --config ${testName}${configExt}`, { cwd, env: { diff --git a/packages/integration-tests-next/fixtures/vite7/basic-cjs.config.cjs b/packages/integration-tests-next/fixtures/vite7/basic-cjs.config.cjs new file mode 100644 index 00000000..c3b54af7 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/basic-cjs.config.cjs @@ -0,0 +1,17 @@ +const { sentryVitePlugin } = require("@sentry/vite-plugin"); +const { defineConfig } = require("vite"); +const { sentryConfig } = require("../configs/basic.config.js"); + +module.exports = defineConfig({ + build: { + minify: false, + rollupOptions: { + input: "src/basic.js", + output: { + dir: "out/basic-cjs", + entryFileNames: "[name].js", + }, + }, + }, + plugins: [sentryVitePlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/vite7/basic-cjs.test.ts b/packages/integration-tests-next/fixtures/vite7/basic-cjs.test.ts new file mode 100644 index 00000000..4b334c16 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/basic-cjs.test.ts @@ -0,0 +1,29 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "basic.js": "!(function() { + try { + var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}; + e.SENTRY_RELEASE = { id: "CURRENT_SHA" }; + var n = new e.Error().stack; + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); + } catch (e2) { + } + })(); + console.log("hello world"); + ", + "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/vite7/utils.ts b/packages/integration-tests-next/fixtures/vite7/utils.ts index 0990f400..6a06244f 100644 --- a/packages/integration-tests-next/fixtures/vite7/utils.ts +++ b/packages/integration-tests-next/fixtures/vite7/utils.ts @@ -26,6 +26,9 @@ export function test(url: string, callback: TestCallback) { // Clear the output directory before running the test rmSync(outDir, { recursive: true, force: true }); + // Detect CJS config files by test name suffix + const configExt = testName.endsWith("-cjs") ? ".config.cjs" : ".config.ts"; + // Vite v7 requires Node 20+ if (NODE_MAJOR_VERSION < 20) { // eslint-disable-next-line @typescript-eslint/no-empty-function @@ -36,7 +39,7 @@ export function test(url: string, callback: TestCallback) { outDir, runBundler: (env) => runBundler( - `vite build --config ${testName}.config.ts`, + `vite build --config ${testName}${configExt}`, { cwd, env: { diff --git a/packages/integration-tests-next/fixtures/vite8/basic-cjs.config.cjs b/packages/integration-tests-next/fixtures/vite8/basic-cjs.config.cjs new file mode 100644 index 00000000..c3b54af7 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/basic-cjs.config.cjs @@ -0,0 +1,17 @@ +const { sentryVitePlugin } = require("@sentry/vite-plugin"); +const { defineConfig } = require("vite"); +const { sentryConfig } = require("../configs/basic.config.js"); + +module.exports = defineConfig({ + build: { + minify: false, + rollupOptions: { + input: "src/basic.js", + output: { + dir: "out/basic-cjs", + entryFileNames: "[name].js", + }, + }, + }, + plugins: [sentryVitePlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/vite8/basic-cjs.test.ts b/packages/integration-tests-next/fixtures/vite8/basic-cjs.test.ts new file mode 100644 index 00000000..4b334c16 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/basic-cjs.test.ts @@ -0,0 +1,29 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "basic.js": "!(function() { + try { + var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}; + e.SENTRY_RELEASE = { id: "CURRENT_SHA" }; + var n = new e.Error().stack; + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); + } catch (e2) { + } + })(); + console.log("hello world"); + ", + "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/vite8/utils.ts b/packages/integration-tests-next/fixtures/vite8/utils.ts index 911fc7cc..271579bb 100644 --- a/packages/integration-tests-next/fixtures/vite8/utils.ts +++ b/packages/integration-tests-next/fixtures/vite8/utils.ts @@ -26,6 +26,9 @@ export function test(url: string, callback: TestCallback) { // Clear the output directory before running the test rmSync(outDir, { recursive: true, force: true }); + // Detect CJS config files by test name suffix + const configExt = testName.endsWith("-cjs") ? ".config.cjs" : ".config.ts"; + // Vite v8 requires Node 20+ if (NODE_MAJOR_VERSION < 20) { // eslint-disable-next-line @typescript-eslint/no-empty-function @@ -36,7 +39,7 @@ export function test(url: string, callback: TestCallback) { outDir, runBundler: (env) => runBundler( - `vite build --config ${testName}.config.ts`, + `vite build --config ${testName}${configExt}`, { cwd, env: { diff --git a/packages/integration-tests-next/fixtures/webpack5/basic-cjs.config.cjs b/packages/integration-tests-next/fixtures/webpack5/basic-cjs.config.cjs new file mode 100644 index 00000000..578ca4e1 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/basic-cjs.config.cjs @@ -0,0 +1,17 @@ +const { sentryWebpackPlugin } = require("@sentry/webpack-plugin"); +const { sentryConfig } = require("../configs/basic.config.js"); +const { resolve } = require("node:path"); + +module.exports = { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve("./out/basic-cjs"), + filename: "basic.js", + }, + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/basic-cjs.test.ts b/packages/integration-tests-next/fixtures/webpack5/basic-cjs.test.ts new file mode 100644 index 00000000..baa396d2 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/basic-cjs.test.ts @@ -0,0 +1,26 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + // eslint-disable-next-line no-console + console.log("hello world"); + + /******/ })() + ;", + "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/webpack5/utils.ts b/packages/integration-tests-next/fixtures/webpack5/utils.ts index 010edbb0..00a7b04b 100644 --- a/packages/integration-tests-next/fixtures/webpack5/utils.ts +++ b/packages/integration-tests-next/fixtures/webpack5/utils.ts @@ -25,12 +25,15 @@ export function test(url: string, callback: TestCallback) { // Clear the output directory before running the test rmSync(outDir, { recursive: true, force: true }); + // Detect CJS config files by test name suffix + const configExt = testName.endsWith("-cjs") ? ".config.cjs" : ".config.js"; + vitestTest(`webpack v5 > ${testName}`, (ctx) => callback({ outDir, runBundler: (env) => runBundler( - `pnpm webpack --config ${testName}.config.js`, + `pnpm webpack --config ${testName}${configExt}`, { cwd, env: { From b314161c7cf51877e7114815546f1b9fd595acc6 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 14 Apr 2026 14:49:02 +0100 Subject: [PATCH 02/11] Add `after-upload-deletion-promise` tests --- .../after-upload-deletion-promise.config.js | 16 +++++++++++++++ .../after-upload-deletion-promise.config.js | 15 ++++++++++++++ .../after-upload-deletion-promise.test.ts | 16 +++++++++++++++ .../after-upload-deletion-promise.config.ts | 14 +++++++++++++ .../after-upload-deletion-promise.test.ts | 16 +++++++++++++++ .../after-upload-deletion-promise.config.js | 14 +++++++++++++ .../after-upload-deletion-promise.test.ts | 16 +++++++++++++++ .../after-upload-deletion-promise.config.js | 14 +++++++++++++ .../after-upload-deletion-promise.test.ts | 16 +++++++++++++++ .../after-upload-deletion-promise.config.ts | 20 +++++++++++++++++++ .../after-upload-deletion-promise.test.ts | 16 +++++++++++++++ .../after-upload-deletion-promise.config.ts | 20 +++++++++++++++++++ .../after-upload-deletion-promise.test.ts | 16 +++++++++++++++ .../after-upload-deletion-promise.config.ts | 20 +++++++++++++++++++ .../after-upload-deletion-promise.test.ts | 16 +++++++++++++++ .../after-upload-deletion-promise.config.js | 20 +++++++++++++++++++ .../after-upload-deletion-promise.test.ts | 16 +++++++++++++++ 17 files changed, 281 insertions(+) create mode 100644 packages/integration-tests-next/fixtures/configs/after-upload-deletion-promise.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/after-upload-deletion-promise.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/after-upload-deletion-promise.test.ts create mode 100644 packages/integration-tests-next/fixtures/rolldown/after-upload-deletion-promise.config.ts create mode 100644 packages/integration-tests-next/fixtures/rolldown/after-upload-deletion-promise.test.ts create mode 100644 packages/integration-tests-next/fixtures/rollup3/after-upload-deletion-promise.config.js create mode 100644 packages/integration-tests-next/fixtures/rollup3/after-upload-deletion-promise.test.ts create mode 100644 packages/integration-tests-next/fixtures/rollup4/after-upload-deletion-promise.config.js create mode 100644 packages/integration-tests-next/fixtures/rollup4/after-upload-deletion-promise.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite4/after-upload-deletion-promise.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite4/after-upload-deletion-promise.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite7/after-upload-deletion-promise.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite7/after-upload-deletion-promise.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite8/after-upload-deletion-promise.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite8/after-upload-deletion-promise.test.ts create mode 100644 packages/integration-tests-next/fixtures/webpack5/after-upload-deletion-promise.config.js create mode 100644 packages/integration-tests-next/fixtures/webpack5/after-upload-deletion-promise.test.ts diff --git a/packages/integration-tests-next/fixtures/configs/after-upload-deletion-promise.config.js b/packages/integration-tests-next/fixtures/configs/after-upload-deletion-promise.config.js new file mode 100644 index 00000000..bda89247 --- /dev/null +++ b/packages/integration-tests-next/fixtures/configs/after-upload-deletion-promise.config.js @@ -0,0 +1,16 @@ +// Config that uses a Promise for filesToDeleteAfterUpload +// This tests that the plugin can handle async file deletion patterns +export function getSentryConfig(outDir) { + const fileDeletionPromise = new Promise((resolve) => { + setTimeout(() => { + resolve([`${outDir}/basic.js.map`]); + }, 100); + }); + + return { + telemetry: false, + sourcemaps: { + filesToDeleteAfterUpload: fileDeletionPromise, + }, + }; +} diff --git a/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion-promise.config.js b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion-promise.config.js new file mode 100644 index 00000000..f67f4059 --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion-promise.config.js @@ -0,0 +1,15 @@ +import * as esbuild from "esbuild"; +import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin"; +import { getSentryConfig } from "../configs/after-upload-deletion-promise.config.js"; + +const outDir = "./out/after-upload-deletion-promise"; + +await esbuild.build({ + entryPoints: ["./src/basic.js"], + bundle: true, + outfile: `${outDir}/basic.js`, + minify: false, + format: "iife", + sourcemap: true, + plugins: [sentryEsbuildPlugin(getSentryConfig(outDir))], +}); diff --git a/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion-promise.test.ts new file mode 100644 index 00000000..79fe6671 --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion-promise.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { existsSync } from "node:fs"; +import { join } from "node:path"; + +test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { + runBundler(); + + // Verify the JS file exists and works + const output = runFileInNode("basic.js"); + expect(output).toBe("hello world\n"); + + // Verify the sourcemap was deleted (by the Promise) + const sourcemapPath = join(outDir, "basic.js.map"); + expect(existsSync(sourcemapPath)).toBe(false); +}); diff --git a/packages/integration-tests-next/fixtures/rolldown/after-upload-deletion-promise.config.ts b/packages/integration-tests-next/fixtures/rolldown/after-upload-deletion-promise.config.ts new file mode 100644 index 00000000..af3e2e27 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rolldown/after-upload-deletion-promise.config.ts @@ -0,0 +1,14 @@ +import { sentryRollupPlugin } from "@sentry/rollup-plugin"; +import { defineConfig } from "rolldown"; +import { getSentryConfig } from "../configs/after-upload-deletion-promise.config.js"; + +const outDir = "out/after-upload-deletion-promise"; + +export default defineConfig({ + input: "src/basic.js", + output: { + file: `${outDir}/basic.js`, + sourcemap: true, + }, + plugins: [sentryRollupPlugin(getSentryConfig(outDir))], +}); diff --git a/packages/integration-tests-next/fixtures/rolldown/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/rolldown/after-upload-deletion-promise.test.ts new file mode 100644 index 00000000..79fe6671 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rolldown/after-upload-deletion-promise.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { existsSync } from "node:fs"; +import { join } from "node:path"; + +test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { + runBundler(); + + // Verify the JS file exists and works + const output = runFileInNode("basic.js"); + expect(output).toBe("hello world\n"); + + // Verify the sourcemap was deleted (by the Promise) + const sourcemapPath = join(outDir, "basic.js.map"); + expect(existsSync(sourcemapPath)).toBe(false); +}); diff --git a/packages/integration-tests-next/fixtures/rollup3/after-upload-deletion-promise.config.js b/packages/integration-tests-next/fixtures/rollup3/after-upload-deletion-promise.config.js new file mode 100644 index 00000000..ce77934a --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup3/after-upload-deletion-promise.config.js @@ -0,0 +1,14 @@ +import { sentryRollupPlugin } from "@sentry/rollup-plugin"; +import { defineConfig } from "rollup"; +import { getSentryConfig } from "../configs/after-upload-deletion-promise.config.js"; + +const outDir = "out/after-upload-deletion-promise"; + +export default defineConfig({ + input: "src/basic.js", + output: { + file: `${outDir}/basic.js`, + sourcemap: true, + }, + plugins: [sentryRollupPlugin(getSentryConfig(outDir))], +}); diff --git a/packages/integration-tests-next/fixtures/rollup3/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/rollup3/after-upload-deletion-promise.test.ts new file mode 100644 index 00000000..79fe6671 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup3/after-upload-deletion-promise.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { existsSync } from "node:fs"; +import { join } from "node:path"; + +test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { + runBundler(); + + // Verify the JS file exists and works + const output = runFileInNode("basic.js"); + expect(output).toBe("hello world\n"); + + // Verify the sourcemap was deleted (by the Promise) + const sourcemapPath = join(outDir, "basic.js.map"); + expect(existsSync(sourcemapPath)).toBe(false); +}); diff --git a/packages/integration-tests-next/fixtures/rollup4/after-upload-deletion-promise.config.js b/packages/integration-tests-next/fixtures/rollup4/after-upload-deletion-promise.config.js new file mode 100644 index 00000000..ce77934a --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup4/after-upload-deletion-promise.config.js @@ -0,0 +1,14 @@ +import { sentryRollupPlugin } from "@sentry/rollup-plugin"; +import { defineConfig } from "rollup"; +import { getSentryConfig } from "../configs/after-upload-deletion-promise.config.js"; + +const outDir = "out/after-upload-deletion-promise"; + +export default defineConfig({ + input: "src/basic.js", + output: { + file: `${outDir}/basic.js`, + sourcemap: true, + }, + plugins: [sentryRollupPlugin(getSentryConfig(outDir))], +}); diff --git a/packages/integration-tests-next/fixtures/rollup4/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/rollup4/after-upload-deletion-promise.test.ts new file mode 100644 index 00000000..79fe6671 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup4/after-upload-deletion-promise.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { existsSync } from "node:fs"; +import { join } from "node:path"; + +test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { + runBundler(); + + // Verify the JS file exists and works + const output = runFileInNode("basic.js"); + expect(output).toBe("hello world\n"); + + // Verify the sourcemap was deleted (by the Promise) + const sourcemapPath = join(outDir, "basic.js.map"); + expect(existsSync(sourcemapPath)).toBe(false); +}); diff --git a/packages/integration-tests-next/fixtures/vite4/after-upload-deletion-promise.config.ts b/packages/integration-tests-next/fixtures/vite4/after-upload-deletion-promise.config.ts new file mode 100644 index 00000000..92b51077 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/after-upload-deletion-promise.config.ts @@ -0,0 +1,20 @@ +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { defineConfig } from "vite"; +import { getSentryConfig } from "../configs/after-upload-deletion-promise.config.js"; + +const outDir = "out/after-upload-deletion-promise"; + +export default defineConfig({ + build: { + minify: false, + sourcemap: true, + rollupOptions: { + input: "src/basic.js", + output: { + dir: outDir, + entryFileNames: "[name].js", + }, + }, + }, + plugins: [sentryVitePlugin(getSentryConfig(outDir))], +}); diff --git a/packages/integration-tests-next/fixtures/vite4/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/vite4/after-upload-deletion-promise.test.ts new file mode 100644 index 00000000..79fe6671 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/after-upload-deletion-promise.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { existsSync } from "node:fs"; +import { join } from "node:path"; + +test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { + runBundler(); + + // Verify the JS file exists and works + const output = runFileInNode("basic.js"); + expect(output).toBe("hello world\n"); + + // Verify the sourcemap was deleted (by the Promise) + const sourcemapPath = join(outDir, "basic.js.map"); + expect(existsSync(sourcemapPath)).toBe(false); +}); diff --git a/packages/integration-tests-next/fixtures/vite7/after-upload-deletion-promise.config.ts b/packages/integration-tests-next/fixtures/vite7/after-upload-deletion-promise.config.ts new file mode 100644 index 00000000..92b51077 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/after-upload-deletion-promise.config.ts @@ -0,0 +1,20 @@ +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { defineConfig } from "vite"; +import { getSentryConfig } from "../configs/after-upload-deletion-promise.config.js"; + +const outDir = "out/after-upload-deletion-promise"; + +export default defineConfig({ + build: { + minify: false, + sourcemap: true, + rollupOptions: { + input: "src/basic.js", + output: { + dir: outDir, + entryFileNames: "[name].js", + }, + }, + }, + plugins: [sentryVitePlugin(getSentryConfig(outDir))], +}); diff --git a/packages/integration-tests-next/fixtures/vite7/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/vite7/after-upload-deletion-promise.test.ts new file mode 100644 index 00000000..79fe6671 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/after-upload-deletion-promise.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { existsSync } from "node:fs"; +import { join } from "node:path"; + +test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { + runBundler(); + + // Verify the JS file exists and works + const output = runFileInNode("basic.js"); + expect(output).toBe("hello world\n"); + + // Verify the sourcemap was deleted (by the Promise) + const sourcemapPath = join(outDir, "basic.js.map"); + expect(existsSync(sourcemapPath)).toBe(false); +}); diff --git a/packages/integration-tests-next/fixtures/vite8/after-upload-deletion-promise.config.ts b/packages/integration-tests-next/fixtures/vite8/after-upload-deletion-promise.config.ts new file mode 100644 index 00000000..92b51077 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/after-upload-deletion-promise.config.ts @@ -0,0 +1,20 @@ +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { defineConfig } from "vite"; +import { getSentryConfig } from "../configs/after-upload-deletion-promise.config.js"; + +const outDir = "out/after-upload-deletion-promise"; + +export default defineConfig({ + build: { + minify: false, + sourcemap: true, + rollupOptions: { + input: "src/basic.js", + output: { + dir: outDir, + entryFileNames: "[name].js", + }, + }, + }, + plugins: [sentryVitePlugin(getSentryConfig(outDir))], +}); diff --git a/packages/integration-tests-next/fixtures/vite8/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/vite8/after-upload-deletion-promise.test.ts new file mode 100644 index 00000000..79fe6671 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/after-upload-deletion-promise.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { existsSync } from "node:fs"; +import { join } from "node:path"; + +test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { + runBundler(); + + // Verify the JS file exists and works + const output = runFileInNode("basic.js"); + expect(output).toBe("hello world\n"); + + // Verify the sourcemap was deleted (by the Promise) + const sourcemapPath = join(outDir, "basic.js.map"); + expect(existsSync(sourcemapPath)).toBe(false); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion-promise.config.js b/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion-promise.config.js new file mode 100644 index 00000000..4d2cef66 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion-promise.config.js @@ -0,0 +1,20 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { getSentryConfig } from "../configs/after-upload-deletion-promise.config.js"; +import { resolve } from "node:path"; + +const outDir = "./out/after-upload-deletion-promise"; + +export default { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve(outDir), + filename: "basic.js", + }, + devtool: "source-map", + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(getSentryConfig(outDir))], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion-promise.test.ts new file mode 100644 index 00000000..79fe6671 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion-promise.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { existsSync } from "node:fs"; +import { join } from "node:path"; + +test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { + runBundler(); + + // Verify the JS file exists and works + const output = runFileInNode("basic.js"); + expect(output).toBe("hello world\n"); + + // Verify the sourcemap was deleted (by the Promise) + const sourcemapPath = join(outDir, "basic.js.map"); + expect(existsSync(sourcemapPath)).toBe(false); +}); From 5aea4f81221e9d1db3c412a828e8936f9c4be88b Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 14 Apr 2026 14:51:44 +0100 Subject: [PATCH 03/11] Add `dont-mess-up-user-code` tests --- .../configs/dont-mess-up-user-code.config.js | 4 ++ .../esbuild/dont-mess-up-user-code.config.js | 13 ++++++ .../esbuild/dont-mess-up-user-code.test.ts | 46 +++++++++++++++++++ .../fixtures/esbuild/src/import.js | 4 ++ .../fixtures/esbuild/src/index.js | 4 ++ .../rolldown/dont-mess-up-user-code.config.ts | 12 +++++ .../rolldown/dont-mess-up-user-code.test.ts | 31 +++++++++++++ .../fixtures/rolldown/src/import.js | 4 ++ .../fixtures/rolldown/src/index.js | 4 ++ .../rollup3/dont-mess-up-user-code.config.js | 12 +++++ .../rollup3/dont-mess-up-user-code.test.ts | 22 +++++++++ .../fixtures/rollup3/src/import.js | 4 ++ .../fixtures/rollup3/src/index.js | 4 ++ .../rollup4/dont-mess-up-user-code.config.js | 12 +++++ .../rollup4/dont-mess-up-user-code.test.ts | 22 +++++++++ .../fixtures/rollup4/src/import.js | 4 ++ .../fixtures/rollup4/src/index.js | 4 ++ .../vite4/dont-mess-up-user-code.config.ts | 18 ++++++++ .../vite4/dont-mess-up-user-code.test.ts | 28 +++++++++++ .../fixtures/vite4/src/import.js | 4 ++ .../fixtures/vite4/src/index.js | 4 ++ .../vite7/dont-mess-up-user-code.config.ts | 18 ++++++++ .../vite7/dont-mess-up-user-code.test.ts | 28 +++++++++++ .../fixtures/vite7/src/import.js | 4 ++ .../fixtures/vite7/src/index.js | 4 ++ .../vite8/dont-mess-up-user-code.config.ts | 18 ++++++++ .../vite8/dont-mess-up-user-code.test.ts | 28 +++++++++++ .../fixtures/vite8/src/import.js | 4 ++ .../fixtures/vite8/src/index.js | 4 ++ 29 files changed, 368 insertions(+) create mode 100644 packages/integration-tests-next/fixtures/configs/dont-mess-up-user-code.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/dont-mess-up-user-code.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/dont-mess-up-user-code.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/src/import.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/src/index.js create mode 100644 packages/integration-tests-next/fixtures/rolldown/dont-mess-up-user-code.config.ts create mode 100644 packages/integration-tests-next/fixtures/rolldown/dont-mess-up-user-code.test.ts create mode 100644 packages/integration-tests-next/fixtures/rolldown/src/import.js create mode 100644 packages/integration-tests-next/fixtures/rolldown/src/index.js create mode 100644 packages/integration-tests-next/fixtures/rollup3/dont-mess-up-user-code.config.js create mode 100644 packages/integration-tests-next/fixtures/rollup3/dont-mess-up-user-code.test.ts create mode 100644 packages/integration-tests-next/fixtures/rollup3/src/import.js create mode 100644 packages/integration-tests-next/fixtures/rollup3/src/index.js create mode 100644 packages/integration-tests-next/fixtures/rollup4/dont-mess-up-user-code.config.js create mode 100644 packages/integration-tests-next/fixtures/rollup4/dont-mess-up-user-code.test.ts create mode 100644 packages/integration-tests-next/fixtures/rollup4/src/import.js create mode 100644 packages/integration-tests-next/fixtures/rollup4/src/index.js create mode 100644 packages/integration-tests-next/fixtures/vite4/dont-mess-up-user-code.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite4/dont-mess-up-user-code.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite4/src/import.js create mode 100644 packages/integration-tests-next/fixtures/vite4/src/index.js create mode 100644 packages/integration-tests-next/fixtures/vite7/dont-mess-up-user-code.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite7/dont-mess-up-user-code.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite7/src/import.js create mode 100644 packages/integration-tests-next/fixtures/vite7/src/index.js create mode 100644 packages/integration-tests-next/fixtures/vite8/dont-mess-up-user-code.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite8/dont-mess-up-user-code.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite8/src/import.js create mode 100644 packages/integration-tests-next/fixtures/vite8/src/index.js diff --git a/packages/integration-tests-next/fixtures/configs/dont-mess-up-user-code.config.js b/packages/integration-tests-next/fixtures/configs/dont-mess-up-user-code.config.js new file mode 100644 index 00000000..615bdc33 --- /dev/null +++ b/packages/integration-tests-next/fixtures/configs/dont-mess-up-user-code.config.js @@ -0,0 +1,4 @@ +export const sentryConfig = { + telemetry: false, + release: { name: "I am release!", create: false }, +}; diff --git a/packages/integration-tests-next/fixtures/esbuild/dont-mess-up-user-code.config.js b/packages/integration-tests-next/fixtures/esbuild/dont-mess-up-user-code.config.js new file mode 100644 index 00000000..e0375d7d --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/dont-mess-up-user-code.config.js @@ -0,0 +1,13 @@ +import * as esbuild from "esbuild"; +import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin"; +import { sentryConfig } from "../configs/dont-mess-up-user-code.config.js"; + +await esbuild.build({ + entryPoints: ["./src/index.js"], + bundle: true, + outfile: "./out/dont-mess-up-user-code/index.js", + minify: false, + format: "iife", + sourcemap: true, + plugins: [sentryEsbuildPlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/esbuild/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/esbuild/dont-mess-up-user-code.test.ts new file mode 100644 index 00000000..c9ededa8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/dont-mess-up-user-code.test.ts @@ -0,0 +1,46 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "index.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: "I am release!" }; + } 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/import.js + console.log("I am import!"); + + // src/index.js + console.log("I am index!"); + + // src/index.js?sentryDebugIdProxy=true + var index_default = void 0; + })(); + //# sourceMappingURL=index.js.map + ", + "index.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/import.js","../../src/index.js","../../src/index.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:\\"I am release!\\"};}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(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n","\\n import \\"_sentry-debug-id-injection-stub\\";\\n import * as OriginalModule from \\"./src/index.js\\";\\n export default OriginalModule.default;\\n export * from \\"./src/index.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,gBAAe;AAAA,IAAE,SAAOA,IAAE;AAAA,IAAC;AAAA,EAAC,GAAE;;;ACAxN,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,cAAc;;;ACE1B,UAAQ,IAAI,aAAa;;;ACAX,MAAO,gBAAuB;","names":["e","e"]}", + } + `); + + const output = runFileInNode("index.js"); + expect(output).toContain("I am import!"); + expect(output).toContain("I am index!"); +}); diff --git a/packages/integration-tests-next/fixtures/esbuild/src/import.js b/packages/integration-tests-next/fixtures/esbuild/src/import.js new file mode 100644 index 00000000..733d5d48 --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/src/import.js @@ -0,0 +1,4 @@ +// eslint-disable-next-line no-console +console.log("I am import!"); + +export {}; diff --git a/packages/integration-tests-next/fixtures/esbuild/src/index.js b/packages/integration-tests-next/fixtures/esbuild/src/index.js new file mode 100644 index 00000000..719d8428 --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/src/index.js @@ -0,0 +1,4 @@ +import "./import"; + +// eslint-disable-next-line no-console +console.log("I am index!"); diff --git a/packages/integration-tests-next/fixtures/rolldown/dont-mess-up-user-code.config.ts b/packages/integration-tests-next/fixtures/rolldown/dont-mess-up-user-code.config.ts new file mode 100644 index 00000000..53878c72 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rolldown/dont-mess-up-user-code.config.ts @@ -0,0 +1,12 @@ +import { sentryRollupPlugin } from "@sentry/rollup-plugin"; +import { defineConfig } from "rolldown"; +import { sentryConfig } from "../configs/dont-mess-up-user-code.config.js"; + +export default defineConfig({ + input: "src/index.js", + output: { + file: "out/dont-mess-up-user-code/index.js", + sourcemap: true, + }, + plugins: [sentryRollupPlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/rolldown/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/rolldown/dont-mess-up-user-code.test.ts new file mode 100644 index 00000000..189848f4 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rolldown/dont-mess-up-user-code.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(` + { + "index.js": "//#region src/import.js + (function() { + try { + var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}; + e.SENTRY_RELEASE = { id: "I am release!" }; + var n = new e.Error().stack; + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); + } catch (e) {} + })(); + console.log("I am import!"); + //#endregion + //#region src/index.js + console.log("I am index!"); + //#endregion + + //# sourceMappingURL=index.js.map", + "index.js.map": "{"version":3,"file":"index.js","names":[],"sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"mappings":";;;;;;;;;AACA,QAAQ,IAAI,eAAe;;;ACE3B,QAAQ,IAAI,cAAc"}", + } + `); + + const output = runFileInNode("index.js"); + expect(output).toContain("I am import!"); + expect(output).toContain("I am index!"); +}); diff --git a/packages/integration-tests-next/fixtures/rolldown/src/import.js b/packages/integration-tests-next/fixtures/rolldown/src/import.js new file mode 100644 index 00000000..733d5d48 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rolldown/src/import.js @@ -0,0 +1,4 @@ +// eslint-disable-next-line no-console +console.log("I am import!"); + +export {}; diff --git a/packages/integration-tests-next/fixtures/rolldown/src/index.js b/packages/integration-tests-next/fixtures/rolldown/src/index.js new file mode 100644 index 00000000..719d8428 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rolldown/src/index.js @@ -0,0 +1,4 @@ +import "./import"; + +// eslint-disable-next-line no-console +console.log("I am index!"); diff --git a/packages/integration-tests-next/fixtures/rollup3/dont-mess-up-user-code.config.js b/packages/integration-tests-next/fixtures/rollup3/dont-mess-up-user-code.config.js new file mode 100644 index 00000000..34a819c8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup3/dont-mess-up-user-code.config.js @@ -0,0 +1,12 @@ +import { sentryRollupPlugin } from "@sentry/rollup-plugin"; +import { defineConfig } from "rollup"; +import { sentryConfig } from "../configs/dont-mess-up-user-code.config.js"; + +export default defineConfig({ + input: "src/index.js", + output: { + file: "out/dont-mess-up-user-code/index.js", + sourcemap: true, + }, + plugins: [sentryRollupPlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/rollup3/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/rollup3/dont-mess-up-user-code.test.ts new file mode 100644 index 00000000..58d1c9b0 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup3/dont-mess-up-user-code.test.ts @@ -0,0 +1,22 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "index.js": "// eslint-disable-next-line no-console + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"I am release!"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("I am import!"); + + // eslint-disable-next-line no-console + console.log("I am index!"); + //# sourceMappingURL=index.js.map + ", + "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;2aACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAc,CAAC;;ACC3B,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,KAAA,CAAA,CAAa,CAAC"}", + } + `); + + const output = runFileInNode("index.js"); + expect(output).toContain("I am import!"); + expect(output).toContain("I am index!"); +}); diff --git a/packages/integration-tests-next/fixtures/rollup3/src/import.js b/packages/integration-tests-next/fixtures/rollup3/src/import.js new file mode 100644 index 00000000..733d5d48 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup3/src/import.js @@ -0,0 +1,4 @@ +// eslint-disable-next-line no-console +console.log("I am import!"); + +export {}; diff --git a/packages/integration-tests-next/fixtures/rollup3/src/index.js b/packages/integration-tests-next/fixtures/rollup3/src/index.js new file mode 100644 index 00000000..719d8428 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup3/src/index.js @@ -0,0 +1,4 @@ +import "./import"; + +// eslint-disable-next-line no-console +console.log("I am index!"); diff --git a/packages/integration-tests-next/fixtures/rollup4/dont-mess-up-user-code.config.js b/packages/integration-tests-next/fixtures/rollup4/dont-mess-up-user-code.config.js new file mode 100644 index 00000000..34a819c8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup4/dont-mess-up-user-code.config.js @@ -0,0 +1,12 @@ +import { sentryRollupPlugin } from "@sentry/rollup-plugin"; +import { defineConfig } from "rollup"; +import { sentryConfig } from "../configs/dont-mess-up-user-code.config.js"; + +export default defineConfig({ + input: "src/index.js", + output: { + file: "out/dont-mess-up-user-code/index.js", + sourcemap: true, + }, + plugins: [sentryRollupPlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/rollup4/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/rollup4/dont-mess-up-user-code.test.ts new file mode 100644 index 00000000..58d1c9b0 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup4/dont-mess-up-user-code.test.ts @@ -0,0 +1,22 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "index.js": "// eslint-disable-next-line no-console + !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"I am release!"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();console.log("I am import!"); + + // eslint-disable-next-line no-console + console.log("I am index!"); + //# sourceMappingURL=index.js.map + ", + "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;2aACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAc,CAAC;;ACC3B,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,KAAA,CAAA,CAAa,CAAC"}", + } + `); + + const output = runFileInNode("index.js"); + expect(output).toContain("I am import!"); + expect(output).toContain("I am index!"); +}); diff --git a/packages/integration-tests-next/fixtures/rollup4/src/import.js b/packages/integration-tests-next/fixtures/rollup4/src/import.js new file mode 100644 index 00000000..733d5d48 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup4/src/import.js @@ -0,0 +1,4 @@ +// eslint-disable-next-line no-console +console.log("I am import!"); + +export {}; diff --git a/packages/integration-tests-next/fixtures/rollup4/src/index.js b/packages/integration-tests-next/fixtures/rollup4/src/index.js new file mode 100644 index 00000000..719d8428 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup4/src/index.js @@ -0,0 +1,4 @@ +import "./import"; + +// eslint-disable-next-line no-console +console.log("I am index!"); diff --git a/packages/integration-tests-next/fixtures/vite4/dont-mess-up-user-code.config.ts b/packages/integration-tests-next/fixtures/vite4/dont-mess-up-user-code.config.ts new file mode 100644 index 00000000..20057f5a --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/dont-mess-up-user-code.config.ts @@ -0,0 +1,18 @@ +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { defineConfig } from "vite"; +import { sentryConfig } from "../configs/dont-mess-up-user-code.config.js"; + +export default defineConfig({ + build: { + minify: false, + sourcemap: true, + rollupOptions: { + input: "src/index.js", + output: { + dir: "out/dont-mess-up-user-code", + entryFileNames: "[name].js", + }, + }, + }, + plugins: [sentryVitePlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/vite4/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/vite4/dont-mess-up-user-code.test.ts new file mode 100644 index 00000000..dd4ddc34 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/dont-mess-up-user-code.test.ts @@ -0,0 +1,28 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "index.js": "!(function() { + try { + var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}; + e.SENTRY_RELEASE = { id: "I am release!" }; + var n = new e.Error().stack; + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); + } catch (e2) { + } + })(); + console.log("I am import!"); + console.log("I am index!"); + //# sourceMappingURL=index.js.map + ", + "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":";;;;;;;;;AACA,QAAQ,IAAI,cAAc;ACE1B,QAAQ,IAAI,aAAa;"}", + } + `); + + const output = runFileInNode("index.js"); + expect(output).toContain("I am import!"); + expect(output).toContain("I am index!"); +}); diff --git a/packages/integration-tests-next/fixtures/vite4/src/import.js b/packages/integration-tests-next/fixtures/vite4/src/import.js new file mode 100644 index 00000000..733d5d48 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/src/import.js @@ -0,0 +1,4 @@ +// eslint-disable-next-line no-console +console.log("I am import!"); + +export {}; diff --git a/packages/integration-tests-next/fixtures/vite4/src/index.js b/packages/integration-tests-next/fixtures/vite4/src/index.js new file mode 100644 index 00000000..719d8428 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/src/index.js @@ -0,0 +1,4 @@ +import "./import"; + +// eslint-disable-next-line no-console +console.log("I am index!"); diff --git a/packages/integration-tests-next/fixtures/vite7/dont-mess-up-user-code.config.ts b/packages/integration-tests-next/fixtures/vite7/dont-mess-up-user-code.config.ts new file mode 100644 index 00000000..20057f5a --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/dont-mess-up-user-code.config.ts @@ -0,0 +1,18 @@ +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { defineConfig } from "vite"; +import { sentryConfig } from "../configs/dont-mess-up-user-code.config.js"; + +export default defineConfig({ + build: { + minify: false, + sourcemap: true, + rollupOptions: { + input: "src/index.js", + output: { + dir: "out/dont-mess-up-user-code", + entryFileNames: "[name].js", + }, + }, + }, + plugins: [sentryVitePlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/vite7/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/vite7/dont-mess-up-user-code.test.ts new file mode 100644 index 00000000..dd4ddc34 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/dont-mess-up-user-code.test.ts @@ -0,0 +1,28 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "index.js": "!(function() { + try { + var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}; + e.SENTRY_RELEASE = { id: "I am release!" }; + var n = new e.Error().stack; + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); + } catch (e2) { + } + })(); + console.log("I am import!"); + console.log("I am index!"); + //# sourceMappingURL=index.js.map + ", + "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":";;;;;;;;;AACA,QAAQ,IAAI,cAAc;ACE1B,QAAQ,IAAI,aAAa;"}", + } + `); + + const output = runFileInNode("index.js"); + expect(output).toContain("I am import!"); + expect(output).toContain("I am index!"); +}); diff --git a/packages/integration-tests-next/fixtures/vite7/src/import.js b/packages/integration-tests-next/fixtures/vite7/src/import.js new file mode 100644 index 00000000..733d5d48 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/src/import.js @@ -0,0 +1,4 @@ +// eslint-disable-next-line no-console +console.log("I am import!"); + +export {}; diff --git a/packages/integration-tests-next/fixtures/vite7/src/index.js b/packages/integration-tests-next/fixtures/vite7/src/index.js new file mode 100644 index 00000000..719d8428 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/src/index.js @@ -0,0 +1,4 @@ +import "./import"; + +// eslint-disable-next-line no-console +console.log("I am index!"); diff --git a/packages/integration-tests-next/fixtures/vite8/dont-mess-up-user-code.config.ts b/packages/integration-tests-next/fixtures/vite8/dont-mess-up-user-code.config.ts new file mode 100644 index 00000000..20057f5a --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/dont-mess-up-user-code.config.ts @@ -0,0 +1,18 @@ +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { defineConfig } from "vite"; +import { sentryConfig } from "../configs/dont-mess-up-user-code.config.js"; + +export default defineConfig({ + build: { + minify: false, + sourcemap: true, + rollupOptions: { + input: "src/index.js", + output: { + dir: "out/dont-mess-up-user-code", + entryFileNames: "[name].js", + }, + }, + }, + plugins: [sentryVitePlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/vite8/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/vite8/dont-mess-up-user-code.test.ts new file mode 100644 index 00000000..dd4ddc34 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/dont-mess-up-user-code.test.ts @@ -0,0 +1,28 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "index.js": "!(function() { + try { + var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}; + e.SENTRY_RELEASE = { id: "I am release!" }; + var n = new e.Error().stack; + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); + } catch (e2) { + } + })(); + console.log("I am import!"); + console.log("I am index!"); + //# sourceMappingURL=index.js.map + ", + "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":";;;;;;;;;AACA,QAAQ,IAAI,cAAc;ACE1B,QAAQ,IAAI,aAAa;"}", + } + `); + + const output = runFileInNode("index.js"); + expect(output).toContain("I am import!"); + expect(output).toContain("I am index!"); +}); diff --git a/packages/integration-tests-next/fixtures/vite8/src/import.js b/packages/integration-tests-next/fixtures/vite8/src/import.js new file mode 100644 index 00000000..733d5d48 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/src/import.js @@ -0,0 +1,4 @@ +// eslint-disable-next-line no-console +console.log("I am import!"); + +export {}; diff --git a/packages/integration-tests-next/fixtures/vite8/src/index.js b/packages/integration-tests-next/fixtures/vite8/src/index.js new file mode 100644 index 00000000..719d8428 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/src/index.js @@ -0,0 +1,4 @@ +import "./import"; + +// eslint-disable-next-line no-console +console.log("I am index!"); From 8a694839177f3998ce2aae3344213fc89c3ed002 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 14 Apr 2026 15:08:35 +0100 Subject: [PATCH 04/11] Add `errorhandling` tests --- .../fixtures/configs/errorhandling.config.js | 12 +++++ .../fixtures/esbuild/errorhandling.config.js | 15 ++++++ .../fixtures/esbuild/errorhandling.test.ts | 16 +++++++ .../fixtures/rolldown/errorhandling.config.ts | 15 ++++++ .../fixtures/rolldown/errorhandling.test.ts | 16 +++++++ .../fixtures/rollup3/errorhandling.config.js | 15 ++++++ .../fixtures/rollup3/errorhandling.test.ts | 16 +++++++ .../fixtures/rollup4/errorhandling.config.js | 15 ++++++ .../fixtures/rollup4/errorhandling.test.ts | 16 +++++++ .../integration-tests-next/fixtures/utils.ts | 47 +++++++++++++++++++ .../fixtures/vite4/errorhandling.config.ts | 21 +++++++++ .../fixtures/vite4/errorhandling.test.ts | 16 +++++++ .../fixtures/vite7/errorhandling.config.ts | 21 +++++++++ .../fixtures/vite7/errorhandling.test.ts | 16 +++++++ .../fixtures/vite8/errorhandling.config.ts | 21 +++++++++ .../fixtures/vite8/errorhandling.test.ts | 16 +++++++ .../fixtures/webpack5/errorhandling.config.js | 21 +++++++++ .../fixtures/webpack5/errorhandling.test.ts | 16 +++++++ 18 files changed, 331 insertions(+) create mode 100644 packages/integration-tests-next/fixtures/configs/errorhandling.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/errorhandling.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/errorhandling.test.ts create mode 100644 packages/integration-tests-next/fixtures/rolldown/errorhandling.config.ts create mode 100644 packages/integration-tests-next/fixtures/rolldown/errorhandling.test.ts create mode 100644 packages/integration-tests-next/fixtures/rollup3/errorhandling.config.js create mode 100644 packages/integration-tests-next/fixtures/rollup3/errorhandling.test.ts create mode 100644 packages/integration-tests-next/fixtures/rollup4/errorhandling.config.js create mode 100644 packages/integration-tests-next/fixtures/rollup4/errorhandling.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite4/errorhandling.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite4/errorhandling.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite7/errorhandling.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite7/errorhandling.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite8/errorhandling.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite8/errorhandling.test.ts create mode 100644 packages/integration-tests-next/fixtures/webpack5/errorhandling.config.js create mode 100644 packages/integration-tests-next/fixtures/webpack5/errorhandling.test.ts diff --git a/packages/integration-tests-next/fixtures/configs/errorhandling.config.js b/packages/integration-tests-next/fixtures/configs/errorhandling.config.js new file mode 100644 index 00000000..d3e2a6a1 --- /dev/null +++ b/packages/integration-tests-next/fixtures/configs/errorhandling.config.js @@ -0,0 +1,12 @@ +export function getErrorHandlingConfig(port) { + return { + url: `http://localhost:${port}`, + authToken: "fake-auth", + org: "fake-org", + project: "fake-project", + release: { + name: "1.0.0", + }, + debug: true, + }; +} diff --git a/packages/integration-tests-next/fixtures/esbuild/errorhandling.config.js b/packages/integration-tests-next/fixtures/esbuild/errorhandling.config.js new file mode 100644 index 00000000..dce81a1a --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/errorhandling.config.js @@ -0,0 +1,15 @@ +import * as esbuild from "esbuild"; +import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin"; +import { getErrorHandlingConfig } from "../configs/errorhandling.config.js"; + +const FAKE_SENTRY_PORT = process.env.FAKE_SENTRY_PORT || "9876"; + +await esbuild.build({ + entryPoints: ["./src/basic.js"], + bundle: true, + outfile: "./out/errorhandling/basic.js", + minify: false, + format: "cjs", + sourcemap: true, + plugins: [sentryEsbuildPlugin(getErrorHandlingConfig(FAKE_SENTRY_PORT))], +}); diff --git a/packages/integration-tests-next/fixtures/esbuild/errorhandling.test.ts b/packages/integration-tests-next/fixtures/esbuild/errorhandling.test.ts new file mode 100644 index 00000000..f2672a37 --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/errorhandling.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { withFakeSentryServer } from "../utils"; + +test(import.meta.url, async ({ runBundler }) => { + await withFakeSentryServer((port) => { + // Run bundler with fake server - should succeed despite server errors + runBundler({ + FAKE_SENTRY_PORT: port, + SENTRY_HTTP_MAX_RETRIES: "1", // Only retry once to avoid timeout + }); + + // If we get here, the build succeeded (didn't throw) + expect(true).toBe(true); + }); +}); diff --git a/packages/integration-tests-next/fixtures/rolldown/errorhandling.config.ts b/packages/integration-tests-next/fixtures/rolldown/errorhandling.config.ts new file mode 100644 index 00000000..2f0f3990 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rolldown/errorhandling.config.ts @@ -0,0 +1,15 @@ +import { sentryRollupPlugin } from "@sentry/rollup-plugin"; +import { defineConfig } from "rolldown"; +import { getErrorHandlingConfig } from "../configs/errorhandling.config.js"; + +const FAKE_SENTRY_PORT = process.env.FAKE_SENTRY_PORT || "9876"; + +export default defineConfig({ + input: "src/basic.js", + output: { + file: "out/errorhandling/basic.js", + format: "cjs", + sourcemap: true, + }, + plugins: [sentryRollupPlugin(getErrorHandlingConfig(FAKE_SENTRY_PORT))], +}); diff --git a/packages/integration-tests-next/fixtures/rolldown/errorhandling.test.ts b/packages/integration-tests-next/fixtures/rolldown/errorhandling.test.ts new file mode 100644 index 00000000..f2672a37 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rolldown/errorhandling.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { withFakeSentryServer } from "../utils"; + +test(import.meta.url, async ({ runBundler }) => { + await withFakeSentryServer((port) => { + // Run bundler with fake server - should succeed despite server errors + runBundler({ + FAKE_SENTRY_PORT: port, + SENTRY_HTTP_MAX_RETRIES: "1", // Only retry once to avoid timeout + }); + + // If we get here, the build succeeded (didn't throw) + expect(true).toBe(true); + }); +}); diff --git a/packages/integration-tests-next/fixtures/rollup3/errorhandling.config.js b/packages/integration-tests-next/fixtures/rollup3/errorhandling.config.js new file mode 100644 index 00000000..c32f6b65 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup3/errorhandling.config.js @@ -0,0 +1,15 @@ +import { sentryRollupPlugin } from "@sentry/rollup-plugin"; +import { defineConfig } from "rollup"; +import { getErrorHandlingConfig } from "../configs/errorhandling.config.js"; + +const FAKE_SENTRY_PORT = process.env.FAKE_SENTRY_PORT || "9876"; + +export default defineConfig({ + input: "src/basic.js", + output: { + file: "out/errorhandling/basic.js", + format: "cjs", + sourcemap: true, + }, + plugins: [sentryRollupPlugin(getErrorHandlingConfig(FAKE_SENTRY_PORT))], +}); diff --git a/packages/integration-tests-next/fixtures/rollup3/errorhandling.test.ts b/packages/integration-tests-next/fixtures/rollup3/errorhandling.test.ts new file mode 100644 index 00000000..f2672a37 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup3/errorhandling.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { withFakeSentryServer } from "../utils"; + +test(import.meta.url, async ({ runBundler }) => { + await withFakeSentryServer((port) => { + // Run bundler with fake server - should succeed despite server errors + runBundler({ + FAKE_SENTRY_PORT: port, + SENTRY_HTTP_MAX_RETRIES: "1", // Only retry once to avoid timeout + }); + + // If we get here, the build succeeded (didn't throw) + expect(true).toBe(true); + }); +}); diff --git a/packages/integration-tests-next/fixtures/rollup4/errorhandling.config.js b/packages/integration-tests-next/fixtures/rollup4/errorhandling.config.js new file mode 100644 index 00000000..c32f6b65 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup4/errorhandling.config.js @@ -0,0 +1,15 @@ +import { sentryRollupPlugin } from "@sentry/rollup-plugin"; +import { defineConfig } from "rollup"; +import { getErrorHandlingConfig } from "../configs/errorhandling.config.js"; + +const FAKE_SENTRY_PORT = process.env.FAKE_SENTRY_PORT || "9876"; + +export default defineConfig({ + input: "src/basic.js", + output: { + file: "out/errorhandling/basic.js", + format: "cjs", + sourcemap: true, + }, + plugins: [sentryRollupPlugin(getErrorHandlingConfig(FAKE_SENTRY_PORT))], +}); diff --git a/packages/integration-tests-next/fixtures/rollup4/errorhandling.test.ts b/packages/integration-tests-next/fixtures/rollup4/errorhandling.test.ts new file mode 100644 index 00000000..f2672a37 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup4/errorhandling.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { withFakeSentryServer } from "../utils"; + +test(import.meta.url, async ({ runBundler }) => { + await withFakeSentryServer((port) => { + // Run bundler with fake server - should succeed despite server errors + runBundler({ + FAKE_SENTRY_PORT: port, + SENTRY_HTTP_MAX_RETRIES: "1", // Only retry once to avoid timeout + }); + + // If we get here, the build succeeded (didn't throw) + expect(true).toBe(true); + }); +}); diff --git a/packages/integration-tests-next/fixtures/utils.ts b/packages/integration-tests-next/fixtures/utils.ts index a6b2500a..b4ff3600 100644 --- a/packages/integration-tests-next/fixtures/utils.ts +++ b/packages/integration-tests-next/fixtures/utils.ts @@ -97,3 +97,50 @@ process.on("exit", () => { rmSync(dir, { recursive: true, force: true }); } }); + +/** + * Runs a callback with a fake Sentry server running on an auto-allocated port. + * The server returns 503 errors for all requests. + * Automatically starts and stops the server. + * The allocated port is passed to the callback. + */ +export async function withFakeSentryServer( + callback: (port: string) => void | Promise +): Promise { + const { createServer } = await import("node:http"); + + const server = createServer((req, res) => { + if (DEBUG) { + // eslint-disable-next-line no-console + console.log("[FAKE SENTRY] incoming request", req.url); + } + res.statusCode = 503; + res.end("Error: Sentry unreachable"); + }); + + // Listen on port 0 to get an auto-allocated port + await new Promise((resolve) => { + server.listen(0, () => { + resolve(); + }); + }); + + const address = server.address(); + if (!address || typeof address === "string") { + throw new Error("Failed to get server port"); + } + const port = address.port.toString(); + + if (DEBUG) { + // eslint-disable-next-line no-console + console.log(`[FAKE SENTRY] running on http://localhost:${port}/`); + } + + try { + await callback(port); + } finally { + await new Promise((resolve) => { + server.close(() => resolve()); + }); + } +} diff --git a/packages/integration-tests-next/fixtures/vite4/errorhandling.config.ts b/packages/integration-tests-next/fixtures/vite4/errorhandling.config.ts new file mode 100644 index 00000000..974a4857 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/errorhandling.config.ts @@ -0,0 +1,21 @@ +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { defineConfig } from "vite"; +import { getErrorHandlingConfig } from "../configs/errorhandling.config.js"; + +const FAKE_SENTRY_PORT = process.env.FAKE_SENTRY_PORT || "9876"; + +export default defineConfig({ + build: { + minify: false, + sourcemap: true, + rollupOptions: { + input: "src/basic.js", + output: { + dir: "out/errorhandling", + entryFileNames: "[name].js", + format: "cjs", + }, + }, + }, + plugins: [sentryVitePlugin(getErrorHandlingConfig(FAKE_SENTRY_PORT))], +}); diff --git a/packages/integration-tests-next/fixtures/vite4/errorhandling.test.ts b/packages/integration-tests-next/fixtures/vite4/errorhandling.test.ts new file mode 100644 index 00000000..f2672a37 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/errorhandling.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { withFakeSentryServer } from "../utils"; + +test(import.meta.url, async ({ runBundler }) => { + await withFakeSentryServer((port) => { + // Run bundler with fake server - should succeed despite server errors + runBundler({ + FAKE_SENTRY_PORT: port, + SENTRY_HTTP_MAX_RETRIES: "1", // Only retry once to avoid timeout + }); + + // If we get here, the build succeeded (didn't throw) + expect(true).toBe(true); + }); +}); diff --git a/packages/integration-tests-next/fixtures/vite7/errorhandling.config.ts b/packages/integration-tests-next/fixtures/vite7/errorhandling.config.ts new file mode 100644 index 00000000..974a4857 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/errorhandling.config.ts @@ -0,0 +1,21 @@ +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { defineConfig } from "vite"; +import { getErrorHandlingConfig } from "../configs/errorhandling.config.js"; + +const FAKE_SENTRY_PORT = process.env.FAKE_SENTRY_PORT || "9876"; + +export default defineConfig({ + build: { + minify: false, + sourcemap: true, + rollupOptions: { + input: "src/basic.js", + output: { + dir: "out/errorhandling", + entryFileNames: "[name].js", + format: "cjs", + }, + }, + }, + plugins: [sentryVitePlugin(getErrorHandlingConfig(FAKE_SENTRY_PORT))], +}); diff --git a/packages/integration-tests-next/fixtures/vite7/errorhandling.test.ts b/packages/integration-tests-next/fixtures/vite7/errorhandling.test.ts new file mode 100644 index 00000000..f2672a37 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/errorhandling.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { withFakeSentryServer } from "../utils"; + +test(import.meta.url, async ({ runBundler }) => { + await withFakeSentryServer((port) => { + // Run bundler with fake server - should succeed despite server errors + runBundler({ + FAKE_SENTRY_PORT: port, + SENTRY_HTTP_MAX_RETRIES: "1", // Only retry once to avoid timeout + }); + + // If we get here, the build succeeded (didn't throw) + expect(true).toBe(true); + }); +}); diff --git a/packages/integration-tests-next/fixtures/vite8/errorhandling.config.ts b/packages/integration-tests-next/fixtures/vite8/errorhandling.config.ts new file mode 100644 index 00000000..974a4857 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/errorhandling.config.ts @@ -0,0 +1,21 @@ +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { defineConfig } from "vite"; +import { getErrorHandlingConfig } from "../configs/errorhandling.config.js"; + +const FAKE_SENTRY_PORT = process.env.FAKE_SENTRY_PORT || "9876"; + +export default defineConfig({ + build: { + minify: false, + sourcemap: true, + rollupOptions: { + input: "src/basic.js", + output: { + dir: "out/errorhandling", + entryFileNames: "[name].js", + format: "cjs", + }, + }, + }, + plugins: [sentryVitePlugin(getErrorHandlingConfig(FAKE_SENTRY_PORT))], +}); diff --git a/packages/integration-tests-next/fixtures/vite8/errorhandling.test.ts b/packages/integration-tests-next/fixtures/vite8/errorhandling.test.ts new file mode 100644 index 00000000..f2672a37 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/errorhandling.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { withFakeSentryServer } from "../utils"; + +test(import.meta.url, async ({ runBundler }) => { + await withFakeSentryServer((port) => { + // Run bundler with fake server - should succeed despite server errors + runBundler({ + FAKE_SENTRY_PORT: port, + SENTRY_HTTP_MAX_RETRIES: "1", // Only retry once to avoid timeout + }); + + // If we get here, the build succeeded (didn't throw) + expect(true).toBe(true); + }); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/errorhandling.config.js b/packages/integration-tests-next/fixtures/webpack5/errorhandling.config.js new file mode 100644 index 00000000..c3b47736 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/errorhandling.config.js @@ -0,0 +1,21 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { getErrorHandlingConfig } from "../configs/errorhandling.config.js"; +import { resolve } from "node:path"; + +const FAKE_SENTRY_PORT = process.env.FAKE_SENTRY_PORT || "9876"; + +export default { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve("./out/errorhandling"), + filename: "basic.js", + libraryTarget: "commonjs2", + }, + devtool: "source-map", + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(getErrorHandlingConfig(FAKE_SENTRY_PORT))], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/errorhandling.test.ts b/packages/integration-tests-next/fixtures/webpack5/errorhandling.test.ts new file mode 100644 index 00000000..f2672a37 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/errorhandling.test.ts @@ -0,0 +1,16 @@ +import { expect } from "vitest"; +import { test } from "./utils"; +import { withFakeSentryServer } from "../utils"; + +test(import.meta.url, async ({ runBundler }) => { + await withFakeSentryServer((port) => { + // Run bundler with fake server - should succeed despite server errors + runBundler({ + FAKE_SENTRY_PORT: port, + SENTRY_HTTP_MAX_RETRIES: "1", // Only retry once to avoid timeout + }); + + // If we get here, the build succeeded (didn't throw) + expect(true).toBe(true); + }); +}); From a658008cdc609c48c6d881f05c2d4cdf821f15be Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 14 Apr 2026 15:09:42 +0100 Subject: [PATCH 05/11] Some linting --- .../fixtures/esbuild/after-upload-deletion-promise.test.ts | 4 ++-- .../fixtures/esbuild/dont-mess-up-user-code.test.ts | 2 +- .../fixtures/rolldown/after-upload-deletion-promise.test.ts | 4 ++-- .../fixtures/rolldown/dont-mess-up-user-code.test.ts | 2 +- .../fixtures/rollup3/after-upload-deletion-promise.test.ts | 4 ++-- .../fixtures/rollup3/dont-mess-up-user-code.test.ts | 2 +- .../fixtures/rollup4/after-upload-deletion-promise.test.ts | 4 ++-- .../fixtures/rollup4/dont-mess-up-user-code.test.ts | 2 +- .../fixtures/vite4/after-upload-deletion-promise.test.ts | 4 ++-- .../fixtures/vite4/dont-mess-up-user-code.test.ts | 2 +- .../fixtures/vite7/after-upload-deletion-promise.test.ts | 4 ++-- .../fixtures/vite7/dont-mess-up-user-code.test.ts | 2 +- .../fixtures/vite8/after-upload-deletion-promise.test.ts | 4 ++-- .../fixtures/vite8/dont-mess-up-user-code.test.ts | 2 +- .../fixtures/webpack5/after-upload-deletion-promise.test.ts | 4 ++-- 15 files changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion-promise.test.ts index 79fe6671..92c6bd55 100644 --- a/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion-promise.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/after-upload-deletion-promise.test.ts @@ -5,11 +5,11 @@ import { join } from "node:path"; test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { runBundler(); - + // Verify the JS file exists and works const output = runFileInNode("basic.js"); expect(output).toBe("hello world\n"); - + // Verify the sourcemap was deleted (by the Promise) const sourcemapPath = join(outDir, "basic.js.map"); expect(existsSync(sourcemapPath)).toBe(false); diff --git a/packages/integration-tests-next/fixtures/esbuild/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/esbuild/dont-mess-up-user-code.test.ts index c9ededa8..571aad51 100644 --- a/packages/integration-tests-next/fixtures/esbuild/dont-mess-up-user-code.test.ts +++ b/packages/integration-tests-next/fixtures/esbuild/dont-mess-up-user-code.test.ts @@ -39,7 +39,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { "index.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/import.js","../../src/index.js","../../src/index.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:\\"I am release!\\"};}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(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n","\\n import \\"_sentry-debug-id-injection-stub\\";\\n import * as OriginalModule from \\"./src/index.js\\";\\n export default OriginalModule.default;\\n export * from \\"./src/index.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,gBAAe;AAAA,IAAE,SAAOA,IAAE;AAAA,IAAC;AAAA,EAAC,GAAE;;;ACAxN,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,cAAc;;;ACE1B,UAAQ,IAAI,aAAa;;;ACAX,MAAO,gBAAuB;","names":["e","e"]}", } `); - + const output = runFileInNode("index.js"); expect(output).toContain("I am import!"); expect(output).toContain("I am index!"); diff --git a/packages/integration-tests-next/fixtures/rolldown/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/rolldown/after-upload-deletion-promise.test.ts index 79fe6671..92c6bd55 100644 --- a/packages/integration-tests-next/fixtures/rolldown/after-upload-deletion-promise.test.ts +++ b/packages/integration-tests-next/fixtures/rolldown/after-upload-deletion-promise.test.ts @@ -5,11 +5,11 @@ import { join } from "node:path"; test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { runBundler(); - + // Verify the JS file exists and works const output = runFileInNode("basic.js"); expect(output).toBe("hello world\n"); - + // Verify the sourcemap was deleted (by the Promise) const sourcemapPath = join(outDir, "basic.js.map"); expect(existsSync(sourcemapPath)).toBe(false); diff --git a/packages/integration-tests-next/fixtures/rolldown/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/rolldown/dont-mess-up-user-code.test.ts index 189848f4..08a0afff 100644 --- a/packages/integration-tests-next/fixtures/rolldown/dont-mess-up-user-code.test.ts +++ b/packages/integration-tests-next/fixtures/rolldown/dont-mess-up-user-code.test.ts @@ -24,7 +24,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { "index.js.map": "{"version":3,"file":"index.js","names":[],"sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"mappings":";;;;;;;;;AACA,QAAQ,IAAI,eAAe;;;ACE3B,QAAQ,IAAI,cAAc"}", } `); - + const output = runFileInNode("index.js"); expect(output).toContain("I am import!"); expect(output).toContain("I am index!"); diff --git a/packages/integration-tests-next/fixtures/rollup3/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/rollup3/after-upload-deletion-promise.test.ts index 79fe6671..92c6bd55 100644 --- a/packages/integration-tests-next/fixtures/rollup3/after-upload-deletion-promise.test.ts +++ b/packages/integration-tests-next/fixtures/rollup3/after-upload-deletion-promise.test.ts @@ -5,11 +5,11 @@ import { join } from "node:path"; test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { runBundler(); - + // Verify the JS file exists and works const output = runFileInNode("basic.js"); expect(output).toBe("hello world\n"); - + // Verify the sourcemap was deleted (by the Promise) const sourcemapPath = join(outDir, "basic.js.map"); expect(existsSync(sourcemapPath)).toBe(false); diff --git a/packages/integration-tests-next/fixtures/rollup3/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/rollup3/dont-mess-up-user-code.test.ts index 58d1c9b0..42d6d367 100644 --- a/packages/integration-tests-next/fixtures/rollup3/dont-mess-up-user-code.test.ts +++ b/packages/integration-tests-next/fixtures/rollup3/dont-mess-up-user-code.test.ts @@ -15,7 +15,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;2aACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAc,CAAC;;ACC3B,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,KAAA,CAAA,CAAa,CAAC"}", } `); - + const output = runFileInNode("index.js"); expect(output).toContain("I am import!"); expect(output).toContain("I am index!"); diff --git a/packages/integration-tests-next/fixtures/rollup4/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/rollup4/after-upload-deletion-promise.test.ts index 79fe6671..92c6bd55 100644 --- a/packages/integration-tests-next/fixtures/rollup4/after-upload-deletion-promise.test.ts +++ b/packages/integration-tests-next/fixtures/rollup4/after-upload-deletion-promise.test.ts @@ -5,11 +5,11 @@ import { join } from "node:path"; test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { runBundler(); - + // Verify the JS file exists and works const output = runFileInNode("basic.js"); expect(output).toBe("hello world\n"); - + // Verify the sourcemap was deleted (by the Promise) const sourcemapPath = join(outDir, "basic.js.map"); expect(existsSync(sourcemapPath)).toBe(false); diff --git a/packages/integration-tests-next/fixtures/rollup4/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/rollup4/dont-mess-up-user-code.test.ts index 58d1c9b0..42d6d367 100644 --- a/packages/integration-tests-next/fixtures/rollup4/dont-mess-up-user-code.test.ts +++ b/packages/integration-tests-next/fixtures/rollup4/dont-mess-up-user-code.test.ts @@ -15,7 +15,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;2aACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAc,CAAC;;ACC3B,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,EAAA,CAAA;AACA,OAAO,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA,EAAA,CAAA,KAAA,CAAA,CAAa,CAAC"}", } `); - + const output = runFileInNode("index.js"); expect(output).toContain("I am import!"); expect(output).toContain("I am index!"); diff --git a/packages/integration-tests-next/fixtures/vite4/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/vite4/after-upload-deletion-promise.test.ts index 79fe6671..92c6bd55 100644 --- a/packages/integration-tests-next/fixtures/vite4/after-upload-deletion-promise.test.ts +++ b/packages/integration-tests-next/fixtures/vite4/after-upload-deletion-promise.test.ts @@ -5,11 +5,11 @@ import { join } from "node:path"; test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { runBundler(); - + // Verify the JS file exists and works const output = runFileInNode("basic.js"); expect(output).toBe("hello world\n"); - + // Verify the sourcemap was deleted (by the Promise) const sourcemapPath = join(outDir, "basic.js.map"); expect(existsSync(sourcemapPath)).toBe(false); diff --git a/packages/integration-tests-next/fixtures/vite4/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/vite4/dont-mess-up-user-code.test.ts index dd4ddc34..90177fb7 100644 --- a/packages/integration-tests-next/fixtures/vite4/dont-mess-up-user-code.test.ts +++ b/packages/integration-tests-next/fixtures/vite4/dont-mess-up-user-code.test.ts @@ -21,7 +21,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":";;;;;;;;;AACA,QAAQ,IAAI,cAAc;ACE1B,QAAQ,IAAI,aAAa;"}", } `); - + const output = runFileInNode("index.js"); expect(output).toContain("I am import!"); expect(output).toContain("I am index!"); diff --git a/packages/integration-tests-next/fixtures/vite7/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/vite7/after-upload-deletion-promise.test.ts index 79fe6671..92c6bd55 100644 --- a/packages/integration-tests-next/fixtures/vite7/after-upload-deletion-promise.test.ts +++ b/packages/integration-tests-next/fixtures/vite7/after-upload-deletion-promise.test.ts @@ -5,11 +5,11 @@ import { join } from "node:path"; test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { runBundler(); - + // Verify the JS file exists and works const output = runFileInNode("basic.js"); expect(output).toBe("hello world\n"); - + // Verify the sourcemap was deleted (by the Promise) const sourcemapPath = join(outDir, "basic.js.map"); expect(existsSync(sourcemapPath)).toBe(false); diff --git a/packages/integration-tests-next/fixtures/vite7/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/vite7/dont-mess-up-user-code.test.ts index dd4ddc34..90177fb7 100644 --- a/packages/integration-tests-next/fixtures/vite7/dont-mess-up-user-code.test.ts +++ b/packages/integration-tests-next/fixtures/vite7/dont-mess-up-user-code.test.ts @@ -21,7 +21,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":";;;;;;;;;AACA,QAAQ,IAAI,cAAc;ACE1B,QAAQ,IAAI,aAAa;"}", } `); - + const output = runFileInNode("index.js"); expect(output).toContain("I am import!"); expect(output).toContain("I am index!"); diff --git a/packages/integration-tests-next/fixtures/vite8/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/vite8/after-upload-deletion-promise.test.ts index 79fe6671..92c6bd55 100644 --- a/packages/integration-tests-next/fixtures/vite8/after-upload-deletion-promise.test.ts +++ b/packages/integration-tests-next/fixtures/vite8/after-upload-deletion-promise.test.ts @@ -5,11 +5,11 @@ import { join } from "node:path"; test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { runBundler(); - + // Verify the JS file exists and works const output = runFileInNode("basic.js"); expect(output).toBe("hello world\n"); - + // Verify the sourcemap was deleted (by the Promise) const sourcemapPath = join(outDir, "basic.js.map"); expect(existsSync(sourcemapPath)).toBe(false); diff --git a/packages/integration-tests-next/fixtures/vite8/dont-mess-up-user-code.test.ts b/packages/integration-tests-next/fixtures/vite8/dont-mess-up-user-code.test.ts index dd4ddc34..90177fb7 100644 --- a/packages/integration-tests-next/fixtures/vite8/dont-mess-up-user-code.test.ts +++ b/packages/integration-tests-next/fixtures/vite8/dont-mess-up-user-code.test.ts @@ -21,7 +21,7 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { "index.js.map": "{"version":3,"file":"index.js","sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"names":[],"mappings":";;;;;;;;;AACA,QAAQ,IAAI,cAAc;ACE1B,QAAQ,IAAI,aAAa;"}", } `); - + const output = runFileInNode("index.js"); expect(output).toContain("I am import!"); expect(output).toContain("I am index!"); diff --git a/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion-promise.test.ts b/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion-promise.test.ts index 79fe6671..92c6bd55 100644 --- a/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion-promise.test.ts +++ b/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion-promise.test.ts @@ -5,11 +5,11 @@ import { join } from "node:path"; test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => { runBundler(); - + // Verify the JS file exists and works const output = runFileInNode("basic.js"); expect(output).toBe("hello world\n"); - + // Verify the sourcemap was deleted (by the Promise) const sourcemapPath = join(outDir, "basic.js.map"); expect(existsSync(sourcemapPath)).toBe(false); From b1d7e9b7dedfa65311a56dabc89fa15a0694f4ae Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 14 Apr 2026 15:18:33 +0100 Subject: [PATCH 06/11] Add `esbuild-inject-compat` test --- .../esbuild/esbuild-inject-compat.config.js | 17 +++++++ .../esbuild/esbuild-inject-compat.test.ts | 51 +++++++++++++++++++ .../esbuild/src/inject-compat-index.ts | 4 ++ .../fixtures/esbuild/src/inject.ts | 7 +++ 4 files changed, 79 insertions(+) create mode 100644 packages/integration-tests-next/fixtures/esbuild/esbuild-inject-compat.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/esbuild-inject-compat.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/src/inject-compat-index.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/src/inject.ts diff --git a/packages/integration-tests-next/fixtures/esbuild/esbuild-inject-compat.config.js b/packages/integration-tests-next/fixtures/esbuild/esbuild-inject-compat.config.js new file mode 100644 index 00000000..56103b7d --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/esbuild-inject-compat.config.js @@ -0,0 +1,17 @@ +import * as esbuild from "esbuild"; +import * as path from "path"; +import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin"; + +await esbuild.build({ + entryPoints: ["./src/inject-compat-index.ts"], + bundle: true, + outfile: "./out/esbuild-inject-compat/index.js", + inject: [path.resolve("./src/inject.ts")], + minify: false, + format: "iife", + plugins: [ + sentryEsbuildPlugin({ + telemetry: false, + }), + ], +}); diff --git a/packages/integration-tests-next/fixtures/esbuild/esbuild-inject-compat.test.ts b/packages/integration-tests-next/fixtures/esbuild/esbuild-inject-compat.test.ts new file mode 100644 index 00000000..dae1cb7b --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/esbuild-inject-compat.test.ts @@ -0,0 +1,51 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ readOutputFiles, runBundler, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "index.js": "(() => { + // src/inject.ts + var process = { + env: { + FOO: "some-injected-value" + } + }; + var global2 = globalThis; + + // _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 global2 ? global2 : "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/inject-compat-index.ts + console.log(process.env["FOO"]); + + // src/inject-compat-index.ts?sentryDebugIdProxy=true + var inject_compat_index_default = void 0; + })(); + ", + } + `); + + const output = runFileInNode("index.js"); + expect(output).toMatchInlineSnapshot(` + "some-injected-value + " + `); +}); diff --git a/packages/integration-tests-next/fixtures/esbuild/src/inject-compat-index.ts b/packages/integration-tests-next/fixtures/esbuild/src/inject-compat-index.ts new file mode 100644 index 00000000..25401bb5 --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/src/inject-compat-index.ts @@ -0,0 +1,4 @@ +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore just a test file +// eslint-disable-next-line no-console +console.log(process.env["FOO"]); diff --git a/packages/integration-tests-next/fixtures/esbuild/src/inject.ts b/packages/integration-tests-next/fixtures/esbuild/src/inject.ts new file mode 100644 index 00000000..089b32ff --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/src/inject.ts @@ -0,0 +1,7 @@ +export const process = { + env: { + FOO: "some-injected-value", + }, +}; +// eslint-disable-next-line no-undef +export const global = globalThis; From faf954c2172b909a8a2ba621be76b25ea4bf9542 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 14 Apr 2026 15:38:04 +0100 Subject: [PATCH 07/11] Add `release-value-with-quotes` tests --- .../configs/release-value-with-quotes.config.js | 6 ++++++ .../esbuild/release-value-with-quotes.config.js | 12 ++++++++++++ .../esbuild/release-value-with-quotes.test.ts | 8 ++++++++ .../esbuild/src/release-value-with-quotes.js | 3 +++ .../release-value-with-quotes.config.ts | 12 ++++++++++++ .../rolldown/release-value-with-quotes.test.ts | 8 ++++++++ .../rolldown/src/release-value-with-quotes.js | 3 +++ .../rollup3/release-value-with-quotes.config.js | 12 ++++++++++++ .../rollup3/release-value-with-quotes.test.ts | 8 ++++++++ .../rollup3/src/release-value-with-quotes.js | 3 +++ .../rollup4/release-value-with-quotes.config.js | 12 ++++++++++++ .../rollup4/release-value-with-quotes.test.ts | 8 ++++++++ .../rollup4/src/release-value-with-quotes.js | 3 +++ .../vite4/release-value-with-quotes.config.ts | 17 +++++++++++++++++ .../vite4/release-value-with-quotes.test.ts | 8 ++++++++ .../vite4/src/release-value-with-quotes.js | 3 +++ .../vite7/release-value-with-quotes.config.ts | 17 +++++++++++++++++ .../vite7/release-value-with-quotes.test.ts | 8 ++++++++ .../vite7/src/release-value-with-quotes.js | 3 +++ .../vite8/release-value-with-quotes.config.ts | 17 +++++++++++++++++ .../vite8/release-value-with-quotes.test.ts | 8 ++++++++ .../vite8/src/release-value-with-quotes.js | 3 +++ .../release-value-with-quotes.config.js | 17 +++++++++++++++++ .../webpack5/release-value-with-quotes.test.ts | 8 ++++++++ .../webpack5/src/release-value-with-quotes.js | 3 +++ 25 files changed, 210 insertions(+) create mode 100644 packages/integration-tests-next/fixtures/configs/release-value-with-quotes.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/release-value-with-quotes.config.js create mode 100644 packages/integration-tests-next/fixtures/esbuild/release-value-with-quotes.test.ts create mode 100644 packages/integration-tests-next/fixtures/esbuild/src/release-value-with-quotes.js create mode 100644 packages/integration-tests-next/fixtures/rolldown/release-value-with-quotes.config.ts create mode 100644 packages/integration-tests-next/fixtures/rolldown/release-value-with-quotes.test.ts create mode 100644 packages/integration-tests-next/fixtures/rolldown/src/release-value-with-quotes.js create mode 100644 packages/integration-tests-next/fixtures/rollup3/release-value-with-quotes.config.js create mode 100644 packages/integration-tests-next/fixtures/rollup3/release-value-with-quotes.test.ts create mode 100644 packages/integration-tests-next/fixtures/rollup3/src/release-value-with-quotes.js create mode 100644 packages/integration-tests-next/fixtures/rollup4/release-value-with-quotes.config.js create mode 100644 packages/integration-tests-next/fixtures/rollup4/release-value-with-quotes.test.ts create mode 100644 packages/integration-tests-next/fixtures/rollup4/src/release-value-with-quotes.js create mode 100644 packages/integration-tests-next/fixtures/vite4/release-value-with-quotes.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite4/release-value-with-quotes.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite4/src/release-value-with-quotes.js create mode 100644 packages/integration-tests-next/fixtures/vite7/release-value-with-quotes.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite7/release-value-with-quotes.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite7/src/release-value-with-quotes.js create mode 100644 packages/integration-tests-next/fixtures/vite8/release-value-with-quotes.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite8/release-value-with-quotes.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite8/src/release-value-with-quotes.js create mode 100644 packages/integration-tests-next/fixtures/webpack5/release-value-with-quotes.config.js create mode 100644 packages/integration-tests-next/fixtures/webpack5/release-value-with-quotes.test.ts create mode 100644 packages/integration-tests-next/fixtures/webpack5/src/release-value-with-quotes.js diff --git a/packages/integration-tests-next/fixtures/configs/release-value-with-quotes.config.js b/packages/integration-tests-next/fixtures/configs/release-value-with-quotes.config.js new file mode 100644 index 00000000..95fd62fd --- /dev/null +++ b/packages/integration-tests-next/fixtures/configs/release-value-with-quotes.config.js @@ -0,0 +1,6 @@ +export const sentryConfig = { + telemetry: false, + release: { + name: 'i am a dangerous release value because I contain a "', + }, +}; diff --git a/packages/integration-tests-next/fixtures/esbuild/release-value-with-quotes.config.js b/packages/integration-tests-next/fixtures/esbuild/release-value-with-quotes.config.js new file mode 100644 index 00000000..a84ea0d5 --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/release-value-with-quotes.config.js @@ -0,0 +1,12 @@ +import * as esbuild from "esbuild"; +import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin"; +import { sentryConfig } from "../configs/release-value-with-quotes.config.js"; + +await esbuild.build({ + entryPoints: ["./src/release-value-with-quotes.js"], + bundle: true, + outfile: "./out/release-value-with-quotes/bundle.js", + minify: false, + format: "iife", + plugins: [sentryEsbuildPlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/esbuild/release-value-with-quotes.test.ts b/packages/integration-tests-next/fixtures/esbuild/release-value-with-quotes.test.ts new file mode 100644 index 00000000..314a41b8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/release-value-with-quotes.test.ts @@ -0,0 +1,8 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, runFileInNode }) => { + runBundler(); + const output = runFileInNode("bundle.js"); + expect(output.trimEnd()).toBe('"i am a dangerous release value because I contain a \\""'); +}); diff --git a/packages/integration-tests-next/fixtures/esbuild/src/release-value-with-quotes.js b/packages/integration-tests-next/fixtures/esbuild/src/release-value-with-quotes.js new file mode 100644 index 00000000..aa73bfa8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/esbuild/src/release-value-with-quotes.js @@ -0,0 +1,3 @@ +// Simply output the metadata to the console so it can be checked in a test +// eslint-disable-next-line no-console, @typescript-eslint/no-unsafe-member-access +console.log(JSON.stringify(global.SENTRY_RELEASE.id)); diff --git a/packages/integration-tests-next/fixtures/rolldown/release-value-with-quotes.config.ts b/packages/integration-tests-next/fixtures/rolldown/release-value-with-quotes.config.ts new file mode 100644 index 00000000..b7563a57 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rolldown/release-value-with-quotes.config.ts @@ -0,0 +1,12 @@ +import { sentryRollupPlugin } from "@sentry/rollup-plugin"; +import { defineConfig } from "rolldown"; +import { sentryConfig } from "../configs/release-value-with-quotes.config.js"; + +export default defineConfig({ + input: "src/release-value-with-quotes.js", + output: { + file: "out/release-value-with-quotes/bundle.js", + format: "iife", + }, + plugins: [sentryRollupPlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/rolldown/release-value-with-quotes.test.ts b/packages/integration-tests-next/fixtures/rolldown/release-value-with-quotes.test.ts new file mode 100644 index 00000000..314a41b8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rolldown/release-value-with-quotes.test.ts @@ -0,0 +1,8 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, runFileInNode }) => { + runBundler(); + const output = runFileInNode("bundle.js"); + expect(output.trimEnd()).toBe('"i am a dangerous release value because I contain a \\""'); +}); diff --git a/packages/integration-tests-next/fixtures/rolldown/src/release-value-with-quotes.js b/packages/integration-tests-next/fixtures/rolldown/src/release-value-with-quotes.js new file mode 100644 index 00000000..aa73bfa8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rolldown/src/release-value-with-quotes.js @@ -0,0 +1,3 @@ +// Simply output the metadata to the console so it can be checked in a test +// eslint-disable-next-line no-console, @typescript-eslint/no-unsafe-member-access +console.log(JSON.stringify(global.SENTRY_RELEASE.id)); diff --git a/packages/integration-tests-next/fixtures/rollup3/release-value-with-quotes.config.js b/packages/integration-tests-next/fixtures/rollup3/release-value-with-quotes.config.js new file mode 100644 index 00000000..6c9d13e6 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup3/release-value-with-quotes.config.js @@ -0,0 +1,12 @@ +import { sentryRollupPlugin } from "@sentry/rollup-plugin"; +import { defineConfig } from "rollup"; +import { sentryConfig } from "../configs/release-value-with-quotes.config.js"; + +export default defineConfig({ + input: "src/release-value-with-quotes.js", + output: { + file: "out/release-value-with-quotes/bundle.js", + format: "iife", + }, + plugins: [sentryRollupPlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/rollup3/release-value-with-quotes.test.ts b/packages/integration-tests-next/fixtures/rollup3/release-value-with-quotes.test.ts new file mode 100644 index 00000000..314a41b8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup3/release-value-with-quotes.test.ts @@ -0,0 +1,8 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, runFileInNode }) => { + runBundler(); + const output = runFileInNode("bundle.js"); + expect(output.trimEnd()).toBe('"i am a dangerous release value because I contain a \\""'); +}); diff --git a/packages/integration-tests-next/fixtures/rollup3/src/release-value-with-quotes.js b/packages/integration-tests-next/fixtures/rollup3/src/release-value-with-quotes.js new file mode 100644 index 00000000..aa73bfa8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup3/src/release-value-with-quotes.js @@ -0,0 +1,3 @@ +// Simply output the metadata to the console so it can be checked in a test +// eslint-disable-next-line no-console, @typescript-eslint/no-unsafe-member-access +console.log(JSON.stringify(global.SENTRY_RELEASE.id)); diff --git a/packages/integration-tests-next/fixtures/rollup4/release-value-with-quotes.config.js b/packages/integration-tests-next/fixtures/rollup4/release-value-with-quotes.config.js new file mode 100644 index 00000000..6c9d13e6 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup4/release-value-with-quotes.config.js @@ -0,0 +1,12 @@ +import { sentryRollupPlugin } from "@sentry/rollup-plugin"; +import { defineConfig } from "rollup"; +import { sentryConfig } from "../configs/release-value-with-quotes.config.js"; + +export default defineConfig({ + input: "src/release-value-with-quotes.js", + output: { + file: "out/release-value-with-quotes/bundle.js", + format: "iife", + }, + plugins: [sentryRollupPlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/rollup4/release-value-with-quotes.test.ts b/packages/integration-tests-next/fixtures/rollup4/release-value-with-quotes.test.ts new file mode 100644 index 00000000..314a41b8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup4/release-value-with-quotes.test.ts @@ -0,0 +1,8 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, runFileInNode }) => { + runBundler(); + const output = runFileInNode("bundle.js"); + expect(output.trimEnd()).toBe('"i am a dangerous release value because I contain a \\""'); +}); diff --git a/packages/integration-tests-next/fixtures/rollup4/src/release-value-with-quotes.js b/packages/integration-tests-next/fixtures/rollup4/src/release-value-with-quotes.js new file mode 100644 index 00000000..aa73bfa8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/rollup4/src/release-value-with-quotes.js @@ -0,0 +1,3 @@ +// Simply output the metadata to the console so it can be checked in a test +// eslint-disable-next-line no-console, @typescript-eslint/no-unsafe-member-access +console.log(JSON.stringify(global.SENTRY_RELEASE.id)); diff --git a/packages/integration-tests-next/fixtures/vite4/release-value-with-quotes.config.ts b/packages/integration-tests-next/fixtures/vite4/release-value-with-quotes.config.ts new file mode 100644 index 00000000..25161395 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/release-value-with-quotes.config.ts @@ -0,0 +1,17 @@ +import { defineConfig } from "vite"; +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { sentryConfig } from "../configs/release-value-with-quotes.config.js"; + +export default defineConfig({ + build: { + minify: false, + outDir: "./out/release-value-with-quotes", + rollupOptions: { + input: "./src/release-value-with-quotes.js", + output: { + entryFileNames: "bundle.js", + }, + }, + }, + plugins: [sentryVitePlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/vite4/release-value-with-quotes.test.ts b/packages/integration-tests-next/fixtures/vite4/release-value-with-quotes.test.ts new file mode 100644 index 00000000..314a41b8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/release-value-with-quotes.test.ts @@ -0,0 +1,8 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, runFileInNode }) => { + runBundler(); + const output = runFileInNode("bundle.js"); + expect(output.trimEnd()).toBe('"i am a dangerous release value because I contain a \\""'); +}); diff --git a/packages/integration-tests-next/fixtures/vite4/src/release-value-with-quotes.js b/packages/integration-tests-next/fixtures/vite4/src/release-value-with-quotes.js new file mode 100644 index 00000000..aa73bfa8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/src/release-value-with-quotes.js @@ -0,0 +1,3 @@ +// Simply output the metadata to the console so it can be checked in a test +// eslint-disable-next-line no-console, @typescript-eslint/no-unsafe-member-access +console.log(JSON.stringify(global.SENTRY_RELEASE.id)); diff --git a/packages/integration-tests-next/fixtures/vite7/release-value-with-quotes.config.ts b/packages/integration-tests-next/fixtures/vite7/release-value-with-quotes.config.ts new file mode 100644 index 00000000..25161395 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/release-value-with-quotes.config.ts @@ -0,0 +1,17 @@ +import { defineConfig } from "vite"; +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { sentryConfig } from "../configs/release-value-with-quotes.config.js"; + +export default defineConfig({ + build: { + minify: false, + outDir: "./out/release-value-with-quotes", + rollupOptions: { + input: "./src/release-value-with-quotes.js", + output: { + entryFileNames: "bundle.js", + }, + }, + }, + plugins: [sentryVitePlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/vite7/release-value-with-quotes.test.ts b/packages/integration-tests-next/fixtures/vite7/release-value-with-quotes.test.ts new file mode 100644 index 00000000..314a41b8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/release-value-with-quotes.test.ts @@ -0,0 +1,8 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, runFileInNode }) => { + runBundler(); + const output = runFileInNode("bundle.js"); + expect(output.trimEnd()).toBe('"i am a dangerous release value because I contain a \\""'); +}); diff --git a/packages/integration-tests-next/fixtures/vite7/src/release-value-with-quotes.js b/packages/integration-tests-next/fixtures/vite7/src/release-value-with-quotes.js new file mode 100644 index 00000000..aa73bfa8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/src/release-value-with-quotes.js @@ -0,0 +1,3 @@ +// Simply output the metadata to the console so it can be checked in a test +// eslint-disable-next-line no-console, @typescript-eslint/no-unsafe-member-access +console.log(JSON.stringify(global.SENTRY_RELEASE.id)); diff --git a/packages/integration-tests-next/fixtures/vite8/release-value-with-quotes.config.ts b/packages/integration-tests-next/fixtures/vite8/release-value-with-quotes.config.ts new file mode 100644 index 00000000..25161395 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/release-value-with-quotes.config.ts @@ -0,0 +1,17 @@ +import { defineConfig } from "vite"; +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { sentryConfig } from "../configs/release-value-with-quotes.config.js"; + +export default defineConfig({ + build: { + minify: false, + outDir: "./out/release-value-with-quotes", + rollupOptions: { + input: "./src/release-value-with-quotes.js", + output: { + entryFileNames: "bundle.js", + }, + }, + }, + plugins: [sentryVitePlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/vite8/release-value-with-quotes.test.ts b/packages/integration-tests-next/fixtures/vite8/release-value-with-quotes.test.ts new file mode 100644 index 00000000..314a41b8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/release-value-with-quotes.test.ts @@ -0,0 +1,8 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, runFileInNode }) => { + runBundler(); + const output = runFileInNode("bundle.js"); + expect(output.trimEnd()).toBe('"i am a dangerous release value because I contain a \\""'); +}); diff --git a/packages/integration-tests-next/fixtures/vite8/src/release-value-with-quotes.js b/packages/integration-tests-next/fixtures/vite8/src/release-value-with-quotes.js new file mode 100644 index 00000000..aa73bfa8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/src/release-value-with-quotes.js @@ -0,0 +1,3 @@ +// Simply output the metadata to the console so it can be checked in a test +// eslint-disable-next-line no-console, @typescript-eslint/no-unsafe-member-access +console.log(JSON.stringify(global.SENTRY_RELEASE.id)); diff --git a/packages/integration-tests-next/fixtures/webpack5/release-value-with-quotes.config.js b/packages/integration-tests-next/fixtures/webpack5/release-value-with-quotes.config.js new file mode 100644 index 00000000..1b5374b5 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/release-value-with-quotes.config.js @@ -0,0 +1,17 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/release-value-with-quotes.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/release-value-with-quotes.js", + output: { + path: resolve("./out/release-value-with-quotes"), + filename: "bundle.js", + }, + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/release-value-with-quotes.test.ts b/packages/integration-tests-next/fixtures/webpack5/release-value-with-quotes.test.ts new file mode 100644 index 00000000..314a41b8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/release-value-with-quotes.test.ts @@ -0,0 +1,8 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, runFileInNode }) => { + runBundler(); + const output = runFileInNode("bundle.js"); + expect(output.trimEnd()).toBe('"i am a dangerous release value because I contain a \\""'); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/src/release-value-with-quotes.js b/packages/integration-tests-next/fixtures/webpack5/src/release-value-with-quotes.js new file mode 100644 index 00000000..aa73bfa8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/src/release-value-with-quotes.js @@ -0,0 +1,3 @@ +// Simply output the metadata to the console so it can be checked in a test +// eslint-disable-next-line no-console, @typescript-eslint/no-unsafe-member-access +console.log(JSON.stringify(global.SENTRY_RELEASE.id)); From 597aa6eddfff3050e98f8ea3407e19ba304c5790 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 14 Apr 2026 15:39:04 +0100 Subject: [PATCH 08/11] Add missing declaration files --- .../fixtures/configs/after-upload-deletion-promise.config.d.ts | 2 ++ .../fixtures/configs/dont-mess-up-user-code.config.d.ts | 2 ++ .../fixtures/configs/errorhandling.config.d.ts | 2 ++ .../fixtures/configs/release-value-with-quotes.config.d.ts | 2 ++ 4 files changed, 8 insertions(+) create mode 100644 packages/integration-tests-next/fixtures/configs/after-upload-deletion-promise.config.d.ts create mode 100644 packages/integration-tests-next/fixtures/configs/dont-mess-up-user-code.config.d.ts create mode 100644 packages/integration-tests-next/fixtures/configs/errorhandling.config.d.ts create mode 100644 packages/integration-tests-next/fixtures/configs/release-value-with-quotes.config.d.ts diff --git a/packages/integration-tests-next/fixtures/configs/after-upload-deletion-promise.config.d.ts b/packages/integration-tests-next/fixtures/configs/after-upload-deletion-promise.config.d.ts new file mode 100644 index 00000000..d8036dba --- /dev/null +++ b/packages/integration-tests-next/fixtures/configs/after-upload-deletion-promise.config.d.ts @@ -0,0 +1,2 @@ +import type { SentryRollupPluginOptions } from "@sentry/rollup-plugin"; +export declare function getSentryConfig(outDir: string): SentryRollupPluginOptions; diff --git a/packages/integration-tests-next/fixtures/configs/dont-mess-up-user-code.config.d.ts b/packages/integration-tests-next/fixtures/configs/dont-mess-up-user-code.config.d.ts new file mode 100644 index 00000000..f739482f --- /dev/null +++ b/packages/integration-tests-next/fixtures/configs/dont-mess-up-user-code.config.d.ts @@ -0,0 +1,2 @@ +import type { SentryRollupPluginOptions } from "@sentry/rollup-plugin"; +export declare const sentryConfig: SentryRollupPluginOptions; diff --git a/packages/integration-tests-next/fixtures/configs/errorhandling.config.d.ts b/packages/integration-tests-next/fixtures/configs/errorhandling.config.d.ts new file mode 100644 index 00000000..81563911 --- /dev/null +++ b/packages/integration-tests-next/fixtures/configs/errorhandling.config.d.ts @@ -0,0 +1,2 @@ +import type { SentryRollupPluginOptions } from "@sentry/rollup-plugin"; +export declare function getErrorHandlingConfig(port: string): SentryRollupPluginOptions; diff --git a/packages/integration-tests-next/fixtures/configs/release-value-with-quotes.config.d.ts b/packages/integration-tests-next/fixtures/configs/release-value-with-quotes.config.d.ts new file mode 100644 index 00000000..f739482f --- /dev/null +++ b/packages/integration-tests-next/fixtures/configs/release-value-with-quotes.config.d.ts @@ -0,0 +1,2 @@ +import type { SentryRollupPluginOptions } from "@sentry/rollup-plugin"; +export declare const sentryConfig: SentryRollupPluginOptions; From dbc5465bae5cee5de72a3f15ef7e64e1754886c8 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 14 Apr 2026 16:07:38 +0100 Subject: [PATCH 09/11] Add `vite-mpa-extra-modules` tests --- .../vite-mpa-extra-modules.config.d.ts | 2 + .../configs/vite-mpa-extra-modules.config.js | 3 + .../integration-tests-next/fixtures/utils.ts | 107 ++++++++++-------- .../fixtures/vite4/src/shared-module.js | 10 ++ .../fixtures/vite4/src/vite-mpa-index.html | 11 ++ .../fixtures/vite4/src/vite-mpa-page1.html | 11 ++ .../fixtures/vite4/src/vite-mpa-page2.html | 11 ++ .../vite4/vite-mpa-extra-modules.config.ts | 24 ++++ .../vite4/vite-mpa-extra-modules.test.ts | 94 +++++++++++++++ .../fixtures/vite7/src/shared-module.js | 10 ++ .../fixtures/vite7/src/vite-mpa-index.html | 11 ++ .../fixtures/vite7/src/vite-mpa-page1.html | 11 ++ .../fixtures/vite7/src/vite-mpa-page2.html | 11 ++ .../vite7/vite-mpa-extra-modules.config.ts | 24 ++++ .../vite7/vite-mpa-extra-modules.test.ts | 94 +++++++++++++++ .../fixtures/vite8/src/shared-module.js | 10 ++ .../fixtures/vite8/src/vite-mpa-index.html | 11 ++ .../fixtures/vite8/src/vite-mpa-page1.html | 11 ++ .../fixtures/vite8/src/vite-mpa-page2.html | 11 ++ .../vite8/vite-mpa-extra-modules.config.ts | 24 ++++ .../vite8/vite-mpa-extra-modules.test.ts | 94 +++++++++++++++ 21 files changed, 546 insertions(+), 49 deletions(-) create mode 100644 packages/integration-tests-next/fixtures/configs/vite-mpa-extra-modules.config.d.ts create mode 100644 packages/integration-tests-next/fixtures/configs/vite-mpa-extra-modules.config.js create mode 100644 packages/integration-tests-next/fixtures/vite4/src/shared-module.js create mode 100644 packages/integration-tests-next/fixtures/vite4/src/vite-mpa-index.html create mode 100644 packages/integration-tests-next/fixtures/vite4/src/vite-mpa-page1.html create mode 100644 packages/integration-tests-next/fixtures/vite4/src/vite-mpa-page2.html create mode 100644 packages/integration-tests-next/fixtures/vite4/vite-mpa-extra-modules.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite4/vite-mpa-extra-modules.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite7/src/shared-module.js create mode 100644 packages/integration-tests-next/fixtures/vite7/src/vite-mpa-index.html create mode 100644 packages/integration-tests-next/fixtures/vite7/src/vite-mpa-page1.html create mode 100644 packages/integration-tests-next/fixtures/vite7/src/vite-mpa-page2.html create mode 100644 packages/integration-tests-next/fixtures/vite7/vite-mpa-extra-modules.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite7/vite-mpa-extra-modules.test.ts create mode 100644 packages/integration-tests-next/fixtures/vite8/src/shared-module.js create mode 100644 packages/integration-tests-next/fixtures/vite8/src/vite-mpa-index.html create mode 100644 packages/integration-tests-next/fixtures/vite8/src/vite-mpa-page1.html create mode 100644 packages/integration-tests-next/fixtures/vite8/src/vite-mpa-page2.html create mode 100644 packages/integration-tests-next/fixtures/vite8/vite-mpa-extra-modules.config.ts create mode 100644 packages/integration-tests-next/fixtures/vite8/vite-mpa-extra-modules.test.ts diff --git a/packages/integration-tests-next/fixtures/configs/vite-mpa-extra-modules.config.d.ts b/packages/integration-tests-next/fixtures/configs/vite-mpa-extra-modules.config.d.ts new file mode 100644 index 00000000..f739482f --- /dev/null +++ b/packages/integration-tests-next/fixtures/configs/vite-mpa-extra-modules.config.d.ts @@ -0,0 +1,2 @@ +import type { SentryRollupPluginOptions } from "@sentry/rollup-plugin"; +export declare const sentryConfig: SentryRollupPluginOptions; diff --git a/packages/integration-tests-next/fixtures/configs/vite-mpa-extra-modules.config.js b/packages/integration-tests-next/fixtures/configs/vite-mpa-extra-modules.config.js new file mode 100644 index 00000000..8891d92b --- /dev/null +++ b/packages/integration-tests-next/fixtures/configs/vite-mpa-extra-modules.config.js @@ -0,0 +1,3 @@ +export const sentryConfig = { + telemetry: false, +}; diff --git a/packages/integration-tests-next/fixtures/utils.ts b/packages/integration-tests-next/fixtures/utils.ts index b4ff3600..cf276fc0 100644 --- a/packages/integration-tests-next/fixtures/utils.ts +++ b/packages/integration-tests-next/fixtures/utils.ts @@ -26,61 +26,70 @@ export function readAllFiles( customReplacer?: (content: string) => string ): Record { const files: Record = {}; - const entries = readdirSync(directory); - - for (const entry of entries) { - const fullPath = join(directory, entry); - const stat = statSync(fullPath); - - if (stat.isFile()) { - let contents = readFileSync(fullPath, "utf-8"); - // We replace the current SHA with a placeholder to make snapshots deterministic - contents = contents - .replaceAll(CURRENT_SHA, "CURRENT_SHA") - .replaceAll(/"nodeVersion":\d+/g, `"nodeVersion":"NODE_VERSION"`) - .replaceAll(/"nodeVersion": \d+/g, `"nodeVersion":"NODE_VERSION"`) - .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; - map.sources = map.sources.map((c) => c.replace(/\\/g, "/")); - map.sourcesContent = map.sourcesContent.map((c) => c.replace(/\r\n/g, "\n")); - contents = JSON.stringify(map); - } else if (entry === "sentry-cli-mock.json") { - // Remove the temporary directory path too - contents = contents.replace( - /"[^"]+sentry-bundler-plugin-upload.+?",/g, - '"sentry-bundler-plugin-upload-path",' - ); - } else if (entry === "sentry-telemetry.json") { - // Remove the temporary directory path too + function readDirRecursive(currentDir: string, relativePath: string = ""): void { + const entries = readdirSync(currentDir); + + for (const entry of entries) { + const fullPath = join(currentDir, entry); + const stat = statSync(fullPath); + const relativeFilePath = relativePath ? join(relativePath, entry) : entry; + + if (stat.isDirectory()) { + // Recursively read subdirectories + readDirRecursive(fullPath, relativeFilePath); + } else if (stat.isFile()) { + let contents = readFileSync(fullPath, "utf-8"); + // We replace the current SHA with a placeholder to make snapshots deterministic contents = contents - .replace( - /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/g, - "TIMESTAMP" - ) - .replace(/[a-f0-9]{32}/g, "UUID") - .replace(/"duration":[\d.]+/g, '"duration":DURATION') - .replace(/"release":"[\d.]+"/g, '"release":"PLUGIN_VERSION"'); - } else { - // Normalize Windows line endings for cross-platform snapshots - contents = contents.replace(/\r\n/g, "\n"); - // Normalize debug IDs to make snapshots deterministic across environments - contents = contents.replace( - /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, - "00000000-0000-0000-0000-000000000000" - ); + .replaceAll(CURRENT_SHA, "CURRENT_SHA") + .replaceAll(/"nodeVersion":\d+/g, `"nodeVersion":"NODE_VERSION"`) + .replaceAll(/"nodeVersion": \d+/g, `"nodeVersion":"NODE_VERSION"`) + .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; + map.sources = map.sources.map((c) => c.replace(/\\/g, "/")); + map.sourcesContent = map.sourcesContent.map((c) => c.replace(/\r\n/g, "\n")); + contents = JSON.stringify(map); + } else if (entry === "sentry-cli-mock.json") { + // Remove the temporary directory path too + contents = contents.replace( + /"[^"]+sentry-bundler-plugin-upload.+?",/g, + '"sentry-bundler-plugin-upload-path",' + ); + } else if (entry === "sentry-telemetry.json") { + // Remove the temporary directory path too + contents = contents + .replace( + /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/g, + "TIMESTAMP" + ) + .replace(/[a-f0-9]{32}/g, "UUID") + .replace(/"duration":[\d.]+/g, '"duration":DURATION') + .replace(/"release":"[\d.]+"/g, '"release":"PLUGIN_VERSION"'); + } else { + // Normalize Windows line endings for cross-platform snapshots + contents = contents.replace(/\r\n/g, "\n"); + // Normalize debug IDs to make snapshots deterministic across environments + contents = contents.replace( + /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, + "00000000-0000-0000-0000-000000000000" + ); + } + // Use forward slashes for consistent cross-platform keys + files[relativeFilePath.replace(/\\/g, "/")] = contents; } - files[entry] = contents; } } + readDirRecursive(directory); return files; } diff --git a/packages/integration-tests-next/fixtures/vite4/src/shared-module.js b/packages/integration-tests-next/fixtures/vite4/src/shared-module.js new file mode 100644 index 00000000..07182654 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/src/shared-module.js @@ -0,0 +1,10 @@ +// This is a shared module that is used by multiple HTML pages +export function greet(name) { + // eslint-disable-next-line no-console + console.log(`Hello, ${String(name)}!`); +} + +export const VERSION = "1.0.0"; + +// Side effect: greet on load +greet("World"); diff --git a/packages/integration-tests-next/fixtures/vite4/src/vite-mpa-index.html b/packages/integration-tests-next/fixtures/vite4/src/vite-mpa-index.html new file mode 100644 index 00000000..b18731ac --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/src/vite-mpa-index.html @@ -0,0 +1,11 @@ + + + + + Index Page + + +

Index Page - No Scripts

+ + + diff --git a/packages/integration-tests-next/fixtures/vite4/src/vite-mpa-page1.html b/packages/integration-tests-next/fixtures/vite4/src/vite-mpa-page1.html new file mode 100644 index 00000000..44cb873c --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/src/vite-mpa-page1.html @@ -0,0 +1,11 @@ + + + + + Page 1 + + +

Page 1 - With Shared Module

+ + + diff --git a/packages/integration-tests-next/fixtures/vite4/src/vite-mpa-page2.html b/packages/integration-tests-next/fixtures/vite4/src/vite-mpa-page2.html new file mode 100644 index 00000000..6cac57fe --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/src/vite-mpa-page2.html @@ -0,0 +1,11 @@ + + + + + Page 2 + + +

Page 2 - With Shared Module

+ + + diff --git a/packages/integration-tests-next/fixtures/vite4/vite-mpa-extra-modules.config.ts b/packages/integration-tests-next/fixtures/vite4/vite-mpa-extra-modules.config.ts new file mode 100644 index 00000000..d21a3814 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/vite-mpa-extra-modules.config.ts @@ -0,0 +1,24 @@ +import { defineConfig } from "vite"; +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { sentryConfig } from "../configs/vite-mpa-extra-modules.config.js"; +import { resolve } from "node:path"; + +export default defineConfig({ + build: { + minify: false, + sourcemap: true, + outDir: "./out/vite-mpa-extra-modules", + rollupOptions: { + input: { + index: resolve("./src/vite-mpa-index.html"), + page1: resolve("./src/vite-mpa-page1.html"), + page2: resolve("./src/vite-mpa-page2.html"), + }, + output: { + chunkFileNames: "[name].js", + entryFileNames: "[name].js", + }, + }, + }, + plugins: [sentryVitePlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/vite4/vite-mpa-extra-modules.test.ts b/packages/integration-tests-next/fixtures/vite4/vite-mpa-extra-modules.test.ts new file mode 100644 index 00000000..0d9b6cb5 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite4/vite-mpa-extra-modules.test.ts @@ -0,0 +1,94 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "index.js.map": "{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}", + "page1.js.map": "{"version":3,"file":"page1.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}", + "page2.js.map": "{"version":3,"file":"page2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}", + "shared-module.js": "!(function() { + try { + var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}; + e.SENTRY_RELEASE = { id: "CURRENT_SHA" }; + var n = new e.Error().stack; + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); + } catch (e2) { + } + })(); + (function polyfill() { + const relList = document.createElement("link").relList; + if (relList && relList.supports && relList.supports("modulepreload")) return; + for (const link of document.querySelectorAll('link[rel="modulepreload"]')) processPreload(link); + new MutationObserver((mutations) => { + for (const mutation of mutations) { + if (mutation.type !== "childList") continue; + for (const node of mutation.addedNodes) if (node.tagName === "LINK" && node.rel === "modulepreload") processPreload(node); + } + }).observe(document, { + childList: true, + subtree: true + }); + function getFetchOpts(link) { + const fetchOpts = {}; + if (link.integrity) fetchOpts.integrity = link.integrity; + if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy; + if (link.crossOrigin === "use-credentials") fetchOpts.credentials = "include"; + else if (link.crossOrigin === "anonymous") fetchOpts.credentials = "omit"; + else fetchOpts.credentials = "same-origin"; + return fetchOpts; + } + function processPreload(link) { + if (link.ep) return; + link.ep = true; + const fetchOpts = getFetchOpts(link); + fetch(link.href, fetchOpts); + } + })(); + function greet(name) { + console.log(\`Hello, \${String(name)}!\`); + } + greet("World"); + //# sourceMappingURL=shared-module.js.map + ", + "shared-module.js.map": "{"version":3,"file":"shared-module.js","sources":["../../src/shared-module.js"],"sourcesContent":["// This is a shared module that is used by multiple HTML pages\\nexport function greet(name) {\\n // eslint-disable-next-line no-console\\n console.log(\`Hello, \${String(name)}!\`);\\n}\\n\\nexport const VERSION = \\"1.0.0\\";\\n\\n// Side effect: greet on load\\ngreet(\\"World\\");\\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACO,SAAS,MAAM,MAAM;AAE1B,UAAQ,IAAI,UAAU,OAAO,IAAI,CAAC,GAAG;AACvC;AAKA,MAAM,OAAO;"}", + "src/vite-mpa-index.html": " + + + + Index Page + + +

Index Page - No Scripts

+ + + + ", + "src/vite-mpa-page1.html": " + + + + Page 1 + + + +

Page 1 - With Shared Module

+ + + ", + "src/vite-mpa-page2.html": " + + + + Page 2 + + + +

Page 2 - With Shared Module

+ + + ", + } + `); +}); diff --git a/packages/integration-tests-next/fixtures/vite7/src/shared-module.js b/packages/integration-tests-next/fixtures/vite7/src/shared-module.js new file mode 100644 index 00000000..07182654 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/src/shared-module.js @@ -0,0 +1,10 @@ +// This is a shared module that is used by multiple HTML pages +export function greet(name) { + // eslint-disable-next-line no-console + console.log(`Hello, ${String(name)}!`); +} + +export const VERSION = "1.0.0"; + +// Side effect: greet on load +greet("World"); diff --git a/packages/integration-tests-next/fixtures/vite7/src/vite-mpa-index.html b/packages/integration-tests-next/fixtures/vite7/src/vite-mpa-index.html new file mode 100644 index 00000000..b18731ac --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/src/vite-mpa-index.html @@ -0,0 +1,11 @@ + + + + + Index Page + + +

Index Page - No Scripts

+ + + diff --git a/packages/integration-tests-next/fixtures/vite7/src/vite-mpa-page1.html b/packages/integration-tests-next/fixtures/vite7/src/vite-mpa-page1.html new file mode 100644 index 00000000..44cb873c --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/src/vite-mpa-page1.html @@ -0,0 +1,11 @@ + + + + + Page 1 + + +

Page 1 - With Shared Module

+ + + diff --git a/packages/integration-tests-next/fixtures/vite7/src/vite-mpa-page2.html b/packages/integration-tests-next/fixtures/vite7/src/vite-mpa-page2.html new file mode 100644 index 00000000..6cac57fe --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/src/vite-mpa-page2.html @@ -0,0 +1,11 @@ + + + + + Page 2 + + +

Page 2 - With Shared Module

+ + + diff --git a/packages/integration-tests-next/fixtures/vite7/vite-mpa-extra-modules.config.ts b/packages/integration-tests-next/fixtures/vite7/vite-mpa-extra-modules.config.ts new file mode 100644 index 00000000..d21a3814 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/vite-mpa-extra-modules.config.ts @@ -0,0 +1,24 @@ +import { defineConfig } from "vite"; +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { sentryConfig } from "../configs/vite-mpa-extra-modules.config.js"; +import { resolve } from "node:path"; + +export default defineConfig({ + build: { + minify: false, + sourcemap: true, + outDir: "./out/vite-mpa-extra-modules", + rollupOptions: { + input: { + index: resolve("./src/vite-mpa-index.html"), + page1: resolve("./src/vite-mpa-page1.html"), + page2: resolve("./src/vite-mpa-page2.html"), + }, + output: { + chunkFileNames: "[name].js", + entryFileNames: "[name].js", + }, + }, + }, + plugins: [sentryVitePlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/vite7/vite-mpa-extra-modules.test.ts b/packages/integration-tests-next/fixtures/vite7/vite-mpa-extra-modules.test.ts new file mode 100644 index 00000000..0d9b6cb5 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite7/vite-mpa-extra-modules.test.ts @@ -0,0 +1,94 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "index.js.map": "{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}", + "page1.js.map": "{"version":3,"file":"page1.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}", + "page2.js.map": "{"version":3,"file":"page2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}", + "shared-module.js": "!(function() { + try { + var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}; + e.SENTRY_RELEASE = { id: "CURRENT_SHA" }; + var n = new e.Error().stack; + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); + } catch (e2) { + } + })(); + (function polyfill() { + const relList = document.createElement("link").relList; + if (relList && relList.supports && relList.supports("modulepreload")) return; + for (const link of document.querySelectorAll('link[rel="modulepreload"]')) processPreload(link); + new MutationObserver((mutations) => { + for (const mutation of mutations) { + if (mutation.type !== "childList") continue; + for (const node of mutation.addedNodes) if (node.tagName === "LINK" && node.rel === "modulepreload") processPreload(node); + } + }).observe(document, { + childList: true, + subtree: true + }); + function getFetchOpts(link) { + const fetchOpts = {}; + if (link.integrity) fetchOpts.integrity = link.integrity; + if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy; + if (link.crossOrigin === "use-credentials") fetchOpts.credentials = "include"; + else if (link.crossOrigin === "anonymous") fetchOpts.credentials = "omit"; + else fetchOpts.credentials = "same-origin"; + return fetchOpts; + } + function processPreload(link) { + if (link.ep) return; + link.ep = true; + const fetchOpts = getFetchOpts(link); + fetch(link.href, fetchOpts); + } + })(); + function greet(name) { + console.log(\`Hello, \${String(name)}!\`); + } + greet("World"); + //# sourceMappingURL=shared-module.js.map + ", + "shared-module.js.map": "{"version":3,"file":"shared-module.js","sources":["../../src/shared-module.js"],"sourcesContent":["// This is a shared module that is used by multiple HTML pages\\nexport function greet(name) {\\n // eslint-disable-next-line no-console\\n console.log(\`Hello, \${String(name)}!\`);\\n}\\n\\nexport const VERSION = \\"1.0.0\\";\\n\\n// Side effect: greet on load\\ngreet(\\"World\\");\\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACO,SAAS,MAAM,MAAM;AAE1B,UAAQ,IAAI,UAAU,OAAO,IAAI,CAAC,GAAG;AACvC;AAKA,MAAM,OAAO;"}", + "src/vite-mpa-index.html": " + + + + Index Page + + +

Index Page - No Scripts

+ + + + ", + "src/vite-mpa-page1.html": " + + + + Page 1 + + + +

Page 1 - With Shared Module

+ + + ", + "src/vite-mpa-page2.html": " + + + + Page 2 + + + +

Page 2 - With Shared Module

+ + + ", + } + `); +}); diff --git a/packages/integration-tests-next/fixtures/vite8/src/shared-module.js b/packages/integration-tests-next/fixtures/vite8/src/shared-module.js new file mode 100644 index 00000000..07182654 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/src/shared-module.js @@ -0,0 +1,10 @@ +// This is a shared module that is used by multiple HTML pages +export function greet(name) { + // eslint-disable-next-line no-console + console.log(`Hello, ${String(name)}!`); +} + +export const VERSION = "1.0.0"; + +// Side effect: greet on load +greet("World"); diff --git a/packages/integration-tests-next/fixtures/vite8/src/vite-mpa-index.html b/packages/integration-tests-next/fixtures/vite8/src/vite-mpa-index.html new file mode 100644 index 00000000..b18731ac --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/src/vite-mpa-index.html @@ -0,0 +1,11 @@ + + + + + Index Page + + +

Index Page - No Scripts

+ + + diff --git a/packages/integration-tests-next/fixtures/vite8/src/vite-mpa-page1.html b/packages/integration-tests-next/fixtures/vite8/src/vite-mpa-page1.html new file mode 100644 index 00000000..44cb873c --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/src/vite-mpa-page1.html @@ -0,0 +1,11 @@ + + + + + Page 1 + + +

Page 1 - With Shared Module

+ + + diff --git a/packages/integration-tests-next/fixtures/vite8/src/vite-mpa-page2.html b/packages/integration-tests-next/fixtures/vite8/src/vite-mpa-page2.html new file mode 100644 index 00000000..6cac57fe --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/src/vite-mpa-page2.html @@ -0,0 +1,11 @@ + + + + + Page 2 + + +

Page 2 - With Shared Module

+ + + diff --git a/packages/integration-tests-next/fixtures/vite8/vite-mpa-extra-modules.config.ts b/packages/integration-tests-next/fixtures/vite8/vite-mpa-extra-modules.config.ts new file mode 100644 index 00000000..d21a3814 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/vite-mpa-extra-modules.config.ts @@ -0,0 +1,24 @@ +import { defineConfig } from "vite"; +import { sentryVitePlugin } from "@sentry/vite-plugin"; +import { sentryConfig } from "../configs/vite-mpa-extra-modules.config.js"; +import { resolve } from "node:path"; + +export default defineConfig({ + build: { + minify: false, + sourcemap: true, + outDir: "./out/vite-mpa-extra-modules", + rollupOptions: { + input: { + index: resolve("./src/vite-mpa-index.html"), + page1: resolve("./src/vite-mpa-page1.html"), + page2: resolve("./src/vite-mpa-page2.html"), + }, + output: { + chunkFileNames: "[name].js", + entryFileNames: "[name].js", + }, + }, + }, + plugins: [sentryVitePlugin(sentryConfig)], +}); diff --git a/packages/integration-tests-next/fixtures/vite8/vite-mpa-extra-modules.test.ts b/packages/integration-tests-next/fixtures/vite8/vite-mpa-extra-modules.test.ts new file mode 100644 index 00000000..0d9b6cb5 --- /dev/null +++ b/packages/integration-tests-next/fixtures/vite8/vite-mpa-extra-modules.test.ts @@ -0,0 +1,94 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "index.js.map": "{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}", + "page1.js.map": "{"version":3,"file":"page1.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}", + "page2.js.map": "{"version":3,"file":"page2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}", + "shared-module.js": "!(function() { + try { + var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}; + e.SENTRY_RELEASE = { id: "CURRENT_SHA" }; + var n = new e.Error().stack; + n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000"); + } catch (e2) { + } + })(); + (function polyfill() { + const relList = document.createElement("link").relList; + if (relList && relList.supports && relList.supports("modulepreload")) return; + for (const link of document.querySelectorAll('link[rel="modulepreload"]')) processPreload(link); + new MutationObserver((mutations) => { + for (const mutation of mutations) { + if (mutation.type !== "childList") continue; + for (const node of mutation.addedNodes) if (node.tagName === "LINK" && node.rel === "modulepreload") processPreload(node); + } + }).observe(document, { + childList: true, + subtree: true + }); + function getFetchOpts(link) { + const fetchOpts = {}; + if (link.integrity) fetchOpts.integrity = link.integrity; + if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy; + if (link.crossOrigin === "use-credentials") fetchOpts.credentials = "include"; + else if (link.crossOrigin === "anonymous") fetchOpts.credentials = "omit"; + else fetchOpts.credentials = "same-origin"; + return fetchOpts; + } + function processPreload(link) { + if (link.ep) return; + link.ep = true; + const fetchOpts = getFetchOpts(link); + fetch(link.href, fetchOpts); + } + })(); + function greet(name) { + console.log(\`Hello, \${String(name)}!\`); + } + greet("World"); + //# sourceMappingURL=shared-module.js.map + ", + "shared-module.js.map": "{"version":3,"file":"shared-module.js","sources":["../../src/shared-module.js"],"sourcesContent":["// This is a shared module that is used by multiple HTML pages\\nexport function greet(name) {\\n // eslint-disable-next-line no-console\\n console.log(\`Hello, \${String(name)}!\`);\\n}\\n\\nexport const VERSION = \\"1.0.0\\";\\n\\n// Side effect: greet on load\\ngreet(\\"World\\");\\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACO,SAAS,MAAM,MAAM;AAE1B,UAAQ,IAAI,UAAU,OAAO,IAAI,CAAC,GAAG;AACvC;AAKA,MAAM,OAAO;"}", + "src/vite-mpa-index.html": " + + + + Index Page + + +

Index Page - No Scripts

+ + + + ", + "src/vite-mpa-page1.html": " + + + + Page 1 + + + +

Page 1 - With Shared Module

+ + + ", + "src/vite-mpa-page2.html": " + + + + Page 2 + + + +

Page 2 - With Shared Module

+ + + ", + } + `); +}); From 6a8ee1fe879e644bf64c3a8ee90db45865f86174 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 14 Apr 2026 16:35:46 +0100 Subject: [PATCH 10/11] Fix Node.js v18 require(esm) issues --- .../fixtures/configs/basic.config.cjs | 6 ++++++ .../fixtures/esbuild/basic-cjs.config.cjs | 2 +- .../fixtures/rollup3/basic-cjs.config.cjs | 2 +- .../fixtures/rollup4/basic-cjs.config.cjs | 2 +- .../fixtures/webpack5/basic-cjs.config.cjs | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 packages/integration-tests-next/fixtures/configs/basic.config.cjs diff --git a/packages/integration-tests-next/fixtures/configs/basic.config.cjs b/packages/integration-tests-next/fixtures/configs/basic.config.cjs new file mode 100644 index 00000000..3e4aac9e --- /dev/null +++ b/packages/integration-tests-next/fixtures/configs/basic.config.cjs @@ -0,0 +1,6 @@ +exports.sentryConfig = { + telemetry: false, + authToken: "fake-auth", + org: "fake-org", + project: "fake-project", +}; diff --git a/packages/integration-tests-next/fixtures/esbuild/basic-cjs.config.cjs b/packages/integration-tests-next/fixtures/esbuild/basic-cjs.config.cjs index 5187390a..60e49b8b 100644 --- a/packages/integration-tests-next/fixtures/esbuild/basic-cjs.config.cjs +++ b/packages/integration-tests-next/fixtures/esbuild/basic-cjs.config.cjs @@ -1,6 +1,6 @@ const esbuild = require("esbuild"); const { sentryEsbuildPlugin } = require("@sentry/esbuild-plugin"); -const { sentryConfig } = require("../configs/basic.config.js"); +const { sentryConfig } = require("../configs/basic.config.cjs"); esbuild.build({ entryPoints: ["./src/basic.js"], diff --git a/packages/integration-tests-next/fixtures/rollup3/basic-cjs.config.cjs b/packages/integration-tests-next/fixtures/rollup3/basic-cjs.config.cjs index 275ef5bb..756fc350 100644 --- a/packages/integration-tests-next/fixtures/rollup3/basic-cjs.config.cjs +++ b/packages/integration-tests-next/fixtures/rollup3/basic-cjs.config.cjs @@ -1,6 +1,6 @@ const { sentryRollupPlugin } = require("@sentry/rollup-plugin"); const { defineConfig } = require("rollup"); -const { sentryConfig } = require("../configs/basic.config.js"); +const { sentryConfig } = require("../configs/basic.config.cjs"); module.exports = defineConfig({ input: "src/basic.js", diff --git a/packages/integration-tests-next/fixtures/rollup4/basic-cjs.config.cjs b/packages/integration-tests-next/fixtures/rollup4/basic-cjs.config.cjs index 275ef5bb..756fc350 100644 --- a/packages/integration-tests-next/fixtures/rollup4/basic-cjs.config.cjs +++ b/packages/integration-tests-next/fixtures/rollup4/basic-cjs.config.cjs @@ -1,6 +1,6 @@ const { sentryRollupPlugin } = require("@sentry/rollup-plugin"); const { defineConfig } = require("rollup"); -const { sentryConfig } = require("../configs/basic.config.js"); +const { sentryConfig } = require("../configs/basic.config.cjs"); module.exports = defineConfig({ input: "src/basic.js", diff --git a/packages/integration-tests-next/fixtures/webpack5/basic-cjs.config.cjs b/packages/integration-tests-next/fixtures/webpack5/basic-cjs.config.cjs index 578ca4e1..07bf2406 100644 --- a/packages/integration-tests-next/fixtures/webpack5/basic-cjs.config.cjs +++ b/packages/integration-tests-next/fixtures/webpack5/basic-cjs.config.cjs @@ -1,5 +1,5 @@ const { sentryWebpackPlugin } = require("@sentry/webpack-plugin"); -const { sentryConfig } = require("../configs/basic.config.js"); +const { sentryConfig } = require("../configs/basic.config.cjs"); const { resolve } = require("node:path"); module.exports = { From 1f12cf054922dbd7a2093b7fb0b7483160876c0b Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 14 Apr 2026 16:37:37 +0100 Subject: [PATCH 11/11] Fix types and lint --- .../fixtures/configs/after-upload-deletion-promise.config.js | 1 + .../fixtures/configs/errorhandling.config.js | 1 + .../fixtures/rolldown/errorhandling.config.ts | 2 +- packages/integration-tests-next/fixtures/utils.ts | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/integration-tests-next/fixtures/configs/after-upload-deletion-promise.config.js b/packages/integration-tests-next/fixtures/configs/after-upload-deletion-promise.config.js index bda89247..a165efa1 100644 --- a/packages/integration-tests-next/fixtures/configs/after-upload-deletion-promise.config.js +++ b/packages/integration-tests-next/fixtures/configs/after-upload-deletion-promise.config.js @@ -3,6 +3,7 @@ export function getSentryConfig(outDir) { const fileDeletionPromise = new Promise((resolve) => { setTimeout(() => { + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions resolve([`${outDir}/basic.js.map`]); }, 100); }); diff --git a/packages/integration-tests-next/fixtures/configs/errorhandling.config.js b/packages/integration-tests-next/fixtures/configs/errorhandling.config.js index d3e2a6a1..d5b3f564 100644 --- a/packages/integration-tests-next/fixtures/configs/errorhandling.config.js +++ b/packages/integration-tests-next/fixtures/configs/errorhandling.config.js @@ -1,5 +1,6 @@ export function getErrorHandlingConfig(port) { return { + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions url: `http://localhost:${port}`, authToken: "fake-auth", org: "fake-org", diff --git a/packages/integration-tests-next/fixtures/rolldown/errorhandling.config.ts b/packages/integration-tests-next/fixtures/rolldown/errorhandling.config.ts index 2f0f3990..76682aad 100644 --- a/packages/integration-tests-next/fixtures/rolldown/errorhandling.config.ts +++ b/packages/integration-tests-next/fixtures/rolldown/errorhandling.config.ts @@ -2,7 +2,7 @@ import { sentryRollupPlugin } from "@sentry/rollup-plugin"; import { defineConfig } from "rolldown"; import { getErrorHandlingConfig } from "../configs/errorhandling.config.js"; -const FAKE_SENTRY_PORT = process.env.FAKE_SENTRY_PORT || "9876"; +const FAKE_SENTRY_PORT = process.env["FAKE_SENTRY_PORT"] || "9876"; export default defineConfig({ input: "src/basic.js", diff --git a/packages/integration-tests-next/fixtures/utils.ts b/packages/integration-tests-next/fixtures/utils.ts index cf276fc0..883f25c5 100644 --- a/packages/integration-tests-next/fixtures/utils.ts +++ b/packages/integration-tests-next/fixtures/utils.ts @@ -27,7 +27,7 @@ export function readAllFiles( ): Record { const files: Record = {}; - function readDirRecursive(currentDir: string, relativePath: string = ""): void { + function readDirRecursive(currentDir: string, relativePath = ""): void { const entries = readdirSync(currentDir); for (const entry of entries) {