diff --git a/cli.json b/cli.json index e5dca43..5888a38 100644 --- a/cli.json +++ b/cli.json @@ -213,7 +213,7 @@ "rncli": { "default": false }, - "disableHermes": { + "hermes": { "default": false }, "name": { diff --git a/src/bundle.ts b/src/bundle.ts index 22d6218..8cf954e 100644 --- a/src/bundle.ts +++ b/src/bundle.ts @@ -42,7 +42,7 @@ async function runReactNativeBundleCommand({ platform, sourcemapOutput, config, - disableHermes, + forceHermes, cli, }: { bundleName: string; @@ -52,7 +52,7 @@ async function runReactNativeBundleCommand({ platform: string; sourcemapOutput: string; config?: string; - disableHermes?: boolean; + forceHermes?: boolean; cli: { taro?: boolean; expo?: boolean; @@ -163,16 +163,21 @@ async function runReactNativeBundleCommand({ bundleCommand = 'build'; } + if (platform === 'harmony') { + bundleName = 'harmony.bundle.js'; + if (forceHermes === undefined) { + // enable hermes by default for harmony + forceHermes = true; + } + } + reactNativeBundleArgs.push( cliPath, bundleCommand, '--assets-dest', outputFolder, '--bundle-output', - path.join( - outputFolder, - platform === 'harmony' ? 'harmony.bundle.js' : bundleName, - ), + path.join(outputFolder, bundleName), ); if (platform !== 'harmony') { @@ -213,9 +218,9 @@ async function runReactNativeBundleCommand({ } else { let hermesEnabled: boolean | undefined = false; - if (disableHermes) { - hermesEnabled = false; - console.log(t('hermesDisabled')); + if (forceHermes) { + hermesEnabled = true; + console.log(t('forceHermes')); } else if (platform === 'android') { const gradlePropeties = await new Promise<{ hermesEnabled?: boolean; @@ -445,7 +450,12 @@ async function uploadSourcemapForSentry( } } -const ignorePackingFileNames = ['.', '..', 'index.bundlejs.map']; +const ignorePackingFileNames = [ + '.', + '..', + 'index.bundlejs.map', + 'harmony.bundle.js.map', +]; const ignorePackingExtensions = ['DS_Store', 'txt.map']; async function pack(dir: string, output: string) { console.log(t('packing')); @@ -886,7 +896,7 @@ export const bundleCommands = { taro, expo, rncli, - disableHermes, + hermes, name, description, metaInfo, @@ -927,7 +937,7 @@ export const bundleCommands = { outputFolder: intermediaDir, platform, sourcemapOutput: sourcemap || sourcemapPlugin ? sourcemapOutput : '', - disableHermes: !!disableHermes, + forceHermes: hermes as unknown as boolean, cli: { taro: !!taro, expo: !!expo, diff --git a/src/locales/en.ts b/src/locales/en.ts index 844e7b1..994edc1 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -49,7 +49,7 @@ export default { fileGenerated: '{{- file}} generated.', fileSizeExceeded: 'This file size is {{fileSize}} , exceeding the current quota {{maxSize}} . You may consider upgrading to a higher plan to increase this quota. Details can be found at: {{- pricingPageUrl}}', - hermesDisabled: 'Hermes disabled', + forceHermes: 'Forcing Hermes enabled for this build', hermesEnabledCompiling: 'Hermes enabled, now compiling to hermes bytecode:\n', ipaUploadSuccess: 'Successfully uploaded IPA native package (id: {{id}}, version: {{version}}, buildTime: {{buildTime}})', diff --git a/src/locales/zh.ts b/src/locales/zh.ts index a14024a..d8e00be 100644 --- a/src/locales/zh.ts +++ b/src/locales/zh.ts @@ -47,7 +47,7 @@ export default { fileGenerated: '已生成 {{- file}}', fileSizeExceeded: '此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{- pricingPageUrl}}', - hermesDisabled: 'Hermes 已禁用', + forceHermes: '强制启用 Hermes 编译', hermesEnabledCompiling: 'Hermes 已启用,正在编译为 hermes 字节码:\n', ipaUploadSuccess: '已成功上传ipa原生包(id: {{id}}, version: {{version}}, buildTime: {{buildTime}})', diff --git a/src/modules/bundle-module.ts b/src/modules/bundle-module.ts index 930f9dd..269b6ee 100644 --- a/src/modules/bundle-module.ts +++ b/src/modules/bundle-module.ts @@ -53,7 +53,7 @@ export const bundleModule: CLIModule = { taro = false, expo = false, rncli = false, - disableHermes = false, + hermes = false, output, } = context.options; @@ -73,7 +73,7 @@ export const bundleModule: CLIModule = { taro, expo, rncli, - disableHermes, + hermes, intermediaDir: '${tempDir}/intermedia/${platform}', output: '${tempDir}/output/${platform}.${time}.ppk', }; @@ -170,10 +170,10 @@ export const bundleModule: CLIModule = { default: false, description: 'Use React Native CLI', }, - disableHermes: { + hermes: { hasValue: false, default: false, - description: 'Disable Hermes', + description: 'Force enable Hermes', }, name: { hasValue: true, diff --git a/src/provider.ts b/src/provider.ts index 14b29c0..8f735cf 100644 --- a/src/provider.ts +++ b/src/provider.ts @@ -42,7 +42,7 @@ export class CLIProviderImpl implements CLIProvider { taro: options.taro || false, expo: options.expo || false, rncli: options.rncli || false, - disableHermes: options.disableHermes || false, + hermes: options.hermes || false, }, }; diff --git a/src/types.ts b/src/types.ts index 339f1cb..7830678 100644 --- a/src/types.ts +++ b/src/types.ts @@ -65,7 +65,7 @@ export interface BundleOptions { taro?: boolean; expo?: boolean; rncli?: boolean; - disableHermes?: boolean; + hermes?: boolean; } export interface PublishOptions {