Skip to content

Commit

Permalink
feat(metro): enableHermes options compile binary (#120)
Browse files Browse the repository at this point in the history
* feat(metro): useHermes options

* fix: console

* fix: console

* fix: unused

* fix: enableHermes

* fix: not optional

* fix:base

* feat: output

* fix: sourcemap

* fix: update

* fix: comment
  • Loading branch information
gronxb authored Feb 19, 2025
1 parent 0860106 commit e697756
Show file tree
Hide file tree
Showing 15 changed files with 320 additions and 29 deletions.
15 changes: 14 additions & 1 deletion examples/v0.71.19/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ function App(): React.JSX.Element {
setBundleId(bundleId);
}, []);

// @ts-expect-error
// @ts-ignore
const isTurboModuleEnabled = global.__turboModuleProxy != null;

// @ts-ignore
const isHermes = () => !!global.HermesInternal;

const { progress } = useHotUpdaterStore();
return (
<SafeAreaView>
Expand Down Expand Up @@ -70,6 +73,16 @@ function App(): React.JSX.Element {
>
isTurboModuleEnabled: {isTurboModuleEnabled ? "true" : "false"}
</Text>
<Text
style={{
marginVertical: 20,
fontSize: 20,
fontWeight: "bold",
textAlign: "center",
}}
>
isHermes: {isHermes() ? "true" : "false"}
</Text>

<Image
style={{
Expand Down
4 changes: 3 additions & 1 deletion examples/v0.71.19/hot-updater.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { defineConfig } from "hot-updater";
import "dotenv/config";

export default defineConfig({
build: metro(),
build: metro({
enableHermes: true,
}),
storage: supabaseStorage({
supabaseUrl: process.env.HOT_UPDATER_SUPABASE_URL!,
supabaseAnonKey: process.env.HOT_UPDATER_SUPABASE_ANON_KEY!,
Expand Down
15 changes: 14 additions & 1 deletion examples/v0.74.1/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ function App(): React.JSX.Element {
setBundleId(bundleId);
}, []);

// @ts-expect-error
// @ts-ignore
const isTurboModuleEnabled = global.__turboModuleProxy != null;

// @ts-ignore
const isHermes = () => !!global.HermesInternal;

const { progress } = useHotUpdaterStore();
return (
<SafeAreaView>
Expand Down Expand Up @@ -70,6 +73,16 @@ function App(): React.JSX.Element {
>
isTurboModuleEnabled: {isTurboModuleEnabled ? "true" : "false"}
</Text>
<Text
style={{
marginVertical: 20,
fontSize: 20,
fontWeight: "bold",
textAlign: "center",
}}
>
isHermes: {isHermes() ? "true" : "false"}
</Text>

<Image
style={{
Expand Down
4 changes: 3 additions & 1 deletion examples/v0.74.1/hot-updater.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { defineConfig } from "hot-updater";
import "dotenv/config";

export default defineConfig({
build: metro(),
build: metro({
enableHermes: true,
}),
storage: supabaseStorage({
supabaseUrl: process.env.HOT_UPDATER_SUPABASE_URL!,
supabaseAnonKey: process.env.HOT_UPDATER_SUPABASE_ANON_KEY!,
Expand Down
15 changes: 14 additions & 1 deletion examples/v0.76.1-new-arch/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ function App(): React.JSX.Element {
setBundleId(bundleId);
}, []);

// @ts-expect-error
// @ts-ignore
const isTurboModuleEnabled = global.__turboModuleProxy != null;

// @ts-ignore
const isHermes = () => !!global.HermesInternal;

const { progress } = useHotUpdaterStore();
return (
<SafeAreaView>
Expand Down Expand Up @@ -70,6 +73,16 @@ function App(): React.JSX.Element {
>
isTurboModuleEnabled: {isTurboModuleEnabled ? "true" : "false"}
</Text>
<Text
style={{
marginVertical: 20,
fontSize: 20,
fontWeight: "bold",
textAlign: "center",
}}
>
isHermes: {isHermes() ? "true" : "false"}
</Text>

<Image
style={{
Expand Down
5 changes: 3 additions & 2 deletions examples/v0.76.1-new-arch/hot-updater.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

import { metro } from "@hot-updater/metro";
import { supabaseDatabase, supabaseStorage } from "@hot-updater/supabase";
import { defineConfig } from "hot-updater";
import "dotenv/config";

export default defineConfig({
build: metro(),
build: metro({
enableHermes: true,
}),
storage: supabaseStorage({
supabaseUrl: process.env.HOT_UPDATER_SUPABASE_URL!,
supabaseAnonKey: process.env.HOT_UPDATER_SUPABASE_ANON_KEY!,
Expand Down
13 changes: 13 additions & 0 deletions examples/v0.77.0/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ function App(): React.JSX.Element {

const isTurboModuleEnabled = global.__turboModuleProxy != null;

// @ts-ignore
const isHermes = () => !!global.HermesInternal;

const { progress } = useHotUpdaterStore();
return (
<SafeAreaView>
Expand Down Expand Up @@ -69,6 +72,16 @@ function App(): React.JSX.Element {
>
isTurboModuleEnabled: {isTurboModuleEnabled ? "true" : "false"}
</Text>
<Text
style={{
marginVertical: 20,
fontSize: 20,
fontWeight: "bold",
textAlign: "center",
}}
>
isHermes: {isHermes() ? "true" : "false"}
</Text>

<Image
style={{
Expand Down
5 changes: 3 additions & 2 deletions examples/v0.77.0/hot-updater.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

import { metro } from "@hot-updater/metro";
import { supabaseDatabase, supabaseStorage } from "@hot-updater/supabase";
import { defineConfig } from "hot-updater";
import "dotenv/config";

export default defineConfig({
build: metro(),
build: metro({
enableHermes: true,
}),
storage: supabaseStorage({
supabaseUrl: process.env.HOT_UPDATER_SUPABASE_URL!,
supabaseAnonKey: process.env.HOT_UPDATER_SUPABASE_ANON_KEY!,
Expand Down
4 changes: 2 additions & 2 deletions examples/v0.77.0/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PODS:
- hermes-engine (0.77.0):
- hermes-engine/Pre-built (= 0.77.0)
- hermes-engine/Pre-built (0.77.0)
- HotUpdater (0.6.0):
- HotUpdater (0.9.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1746,7 +1746,7 @@ SPEC CHECKSUMS:
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
glog: eb93e2f488219332457c3c4eafd2738ddc7e80b8
hermes-engine: 1f783c3d53940aed0d2c84586f0b7a85ab7827ef
HotUpdater: 1928a508634c7d6d97005d6143bd097fbe16343f
HotUpdater: 20de0dee7a75f256313e94d1cb8ca0c89121e4e4
RCT-Folly: 36fe2295e44b10d831836cc0d1daec5f8abcf809
RCTDeprecation: f5c19ebdb8804b53ed029123eb69914356192fc8
RCTRequired: 6ae6cebe470486e0e0ce89c1c0eabb998e7c51f4
Expand Down
23 changes: 20 additions & 3 deletions packages/hot-updater/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,39 @@ export const deploy = async (options: DeployOptions) => {
]);

try {
const taskRef: {
buildResult: {
buildPath: string;
bundleId: string;
stdout: string | null;
} | null;
} = {
buildResult: null,
};

await p.tasks([
{
title: `📦 Building Bundle (${buildPlugin.name})`,
task: async () => {
const buildResult = await buildPlugin.build({
taskRef.buildResult = await buildPlugin.build({
platform: platform,
});
await createZip(buildResult.buildPath, "bundle.zip");
await createZip(taskRef.buildResult.buildPath, "bundle.zip");

bundleId = buildResult.bundleId;
bundleId = taskRef.buildResult.bundleId;
bundlePath = path.join(getCwd(), "bundle.zip");
fileHash = await getFileHashFromFile(bundlePath);

return `✅ Build Complete (${buildPlugin.name})`;
},
},
]);

if (taskRef.buildResult?.stdout) {
p.log.success(taskRef.buildResult.stdout);
}

await p.tasks([
{
title: `📦 Uploading to Storage (${storagePlugin.name})`,
task: async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ const deployWorker = async (
d1DatabaseName,
}: { d1DatabaseId: string; d1DatabaseName: string },
) => {
const workerPath = require.resolve("@hot-updater/cloudflare/worker");
const workerPath = require.resolve("@hot-updater/cloudflare/worker", {
paths: [getCwd()],
});
const workerDir = path.dirname(workerPath);
const { tmpDir, removeTmpDir } = await copyDirToTmp(workerDir);

Expand Down
4 changes: 2 additions & 2 deletions plugins/metro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"@hot-updater/plugin-core": "0.9.0"
},
"devDependencies": {
"@types/node": "^22.8.7",
"execa": "^9.5.2",
"uuidv7": "^1.0.2",
"@types/node": "^22.8.7"
"uuidv7": "^1.0.2"
}
}
Loading

0 comments on commit e697756

Please sign in to comment.