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

Compare commits

..

2 Commits

Author SHA1 Message Date
sunnylqm
f9adc700ed v1.11.0 2023-01-11 23:36:13 +08:00
sunnylqm
dcff16cbb5 support source-map 2023-01-11 23:35:39 +08:00
3 changed files with 30 additions and 20 deletions

View File

@@ -140,7 +140,9 @@
"default": ".pushy/output/${platform}.${time}.ppk", "default": ".pushy/output/${platform}.${time}.ppk",
"hasValue": true "hasValue": true
}, },
"verbose": {} "sourcemap": {
"default": false
}
} }
}, },
"release": { "release": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "react-native-update-cli", "name": "react-native-update-cli",
"version": "1.10.0", "version": "1.11.0",
"description": "Command tools for javaScript updater with `pushy` service for react native apps.", "description": "Command tools for javaScript updater with `pushy` service for react native apps.",
"main": "index.js", "main": "index.js",
"bin": { "bin": {

View File

@@ -48,7 +48,6 @@ async function runReactNativeBundleCommand(
fs.emptyDirSync(outputFolder); fs.emptyDirSync(outputFolder);
// TODO sourcemap
Array.prototype.push.apply(reactNativeBundleArgs, [ Array.prototype.push.apply(reactNativeBundleArgs, [
path.join('node_modules', 'react-native', 'local-cli', 'cli.js'), path.join('node_modules', 'react-native', 'local-cli', 'cli.js'),
'bundle', 'bundle',
@@ -99,7 +98,11 @@ async function runReactNativeBundleCommand(
(platform === 'android' && gradleConfig.enableHermes) || (platform === 'android' && gradleConfig.enableHermes) ||
(platform === 'ios' && fs.existsSync('ios/Pods/hermes-engine')) (platform === 'ios' && fs.existsSync('ios/Pods/hermes-engine'))
) { ) {
await compileHermesByteCode(bundleName, outputFolder); await compileHermesByteCode(
bundleName,
outputFolder,
sourcemapOutput,
);
} }
resolve(null); resolve(null);
} }
@@ -136,7 +139,11 @@ async function checkGradleConfig() {
}; };
} }
async function compileHermesByteCode(bundleName, outputFolder) { async function compileHermesByteCode(
bundleName,
outputFolder,
sourcemapOutput,
) {
console.log(`Hermes enabled, now compiling to hermes bytecode:\n`); console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
// >= rn 0.69 // >= rn 0.69
let hermesCommand = `node_modules/react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`; let hermesCommand = `node_modules/react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`;
@@ -151,19 +158,19 @@ async function compileHermesByteCode(bundleName, outputFolder) {
? `${hermesPath}/hermesc` // 0.5+ ? `${hermesPath}/hermesc` // 0.5+
: `${hermesPath}/hermes`; // < 0.5 : `${hermesPath}/hermes`; // < 0.5
} }
const args = [
// TODO sourcemap
spawnSync(
path.join.apply(null, hermesCommand.split('/')),
[
'-emit-binary', '-emit-binary',
'-out', '-out',
path.join(outputFolder, bundleName), path.join(outputFolder, bundleName),
path.join(outputFolder, bundleName), path.join(outputFolder, bundleName),
'-O', '-O',
], ];
{ stdio: 'ignore' }, if (sourcemapOutput) {
); args.push('-output-source-map');
}
spawnSync(path.join.apply(null, hermesCommand.split('/')), args, {
stdio: 'ignore',
});
} }
async function pack(dir, output) { async function pack(dir, output) {
@@ -524,13 +531,13 @@ export const commands = {
options.platform || (await question('平台(ios/android):')), options.platform || (await question('平台(ios/android):')),
); );
let { bundleName, entryFile, intermediaDir, output, dev, verbose } = let { bundleName, entryFile, intermediaDir, output, dev, sourcemap } =
translateOptions({ translateOptions({
...options, ...options,
platform, platform,
}); });
// const sourcemapOutput = path.join(intermediaDir, bundleName + ".map"); const sourcemapOutput = path.join(intermediaDir, bundleName + '.map');
const realOutput = output.replace(/\$\{time\}/g, '' + Date.now()); const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
@@ -549,6 +556,7 @@ export const commands = {
entryFile, entryFile,
intermediaDir, intermediaDir,
platform, platform,
sourcemap ? sourcemapOutput : '',
); );
await pack(path.resolve(intermediaDir), realOutput); await pack(path.resolve(intermediaDir), realOutput);