nrwl / nx

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

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

Open guillempuche opened 4 months ago

guillempuche commented 4 months 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 4 months 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 4 months 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": "*",
brendan-hurley commented 1 month ago

I have the same problem, but with some additional dependencies added:

Node           : 20.11.0
OS             : darwin-arm64
Native Target  : aarch64-macos
yarn           : 1.22.22

nx                 : 19.8.4
@nx/js             : 19.8.4
@nx/jest           : 19.8.4
@nx/linter         : 19.8.4
@nx/eslint         : 19.8.4
@nx/workspace      : 19.8.4
@nx/cypress        : 19.8.4
@nx/detox          : 19.8.4
@nx/devkit         : 19.8.4
@nx/eslint-plugin  : 19.8.4
@nx/expo           : 19.8.4
@nx/react          : 19.8.4
@nx/react-native   : 19.8.4
@nx/rollup         : 19.8.4
@nx/storybook      : 19.8.4
@nrwl/tao          : 19.8.4
@nx/web            : 19.8.4
@nx/webpack        : 19.8.4
nx-cloud           : 19.1.0
typescript         : 5.3.3

These are added to dependencies:

    "@nx/devkit": "*",
    "@nx/eslint": "*",
    "enhanced-resolve": "*",
    "metro-resolver": "*",
    "node-fetch": "*",
    "picocolors": "*",
    "ajv": "*",
    "chalk": "*",
    "glob": "*",
    "ignore": "*"

Is the recommended advice just to exclude these? Like @guillempuche these things seem to populate from nowhere.