diff --git a/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion.config.js b/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion.config.js new file mode 100644 index 00000000..40d37d62 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion.config.js @@ -0,0 +1,18 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/after-upload-deletion.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve("./out/after-upload-deletion"), + filename: "basic.js", + }, + devtool: "source-map", + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion.test.ts b/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion.test.ts new file mode 100644 index 00000000..53c8e5a4 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/after-upload-deletion.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(` + { + "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]="33730b8e-5b8d-4795-94b2-666cea28fce6",e._sentryDebugIdIdentifier="sentry-dbid-33730b8e-5b8d-4795-94b2-666cea28fce6");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + // eslint-disable-next-line no-console + console.log("hello world"); + + /******/ })() + ; + //# sourceMappingURL=basic.js.map", + } + `); + + const output = runFileInNode("basic.js"); + expect(output).toBe("hello world\n"); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/application-key.config.js b/packages/integration-tests-next/fixtures/webpack5/application-key.config.js new file mode 100644 index 00000000..fdfa64ff --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/application-key.config.js @@ -0,0 +1,17 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/application-key.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve("./out/application-key"), + filename: "basic.js", + }, + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/application-key.test.ts b/packages/integration-tests-next/fixtures/webpack5/application-key.test.ts new file mode 100644 index 00000000..10ccca8a --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/application-key.test.ts @@ -0,0 +1,18 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { // webpackBootstrap + /******/ "use strict"; + // eslint-disable-next-line no-console + console.log("hello world"); + + /******/ })() + ;", + } + `); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/basic-release-disabled.config.js b/packages/integration-tests-next/fixtures/webpack5/basic-release-disabled.config.js new file mode 100644 index 00000000..45653852 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/basic-release-disabled.config.js @@ -0,0 +1,17 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/basic-release-disabled.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve("./out/basic-release-disabled"), + filename: "basic.js", + }, + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/basic-release-disabled.test.ts b/packages/integration-tests-next/fixtures/webpack5/basic-release-disabled.test.ts new file mode 100644 index 00000000..f939d675 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/basic-release-disabled.test.ts @@ -0,0 +1,18 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6438758c-c236-4f8b-af24-575a5948a617",e._sentryDebugIdIdentifier="sentry-dbid-6438758c-c236-4f8b-af24-575a5948a617");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + // eslint-disable-next-line no-console + console.log("hello world"); + + /******/ })() + ;", + } + `); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/basic-sourcemaps.config.js b/packages/integration-tests-next/fixtures/webpack5/basic-sourcemaps.config.js new file mode 100644 index 00000000..4ed0d5e7 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/basic-sourcemaps.config.js @@ -0,0 +1,18 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/basic-sourcemaps.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve("./out/basic-sourcemaps"), + filename: "basic.js", + }, + devtool: "source-map", + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/basic-sourcemaps.test.ts b/packages/integration-tests-next/fixtures/webpack5/basic-sourcemaps.test.ts new file mode 100644 index 00000000..3fcf5311 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/basic-sourcemaps.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(` + { + "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]="33730b8e-5b8d-4795-94b2-666cea28fce6",e._sentryDebugIdIdentifier="sentry-dbid-33730b8e-5b8d-4795-94b2-666cea28fce6");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + // eslint-disable-next-line no-console + console.log("hello world"); + + /******/ })() + ; + //# sourceMappingURL=basic.js.map", + "basic.js.map": "{"version":3,"file":"basic.js","mappings":";;;AAAA;AACA","sources":["webpack://rollup4-integration-tests/./src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"sourceRoot":""}", + "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/basic.config.js b/packages/integration-tests-next/fixtures/webpack5/basic.config.js new file mode 100644 index 00000000..7c469c43 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/basic.config.js @@ -0,0 +1,17 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/basic.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve("./out/basic"), + filename: "basic.js", + }, + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/basic.test.ts b/packages/integration-tests-next/fixtures/webpack5/basic.test.ts new file mode 100644 index 00000000..484819ee --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/basic.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]="6438758c-c236-4f8b-af24-575a5948a617",e._sentryDebugIdIdentifier="sentry-dbid-6438758c-c236-4f8b-af24-575a5948a617");}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/build-info.config.js b/packages/integration-tests-next/fixtures/webpack5/build-info.config.js new file mode 100644 index 00000000..5c13b5d0 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/build-info.config.js @@ -0,0 +1,17 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/build-info.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve("./out/build-info"), + filename: "basic.js", + }, + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/build-info.test.ts b/packages/integration-tests-next/fixtures/webpack5/build-info.test.ts new file mode 100644 index 00000000..7d4537a4 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/build-info.test.ts @@ -0,0 +1,18 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"build-information-injection-test"};e.SENTRY_BUILD_INFO={"deps":["@sentry/webpack-plugin","webpack","webpack-cli"],"depsVersions":{"webpack":5},"nodeVersion":"NODE_VERSION"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6438758c-c236-4f8b-af24-575a5948a617",e._sentryDebugIdIdentifier="sentry-dbid-6438758c-c236-4f8b-af24-575a5948a617");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + // eslint-disable-next-line no-console + console.log("hello world"); + + /******/ })() + ;", + } + `); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/bundle-size-optimizations.config.js b/packages/integration-tests-next/fixtures/webpack5/bundle-size-optimizations.config.js new file mode 100644 index 00000000..f8e9fda6 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/bundle-size-optimizations.config.js @@ -0,0 +1,17 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/bundle-size-optimizations.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/bundle.js", + output: { + path: resolve("./out/bundle-size-optimizations"), + filename: "bundle.js", + }, + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/bundle-size-optimizations.test.ts b/packages/integration-tests-next/fixtures/webpack5/bundle-size-optimizations.test.ts new file mode 100644 index 00000000..ea838e8c --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/bundle-size-optimizations.test.ts @@ -0,0 +1,32 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "bundle.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1ddfd748-f716-49b5-a6bb-a08a480112e2",e._sentryDebugIdIdentifier="sentry-dbid-1ddfd748-f716-49b5-a6bb-a08a480112e2");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + console.log( + JSON.stringify({ + debug: false ? 0 : "b", + trace: false ? 0 : "b", + replayCanvas: true ? "a" : 0, + replayIframe: true ? "a" : 0, + replayShadowDom: true ? "a" : 0, + replayWorker: true ? "a" : 0, + }) + ); + + /******/ })() + ;", + } + `); + + const output = runFileInNode("bundle.js"); + expect(output).toMatchInlineSnapshot(` + "{"debug":"b","trace":"b","replayCanvas":"a","replayIframe":"a","replayShadowDom":"a","replayWorker":"a"} + " + `); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/component-annotation-disabled.config.js b/packages/integration-tests-next/fixtures/webpack5/component-annotation-disabled.config.js new file mode 100644 index 00000000..67568f40 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/component-annotation-disabled.config.js @@ -0,0 +1,38 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/component-annotation-disabled.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/app.jsx", + output: { + path: resolve("./out/component-annotation-disabled"), + filename: "app.js", + }, + optimization: { + minimize: false, + }, + mode: "production", + module: { + rules: [ + { + test: /\.(js|jsx)$/, + exclude: /node_modules/, + use: { + loader: "babel-loader", + options: { + presets: [["@babel/preset-react", { runtime: "automatic" }]], + }, + }, + }, + ], + }, + resolve: { + extensions: [".js", ".jsx", ".ts", ".tsx"], + }, + externals: { + react: "react", + "react/jsx-runtime": "react/jsx-runtime", + }, + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/component-annotation-disabled.test.ts b/packages/integration-tests-next/fixtures/webpack5/component-annotation-disabled.test.ts new file mode 100644 index 00000000..fe31a028 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/component-annotation-disabled.test.ts @@ -0,0 +1,40 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0c0c0033-ce3e-495b-a746-b130c60bc714",e._sentryDebugIdIdentifier="sentry-dbid-0c0c0033-ce3e-495b-a746-b130c60bc714");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + + // UNUSED EXPORTS: default + + ;// external "react/jsx-runtime" + const jsx_runtime_namespaceObject = react/jsx-runtime; + ;// ./src/component-a.jsx + /* unused harmony import specifier */ var _jsx; + + function ComponentA() { + return /*#__PURE__*/_jsx("span", { + children: "Component A" + }); + } + ;// ./src/app.jsx + /* unused harmony import specifier */ var app_ComponentA; + /* unused harmony import specifier */ var app_jsx; + /* unused harmony import specifier */ var _jsxs; + + + + function App() { + return /*#__PURE__*/_jsxs("span", { + children: [/*#__PURE__*/app_jsx(app_ComponentA, {}), ";"] + }); + } + /******/ })() + ;", + } + `); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/component-annotation-next.config.js b/packages/integration-tests-next/fixtures/webpack5/component-annotation-next.config.js new file mode 100644 index 00000000..bdbbe93a --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/component-annotation-next.config.js @@ -0,0 +1,38 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/component-annotation-next.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/app.jsx", + output: { + path: resolve("./out/component-annotation-next"), + filename: "app.js", + }, + optimization: { + minimize: false, + }, + mode: "production", + module: { + rules: [ + { + test: /\.(js|jsx)$/, + exclude: /node_modules/, + use: { + loader: "babel-loader", + options: { + presets: [["@babel/preset-react", { runtime: "automatic" }]], + }, + }, + }, + ], + }, + resolve: { + extensions: [".js", ".jsx", ".ts", ".tsx"], + }, + externals: { + react: "react", + "react/jsx-runtime": "react/jsx-runtime", + }, + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/component-annotation-next.test.ts b/packages/integration-tests-next/fixtures/webpack5/component-annotation-next.test.ts new file mode 100644 index 00000000..56f4e02c --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/component-annotation-next.test.ts @@ -0,0 +1,47 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, ctx }) => { + if (process.platform === "win32") { + ctx.skip("Windows Debug IDs do not match snapshots"); + return; + } + + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c1e4d370-1d54-4310-be89-73f61bd8869b",e._sentryDebugIdIdentifier="sentry-dbid-c1e4d370-1d54-4310-be89-73f61bd8869b");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + + // UNUSED EXPORTS: default + + ;// external "react/jsx-runtime" + const jsx_runtime_namespaceObject = react/jsx-runtime; + ;// ./src/component-a.jsx + /* unused harmony import specifier */ var _jsx; + + function ComponentA() { + return /*#__PURE__*/_jsx("span", { + "data-sentry-component": "ComponentA", + children: "Component A" + }); + } + ;// ./src/app.jsx + /* unused harmony import specifier */ var app_ComponentA; + /* unused harmony import specifier */ var app_jsx; + /* unused harmony import specifier */ var _jsxs; + + + + function App() { + return /*#__PURE__*/_jsxs("span", { + "data-sentry-component": "App", + children: [/*#__PURE__*/app_jsx(app_ComponentA, {}), ";"] + }); + } + /******/ })() + ;", + } + `); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/component-annotation.config.js b/packages/integration-tests-next/fixtures/webpack5/component-annotation.config.js new file mode 100644 index 00000000..b2ea18bb --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/component-annotation.config.js @@ -0,0 +1,38 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/component-annotation.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/app.jsx", + output: { + path: resolve("./out/component-annotation"), + filename: "app.js", + }, + optimization: { + minimize: false, + }, + mode: "production", + module: { + rules: [ + { + test: /\.(js|jsx)$/, + exclude: /node_modules/, + use: { + loader: "babel-loader", + options: { + presets: [["@babel/preset-react", { runtime: "automatic" }]], + }, + }, + }, + ], + }, + resolve: { + extensions: [".js", ".jsx", ".ts", ".tsx"], + }, + externals: { + react: "react", + "react/jsx-runtime": "react/jsx-runtime", + }, + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/component-annotation.test.ts b/packages/integration-tests-next/fixtures/webpack5/component-annotation.test.ts new file mode 100644 index 00000000..192e2a71 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/component-annotation.test.ts @@ -0,0 +1,52 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, ctx }) => { + if (process.platform === "win32") { + ctx.skip("Windows Debug IDs do not match snapshots"); + return; + } + + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "app.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e3bed504-a59a-4ad9-a354-5b25dcad2b77",e._sentryDebugIdIdentifier="sentry-dbid-e3bed504-a59a-4ad9-a354-5b25dcad2b77");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + + // UNUSED EXPORTS: default + + ;// external "react/jsx-runtime" + const jsx_runtime_namespaceObject = react/jsx-runtime; + ;// ./src/component-a.jsx + /* unused harmony import specifier */ var _jsx; + + function ComponentA() { + return /*#__PURE__*/_jsx("span", { + "data-sentry-component": "ComponentA", + "data-sentry-source-file": "component-a.jsx", + children: "Component A" + }); + } + ;// ./src/app.jsx + /* unused harmony import specifier */ var app_ComponentA; + /* unused harmony import specifier */ var app_jsx; + /* unused harmony import specifier */ var _jsxs; + + + + function App() { + return /*#__PURE__*/_jsxs("span", { + "data-sentry-component": "App", + "data-sentry-source-file": "app.jsx", + children: [/*#__PURE__*/app_jsx(app_ComponentA, { + "data-sentry-element": "ComponentA", + "data-sentry-source-file": "app.jsx" + }), ";"] + }); + } + /******/ })() + ;", + } + `); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/debugid-disabled.config.js b/packages/integration-tests-next/fixtures/webpack5/debugid-disabled.config.js new file mode 100644 index 00000000..d60f5747 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/debugid-disabled.config.js @@ -0,0 +1,18 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/debugid-disabled.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve("./out/debugid-disabled"), + filename: "basic.js", + }, + devtool: "source-map", + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/debugid-disabled.test.ts b/packages/integration-tests-next/fixtures/webpack5/debugid-disabled.test.ts new file mode 100644 index 00000000..da3fa272 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/debugid-disabled.test.ts @@ -0,0 +1,19 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "basic.js": "/******/ (() => { // webpackBootstrap + /******/ "use strict"; + // eslint-disable-next-line no-console + console.log("hello world"); + + /******/ })() + ; + //# sourceMappingURL=basic.js.map", + "basic.js.map": "{"version":3,"file":"basic.js","mappings":";;AAAA;AACA","sources":["webpack://rollup4-integration-tests/./src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"sourceRoot":""}", + } + `); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/debugids-already-injected.config.js b/packages/integration-tests-next/fixtures/webpack5/debugids-already-injected.config.js new file mode 100644 index 00000000..abb4f264 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/debugids-already-injected.config.js @@ -0,0 +1,18 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/debugids-already-injected.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve("./out/debugids-already-injected"), + filename: "basic.js", + }, + devtool: "source-map", + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/debugids-already-injected.test.ts b/packages/integration-tests-next/fixtures/webpack5/debugids-already-injected.test.ts new file mode 100644 index 00000000..7d043c77 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/debugids-already-injected.test.ts @@ -0,0 +1,25 @@ +import { expect } from "vitest"; +import { readAllFiles } from "../utils"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, createTempDir }) => { + const tempDir = createTempDir(); + + runBundler({ SENTRY_TEST_OVERRIDE_TEMP_DIR: tempDir }); + const files = readAllFiles(tempDir); + expect(files).toMatchInlineSnapshot(` + { + "33730b8e-5b8d-4795-94b2-666cea28fce6-0.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="33730b8e-5b8d-4795-94b2-666cea28fce6",e._sentryDebugIdIdentifier="sentry-dbid-33730b8e-5b8d-4795-94b2-666cea28fce6");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + // eslint-disable-next-line no-console + console.log("hello world"); + + /******/ })() + ; + //# sourceMappingURL=basic.js.map + //# debugId=33730b8e-5b8d-4795-94b2-666cea28fce6", + "33730b8e-5b8d-4795-94b2-666cea28fce6-0.js.map": "{"version":3,"file":"basic.js","mappings":";;;AAAA;AACA","sources":["rollup4-integration-tests/./src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"sourceRoot":"","debug_id":"33730b8e-5b8d-4795-94b2-666cea28fce6","debugId":"33730b8e-5b8d-4795-94b2-666cea28fce6"}", + } + `); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/module-metadata.config.js b/packages/integration-tests-next/fixtures/webpack5/module-metadata.config.js new file mode 100644 index 00000000..aabbcd6f --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/module-metadata.config.js @@ -0,0 +1,17 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/module-metadata.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve("./out/module-metadata"), + filename: "basic.js", + }, + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/module-metadata.test.ts b/packages/integration-tests-next/fixtures/webpack5/module-metadata.test.ts new file mode 100644 index 00000000..44bc19d9 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/module-metadata.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": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n { // webpackBootstrap + /******/ "use strict"; + // eslint-disable-next-line no-console + console.log("hello world"); + + /******/ })() + ;", + } + `); + + const output = runFileInNode("basic.js"); + expect(output).toBe("hello world\n"); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/multiple-entry-points.config.js b/packages/integration-tests-next/fixtures/webpack5/multiple-entry-points.config.js new file mode 100644 index 00000000..f25bc02d --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/multiple-entry-points.config.js @@ -0,0 +1,20 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/multiple-entry-points.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: { + entry1: "./src/entry1.js", + entry2: "./src/entry2.js", + }, + output: { + path: resolve("./out/multiple-entry-points"), + filename: "[name].js", + }, + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/multiple-entry-points.test.ts b/packages/integration-tests-next/fixtures/webpack5/multiple-entry-points.test.ts new file mode 100644 index 00000000..fa76d2b4 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/multiple-entry-points.test.ts @@ -0,0 +1,53 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "entry1.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a50aee12-d2d3-4d16-88bd-652f76f59160",e._sentryDebugIdIdentifier="sentry-dbid-a50aee12-d2d3-4d16-88bd-652f76f59160");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + + ;// ./src/common.js + function add(a, b) { + return a + b; + } + + ;// ./src/entry1.js + + + console.log(add(1, 2)); + + /******/ })() + ;", + "entry2.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ca296a6b-7e8f-4158-a4c6-725f2e93e232",e._sentryDebugIdIdentifier="sentry-dbid-ca296a6b-7e8f-4158-a4c6-725f2e93e232");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + + ;// ./src/common.js + function add(a, b) { + return a + b; + } + + ;// ./src/entry2.js + + + console.log(add(2, 4)); + + /******/ })() + ;", + } + `); + + const output1 = runFileInNode("entry1.js"); + expect(output1).toMatchInlineSnapshot(` + "3 + " + `); + const output2 = runFileInNode("entry2.js"); + expect(output2).toMatchInlineSnapshot(` + "6 + " + `); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/package.json b/packages/integration-tests-next/fixtures/webpack5/package.json new file mode 100644 index 00000000..aab67952 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/package.json @@ -0,0 +1,21 @@ +{ + "name": "rollup4-integration-tests", + "version": "1.0.0", + "private": true, + "type": "module", + "dependencies": { + "webpack": "5.105.4", + "webpack-cli": "6.0.1", + "@sentry/webpack-plugin": "5.1.1" + }, + "pnpm": { + "overrides": { + "@sentry/bundler-plugin-core": "file:../../../bundler-plugin-core/sentry-bundler-plugin-core-5.1.1.tgz", + "@sentry/webpack-plugin": "file:../../../webpack-plugin/sentry-webpack-plugin-5.1.1.tgz", + "@sentry/babel-plugin-component-annotate": "file:../../../babel-plugin-component-annotate/sentry-babel-plugin-component-annotate-5.1.1.tgz" + }, + "patchedDependencies": { + "@sentry/cli": "../patches/@sentry__cli.patch" + } + } +} diff --git a/packages/integration-tests-next/fixtures/webpack5/release-disabled.config.js b/packages/integration-tests-next/fixtures/webpack5/release-disabled.config.js new file mode 100644 index 00000000..2022c635 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/release-disabled.config.js @@ -0,0 +1,17 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/release-disabled.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve("./out/release-disabled"), + filename: "basic.js", + }, + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/release-disabled.test.ts b/packages/integration-tests-next/fixtures/webpack5/release-disabled.test.ts new file mode 100644 index 00000000..721d02f6 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/release-disabled.test.ts @@ -0,0 +1,22 @@ +import { expect } from "vitest"; +import { test } from "./utils"; + +test(import.meta.url, ({ runBundler, readOutputFiles }) => { + runBundler(); + expect(readOutputFiles()).toMatchInlineSnapshot(` + { + "basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6438758c-c236-4f8b-af24-575a5948a617",e._sentryDebugIdIdentifier="sentry-dbid-6438758c-c236-4f8b-af24-575a5948a617");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + // eslint-disable-next-line no-console + console.log("hello world"); + + /******/ })() + ;", + "sentry-cli-mock.json": "["releases","set-commits","CURRENT_SHA","--auto","--ignore-missing"], + ["releases","finalize","CURRENT_SHA"], + ["sourcemaps","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path","--ignore","node_modules","--no-rewrite"], + ", + } + `); +}); diff --git a/packages/integration-tests-next/fixtures/webpack5/src/app.jsx b/packages/integration-tests-next/fixtures/webpack5/src/app.jsx new file mode 100644 index 00000000..614d38c8 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/src/app.jsx @@ -0,0 +1,9 @@ +import { ComponentA } from "./component-a"; + +export default function App() { + return ( + + ; + + ); +} diff --git a/packages/integration-tests-next/fixtures/webpack5/src/basic.js b/packages/integration-tests-next/fixtures/webpack5/src/basic.js new file mode 100644 index 00000000..7ef02afb --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/src/basic.js @@ -0,0 +1,2 @@ +// eslint-disable-next-line no-console +console.log("hello world"); diff --git a/packages/integration-tests-next/fixtures/webpack5/src/bundle.js b/packages/integration-tests-next/fixtures/webpack5/src/bundle.js new file mode 100644 index 00000000..0d62e559 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/src/bundle.js @@ -0,0 +1,10 @@ +console.log( + JSON.stringify({ + debug: __SENTRY_DEBUG__ ? "a" : "b", + trace: __SENTRY_TRACING__ ? "a" : "b", + replayCanvas: __RRWEB_EXCLUDE_CANVAS__ ? "a" : "b", + replayIframe: __RRWEB_EXCLUDE_IFRAME__ ? "a" : "b", + replayShadowDom: __RRWEB_EXCLUDE_SHADOW_DOM__ ? "a" : "b", + replayWorker: __SENTRY_EXCLUDE_REPLAY_WORKER__ ? "a" : "b", + }) +); diff --git a/packages/integration-tests-next/fixtures/webpack5/src/common.js b/packages/integration-tests-next/fixtures/webpack5/src/common.js new file mode 100644 index 00000000..7d658310 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/src/common.js @@ -0,0 +1,3 @@ +export function add(a, b) { + return a + b; +} diff --git a/packages/integration-tests-next/fixtures/webpack5/src/component-a.jsx b/packages/integration-tests-next/fixtures/webpack5/src/component-a.jsx new file mode 100644 index 00000000..5d57ab22 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/src/component-a.jsx @@ -0,0 +1,3 @@ +export function ComponentA() { + return Component A; +} diff --git a/packages/integration-tests-next/fixtures/webpack5/src/entry1.js b/packages/integration-tests-next/fixtures/webpack5/src/entry1.js new file mode 100644 index 00000000..6ab03d8d --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/src/entry1.js @@ -0,0 +1,3 @@ +import { add } from "./common.js"; + +console.log(add(1, 2)); diff --git a/packages/integration-tests-next/fixtures/webpack5/src/entry2.js b/packages/integration-tests-next/fixtures/webpack5/src/entry2.js new file mode 100644 index 00000000..675580cf --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/src/entry2.js @@ -0,0 +1,3 @@ +import { add } from "./common.js"; + +console.log(add(2, 4)); diff --git a/packages/integration-tests-next/fixtures/webpack5/telemetry.config.js b/packages/integration-tests-next/fixtures/webpack5/telemetry.config.js new file mode 100644 index 00000000..09da2ef5 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/telemetry.config.js @@ -0,0 +1,17 @@ +import { sentryWebpackPlugin } from "@sentry/webpack-plugin"; +import { sentryConfig } from "../configs/telemetry.config.js"; +import { resolve } from "node:path"; + +export default { + cache: false, + entry: "./src/basic.js", + output: { + path: resolve("./out/telemetry"), + filename: "basic.js", + }, + optimization: { + minimize: false, + }, + mode: "production", + plugins: [sentryWebpackPlugin(sentryConfig)], +}; diff --git a/packages/integration-tests-next/fixtures/webpack5/telemetry.test.ts b/packages/integration-tests-next/fixtures/webpack5/telemetry.test.ts new file mode 100644 index 00000000..bf7f62d0 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/telemetry.test.ts @@ -0,0 +1,23 @@ +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]="6438758c-c236-4f8b-af24-575a5948a617",e._sentryDebugIdIdentifier="sentry-dbid-6438758c-c236-4f8b-af24-575a5948a617");}catch(e){}}(); + /******/ (() => { // webpackBootstrap + /******/ "use strict"; + // eslint-disable-next-line no-console + console.log("hello world"); + + /******/ })() + ;", + "sentry-telemetry.json": "[{"sent_at":"TIMESTAMP","sdk":{"name":"sentry.javascript.node","version":"8.30.0"}},[[{"type":"session"},{"sid":"UUID","init":false,"started":"TIMESTAMP","timestamp":"TIMESTAMP","status":"exited","errors":0,"duration":DURATION,"attrs":{"release":"PLUGIN_VERSION","environment":"production"}}]]], + ", + } + `); + + 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 new file mode 100644 index 00000000..010edbb0 --- /dev/null +++ b/packages/integration-tests-next/fixtures/webpack5/utils.ts @@ -0,0 +1,55 @@ +import { basename, dirname, join } from "node:path"; +import { createTempDir, readAllFiles, runBundler } from "../utils"; +import { fileURLToPath } from "node:url"; +import { rmSync } from "node:fs"; +import { TestContext, test as vitestTest } from "vitest"; +import { execSync } from "node:child_process"; + +const cwd = dirname(fileURLToPath(import.meta.url)); + +type TestCallback = (props: { + outDir: string; + runBundler: (env?: Record) => void; + readOutputFiles: () => Record; + runFileInNode: (file: string) => string; + createTempDir: () => string; + ctx: TestContext; +}) => void | Promise; + +export function test(url: string, callback: TestCallback) { + const filePath = fileURLToPath(url); + const filename = basename(filePath); + const testName = filename.replace(/\.test\.ts$/, ""); + const outDir = join(cwd, "out", testName); + + // Clear the output directory before running the test + rmSync(outDir, { recursive: true, force: true }); + + vitestTest(`webpack v5 > ${testName}`, (ctx) => + callback({ + outDir, + runBundler: (env) => + runBundler( + `pnpm webpack --config ${testName}.config.js`, + { + cwd, + env: { + ...process.env, + ...env, + }, + }, + outDir + ), + readOutputFiles: () => readAllFiles(outDir), + runFileInNode: (file) => { + const fullPath = join(outDir, file); + return execSync(`node ${fullPath}`, { + cwd, + env: { ...process.env, NO_COLOR: "1", FORCE_COLOR: "0" }, + }).toString(); + }, + createTempDir: () => createTempDir(), + ctx, + }) + ); +}