1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-11-08 10:15:47 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

compose sourcemap

This commit is contained in:
sunny.luo
2024-11-19 23:26:48 +08:00
parent fa750ba157
commit 3f68fa0f11
4 changed files with 28 additions and 1 deletions

View File

@@ -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) {