@@ -27,8 +27,8 @@ import { I18nOptions } from './i18n-options';
27
27
const cacache = require ( 'cacache' ) ;
28
28
const deserialize = ( ( v8 as unknown ) as { deserialize ( buffer : Buffer ) : unknown } ) . deserialize ;
29
29
30
- // If code size is larger than 500KB , consider lower fidelity but faster sourcemap merge
31
- const FAST_SOURCEMAP_THRESHOLD = 500 * 1024 ;
30
+ // If code size is larger than 1MB , consider lower fidelity but faster sourcemap merge
31
+ const FAST_SOURCEMAP_THRESHOLD = 1024 * 1024 ;
32
32
33
33
export interface ProcessBundleOptions {
34
34
filename : string ;
@@ -255,6 +255,25 @@ async function mergeSourceMapsFast(first: RawSourceMap, second: RawSourceMap) {
255
255
map . file = second . file ;
256
256
map . sourceRoot = sourceRoot ;
257
257
258
+ // Add source content if present
259
+ if ( first . sourcesContent ) {
260
+ // Source content array is based on index of sources
261
+ const sourceContentMap = new Map < string , number > ( ) ;
262
+ for ( let i = 0 ; i < first . sources . length ; i ++ ) {
263
+ // make paths "absolute" so they can be compared (`./a.js` and `a.js` are equivalent)
264
+ sourceContentMap . set ( path . resolve ( '/' , first . sources [ i ] ) , i ) ;
265
+ }
266
+ map . sourcesContent = [ ] ;
267
+ for ( let i = 0 ; i < map . sources . length ; i ++ ) {
268
+ const contentIndex = sourceContentMap . get ( path . resolve ( '/' , map . sources [ i ] ) ) ;
269
+ if ( contentIndex === undefined ) {
270
+ map . sourcesContent . push ( '' ) ;
271
+ } else {
272
+ map . sourcesContent . push ( first . sourcesContent [ contentIndex ] ) ;
273
+ }
274
+ }
275
+ }
276
+
258
277
// Put the sourceRoot back
259
278
if ( sourceRoot ) {
260
279
first . sourceRoot = sourceRoot ;
0 commit comments