@@ -2,12 +2,12 @@ import * as fs from 'fs';
22import * as os from 'os' ;
33import * as path from 'path' ;
44import { rollup } from 'rollup' ;
5- import { rolldown } from 'rolldown' ;
65import { describe , it , expect , beforeEach , afterEach } from 'vitest' ;
76import { sentryRollupPlugin } from '../../src/rollup' ;
87import { sentryVitePlugin } from '../../src/vite' ;
98
109const DEBUG_ID_MARKER = / s e n t r y - d b i d - ( [ 0 - 9 a - f - ] { 36 } ) / ;
10+ const NODE_MAJOR_VERSION = parseInt ( process . versions . node . split ( '.' ) [ 0 ] ! ) ;
1111
1212describe ( 'sourcemaps.disable: "disable-upload"' , ( ) => {
1313 let tmpDir : string ;
@@ -41,23 +41,28 @@ describe('sourcemaps.disable: "disable-upload"', () => {
4141 expect ( chunk ) . toContain ( `//# debugId=${ debugId } ` ) ;
4242 } ) ;
4343
44- it ( 'stamps the emitted source map with the debug ID injected into the chunk (rolldown / vite)' , async ( ) => {
45- const outDir = path . join ( tmpDir , 'dist' ) ;
46- const build = await rolldown ( {
47- input : entry ,
48- plugins : sentryVitePlugin ( { telemetry : false , sourcemaps : { disable : 'disable-upload' } } ) ,
49- } ) ;
50- await build . write ( { dir : outDir , sourcemap : true } ) ;
51-
52- const chunk = fs . readFileSync ( path . join ( outDir , 'entry.js' ) , 'utf8' ) ;
53- const map = JSON . parse ( fs . readFileSync ( path . join ( outDir , 'entry.js.map' ) , 'utf8' ) ) ;
54- const debugId = chunk . match ( DEBUG_ID_MARKER ) ?. [ 1 ] ;
55-
56- expect ( debugId ) . toBeDefined ( ) ;
57- expect ( map . debug_id ) . toBe ( debugId ) ;
58- expect ( map . debugId ) . toBe ( debugId ) ;
59- expect ( chunk ) . toContain ( `//# debugId=${ debugId } ` ) ;
60- } ) ;
44+ it . skipIf ( NODE_MAJOR_VERSION < 20 ) (
45+ 'stamps the emitted source map with the debug ID injected into the chunk (rolldown / vite)' ,
46+ async ( ) => {
47+ // Rolldown uses Node APIs unavailable on Node 18, so importing it must also be skipped.
48+ const { rolldown } = await import ( 'rolldown' ) ;
49+ const outDir = path . join ( tmpDir , 'dist' ) ;
50+ const build = await rolldown ( {
51+ input : entry ,
52+ plugins : sentryVitePlugin ( { telemetry : false , sourcemaps : { disable : 'disable-upload' } } ) ,
53+ } ) ;
54+ await build . write ( { dir : outDir , sourcemap : true } ) ;
55+
56+ const chunk = fs . readFileSync ( path . join ( outDir , 'entry.js' ) , 'utf8' ) ;
57+ const map = JSON . parse ( fs . readFileSync ( path . join ( outDir , 'entry.js.map' ) , 'utf8' ) ) ;
58+ const debugId = chunk . match ( DEBUG_ID_MARKER ) ?. [ 1 ] ;
59+
60+ expect ( debugId ) . toBeDefined ( ) ;
61+ expect ( map . debug_id ) . toBe ( debugId ) ;
62+ expect ( map . debugId ) . toBe ( debugId ) ;
63+ expect ( chunk ) . toContain ( `//# debugId=${ debugId } ` ) ;
64+ } ,
65+ ) ;
6166
6267 it ( 'stamps a hidden source map that the chunk does not reference' , async ( ) => {
6368 const outDir = path . join ( tmpDir , 'dist' ) ;
0 commit comments