@@ -10,14 +10,23 @@ import { sentryWebpackPlugin } from "@sentry/webpack-plugin";
10
10
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin" ;
11
11
import { sentryRollupPlugin } from "@sentry/rollup-plugin" ;
12
12
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 ;
15
24
16
25
export function createCjsBundles (
17
26
entrypoints : { [ name : string ] : string } ,
18
27
outFolder : string ,
19
28
sentryUnpluginOptions : Options ,
20
- plugins : string [ ] = [ ]
29
+ plugins : Bundlers [ ] = [ ]
21
30
) : void {
22
31
if ( plugins . length === 0 || plugins . includes ( "vite" ) ) {
23
32
void vite . build ( {
@@ -36,6 +45,27 @@ export function createCjsBundles(
36
45
plugins : [ sentryVitePlugin ( sentryUnpluginOptions ) ] ,
37
46
} ) ;
38
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 vite ;
52
+ void vite6 . build ( {
53
+ clearScreen : false ,
54
+ build : {
55
+ sourcemap : true ,
56
+ outDir : path . join ( outFolder , "vite" ) ,
57
+ rollupOptions : {
58
+ input : entrypoints ,
59
+ output : {
60
+ format : "cjs" ,
61
+ entryFileNames : "[name].js" ,
62
+ } ,
63
+ } ,
64
+ } ,
65
+ plugins : [ sentryVitePlugin ( sentryUnpluginOptions ) ] ,
66
+ } ) ;
67
+ }
68
+
39
69
if ( plugins . length === 0 || plugins . includes ( "rollup" ) ) {
40
70
void rollup
41
71
. rollup ( {
@@ -52,6 +82,24 @@ export function createCjsBundles(
52
82
) ;
53
83
}
54
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 rollup ;
88
+ void rollup4
89
+ . rollup ( {
90
+ input : entrypoints ,
91
+ plugins : [ sentryRollupPlugin ( sentryUnpluginOptions ) ] ,
92
+ } )
93
+ . then ( ( bundle ) =>
94
+ bundle . write ( {
95
+ sourcemap : true ,
96
+ dir : path . join ( outFolder , "rollup" ) ,
97
+ format : "cjs" ,
98
+ exports : "named" ,
99
+ } )
100
+ ) ;
101
+ }
102
+
55
103
if ( plugins . length === 0 || plugins . includes ( "esbuild" ) ) {
56
104
void esbuild . build ( {
57
105
sourcemap : true ,
@@ -65,7 +113,7 @@ export function createCjsBundles(
65
113
}
66
114
67
115
// 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" ) ) ) {
69
117
webpack4 (
70
118
{
71
119
devtool : "source-map" ,
0 commit comments