Skip to content

test: More bundler versions #725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ jobs:
# "10.24.1",
# vite uses optional chaining which isn't compatible with node 12
# "12.22.12",
"14.21.1",
"16.18.1",
"18.12.1",
"14",
"16",
"18",
"20",
"22",
]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { testIfNodeMajorVersionIsLessThan18 } from "../../utils/testIf";

function checkBundle(bundlePath1: string, bundlePath2: string) {
const process1Output = childProcess.execSync(`node ${bundlePath1}`, { encoding: "utf-8" });
expect(process1Output).toBe("undefined\n");
Copy link
Collaborator Author

@timfish timfish Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like newer versions of Node have more/different control characters at the end of the output because these were failing on v20 and v22!

expect(process1Output).toMatch(/undefined/);

const process2Output = childProcess.execSync(`node ${bundlePath2}`, { encoding: "utf-8" });
expect(process2Output).toBe("undefined\n");
expect(process2Output).toMatch(/undefined/);
}

describe("should not inject debug IDs when `sourcemaps.disable` is `true`", () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rollup": "3.2.0",
"rollup4": "npm:rollup@^4",
"ts-node": "^10.9.1",
"vite": "3.0.0",
"vite6": "npm:vite@^6",
"webpack4": "npm:webpack@^4",
"webpack5": "npm:webpack@5.74.0"
},
Expand Down
68 changes: 60 additions & 8 deletions packages/integration-tests/utils/create-cjs-bundles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vite from "vite";
import * as vite3 from "vite";
import * as path from "path";
import * as rollup from "rollup";
import * as rollup3 from "rollup";
import { default as webpack4 } from "webpack4";
import { webpack as webpack5 } from "webpack5";
import * as esbuild from "esbuild";
Expand All @@ -10,17 +10,48 @@ import { sentryWebpackPlugin } from "@sentry/webpack-plugin";
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
import { sentryRollupPlugin } from "@sentry/rollup-plugin";

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const nodejsMajorversion = process.version.split(".")[0]!.slice(1);
const [NODE_MAJOR_VERSION] = process.version.split(".").map(Number) as [number];

type Bundlers =
| "webpack4"
| "webpack5"
| "esbuild"
| "rollup"
| "rollup4"
| "vite"
| "vite6"
| string;

export function createCjsBundles(
entrypoints: { [name: string]: string },
outFolder: string,
sentryUnpluginOptions: Options,
plugins: string[] = []
plugins: Bundlers[] = []
): void {
if (plugins.length === 0 || plugins.includes("vite")) {
void vite.build({
void vite3.build({
clearScreen: false,
build: {
sourcemap: true,
outDir: path.join(outFolder, "vite"),
rollupOptions: {
input: entrypoints,
output: {
format: "cjs",
entryFileNames: "[name].js",
},
},
},
plugins: [sentryVitePlugin(sentryUnpluginOptions)],
});
}

if (NODE_MAJOR_VERSION >= 18 && (plugins.length === 0 || plugins.includes("vite6"))) {
// We can't import this at the top of the file because they are not
// compatible with Node v14
// eslint-disable-next-line @typescript-eslint/no-var-requires
const vite6 = require("vite6") as typeof vite3;
void vite6.build({
clearScreen: false,
build: {
sourcemap: true,
Expand All @@ -36,8 +67,29 @@ export function createCjsBundles(
plugins: [sentryVitePlugin(sentryUnpluginOptions)],
});
}

if (plugins.length === 0 || plugins.includes("rollup")) {
void rollup
void rollup3
.rollup({
input: entrypoints,
plugins: [sentryRollupPlugin(sentryUnpluginOptions)],
})
.then((bundle) =>
bundle.write({
sourcemap: true,
dir: path.join(outFolder, "rollup"),
format: "cjs",
exports: "named",
})
);
}

if (NODE_MAJOR_VERSION >= 18 && (plugins.length === 0 || plugins.includes("rollup4"))) {
// We can't import this at the top of the file because they are not
// compatible with Node v14
// eslint-disable-next-line @typescript-eslint/no-var-requires
const rollup4 = require("rollup4") as typeof rollup3;
void rollup4
.rollup({
input: entrypoints,
plugins: [sentryRollupPlugin(sentryUnpluginOptions)],
Expand Down Expand Up @@ -65,7 +117,7 @@ export function createCjsBundles(
}

// Webpack 4 doesn't work on Node.js versions >= 18
if (parseInt(nodejsMajorversion) < 18 && (plugins.length === 0 || plugins.includes("webpack4"))) {
if (NODE_MAJOR_VERSION < 18 && (plugins.length === 0 || plugins.includes("webpack4"))) {
webpack4(
{
devtool: "source-map",
Expand Down
Loading
Loading