nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
22.7k stars 2.27k forks source link

@nx/expo executor `sync-deps` add more dependencies than necessary #26571

Open guillempuche opened 1 month ago

guillempuche commented 1 month ago

Current Behavior

I create a blank Expo project with Nx create with this package https://github.com/guillempuche/test-nx-expo/blob/main/apps/expo/package.json (Emily already fixed a problem https://github.com/nrwl/nx/issues/26285#issuecomment-2159343424).

The problem happens when running npm exec nx run expo:sync-deps from the root, it adds packages in dependencies that will be bundled in the app.

// apps/expo/package.json

{
  "name": "expo",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "@testing-library/jest-native": "*",
    "@testing-library/react-native": "*",
    "metro-config": "*",
    "react-native": "*",
    "expo": "*",
    "react-native-svg": "*",
    "react-native-web": "*",
    "expo-dev-client": "~3.3.12",
    "react": "18.2.0",
    "expo-modules-core": "*",
    "expo-dev-launcher": "*",
    "expo-dev-menu": "*",
    "expo-json-menu": "*",
    "expo-json-utils": "*",
    "expo-manifests": "*",
    "expo-asset": "*",
    "expo-font": "*",
    "jest-expo": "*",
    "@nx/devkit": "*",
    "@nx/eslint": "*",
    "@nx/jest": "*",
    "@nx/js": "*",
    "@nx/react": "*",
    "@nx/web": "*",
    "@nx/webpack": "*",
    "chalk": "*",
    "enhanced-resolve": "*",
    "fs-extra": "*",
    "metro-resolver": "*",
    "node-fetch": "*",
    "tsconfig-paths": "*",
    "tslib": "*",
    "@expo/metro-config": "*",
    "react-native-svg-transformer": "*",
    "tsconfig-paths-webpack-plugin": "*",
    "expo-build-properties": "*"
  },
  "scripts": {
    "eas-build-pre-install": "cd ../../ && node tools/scripts/eas-build-pre-install.mjs . apps/expo && cp package-lock.json apps/expo",
    "eas-build-post-install": "cd ../../ && node tools/scripts/eas-build-post-install.mjs . apps/expo",
    "android": "expo run:android",
    "ios": "expo run:ios"
  },
  "devDependencies": {}
}

Expected Behavior

// apps/expo/package.json

{
  "name": "expo",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "@testing-library/jest-native": "*",
    "@testing-library/react-native": "*",
    "metro-config": "*",
    "react-native": "*",
    "expo": "*",
    "react-native-svg": "*",
    "react-native-web": "*",
    "expo-dev-client": "~3.3.12",
    "react": "18.2.0",
    "expo-modules-core": "*",
    "expo-dev-launcher": "*",
    "expo-dev-menu": "*",
    "expo-json-menu": "*",
    "expo-json-utils": "*",
    "expo-manifests": "*",
    "expo-asset": "*",
    "expo-font": "*"
  },
  "scripts": {
    "eas-build-pre-install": "cd ../../ && node tools/scripts/eas-build-pre-install.mjs . apps/expo && cp package-lock.json apps/expo",
    "eas-build-post-install": "cd ../../ && node tools/scripts/eas-build-post-install.mjs . apps/expo",
    "android": "expo run:android",
    "ios": "expo run:ios"
  }
}

GitHub Repo

https://github.com/guillempuche/test-nx-expo/

Steps to Reproduce

  1. npm i
  2. npm exec nx run expo:sync-deps
  3. Packages added

Nx Report

Node   : 20.14.0
OS     : darwin-arm64
npm    : 10.7.0

nx                 : 19.2.3
@nx/js             : 19.2.3
@nx/jest           : 19.2.3
@nx/linter         : 19.2.3
@nx/eslint         : 19.2.3
@nx/workspace      : 19.2.3
@nx/detox          : 19.2.3
@nx/devkit         : 19.2.3
@nx/eslint-plugin  : 19.2.3
@nx/expo           : 19.2.3
@nx/react          : 19.2.3
@nrwl/tao          : 19.2.3
@nx/web            : 19.2.3
@nx/webpack        : 19.2.3
typescript         : 5.3.3
---------------------------------------
Registered Plugins:
@nx/expo/plugin
@nx/eslint/plugin
@nx/jest/plugin
@nx/detox/plugin

Failure Logs

No response

Package Manager Version

npm 10.7.0

Operating System

Additional Information

No response

xiongemi commented 1 week ago

you can manually change sync-deps target:

    "sync-deps": {
      "executor": "@nx/expo:sync-deps",
      "options": {
        "excludeImplicit": true,
        "exclude": ["@nx/devkit", "@nx/eslint", "@nx/jest", "@nx/js", "@nx/react", "@nx/web", "@nx/webpack"]
      }
    },
guillempuche commented 1 week ago

I might miss something. Nx adds more than only Nx's plugins.

Why does it add these?

    "chalk": "*",
    "enhanced-resolve": "*",
    "fs-extra": "*",
    "metro-resolver": "*",
    "node-fetch": "*",
    "tsconfig-paths": "*",