Skip to content

Commit d6f1854

Browse files
committed
test: More bundler versions
1 parent 958248e commit d6f1854

File tree

5 files changed

+395
-13
lines changed

5 files changed

+395
-13
lines changed

.github/workflows/checks.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ jobs:
125125
# "10.24.1",
126126
# vite uses optional chaining which isn't compatible with node 12
127127
# "12.22.12",
128-
"14.21.1",
129-
"16.18.1",
130-
"18.12.1",
128+
"14",
129+
"16",
130+
"18",
131+
"20",
132+
"22",
131133
]
132134
os: [ubuntu-latest, windows-latest]
133135
runs-on: ${{ matrix.os }}

packages/integration-tests/fixtures/disabled-debug-id-injection/disabled-debug-id-injection.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { testIfNodeMajorVersionIsLessThan18 } from "../../utils/testIf";
66

77
function checkBundle(bundlePath1: string, bundlePath2: string) {
88
const process1Output = childProcess.execSync(`node ${bundlePath1}`, { encoding: "utf-8" });
9-
expect(process1Output).toBe("undefined\n");
9+
expect(process1Output).toMatch(/undefined/);
1010

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

1515
describe("should not inject debug IDs when `sourcemaps.disable` is `true`", () => {

packages/integration-tests/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@
3939
"react": "^18.2.0",
4040
"react-dom": "^18.2.0",
4141
"rollup": "3.2.0",
42+
"rollup4": "npm:rollup@^4",
4243
"ts-node": "^10.9.1",
4344
"vite": "3.0.0",
45+
"vite6": "npm:vite@^6",
4446
"webpack4": "npm:webpack@^4",
4547
"webpack5": "npm:[email protected]"
4648
},

packages/integration-tests/utils/create-cjs-bundles.ts

+56-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as vite from "vite";
1+
import * as vite3 from "vite";
22
import * as path from "path";
3-
import * as rollup from "rollup";
3+
import * as rollup3 from "rollup";
44
import { default as webpack4 } from "webpack4";
55
import { webpack as webpack5 } from "webpack5";
66
import * as esbuild from "esbuild";
@@ -10,17 +10,46 @@ import { sentryWebpackPlugin } from "@sentry/webpack-plugin";
1010
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
1111
import { sentryRollupPlugin } from "@sentry/rollup-plugin";
1212

13-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
14-
const nodejsMajorversion = process.version.split(".")[0]!.slice(1);
13+
const [NODE_MAJOR_VERSION] = process.version.split(".").map(Number) as [number];
14+
15+
type Bundlers =
16+
| "webpack4"
17+
| "webpack5"
18+
| "esbuild"
19+
| "rollup"
20+
| "rollup4"
21+
| "vite"
22+
| "vite6"
23+
| string;
1524

1625
export function createCjsBundles(
1726
entrypoints: { [name: string]: string },
1827
outFolder: string,
1928
sentryUnpluginOptions: Options,
20-
plugins: string[] = []
29+
plugins: Bundlers[] = []
2130
): void {
2231
if (plugins.length === 0 || plugins.includes("vite")) {
23-
void vite.build({
32+
void vite3.build({
33+
clearScreen: false,
34+
build: {
35+
sourcemap: true,
36+
outDir: path.join(outFolder, "vite"),
37+
rollupOptions: {
38+
input: entrypoints,
39+
output: {
40+
format: "cjs",
41+
entryFileNames: "[name].js",
42+
},
43+
},
44+
},
45+
plugins: [sentryVitePlugin(sentryUnpluginOptions)],
46+
});
47+
}
48+
49+
if ((NODE_MAJOR_VERSION >= 18 && plugins.length === 0) || plugins.includes("vite6")) {
50+
// eslint-disable-next-line @typescript-eslint/no-var-requires
51+
const vite6 = require("vite6") as typeof vite3;
52+
void vite6.build({
2453
clearScreen: false,
2554
build: {
2655
sourcemap: true,
@@ -36,8 +65,27 @@ export function createCjsBundles(
3665
plugins: [sentryVitePlugin(sentryUnpluginOptions)],
3766
});
3867
}
68+
3969
if (plugins.length === 0 || plugins.includes("rollup")) {
40-
void rollup
70+
void rollup3
71+
.rollup({
72+
input: entrypoints,
73+
plugins: [sentryRollupPlugin(sentryUnpluginOptions)],
74+
})
75+
.then((bundle) =>
76+
bundle.write({
77+
sourcemap: true,
78+
dir: path.join(outFolder, "rollup"),
79+
format: "cjs",
80+
exports: "named",
81+
})
82+
);
83+
}
84+
85+
if ((NODE_MAJOR_VERSION >= 18 && plugins.length === 0) || plugins.includes("rollup4")) {
86+
// eslint-disable-next-line @typescript-eslint/no-var-requires
87+
const rollup4 = require("rollup4") as typeof rollup3;
88+
void rollup4
4189
.rollup({
4290
input: entrypoints,
4391
plugins: [sentryRollupPlugin(sentryUnpluginOptions)],
@@ -65,7 +113,7 @@ export function createCjsBundles(
65113
}
66114

67115
// Webpack 4 doesn't work on Node.js versions >= 18
68-
if (parseInt(nodejsMajorversion) < 18 && (plugins.length === 0 || plugins.includes("webpack4"))) {
116+
if (NODE_MAJOR_VERSION < 18 && (plugins.length === 0 || plugins.includes("webpack4"))) {
69117
webpack4(
70118
{
71119
devtool: "source-map",

0 commit comments

Comments
 (0)