Skip to content

Hermes error: Error encoding bytecode #3143

Open

Description

What happened?

On hermes command getting the error, without any specific error message.

error: Error encoding bytecode <Printing the whole js bundle>

I am trying to create bundle for React-Native, earlier we were using the metro bundler, but now we want to add tree-shaking capability to it, so we are trying rnx-kit.

Our react native version: 0.72.7

Trying to create bundle independently without gradle.

Affected Package

@rnx-kit/metro-serializer-esbuild

Version

0.1.33

Which platforms are you seeing this issue on?

  • Android
  • iOS
  • macOS
  • Windows

System Information

System:
  OS: macOS 14.4.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 340.58 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 16.15.1
    path: ~/.nvm/versions/node/v16.15.1/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.nvm/versions/node/v16.15.1/bin/yarn
  npm:
    version: 8.12.1
    path: ~/.nvm/versions/node/v16.15.1/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.11
    path: /Users/<username>/.jenv/shims/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.7
    wanted: 0.72.7
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: false
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Steps to Reproduce

babel.config.js

presets: [["module:metro-react-native-babel-preset", { disableImportExportTransform: true }]]

metro.config.js

const { makeMetroConfig } = require('@rnx-kit/metro-config');
const { MetroSerializer, esbuildTransformerConfig } = require('@rnx-kit/metro-serializer-esbuild');

module.exports = makeMetroConfig({
    serializer: {
        customSerializer: MetroSerializer([], {
            logLevel: 'verbose',
            target: 'hermes0.11.0'
        })
    },
    transformer: esbuildTransformerConfig,
});

Note: Tried default target as well.

Using command to create js bundle.

react-native bundle --platform android --dev false --entry-file index.js --bundle-output bundle.js --sourcemap-output bundle.map --reset-cache

Command to run hermes:

node_modules/react-native/sdks/hermesc/osx-bin/hermesc -O -w -g -emit-binary -output-source-map -out bundle.hbc bundle.js

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions