From 7c20b30c85d288818dd33aa84be6cb550d4e0adb Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Sat, 3 Feb 2024 21:27:47 +0800 Subject: [PATCH] feat: support expo --- src/bundle.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/bundle.js b/src/bundle.js index e89c014..e312ab2 100644 --- a/src/bundle.js +++ b/src/bundle.js @@ -49,11 +49,21 @@ async function runReactNativeBundleCommand( fs.emptyDirSync(outputFolder); - Array.prototype.push.apply(reactNativeBundleArgs, [ - require.resolve('react-native/local-cli/cli.js', { + let cliPath = require.resolve('react-native/local-cli/cli.js', { + paths: [process.cwd()], + }); + try { + cliPath = require.resolve('@expo/cli', { paths: [process.cwd()], - }), // 'react-native' package may be symlinked - 'bundle', + }); + } catch (e) {} + const bundleCommand = cliPath.includes('@expo/cli') + ? 'export:embed' + : 'bundle'; + + Array.prototype.push.apply(reactNativeBundleArgs, [ + cliPath, + bundleCommand, '--assets-dest', outputFolder, '--bundle-output', @@ -204,7 +214,10 @@ async function compileHermesByteCode( if (sourcemapOutput) { args.push('-output-source-map'); } - spawnSync(path.join.apply(null, hermesCommand.split('/')), args, { + console.log( + 'Running hermesc: ' + hermesCommand + ' ' + args.join(' ') + '\n', + ); + spawnSync(hermesCommand, args, { stdio: 'ignore', }); }