Thinkmill / manypkg

☔️ An umbrella for your monorepo
MIT License
884 stars 48 forks source link

"Root has devDependencies" #114

Open theKashey opened 2 years ago

theKashey commented 2 years ago

I would like to raise a concern about this rule mostly due to the problem with npm audit and the general expectation of some underlaying tools that only dependencies should be scanned for vulnerabilities.

Still creates a huge room for some uncertainly of decision which dep should do where, but I would like to have this rule configurable.

Offirmo commented 2 years ago

I agree with this. The "Root has devDependencies" is too opiniated.

Offirmo commented 2 years ago

Also the main reason "The root package.json of a monorepo is not published" is incorrect. There are many uses in having root dependencies or not, in prod or dev. Examples:

Hence my need for "devDependencies" and not "dependencies".

steve-taylor commented 2 years ago

I second this, but would prefer to see this as an option, defaulting to the current behaviour. This would then necessitate another rule for those of us who use Bolt: Ensure that any dependency in a sub-package that's in dependencies is in the root package.json's dependencies, and the same for devDependencies. This would be mutually exclusive with the "Root has devDependencies" rule and perhaps only active for monorepo package managers that require all dependencies be declared in the root. (Bolt is the only one that I know about.) Having said that, I'm aware that @mitchellhamilton recommends Yarn workspaces over Bolt.

My use case: I'm Dockerizing a Next.js app in the monorepo and I want to exclude devDependencies for a smaller Docker image. I have to Dockerize from the root because of symlinks.

TheDunco commented 1 month ago

I have a similar use case to @Offirmo and @steve-taylor. I want to install certain deps when installing on my machine but need a way to ignore them when installing in a Docker container. The only method of doing so I'm aware of is to pass -P to my pnpm install command in my Docker image's configuration while having the deps I don't want in devDependencies.

I agree this rule is too opinionated and there needs to be a way to ignore it.

I'm using pnpm workspaces.

TheDunco commented 1 month ago

Although, I just found out that I was able to add this property to my root package.json to ignore this rule. Doing so added --allow-devDependencies to my manypkg check command. Perhaps the methods to ignore this rule just need to be better documented as it wasn't obvious from the README that you can do this.

  "manypkg": {
    "ignoredRules": [
      "ROOT_HAS_DEV_DEPENDENCIES",
    ]
  },