@@ -9,23 +9,28 @@ const { execBuildOrThrow, execClean } = setup(import.meta.dirname);
99
1010await execBuildOrThrow ( ) ;
1111
12- const jsPath = path . join ( import . meta. dirname , "lib" , "bs" , "src" , "Demo.js" ) ;
13- const mapPath = `${ jsPath } .map` ;
12+ for ( const filename of [ "Demo.cjs" , "Demo.mjs" ] ) {
13+ const jsPath = path . join ( import . meta. dirname , "lib" , "bs" , "src" , filename ) ;
14+ const mapPath = `${ jsPath } .map` ;
1415
15- const js = await fs . readFile ( jsPath , "utf8" ) ;
16- assert . match ( js , / \/ \/ # s o u r c e M a p p i n g U R L = D e m o \. j s \. m a p / ) ;
16+ const js = await fs . readFile ( jsPath , "utf8" ) ;
17+ assert . match (
18+ js ,
19+ new RegExp ( `//# sourceMappingURL=${ filename . replace ( "." , "\\." ) } \\.map` ) ,
20+ ) ;
1721
18- const map = JSON . parse ( await fs . readFile ( mapPath , "utf8" ) ) ;
19- assert . equal ( map . version , 3 ) ;
20- assert . equal ( map . file , "Demo.js" ) ;
21- assert . ok ( map . mappings . length > 0 , "source map should include mappings" ) ;
22- assert . ok (
23- map . sources . some ( source => source . endsWith ( "Demo.res" ) ) ,
24- `source map should include Demo.res, got ${ map . sources . join ( ", " ) } ` ,
25- ) ;
26- assert . ok (
27- map . sourcesContent . some ( content => content . includes ( "let add = (a, b)" ) ) ,
28- "source map should include source contents" ,
29- ) ;
22+ const map = JSON . parse ( await fs . readFile ( mapPath , "utf8" ) ) ;
23+ assert . equal ( map . version , 3 ) ;
24+ assert . equal ( map . file , filename ) ;
25+ assert . ok ( map . mappings . length > 0 , `${ filename } .map should include mappings` ) ;
26+ assert . ok (
27+ map . sources . some ( source => source . endsWith ( "Demo.res" ) ) ,
28+ `${ filename } .map should include Demo.res, got ${ map . sources . join ( ", " ) } ` ,
29+ ) ;
30+ assert . ok (
31+ map . sourcesContent . some ( content => content . includes ( "let add = (a, b)" ) ) ,
32+ `${ filename } .map should include source contents` ,
33+ ) ;
34+ }
3035
3136await execClean ( ) ;
0 commit comments