From ab192ced6938e647819eaaed983158a1feb3ff81 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Wed, 10 Jan 2024 09:58:46 -0800 Subject: [PATCH] Fix `compose-source-maps.js` not outputting composed source map (#42203) Summary: `compose-source-maps.js` fails if `-o` is not specified when it should output the composed source map. ## Changelog: [GENERAL] [FIXED] - Fix `compose-source-maps.js` failing if `-o` is not specified when it should output the composed source map Pull Request resolved: https://github.com/facebook/react-native/pull/42203 Test Plan: Tested this in an internal repo. This was the output before this fix: ``` % node node_modules/react-native/scripts/compose-source-maps.js dist/main.jsbundle.map dist/main.jsbundle.hbc.map node:internal/streams/writable:472 throw new ERR_INVALID_ARG_TYPE( ^ TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received undefined at _write (node:internal/streams/writable:472:13) at Writable.write (node:internal/streams/writable:494:10) at Object. (/~/node_modules/.store/react-native-virtual-c8e66dddc1/node_modules/react-native/scripts/compose-source-maps.js:64:20) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49 { code: 'ERR_INVALID_ARG_TYPE' } Node.js v20.10.0 ``` Reviewed By: christophpurrer Differential Revision: D52650438 Pulled By: arushikesarwani94 fbshipit-source-id: b8f8f01fb6d843887d874a7283a1a6807c7762e7 --- packages/react-native/scripts/compose-source-maps.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/scripts/compose-source-maps.js b/packages/react-native/scripts/compose-source-maps.js index be908e97755..db9ae1aa5ed 100755 --- a/packages/react-native/scripts/compose-source-maps.js +++ b/packages/react-native/scripts/compose-source-maps.js @@ -61,6 +61,6 @@ if (!argv.length) { if (outputPath) { fs.writeFileSync(outputPath, composedMapJSON, 'utf8'); } else { - process.stdout.write(); + process.stdout.write(composedMapJSON); } }