Skip to content

Commit f8edbb8

Browse files
committed
Refactor Hermes option handling in CLI and bundle commands; rename 'disableHermes' to 'hermes' for clarity and update related logic in bundle.ts and provider.ts.
1 parent 15c8052 commit f8edbb8

File tree

7 files changed

+31
-21
lines changed

7 files changed

+31
-21
lines changed

cli.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
"rncli": {
214214
"default": false
215215
},
216-
"disableHermes": {
216+
"hermes": {
217217
"default": false
218218
},
219219
"name": {

src/bundle.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async function runReactNativeBundleCommand({
4242
platform,
4343
sourcemapOutput,
4444
config,
45-
disableHermes,
45+
forceHermes,
4646
cli,
4747
}: {
4848
bundleName: string;
@@ -52,7 +52,7 @@ async function runReactNativeBundleCommand({
5252
platform: string;
5353
sourcemapOutput: string;
5454
config?: string;
55-
disableHermes?: boolean;
55+
forceHermes?: boolean;
5656
cli: {
5757
taro?: boolean;
5858
expo?: boolean;
@@ -163,16 +163,21 @@ async function runReactNativeBundleCommand({
163163
bundleCommand = 'build';
164164
}
165165

166+
if (platform === 'harmony') {
167+
bundleName = 'harmony.bundle.js';
168+
if (forceHermes === undefined) {
169+
// enable hermes by default for harmony
170+
forceHermes = true;
171+
}
172+
}
173+
166174
reactNativeBundleArgs.push(
167175
cliPath,
168176
bundleCommand,
169177
'--assets-dest',
170178
outputFolder,
171179
'--bundle-output',
172-
path.join(
173-
outputFolder,
174-
platform === 'harmony' ? 'harmony.bundle.js' : bundleName,
175-
),
180+
path.join(outputFolder, bundleName),
176181
);
177182

178183
if (platform !== 'harmony') {
@@ -213,9 +218,9 @@ async function runReactNativeBundleCommand({
213218
} else {
214219
let hermesEnabled: boolean | undefined = false;
215220

216-
if (disableHermes) {
217-
hermesEnabled = false;
218-
console.log(t('hermesDisabled'));
221+
if (forceHermes) {
222+
hermesEnabled = true;
223+
console.log(t('forceHermes'));
219224
} else if (platform === 'android') {
220225
const gradlePropeties = await new Promise<{
221226
hermesEnabled?: boolean;
@@ -445,7 +450,12 @@ async function uploadSourcemapForSentry(
445450
}
446451
}
447452

448-
const ignorePackingFileNames = ['.', '..', 'index.bundlejs.map'];
453+
const ignorePackingFileNames = [
454+
'.',
455+
'..',
456+
'index.bundlejs.map',
457+
'harmony.bundle.js.map',
458+
];
449459
const ignorePackingExtensions = ['DS_Store', 'txt.map'];
450460
async function pack(dir: string, output: string) {
451461
console.log(t('packing'));
@@ -886,7 +896,7 @@ export const bundleCommands = {
886896
taro,
887897
expo,
888898
rncli,
889-
disableHermes,
899+
hermes,
890900
name,
891901
description,
892902
metaInfo,
@@ -927,7 +937,7 @@ export const bundleCommands = {
927937
outputFolder: intermediaDir,
928938
platform,
929939
sourcemapOutput: sourcemap || sourcemapPlugin ? sourcemapOutput : '',
930-
disableHermes: !!disableHermes,
940+
forceHermes: hermes as unknown as boolean,
931941
cli: {
932942
taro: !!taro,
933943
expo: !!expo,

src/locales/en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default {
4949
fileGenerated: '{{- file}} generated.',
5050
fileSizeExceeded:
5151
'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}}',
52-
hermesDisabled: 'Hermes disabled',
52+
forceHermes: 'Forcing Hermes enabled for this build',
5353
hermesEnabledCompiling: 'Hermes enabled, now compiling to hermes bytecode:\n',
5454
ipaUploadSuccess:
5555
'Successfully uploaded IPA native package (id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',

src/locales/zh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default {
4747
fileGenerated: '已生成 {{- file}}',
4848
fileSizeExceeded:
4949
'此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{- pricingPageUrl}}',
50-
hermesDisabled: 'Hermes 已禁用',
50+
forceHermes: '强制启用 Hermes 编译',
5151
hermesEnabledCompiling: 'Hermes 已启用,正在编译为 hermes 字节码:\n',
5252
ipaUploadSuccess:
5353
'已成功上传ipa原生包(id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',

src/modules/bundle-module.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const bundleModule: CLIModule = {
5353
taro = false,
5454
expo = false,
5555
rncli = false,
56-
disableHermes = false,
56+
hermes = false,
5757
output,
5858
} = context.options;
5959

@@ -73,7 +73,7 @@ export const bundleModule: CLIModule = {
7373
taro,
7474
expo,
7575
rncli,
76-
disableHermes,
76+
hermes,
7777
intermediaDir: '${tempDir}/intermedia/${platform}',
7878
output: '${tempDir}/output/${platform}.${time}.ppk',
7979
};
@@ -170,10 +170,10 @@ export const bundleModule: CLIModule = {
170170
default: false,
171171
description: 'Use React Native CLI',
172172
},
173-
disableHermes: {
173+
hermes: {
174174
hasValue: false,
175175
default: false,
176-
description: 'Disable Hermes',
176+
description: 'Force enable Hermes',
177177
},
178178
name: {
179179
hasValue: true,

src/provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class CLIProviderImpl implements CLIProvider {
4242
taro: options.taro || false,
4343
expo: options.expo || false,
4444
rncli: options.rncli || false,
45-
disableHermes: options.disableHermes || false,
45+
hermes: options.hermes || false,
4646
},
4747
};
4848

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export interface BundleOptions {
6565
taro?: boolean;
6666
expo?: boolean;
6767
rncli?: boolean;
68-
disableHermes?: boolean;
68+
hermes?: boolean;
6969
}
7070

7171
export interface PublishOptions {

0 commit comments

Comments
 (0)