From 3f68fa0f1196ea2495ad9c3ae0c392f648b2d7fc Mon Sep 17 00:00:00 2001 From: "sunny.luo" Date: Tue, 19 Nov 2024 23:26:48 +0800 Subject: [PATCH] compose sourcemap --- .npmrc | 1 + bun.lockb | Bin 152235 -> 152235 bytes package.json | 2 +- src/bundle.js | 26 ++++++++++++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..e4a4fff --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +registry = "https://registry.npmjs.org" \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index 5d1a07d3e3ef1f3eb2b93d9189c05c58cd1b950e..e3f99af9023f0a58dd9ee11bbd7ef69a36986847 100755 GIT binary patch delta 25 hcmZ3zlymh`&W0_F3+J*k#+m3D=oxNbF_)2fD*%6(2{Hfx delta 25 ecmZ3zlymh`&W0_F3+J*kF@VAL6>}Mxw*mliz6az0 diff --git a/package.json b/package.json index a8f9856..5042b68 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-update-cli", - "version": "1.32.3", + "version": "1.33.0", "description": "Command tools for javaScript updater with `pushy` service for react native apps.", "main": "index.js", "bin": { diff --git a/src/bundle.js b/src/bundle.js index b8c60e1..1d9e12c 100644 --- a/src/bundle.js +++ b/src/bundle.js @@ -226,6 +226,10 @@ async function compileHermesByteCode( '-O', ]; if (sourcemapOutput) { + fs.copyFileSync( + sourcemapOutput, + path.join(outputFolder, bundleName + '.txt.map'), + ); args.push('-output-source-map'); } console.log( @@ -234,6 +238,28 @@ async function compileHermesByteCode( spawnSync(hermesCommand, args, { stdio: 'ignore', }); + if (sourcemapOutput) { + const composerPath = + 'node_modules/react-native/scripts/compose-source-maps.js'; + if (!fs.existsSync(composerPath)) { + return; + } + console.log(`Composing source map`); + spawnSync( + 'node', + [ + composerPath, + path.join(outputFolder, bundleName + '.txt.map'), + path.join(outputFolder, bundleName + '.map'), + '-o', + sourcemapOutput, + ], + { + stdio: 'ignore', + }, + ); + } + fs.removeSync(path.join(outputFolder, bundleName + '.txt.map')); } async function pack(dir, output) {