vuejs / component-compiler-utils

Lower level utilities for compiling Vue single file components
319 stars 75 forks source link

optionalDependencies are installed as normal dependencies #96

Open rchl opened 3 years ago

rchl commented 3 years ago

This package declares prettier in optionalDependencies: https://github.com/vuejs/component-compiler-utils/blob/8b0da745c5a4c7a07b3b88560a1d1cb3c00a9d32/package.json#L68-L70

I'm not sure if that was the intention, but when this @vue/component-compiler-utils is a dependency (or sub-dependency) in a given project, that optionalDependencies will be installed. And it's kinda pointless and unwanted to install prettier in my projects where I don't use it, I feel.

I know that I can use npm i --no-optional but that's a poor solution as nobody remembers to use it.

Also, I understand that it might not be desired to have prettier in peerDependencies as then it will trigger a warning when not installed.

Maybe just mention in the documentation that if you want to use prettier you have to add it manually?

rchl commented 3 years ago

Also see this excerpt from readme:

  // Whether prettify compiled render function or not (development only)
  // default: true
  prettify?: boolean

Does it mean that it's not intentional to have prettier installed when using @vue/component-compiler-utils as a dependency?

bodograumann commented 3 years ago

I have created a project including eslint+prettier with vue-cli and was a bit confused that after updating prettier to v2, there was still an instance of prettier v1 installed as a dependency of @vue-component-compiler-utils. Not sure how to get rid of it. Manually removing it from package-lock.json and using npm i --no-optional installs it still.

Levdbas commented 3 years ago

@sodatea could you take a look at this? It increases my node_module size by around 8mb. So given that I have around 100 projects. installed where component-compiler-utils is a dependency it is around 1 gigabyte of harddrive space that is wasted.

MathisTLD commented 3 years ago

this also brakes prettier-atom's behaviour why ins't prettier removed from dependencies (or installed as dev dependency) ?