@@ -747,6 +747,29 @@ describe('Loader hooks', { concurrency: true }, () => {
747
747
assert . strictEqual ( signal , null ) ;
748
748
} ) ;
749
749
750
+ it ( 'should support source maps in commonjs translator' , async ( ) => {
751
+ const readFile = async ( ) => { } ;
752
+ const { code, signal, stdout, stderr } = await spawnPromisified ( execPath , [
753
+ '--no-warnings' ,
754
+ '--enable-source-maps' ,
755
+ '--experimental-loader' ,
756
+ `data:text/javascript,import{readFile}from"node:fs/promises";export ${
757
+ async function load ( u , c , n ) {
758
+ const r = await n ( u , c ) ;
759
+ if ( c . format === 'commonjs' ) {
760
+ r . source = await readFile ( new URL ( u ) ) ;
761
+ }
762
+ return r ;
763
+ } } `,
764
+ fixtures . path ( 'source-map/throw-on-require.js' ) ,
765
+ ] ) ;
766
+
767
+ assert . strictEqual ( stdout , '' ) ;
768
+ assert . match ( stderr , / t h r o w - o n - r e q u i r e \. t s : 9 : 9 / ) ;
769
+ assert . strictEqual ( code , 1 ) ;
770
+ assert . strictEqual ( signal , null ) ;
771
+ } ) ;
772
+
750
773
it ( 'should handle mixed of opt-in modules and non-opt-in ones' , async ( ) => {
751
774
const { code, signal, stdout, stderr } = await spawnPromisified ( execPath , [
752
775
'--no-warnings' ,
0 commit comments