@@ -20,7 +20,7 @@ import {
2020} from './utils/hermes-base' ;
2121import { t } from './utils/i18n' ;
2222import { getBooleanOption , getStringListOption } from './utils/options' ;
23- import { slimSourceMap } from './utils/slim-sourcemap' ;
23+ import { packSourceMap } from './utils/slim-sourcemap' ;
2424import {
2525 bundleLocationFields ,
2626 readZipEntryWithLocation ,
@@ -546,25 +546,23 @@ export const versionCommands = {
546546 if ( ! sourcemapPath ) {
547547 console . log ( chalk . yellow ( t ( 'sourceMapMissingWarning' ) ) ) ;
548548 }
549- // Archive a slimmed copy: relative paths, no dependency sourcesContent
550- // (see slimSourceMap). Frames keep symbolicating everywhere; only inline
551- // snippets of node_modules code are dropped, and the map shrinks by the
552- // bulk of its bytes. If the file is not a plain map, upload it untouched.
549+ // Archive a slimmed, gzipped copy (see packSourceMap): relative paths, no
550+ // dependency sourcesContent, ~5x smaller on the wire. Frames keep
551+ // symbolicating everywhere; only inline snippets of node_modules code are
552+ // dropped. The temp file keeps the .map extension because /upload routes
553+ // by extension; readers detect gzip by magic bytes.
553554 let uploadSourcemapPath = sourcemapPath ;
554- let slimTempDir : string | undefined ;
555+ let packTempDir : string | undefined ;
555556 if ( sourcemapPath ) {
556- const slimmed = slimSourceMap (
557- fs . readFileSync ( sourcemapPath , 'utf8' ) ,
558- process . cwd ( ) ,
557+ packTempDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'rnu-sourcemap-' ) ) ;
558+ uploadSourcemapPath = path . join (
559+ packTempDir ,
560+ path . basename ( sourcemapPath ) ,
561+ ) ;
562+ fs . writeFileSync (
563+ uploadSourcemapPath ,
564+ packSourceMap ( fs . readFileSync ( sourcemapPath , 'utf8' ) , process . cwd ( ) ) ,
559565 ) ;
560- if ( slimmed !== null ) {
561- slimTempDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'rnu-sourcemap-' ) ) ;
562- uploadSourcemapPath = path . join (
563- slimTempDir ,
564- path . basename ( sourcemapPath ) ,
565- ) ;
566- fs . writeFileSync ( uploadSourcemapPath , slimmed ) ;
567- }
568566 }
569567
570568 // Hashing/caching the bundle and asking git for the commit are independent
@@ -588,8 +586,8 @@ export const versionCommands = {
588586 )
589587 : Promise . resolve ( undefined ) ,
590588 ] ) ;
591- if ( slimTempDir ) {
592- fs . rmSync ( slimTempDir , { recursive : true , force : true } ) ;
589+ if ( packTempDir ) {
590+ fs . rmSync ( packTempDir , { recursive : true , force : true } ) ;
593591 }
594592 const sourceMapKey = sourceMapUpload ?. hash ;
595593 if ( sourcemapPath && ! sourceMapKey ) {
0 commit comments