1
1
import * as vite from "vite" ;
2
+ import * as vite6 from "vite6" ;
2
3
import * as path from "path" ;
3
4
import * as rollup from "rollup" ;
5
+ import * as rollup4 from "rollup4" ;
4
6
import { default as webpack4 } from "webpack4" ;
5
7
import { webpack as webpack5 } from "webpack5" ;
6
8
import * as esbuild from "esbuild" ;
@@ -10,14 +12,15 @@ import { sentryWebpackPlugin } from "@sentry/webpack-plugin";
10
12
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin" ;
11
13
import { sentryRollupPlugin } from "@sentry/rollup-plugin" ;
12
14
13
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
14
- const nodejsMajorversion = process . version . split ( "." ) [ 0 ] ! . slice ( 1 ) ;
15
+ const [ NODE_MAJOR_VERSION ] = process . version . split ( "." ) . map ( Number ) as [ number ] ;
16
+
17
+ type Bundlers = "webpack4" | "webpack5" | "esbuild" | "rollup" | "rollup4" | "vite" | "vite6" ;
15
18
16
19
export function createCjsBundles (
17
20
entrypoints : { [ name : string ] : string } ,
18
21
outFolder : string ,
19
22
sentryUnpluginOptions : Options ,
20
- plugins : string [ ] = [ ]
23
+ plugins : Bundlers [ ] = [ ]
21
24
) : void {
22
25
if ( plugins . length === 0 || plugins . includes ( "vite" ) ) {
23
26
void vite . build ( {
@@ -36,6 +39,25 @@ export function createCjsBundles(
36
39
plugins : [ sentryVitePlugin ( sentryUnpluginOptions ) ] ,
37
40
} ) ;
38
41
}
42
+
43
+ if ( plugins . length === 0 || plugins . includes ( "vite6" ) ) {
44
+ void vite6 . build ( {
45
+ clearScreen : false ,
46
+ build : {
47
+ sourcemap : true ,
48
+ outDir : path . join ( outFolder , "vite" ) ,
49
+ rollupOptions : {
50
+ input : entrypoints ,
51
+ output : {
52
+ format : "cjs" ,
53
+ entryFileNames : "[name].js" ,
54
+ } ,
55
+ } ,
56
+ } ,
57
+ plugins : [ sentryVitePlugin ( sentryUnpluginOptions ) ] ,
58
+ } ) ;
59
+ }
60
+
39
61
if ( plugins . length === 0 || plugins . includes ( "rollup" ) ) {
40
62
void rollup
41
63
. rollup ( {
@@ -52,6 +74,22 @@ export function createCjsBundles(
52
74
) ;
53
75
}
54
76
77
+ if ( NODE_MAJOR_VERSION >= 18 && plugins . length === 0 || plugins . includes ( "rollup4" ) ) {
78
+ void rollup4
79
+ . rollup ( {
80
+ input : entrypoints ,
81
+ plugins : [ sentryRollupPlugin ( sentryUnpluginOptions ) ] ,
82
+ } )
83
+ . then ( ( bundle ) =>
84
+ bundle . write ( {
85
+ sourcemap : true ,
86
+ dir : path . join ( outFolder , "rollup" ) ,
87
+ format : "cjs" ,
88
+ exports : "named" ,
89
+ } )
90
+ ) ;
91
+ }
92
+
55
93
if ( plugins . length === 0 || plugins . includes ( "esbuild" ) ) {
56
94
void esbuild . build ( {
57
95
sourcemap : true ,
@@ -65,7 +103,7 @@ export function createCjsBundles(
65
103
}
66
104
67
105
// Webpack 4 doesn't work on Node.js versions >= 18
68
- if ( parseInt ( nodejsMajorversion ) < 18 && ( plugins . length === 0 || plugins . includes ( "webpack4" ) ) ) {
106
+ if ( NODE_MAJOR_VERSION < 18 && ( plugins . length === 0 || plugins . includes ( "webpack4" ) ) ) {
69
107
webpack4 (
70
108
{
71
109
devtool : "source-map" ,
0 commit comments