react-native-update-cli 2.22.7 → 2.22.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/cli.json +5 -0
- package/lib/api.d.ts +7 -0
- package/lib/api.js +106 -38
- package/lib/app.js +3 -2
- package/lib/bin.js +16 -2
- package/lib/bundle-runner.d.ts +11 -4
- package/lib/bundle-runner.js +176 -90
- package/lib/bundle.d.ts +1 -0
- package/lib/bundle.js +2 -0
- package/lib/diff.d.ts +9 -0
- package/lib/diff.js +162 -120
- package/lib/locales/en.d.ts +1 -0
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.d.ts +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/native-package.d.ts +5 -1
- package/lib/native-package.js +145 -84
- package/lib/package.d.ts +7 -3
- package/lib/package.js +22 -12
- package/lib/types.d.ts +2 -0
- package/lib/utils/dep-versions.d.ts +7 -0
- package/lib/utils/dep-versions.js +66 -31
- package/lib/utils/hbcTransform.d.ts +21 -0
- package/lib/utils/hbcTransform.js +146 -5
- package/lib/utils/hermes-base.d.ts +21 -4
- package/lib/utils/hermes-base.js +146 -37
- package/lib/utils/http-helper.d.ts +6 -1
- package/lib/utils/http-helper.js +23 -11
- package/lib/utils/index.d.ts +30 -1
- package/lib/utils/index.js +98 -24
- package/lib/utils/latest-version/index.d.ts +11 -8
- package/lib/utils/latest-version/index.js +91 -25
- package/lib/utils/zip-entries.js +20 -15
- package/lib/utils/zip-options.d.ts +2 -0
- package/lib/utils/zip-options.js +9 -4
- package/lib/utils/zip-range.d.ts +47 -15
- package/lib/utils/zip-range.js +192 -83
- package/lib/utils/zip-raw-writer.d.ts +47 -0
- package/lib/utils/zip-raw-writer.js +204 -0
- package/lib/versions.js +19 -9
- package/package.json +10 -12
- package/src/api.ts +126 -46
- package/src/app.ts +3 -2
- package/src/bin.ts +17 -2
- package/src/bundle-runner.ts +225 -113
- package/src/bundle.ts +3 -0
- package/src/diff.ts +210 -153
- package/src/locales/en.ts +2 -0
- package/src/locales/zh.ts +2 -0
- package/src/native-package.ts +186 -96
- package/src/package.ts +26 -13
- package/src/types.ts +2 -0
- package/src/utils/dep-versions.ts +76 -33
- package/src/utils/hbcTransform.ts +194 -5
- package/src/utils/hermes-base.ts +156 -45
- package/src/utils/http-helper.ts +24 -13
- package/src/utils/index.ts +136 -26
- package/src/utils/latest-version/index.ts +109 -33
- package/src/utils/zip-entries.ts +18 -16
- package/src/utils/zip-options.ts +8 -3
- package/src/utils/zip-range.ts +244 -88
- package/src/utils/zip-raw-writer.ts +247 -0
- package/src/versions.ts +17 -7
package/src/bundle-runner.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spawn
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
2
|
import { satisfies } from 'compare-versions';
|
|
3
3
|
import * as fs from 'fs-extra';
|
|
4
4
|
import os from 'os';
|
|
@@ -40,6 +40,8 @@ export interface RunBundleCommandOptions {
|
|
|
40
40
|
forceHermes?: boolean;
|
|
41
41
|
/** Hermes -base-bytecode settings; omitted → compile without a base */
|
|
42
42
|
hermesBase?: HermesBaseRequest;
|
|
43
|
+
/** pass --reset-cache to Metro (default true); false reuses its transform cache */
|
|
44
|
+
resetCache?: boolean;
|
|
43
45
|
cli: BundleCliOptions;
|
|
44
46
|
isSentry: boolean;
|
|
45
47
|
}
|
|
@@ -64,6 +66,8 @@ export interface HermesBaseSelectionResult {
|
|
|
64
66
|
bytecodeVersion: number | null;
|
|
65
67
|
/** messages to print when the compile phase starts (kept out of Metro's output) */
|
|
66
68
|
logs: string[];
|
|
69
|
+
/** the hermesc the selection was made with (the compile reuses it) */
|
|
70
|
+
hermesCommand?: string;
|
|
67
71
|
/** hermesc could not be resolved; the compile phase will report it */
|
|
68
72
|
commandUnavailable?: boolean;
|
|
69
73
|
}
|
|
@@ -207,6 +211,7 @@ export async function runReactNativeBundleCommand({
|
|
|
207
211
|
config,
|
|
208
212
|
forceHermes,
|
|
209
213
|
hermesBase,
|
|
214
|
+
resetCache = true,
|
|
210
215
|
cli,
|
|
211
216
|
isSentry,
|
|
212
217
|
}: RunBundleCommandOptions): Promise<HermesCompileResult | null> {
|
|
@@ -312,7 +317,8 @@ export async function runReactNativeBundleCommand({
|
|
|
312
317
|
);
|
|
313
318
|
|
|
314
319
|
if (platform !== 'harmony') {
|
|
315
|
-
reactNativeBundleArgs.push('--platform', platform
|
|
320
|
+
reactNativeBundleArgs.push('--platform', platform);
|
|
321
|
+
if (resetCache) reactNativeBundleArgs.push('--reset-cache');
|
|
316
322
|
}
|
|
317
323
|
|
|
318
324
|
if (cli.taro) {
|
|
@@ -336,16 +342,18 @@ export async function runReactNativeBundleCommand({
|
|
|
336
342
|
forceHermes,
|
|
337
343
|
gradleConfig,
|
|
338
344
|
);
|
|
339
|
-
const pendingBase =
|
|
340
|
-
hermesEnabled && hermesBase
|
|
341
|
-
? startHermesBaseSelection(hermesBase)
|
|
342
|
-
: undefined;
|
|
343
345
|
|
|
344
346
|
const jsRuntime = getJavaScriptRuntime();
|
|
345
347
|
const reactNativeBundleProcess = spawnJavaScript(reactNativeBundleArgs);
|
|
346
348
|
console.log(
|
|
347
349
|
`Running bundle command: ${jsRuntime} ${reactNativeBundleArgs.join(' ')}`,
|
|
348
350
|
);
|
|
351
|
+
// Metro is running; the synchronous head of the selection (hermesc lookup,
|
|
352
|
+
// HBC version probe) now overlaps it instead of delaying its start.
|
|
353
|
+
const pendingBase =
|
|
354
|
+
hermesEnabled && hermesBase
|
|
355
|
+
? startHermesBaseSelection(hermesBase)
|
|
356
|
+
: undefined;
|
|
349
357
|
|
|
350
358
|
let hermesResult: HermesCompileResult | null = null;
|
|
351
359
|
await new Promise<void>((resolve, reject) => {
|
|
@@ -606,12 +614,16 @@ export function summarizeHermescStderr(stderr: string): string {
|
|
|
606
614
|
return (notWarnings.length > 0 ? notWarnings : kept).slice(-3).join(' ');
|
|
607
615
|
}
|
|
608
616
|
|
|
609
|
-
|
|
617
|
+
/** hermesc arguments writing `bundlePath` from `input` (in place by default) */
|
|
618
|
+
export function buildHermescArgs(
|
|
619
|
+
bundlePath: string,
|
|
620
|
+
input: string = bundlePath,
|
|
621
|
+
): string[] {
|
|
610
622
|
return [
|
|
611
623
|
'-emit-binary',
|
|
612
624
|
'-out',
|
|
613
625
|
bundlePath,
|
|
614
|
-
|
|
626
|
+
input,
|
|
615
627
|
'-O',
|
|
616
628
|
'-output-source-map',
|
|
617
629
|
];
|
|
@@ -624,6 +636,9 @@ interface ProcessOutcome {
|
|
|
624
636
|
error?: Error;
|
|
625
637
|
}
|
|
626
638
|
|
|
639
|
+
/** captured stderr is bounded to this much head and this much tail */
|
|
640
|
+
const STDERR_KEEP_BYTES = 512 * 1024;
|
|
641
|
+
|
|
627
642
|
/** spawn without blocking the event loop, so two hermesc runs can overlap */
|
|
628
643
|
function runProcess(
|
|
629
644
|
command: string,
|
|
@@ -634,8 +649,26 @@ function runProcess(
|
|
|
634
649
|
const child = spawn(command, args, {
|
|
635
650
|
stdio: ['ignore', 'ignore', captureStderr ? 'pipe' : 'ignore'],
|
|
636
651
|
});
|
|
637
|
-
|
|
638
|
-
|
|
652
|
+
// hermesc echoes whole (minified) source lines per diagnostic: keep the
|
|
653
|
+
// head and the tail, never an unbounded transcript
|
|
654
|
+
const head: Buffer[] = [];
|
|
655
|
+
const tail: Buffer[] = [];
|
|
656
|
+
let headBytes = 0;
|
|
657
|
+
let tailBytes = 0;
|
|
658
|
+
let dropped = false;
|
|
659
|
+
child.stderr?.on('data', (chunk: Buffer) => {
|
|
660
|
+
if (headBytes < STDERR_KEEP_BYTES) {
|
|
661
|
+
head.push(chunk);
|
|
662
|
+
headBytes += chunk.length;
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
tail.push(chunk);
|
|
666
|
+
tailBytes += chunk.length;
|
|
667
|
+
while (tail.length > 1 && tailBytes > STDERR_KEEP_BYTES) {
|
|
668
|
+
tailBytes -= (tail.shift() as Buffer).length;
|
|
669
|
+
dropped = true;
|
|
670
|
+
}
|
|
671
|
+
});
|
|
639
672
|
let settled = false;
|
|
640
673
|
const finish = (outcome: ProcessOutcome) => {
|
|
641
674
|
if (settled) return;
|
|
@@ -646,7 +679,14 @@ function runProcess(
|
|
|
646
679
|
finish({ status: null, signal: null, stderr: '', error }),
|
|
647
680
|
);
|
|
648
681
|
child.once('close', (status, signal) =>
|
|
649
|
-
finish({
|
|
682
|
+
finish({
|
|
683
|
+
status,
|
|
684
|
+
signal,
|
|
685
|
+
stderr:
|
|
686
|
+
Buffer.concat(head).toString() +
|
|
687
|
+
(dropped ? '\n[... output truncated ...]\n' : '') +
|
|
688
|
+
Buffer.concat(tail).toString(),
|
|
689
|
+
}),
|
|
650
690
|
);
|
|
651
691
|
});
|
|
652
692
|
}
|
|
@@ -657,12 +697,96 @@ export interface CompileHermesOptions {
|
|
|
657
697
|
sourcemapOutput: string;
|
|
658
698
|
shouldCleanSourcemap: boolean;
|
|
659
699
|
baseRequest?: HermesBaseRequest;
|
|
660
|
-
/** base selection started
|
|
700
|
+
/** base selection started alongside Metro (see startHermesBaseSelection) */
|
|
661
701
|
pendingBase?: Promise<HermesBaseSelectionResult>;
|
|
662
|
-
/** defaults to the project's
|
|
702
|
+
/** defaults to the hermesc the selection used, else the project's */
|
|
663
703
|
hermesCommand?: string;
|
|
664
704
|
}
|
|
665
705
|
|
|
706
|
+
/** how long the compile phase waits for a base that is still being fetched */
|
|
707
|
+
const HERMES_BASE_WAIT_MS = 60_000;
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* The selection runs while Metro bundles; when Metro is done first, wait a
|
|
711
|
+
* bounded time for it — a stalled download must never hold up the compile.
|
|
712
|
+
*/
|
|
713
|
+
async function awaitPendingBase(
|
|
714
|
+
pending: Promise<HermesBaseSelectionResult>,
|
|
715
|
+
): Promise<HermesBaseSelectionResult> {
|
|
716
|
+
const waitMs =
|
|
717
|
+
Number(process.env.PUSHY_HERMES_BASE_WAIT_MS) || HERMES_BASE_WAIT_MS;
|
|
718
|
+
let timer: NodeJS.Timeout | undefined;
|
|
719
|
+
const gaveUp = new Promise<HermesBaseSelectionResult>((resolve) => {
|
|
720
|
+
timer = setTimeout(
|
|
721
|
+
() =>
|
|
722
|
+
resolve({
|
|
723
|
+
base: null,
|
|
724
|
+
bytecodeVersion: null,
|
|
725
|
+
logs: [
|
|
726
|
+
t('hermesBaseNone', {
|
|
727
|
+
reason: `base not ready after ${Math.round(waitMs / 1000)}s`,
|
|
728
|
+
}),
|
|
729
|
+
],
|
|
730
|
+
}),
|
|
731
|
+
waitMs,
|
|
732
|
+
);
|
|
733
|
+
});
|
|
734
|
+
try {
|
|
735
|
+
return await Promise.race([pending, gaveUp]);
|
|
736
|
+
} finally {
|
|
737
|
+
clearTimeout(timer);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/** plain compile of `input` into `out`; throws when hermesc fails */
|
|
742
|
+
async function compilePlain(
|
|
743
|
+
hermesCommand: string,
|
|
744
|
+
out: string,
|
|
745
|
+
input: string = out,
|
|
746
|
+
): Promise<void> {
|
|
747
|
+
const args = buildHermescArgs(out, input);
|
|
748
|
+
console.log(
|
|
749
|
+
t('runningHermesc', { command: hermesCommand, args: args.join(' ') }),
|
|
750
|
+
);
|
|
751
|
+
assertSuccessfulSyncProcess(
|
|
752
|
+
await runProcess(hermesCommand, args, false),
|
|
753
|
+
hermesCommand,
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Merge the packager map with the hermes map into `sourcemapOutput` (which is
|
|
759
|
+
* normally the hermes map's own path). Resolves false when React Native's
|
|
760
|
+
* composer cannot be found; throws when it fails.
|
|
761
|
+
*/
|
|
762
|
+
async function composeSourceMaps(
|
|
763
|
+
packagerMap: string,
|
|
764
|
+
hermesMap: string,
|
|
765
|
+
sourcemapOutput: string,
|
|
766
|
+
): Promise<boolean> {
|
|
767
|
+
let composerPath: string;
|
|
768
|
+
try {
|
|
769
|
+
// resolve through the project so hoisted node_modules (monorepos) work
|
|
770
|
+
composerPath = require.resolve(
|
|
771
|
+
'react-native/scripts/compose-source-maps.js',
|
|
772
|
+
{ paths: [process.cwd()] },
|
|
773
|
+
);
|
|
774
|
+
} catch {
|
|
775
|
+
console.warn(t('composeSourceMapsNotFound'));
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
console.log(t('composingSourceMap'));
|
|
779
|
+
assertSuccessfulSyncProcess(
|
|
780
|
+
await runProcess(
|
|
781
|
+
getJavaScriptRuntime(),
|
|
782
|
+
[composerPath, packagerMap, hermesMap, '-o', sourcemapOutput],
|
|
783
|
+
false,
|
|
784
|
+
),
|
|
785
|
+
composerPath,
|
|
786
|
+
);
|
|
787
|
+
return true;
|
|
788
|
+
}
|
|
789
|
+
|
|
666
790
|
export async function compileHermesByteCode({
|
|
667
791
|
bundleName,
|
|
668
792
|
outputFolder,
|
|
@@ -675,19 +799,25 @@ export async function compileHermesByteCode({
|
|
|
675
799
|
console.log(t('hermesEnabledCompiling'));
|
|
676
800
|
|
|
677
801
|
const bundlePath = path.join(outputFolder, bundleName);
|
|
678
|
-
const
|
|
802
|
+
const hermesMap = `${bundlePath}.map`;
|
|
803
|
+
const packagerMap = path.join(outputFolder, `${bundleName}.txt.map`);
|
|
679
804
|
if (sourcemapOutput) {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
805
|
+
// hermesc is about to write its own map at `<bundle>.map`, which is where
|
|
806
|
+
// the packager map normally sits: move it aside (copy only when elsewhere)
|
|
807
|
+
if (path.resolve(sourcemapOutput) === path.resolve(hermesMap)) {
|
|
808
|
+
fs.renameSync(sourcemapOutput, packagerMap);
|
|
809
|
+
} else {
|
|
810
|
+
fs.copyFileSync(sourcemapOutput, packagerMap);
|
|
811
|
+
}
|
|
684
812
|
} else {
|
|
685
|
-
console.log(t('hermesSourcemapKept', { file:
|
|
813
|
+
console.log(t('hermesSourcemapKept', { file: hermesMap }));
|
|
686
814
|
}
|
|
687
815
|
|
|
688
|
-
let selection = pendingBase ? await pendingBase : null;
|
|
816
|
+
let selection = pendingBase ? await awaitPendingBase(pendingBase) : null;
|
|
817
|
+
const command =
|
|
818
|
+
hermesCommand ?? selection?.hermesCommand ?? resolveHermesCommand();
|
|
689
819
|
if (!selection || selection.commandUnavailable) {
|
|
690
|
-
selection = await selectHermesBase(
|
|
820
|
+
selection = await selectHermesBase(command, baseRequest);
|
|
691
821
|
}
|
|
692
822
|
for (const line of selection.logs) console.log(line);
|
|
693
823
|
const result: HermesCompileResult = {
|
|
@@ -695,31 +825,33 @@ export async function compileHermesByteCode({
|
|
|
695
825
|
base: null,
|
|
696
826
|
};
|
|
697
827
|
const base = selection.base;
|
|
828
|
+
// the packager + hermes maps merged into sourcemapOutput
|
|
829
|
+
let composed = false;
|
|
698
830
|
|
|
699
|
-
if (base) {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
//
|
|
703
|
-
//
|
|
704
|
-
//
|
|
705
|
-
// result when the base is rejected
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
const
|
|
709
|
-
const plainPath = path.join(
|
|
831
|
+
if (!base) {
|
|
832
|
+
await compilePlain(command, bundlePath);
|
|
833
|
+
} else {
|
|
834
|
+
// The JS bundle moves into a work dir and both hermesc runs read it there
|
|
835
|
+
// (no copies); the base compile writes the real output, and with
|
|
836
|
+
// verification on the plain compile the check needs runs concurrently
|
|
837
|
+
// into `plain/` — it simply becomes the result when the base is rejected,
|
|
838
|
+
// so a rejected base never costs a third compile.
|
|
839
|
+
const workDir = path.join(outputFolder, '.hermes-base');
|
|
840
|
+
const jsSource = path.join(workDir, bundleName);
|
|
841
|
+
const plainPath = path.join(workDir, 'plain', bundleName);
|
|
710
842
|
const wantPlain = Boolean(baseRequest?.verify);
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
console.log(
|
|
717
|
-
t('runningHermesc', { command: hermesCommand, args: args.join(' ') }),
|
|
843
|
+
fs.ensureDirSync(path.dirname(plainPath));
|
|
844
|
+
fs.renameSync(bundlePath, jsSource);
|
|
845
|
+
const args = hermescArgsWithBase(
|
|
846
|
+
buildHermescArgs(bundlePath, jsSource),
|
|
847
|
+
base.path,
|
|
718
848
|
);
|
|
849
|
+
console.log(t('runningHermesc', { command, args: args.join(' ') }));
|
|
719
850
|
const [attempt, plain] = await Promise.all([
|
|
720
|
-
|
|
851
|
+
// -w: warnings only bloat the captured stderr, errors still print
|
|
852
|
+
runProcess(command, [...args, '-w'], true),
|
|
721
853
|
wantPlain
|
|
722
|
-
? runProcess(
|
|
854
|
+
? runProcess(command, buildHermescArgs(plainPath, jsSource), false)
|
|
723
855
|
: Promise.resolve<ProcessOutcome | null>(null),
|
|
724
856
|
]);
|
|
725
857
|
let usedBase = attempt.status === 0 && !attempt.error;
|
|
@@ -734,8 +866,9 @@ export async function compileHermesByteCode({
|
|
|
734
866
|
}),
|
|
735
867
|
);
|
|
736
868
|
if (fullStderr.trim()) {
|
|
737
|
-
// the summary drops
|
|
738
|
-
|
|
869
|
+
// the summary drops noise; keep everything for bug reports — next to
|
|
870
|
+
// the intermediate dir, never inside it (its content is packed)
|
|
871
|
+
const logPath = hermesBaseErrorLogPath(outputFolder);
|
|
739
872
|
try {
|
|
740
873
|
fs.writeFileSync(logPath, fullStderr);
|
|
741
874
|
console.warn(t('hermesBaseCompileFailedLog', { file: logPath }));
|
|
@@ -743,102 +876,79 @@ export async function compileHermesByteCode({
|
|
|
743
876
|
}
|
|
744
877
|
}
|
|
745
878
|
const plainOk = plain !== null && plain.status === 0 && !plain.error;
|
|
879
|
+
// compose the base output's map while the disassembly compare runs; it is
|
|
880
|
+
// redone from the plain map in the rare case the base is rejected
|
|
881
|
+
const speculativeCompose =
|
|
882
|
+
usedBase && sourcemapOutput
|
|
883
|
+
? composeSourceMaps(packagerMap, hermesMap, sourcemapOutput)
|
|
884
|
+
: null;
|
|
746
885
|
if (usedBase && wantPlain) {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
886
|
+
if (!plainOk) {
|
|
887
|
+
// the check could not run; that is not a verification failure
|
|
888
|
+
console.warn(
|
|
889
|
+
t('hermesBasePlainCompileFailed', {
|
|
890
|
+
reason:
|
|
891
|
+
(plain?.error && String(plain.error.message ?? plain.error)) ||
|
|
892
|
+
`exit ${plain?.status}`,
|
|
893
|
+
}),
|
|
894
|
+
);
|
|
895
|
+
} else {
|
|
896
|
+
let ok: boolean;
|
|
750
897
|
try {
|
|
751
898
|
ok = await verifyHermesBaseEquivalence(
|
|
752
|
-
|
|
899
|
+
command,
|
|
753
900
|
bundlePath,
|
|
754
901
|
plainPath,
|
|
755
902
|
);
|
|
756
903
|
} catch {
|
|
757
904
|
ok = false;
|
|
758
905
|
}
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
906
|
+
result.verified = ok;
|
|
907
|
+
if (ok) {
|
|
908
|
+
console.log(t('hermesBaseVerified'));
|
|
909
|
+
} else {
|
|
910
|
+
console.warn(t('hermesBaseVerifyFailed'));
|
|
911
|
+
usedBase = false;
|
|
912
|
+
}
|
|
766
913
|
}
|
|
767
914
|
}
|
|
915
|
+
if (speculativeCompose) {
|
|
916
|
+
const done = await speculativeCompose.catch((error) => {
|
|
917
|
+
if (usedBase) throw error;
|
|
918
|
+
return false;
|
|
919
|
+
});
|
|
920
|
+
composed = usedBase && done;
|
|
921
|
+
}
|
|
768
922
|
if (!usedBase) {
|
|
769
923
|
if (plainOk) {
|
|
770
924
|
fs.moveSync(plainPath, bundlePath, { overwrite: true });
|
|
771
925
|
if (fs.existsSync(`${plainPath}.map`)) {
|
|
772
|
-
fs.moveSync(`${plainPath}.map`,
|
|
773
|
-
overwrite: true,
|
|
774
|
-
});
|
|
926
|
+
fs.moveSync(`${plainPath}.map`, hermesMap, { overwrite: true });
|
|
775
927
|
}
|
|
776
928
|
} else {
|
|
777
|
-
|
|
778
|
-
console.log(
|
|
779
|
-
t('runningHermesc', {
|
|
780
|
-
command: hermesCommand,
|
|
781
|
-
args: plainArgs.join(' '),
|
|
782
|
-
}),
|
|
783
|
-
);
|
|
784
|
-
assertSuccessfulSyncProcess(
|
|
785
|
-
spawnSync(hermesCommand, plainArgs, { stdio: 'ignore' }),
|
|
786
|
-
hermesCommand,
|
|
787
|
-
);
|
|
929
|
+
await compilePlain(command, bundlePath, jsSource);
|
|
788
930
|
}
|
|
789
931
|
}
|
|
790
|
-
fs.removeSync(
|
|
791
|
-
fs.removeSync(plainDir);
|
|
932
|
+
fs.removeSync(workDir);
|
|
792
933
|
result.base = usedBase ? base : null;
|
|
793
|
-
} else {
|
|
794
|
-
console.log(
|
|
795
|
-
t('runningHermesc', {
|
|
796
|
-
command: hermesCommand,
|
|
797
|
-
args: plainArgs.join(' '),
|
|
798
|
-
}),
|
|
799
|
-
);
|
|
800
|
-
assertSuccessfulSyncProcess(
|
|
801
|
-
spawnSync(hermesCommand, plainArgs, {
|
|
802
|
-
stdio: 'ignore',
|
|
803
|
-
}),
|
|
804
|
-
hermesCommand,
|
|
805
|
-
);
|
|
806
934
|
}
|
|
807
|
-
if (sourcemapOutput) {
|
|
808
|
-
|
|
809
|
-
try {
|
|
810
|
-
// resolve through the project so hoisted node_modules (monorepos) work
|
|
811
|
-
composerPath = require.resolve(
|
|
812
|
-
'react-native/scripts/compose-source-maps.js',
|
|
813
|
-
{ paths: [process.cwd()] },
|
|
814
|
-
);
|
|
815
|
-
} catch {
|
|
816
|
-
console.warn(t('composeSourceMapsNotFound'));
|
|
817
|
-
return result;
|
|
818
|
-
}
|
|
819
|
-
console.log(t('composingSourceMap'));
|
|
820
|
-
assertSuccessfulSyncProcess(
|
|
821
|
-
spawnJavaScriptSync(
|
|
822
|
-
[
|
|
823
|
-
composerPath,
|
|
824
|
-
path.join(outputFolder, `${bundleName}.txt.map`),
|
|
825
|
-
path.join(outputFolder, `${bundleName}.map`),
|
|
826
|
-
'-o',
|
|
827
|
-
sourcemapOutput,
|
|
828
|
-
],
|
|
829
|
-
{
|
|
830
|
-
stdio: 'ignore',
|
|
831
|
-
},
|
|
832
|
-
),
|
|
833
|
-
composerPath,
|
|
834
|
-
);
|
|
935
|
+
if (sourcemapOutput && !composed) {
|
|
936
|
+
await composeSourceMaps(packagerMap, hermesMap, sourcemapOutput);
|
|
835
937
|
}
|
|
836
938
|
if (shouldCleanSourcemap) {
|
|
837
|
-
fs.removeSync(
|
|
939
|
+
fs.removeSync(packagerMap);
|
|
838
940
|
}
|
|
839
941
|
return result;
|
|
840
942
|
}
|
|
841
943
|
|
|
944
|
+
/** where a failed base attempt's full hermesc output goes (never packed) */
|
|
945
|
+
export function hermesBaseErrorLogPath(outputFolder: string): string {
|
|
946
|
+
return path.join(
|
|
947
|
+
path.dirname(path.resolve(outputFolder)),
|
|
948
|
+
'hermes-base-error.log',
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
|
|
842
952
|
/**
|
|
843
953
|
* Begin resolving the base right away (before Metro); the compile phase awaits
|
|
844
954
|
* the result. Never rejects: any failure is reported there instead.
|
|
@@ -867,6 +977,7 @@ export function startHermesBaseSelection(
|
|
|
867
977
|
logs: [
|
|
868
978
|
t('hermesBaseNone', { reason: error?.message ?? String(error) }),
|
|
869
979
|
],
|
|
980
|
+
hermesCommand,
|
|
870
981
|
};
|
|
871
982
|
}
|
|
872
983
|
})();
|
|
@@ -881,6 +992,7 @@ async function selectHermesBase(
|
|
|
881
992
|
base: null,
|
|
882
993
|
bytecodeVersion,
|
|
883
994
|
logs,
|
|
995
|
+
hermesCommand,
|
|
884
996
|
});
|
|
885
997
|
if (!request || request.option === 'none') {
|
|
886
998
|
if (request) {
|
|
@@ -910,7 +1022,7 @@ async function selectHermesBase(
|
|
|
910
1022
|
fetchBase: getHermesBase,
|
|
911
1023
|
log: (message) => logs.push(message),
|
|
912
1024
|
});
|
|
913
|
-
return { base, bytecodeVersion, logs };
|
|
1025
|
+
return { base, bytecodeVersion, logs, hermesCommand };
|
|
914
1026
|
} catch (error: any) {
|
|
915
1027
|
logs.push(t('hermesBaseNone', { reason: error?.message ?? String(error) }));
|
|
916
1028
|
return none(bytecodeVersion);
|
package/src/bundle.ts
CHANGED
|
@@ -39,6 +39,7 @@ type NormalizedBundleOptions = {
|
|
|
39
39
|
hermes: boolean;
|
|
40
40
|
hermesBase: string;
|
|
41
41
|
verifyHermesBase: boolean;
|
|
42
|
+
resetCache: boolean;
|
|
42
43
|
cacheMaxMb?: number;
|
|
43
44
|
name?: string;
|
|
44
45
|
description?: string;
|
|
@@ -118,6 +119,7 @@ export function normalizeBundleOptions(
|
|
|
118
119
|
'verifyHermesBase',
|
|
119
120
|
true,
|
|
120
121
|
),
|
|
122
|
+
resetCache: getBooleanOption(translatedOptions, 'resetCache', true),
|
|
121
123
|
cacheMaxMb: parseCacheMaxMb(translatedOptions.cacheMaxMb),
|
|
122
124
|
name: getOptionalStringOption(translatedOptions, 'name'),
|
|
123
125
|
description: getOptionalStringOption(translatedOptions, 'description'),
|
|
@@ -262,6 +264,7 @@ export const bundleCommands = {
|
|
|
262
264
|
verify: normalized.verifyHermesBase,
|
|
263
265
|
cacheMaxMb: normalized.cacheMaxMb,
|
|
264
266
|
},
|
|
267
|
+
resetCache: normalized.resetCache,
|
|
265
268
|
cli: {
|
|
266
269
|
taro: normalized.taro,
|
|
267
270
|
expo: normalized.expo,
|