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 110 forks source link

Compiling JS failed: 7:1:invalid expression (possible JSX: pass -parse-jsx to parse) #727

Closed ra1nj closed 2 months ago

ra1nj commented 2 months ago

Describe the bug

Everything works fine on dev mode, but once i bundle my miniapp and put the bundle on a remote url, then i load the miniapp, the error thrown :

'[ScriptManager] Failed to load script:', '[CodeExecutionFailure]', { scriptId: 'fcca', caller: undefined, locator: { uniqueId: 'fcca', method: 'GET', url: 'https://somewhere/miniapp-ios@0.0.1/miniapp.container.bundle', absolute: false, timeout: 30000, query: 'platform=ios', body: undefined, headers: undefined, fetch: true, verifyScriptSignature: 'off' }, cache: true }, { originalError: [Error: Compiling JS failed: 7:1:invalid expression (possible JSX: pass -parse-jsx to parse) Buffer size 29480 starts with: 0a0a0a0a0a0a3c21444f435459504520] }

System Info

System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M3
  Memory: 358.70 MB / 24.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.5.1
    path: ~/.nvm/versions/node/v20.5.1/bin/node
  Yarn:
    version: 4.4.0
    path: ~/.nvm/versions/node/v20.5.1/bin/yarn
  npm:
    version: 9.8.0
    path: ~/.nvm/versions/node/v20.5.1/bin/npm
  Watchman:
    version: 2024.07.15.00
    path: /opt/homebrew/bin/watchman
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: 2022.3 AI-223.8836.35.2231.10406996
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 3.2.0
    path: /Users/xxx/.rvm/rubies/ruby-3.2.0/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.5
    wanted: 0.74.5
  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.1

Reproduction

will working on it

Steps to reproduce

will working on it

jbroma commented 2 months ago

hi @ra1nj,

have you checked what gets downloaded? This sort of error can happen when the resource isn't available - we don't check if the file looks like proper bundle before evaluating it (although we could do that to differentiate this case better 🤔).

Try manually downloading the bundle using the config from your logs to verify the correct file gets downloaded

ra1nj commented 2 months ago

hi @ra1nj,

have you checked what gets downloaded? This sort of error can happen when the resource isn't available - we don't check if the file looks like proper bundle before evaluating it (although we could do that to differentiate this case better 🤔).

Try manually downloading the bundle using the config from your logs to verify the correct file gets downloaded

hi @jbroma , thank you for your answer , it seems like it's the network problem, i changed to serve my bundle with a local express server, and it works like a charm 🥳.

ra1nj commented 2 months ago

I checked the bundle file inside my app's file sandbox. Turns out if the bundle was not correctly fetched, the error message will be write into the bundle file.

jbroma commented 2 months ago

@ra1nj feel free to make a PR that could make this error to easier to debug for others. I'm currently busy with other work and don't have capacity for that