nrwl / nx-incremental-large-repo

67 stars 35 forks source link

Why do the apps have no package.json where the libraries are included as dependencies? #26

Closed mklueh closed 2 years ago

mklueh commented 2 years ago

Hello,

I've found this repo and I think the title says it all. I do not understand why there is no package.json or at least, why not even in the root package.json the libraries are explicitly included. Does NX automatically provide access to all libraries within the workspace?

Is this config block in the nx.json file responsible for it to work?

  "implicitDependencies": {
    "workspace.json": "*",
    "package.json": "*",
    ".eslintrc.json": "*",
    "nx.json": "*",
    "tsconfig.base.json": "*"
  },

Thanks in advance

juristr commented 2 years ago

Although you can use Nx also with something like npm/yarn/pnpm workspaces and package.json + node_modules per app/lib (see https://youtu.be/ngdoUQBvAjo), the recommended approach you get when using "npx create-nx-workspace" is a single package.json at the root of the workspace.

This is because Nx follows the single version policy (similar to what Google and other big monorepos recommend). The package linking is done via the tsconfig.base.json TypeScript path mapping.

You can find more on nx.dev

juristr commented 2 years ago

Obviously feel free to ping me on Twitter (@juristr) or @nxdevtools. In mobile, so keeping the response short 😅