callstack / repack

A Webpack-based toolkit to build your React Native application with full support of Webpack ecosystem.
https://re-pack.dev
MIT License
1.48k stars 107 forks source link

ReferenceError: Property '__webpack_require__' doesn't exist, js engine: hermes #743

Closed songdedku closed 1 month ago

songdedku commented 1 month ago

Describe the bug

ReferenceError: Property '__webpack_require__' doesn't exist, js engine: hermes when i build release mode but working on debug mode

System Info

System:
  OS: macOS 14.2
  CPU: (8) arm64 Apple M3
  Memory: 195.69 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.11.1
    path: /usr/local/bin/node
  Yarn:
    version: 3.6.4
    path: ~/mtel/xxx/app/xxx/node_modules/.bin/yarn
  npm:
    version: 10.2.4
    path: /usr/local/bin/npm
  Watchman:
    version: 2024.07.08.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.2 AI-232.10227.8.2321.11479570
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.23
    path: /opt/homebrew/opt/openjdk@11/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.2
    wanted: 0.75.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Re.Pack Version

4.3.2

Reproduction

xxxx

Steps to reproduce

add shellScript = "set -e\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nexport BUNDLE_COMMAND=webpack-bundle\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";

and build release error Property '__webpack_require__' doesn't exist, js engine: hermes but working on debug mode

jbroma commented 1 month ago

@songdedku please provide a valid reproduction where the errors is happening because I can't reproduce it - I tried Re.Pack on a fresh 0.75.3 project and everything works perfectly fine in release mode (on both platforms)

jbroma commented 1 month ago

One thing that comes to mind, where this error could occur is that if you are using ScriptManager in your code, and you make a bundle with metro then this error could pop up because ScriptManager expects __webpack_require__ to be defined as a global.