software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.87k stars 1.29k forks source link

Unexpected token: punc ()) in file node_modules/react-native-reanimated/src/threads.ts #6536

Open DavidBennettUK opened 6 days ago

DavidBennettUK commented 6 days ago

Description

After upgrading to the latest React Native + react-native-reanimated, running the app in development gives a very unhelpful invalid expression error without specifying what the expression is. The line number is very large, so will be pointing to the minified index bundle.

Trying to fetch the bundle via curl results in a more useful error (see below). Disabling minify on the URL results in a successful response, so the problem likely lies with minification.

This is a similar error to https://github.com/software-mansion/react-native-reanimated/issues/6170 but not sure if related. Clearing everything as described in the issue didn't work, and it also happens on multiple dev machines.

{
  "type": "TransformError",
  "lineNumber": 0,
  "errors": [
    {
      "description": "node_modules/react-native-reanimated/src/threads.ts: Unexpected token: punc ()) in file node_modules/react-native-reanimated/src/threads.ts at 337:58",
      "lineNumber": 0
    }
  ],
  "name": "SyntaxError",
  "message": "node_modules/react-native-reanimated/src/threads.ts: Unexpected token: punc ()) in file node_modules/react-native-reanimated/src/threads.ts at 337:58",
  "stack": "Error: Unexpected token: punc ()) in file node_modules/react-native-reanimated/src/threads.ts at 337:58\n    at minifyCode (node_modules/metro-transform-worker/src/index.js:74:13)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async transformJS (node_modules/metro-transform-worker/src/index.js:241:22)\n    at async transformJSWithBabel (node_modules/metro-transform-worker/src/index.js:299:10)\n    at async Object.transform (node_modules/metro-transform-worker/src/index.js:413:12)"
}

All package versions (e.g. babel) are as listed in the RN upgrade tool. See https://raw.githubusercontent.com/react-native-community/rn-diff-purge/release/0.75.3/RnDiffApp/package.json. Babel plugin for this library has been added, etc.

Downgrading to v2 of this library worked to get past this JS error, but it is not officially supported with RN v0.75. And Android will only compile with v3.15 of this library, so downgrading isn't an option for now.

Steps to reproduce

curl "http://localhost:8081/index.bundle?platform=ios&dev=true&minify=true"

Snack or a link to a repository

https://github.com/software-mansion/react-native-reanimated/blob/main/packages/react-native-reanimated/src/threads.ts

Reanimated version

3.15.3

React Native version

0.75.3

Platforms

Android, iOS

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Paper (Old Architecture)

Build type

Debug app & dev bundle

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

github-actions[bot] commented 6 days ago

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?