rnx-kit: metro-serializer-esbuild throws [ERR_INVALID_ARG_TYPE] after bundling

What happened?

I was trying out @rnx-kit/metro-serializer-esbuild with my existing project, which uses React Native 0.67.

Following the installation guide, the first error I encountered is babel not recognising the preset option disableImportExportTransform. I skip ahead to the next step and updated my metro.config.js, but right at the end of bundling it throws the following error:

 BUNDLE  ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (3875/3875)TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received undefined
    at new NodeError (node:internal/errors:399:5)
    at Function.byteLength (node:buffer:738:11)
    at finish (myapps/node_modules/metro/src/Server.js:683:25)
    at Server.requestProcessor [as _processBundleRequest] (myapps/node_modules/metro/src/Server.js:569:7)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Server._processRequest (myapps/node_modules/metro/src/Server.js:380:9)

Affected Package

@rnx-kit/metro-serializer-esbuild

Version

0.1.20

Which platforms are you seeing this issue on?

  • Android
  • iOS
  • macOS
  • Windows

System Information

System:
    OS: macOS 13.1
    CPU: (8) arm64 Apple M1
    Memory: 674.42 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.6.0 - /private/var/folders/gw/lvpkpr9d0nbct414_k55p3vh0000gn/T/xfs-30629ce2/node
    Yarn: 3.3.1 - /private/var/folders/gw/lvpkpr9d0nbct414_k55p3vh0000gn/T/xfs-30629ce2/yarn
    npm: 9.4.0 - /opt/homebrew/bin/npm
    Watchman: 2023.02.06.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: 2022.1 AI-221.6008.13.2211.9477386
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.15 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^17.0.1 => 17.0.2 
    react-native: ^0.67.0 => 0.67.5 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to Reproduce

I cannot reproduce this with a freshly created React Native project.

I want to make a minimum repo, but my knowledge with metro is really limited.

Where shall I start?

Code of Conduct

  • I agree to follow this project’s Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

Hey, I couldn’t build the Android app because of this:

Because I removed my release.keystore

metro.config.js, esbuildTransformerConfig is also incompatible with dev server

That explains a lot, it breaks because I was trying to use this plugin with a dev server.

Sorry for the confusion, and thanks for your help!