@@ -359,7 +359,7 @@ function transformServerModule(
359
359
lastMappedLine ++ ;
360
360
}
361
361
362
- sourceLineCount = program . loc . end . line - 1 ;
362
+ sourceLineCount = program . loc . end . line ;
363
363
if ( sourceLineCount < lastMappedLine ) {
364
364
throw new Error (
365
365
'The source map has more mappings than there are lines.' ,
@@ -374,13 +374,43 @@ function transformServerModule(
374
374
) {
375
375
mappings += ';' ;
376
376
}
377
+ } else {
378
+ // If a file doesn't have a source map then we generate a blank source map that just
379
+ // contains the original content and segments pointing to the original lines.
380
+ sourceLineCount = 1 ;
381
+ let idx = - 1 ;
382
+ while ( ( idx = source . indexOf ( '\n' , idx + 1 ) ) !== - 1 ) {
383
+ sourceLineCount ++ ;
384
+ }
385
+ mappings = 'AAAA' + ';AACA' . repeat ( sourceLineCount - 1 ) ;
386
+ sourceMap = {
387
+ version : 3 ,
388
+ sources : [ url ] ,
389
+ sourcesContent : [ source ] ,
390
+ mappings : mappings ,
391
+ sourceRoot : '' ,
392
+ } ;
393
+ lastSourceIndex = 0 ;
394
+ lastOriginalLine = sourceLineCount ;
395
+ lastOriginalColumn = 0 ;
396
+ lastNameIndex = - 1 ;
397
+ lastMappedLine = sourceLineCount ;
398
+
399
+ for ( let i = 0 ; i < exportedEntries . length ; i ++ ) {
400
+ // Point each entry to original location.
401
+ const entry = exportedEntries [ i ] ;
402
+ entry . originalSource = 0 ;
403
+ entry . originalLine = entry . loc . start . line ;
404
+ // We use column zero since we do the short-hand line-only source maps above.
405
+ entry . originalColumn = 0 ; // entry.loc.start.column;
406
+ }
377
407
}
378
408
379
409
newSrc += '\n\n;' ;
380
410
newSrc +=
381
411
'import {registerServerReference} from "react-server-dom-webpack/server";\n' ;
382
412
if ( mappings ) {
383
- mappings += ';;; ' ;
413
+ mappings += ';;' ;
384
414
}
385
415
386
416
const createMapping = createMappingsSerializer ( ) ;
@@ -417,7 +447,7 @@ function transformServerModule(
417
447
}
418
448
}
419
449
420
- if ( sourceMap && mappings ) {
450
+ if ( sourceMap ) {
421
451
// Override with an new mappings and serialize an inline source map.
422
452
sourceMap . mappings = mappings ;
423
453
newSrc +=
0 commit comments