11import * as vite from "vite" ;
2+ import * as vite6 from "vite6" ;
23import * as path from "path" ;
34import * as rollup from "rollup" ;
5+ import * as rollup4 from "rollup4" ;
46import { default as webpack4 } from "webpack4" ;
57import { webpack as webpack5 } from "webpack5" ;
68import * as esbuild from "esbuild" ;
@@ -10,14 +12,15 @@ import { sentryWebpackPlugin } from "@sentry/webpack-plugin";
1012import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin" ;
1113import { sentryRollupPlugin } from "@sentry/rollup-plugin" ;
1214
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" ;
1518
1619export function createCjsBundles (
1720 entrypoints : { [ name : string ] : string } ,
1821 outFolder : string ,
1922 sentryUnpluginOptions : Options ,
20- plugins : string [ ] = [ ]
23+ plugins : Bundlers [ ] = [ ]
2124) : void {
2225 if ( plugins . length === 0 || plugins . includes ( "vite" ) ) {
2326 void vite . build ( {
@@ -36,6 +39,25 @@ export function createCjsBundles(
3639 plugins : [ sentryVitePlugin ( sentryUnpluginOptions ) ] ,
3740 } ) ;
3841 }
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+
3961 if ( plugins . length === 0 || plugins . includes ( "rollup" ) ) {
4062 void rollup
4163 . rollup ( {
@@ -52,6 +74,22 @@ export function createCjsBundles(
5274 ) ;
5375 }
5476
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+
5593 if ( plugins . length === 0 || plugins . includes ( "esbuild" ) ) {
5694 void esbuild . build ( {
5795 sourcemap : true ,
@@ -65,7 +103,7 @@ export function createCjsBundles(
65103 }
66104
67105 // 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" ) ) ) {
69107 webpack4 (
70108 {
71109 devtool : "source-map" ,
0 commit comments