facebook / metro

🚇 The JavaScript bundler for React Native
https://metrobundler.dev
MIT License
5.21k stars 621 forks source link

Prohibitively slow dev build + Fast Refresh times #862

Open frozencap opened 2 years ago

frozencap commented 2 years ago

Development on our project has basically come to a halt after updating a few packages.

Dev builds and Fast Refresh are taking 15min+.

We are not able to isolate the issue.

Any help ?

System:
    OS: macOS 12.5.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 1.37 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.6.0 - ~/.asdf/installs/nodejs/18.6.0/bin/node
    Yarn: 1.22.19 - ~/.asdf/shims/yarn
    npm: 8.13.2 - ~/.asdf/plugins/nodejs/shims/npm
    Watchman: 2022.07.04.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK:
      API Levels: 23, 29, 30, 31
      Build Tools: 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0
      System Images: android-29 | Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play ARM 64 v8a, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs ARM 64 v8a, android-30 | Google Play ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8609683
    Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.0.0 => 18.0.0 
    react-native: ^0.68.0 => 0.68.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

devDeps from package.json

  "devDependencies": {
    "@babel/core": "^7.18.13",
    "@babel/runtime": "^7.18.9",
    "@react-native-community/eslint-config": "^2.0.0",
    "@rnx-kit/dep-check": "^1.12.18",
    "@types/jest": "^26.0.23",
    "@types/md5": "^2.3.2",
    "@types/phoenix": "^1.5.4",
    "@types/react-native": "^0.69.0",
    "@types/react-native-background-timer": "^2.0.0",
    "@types/react-native-video": "^5.0.14",
    "@types/react-native-webrtc": "^1.75.5",
    "@types/react-test-renderer": "^17.0.1",
    "@types/rn-fetch-blob": "^1.2.3",
    "@types/url-parse": "^1.4.8",
    "@types/uuid": "^8.3.4",
    "@typescript-eslint/eslint-plugin": "^5.35.1",
    "@typescript-eslint/parser": "^5.35.1",
    "babel-jest": "^26.6.3",
    "babel-plugin-module-resolver": "^4.1.0",
    "eslint": "^8.23.0",
    "eslint-plugin-flowtype": "^8.0.3",
    "eslint-plugin-react-hooks": "^4.6.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.72.1",
    "react-native-clean-project": "^4.0.1",
    "react-native-flipper": "^0.162.0",
    "react-test-renderer": "17.0.2",
    "redux-flipper": "^2.0.2",
    "typescript": "^4.8.2"
  },
  "resolutions": {
    "react-devtools-core": "4.25.0"
  },
  "jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  },
  "rnx-kit": {
    "reactNativeVersion": "^0.68.0",
    "kitType": "app",
    "capabilities": [
      "babel-preset-react-native",
      "core",
      "core-android",
      "core-ios",
      "gestures",
      "hooks",
      "jest",
      "navigation/native",
      "navigation/stack",
      "netinfo",
      "react",
      "react-test-renderer",
      "safe-area",
      "screens",
      "storage"
    ]
  }
efstathiosntonas commented 2 years ago

@shawarmaz probably related: https://github.com/facebook/metro/issues/781

frozencap commented 1 year ago

Still getting this, except now exclusively on physical devices.

When it happens, app gets stuck on Bundling 100% for ~4-5x longer than the time it takes to build both the bundle and the native app.

So it's literally faster to just build a release, which is what I'm currently doing pending a solution

Help anyone?

ngima commented 1 year ago

Did anyone find any solution to this issue, I started getting this issue after I upgrade from expo 48 to 49. I tried the #781 workaround by @efstathiosntonas but is still having the issue.