-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Huge 27.4 MB install size #100
Comments
Hi @jaydenseric , First of all, thanks for the investigation. ❤️
yes, we will move it to the
We already thought about removing babel and use
As the project is the development tool, I think it does not hurt much. We will look for other alternatives. |
As far as I know, prettier is an opinionated code formatter, it does not allow writing a plugin which is already built in the prettier. So we can only write pre-processors to the prettier.
It does not accept an AST and it accepts the generated code as a string. |
@trivago/prettier-plugin-sort-imports
(currently v3) has a huge 27.4 MB install size:https://packagephobia.com/result?p=@trivago/[email protected]
This is unnecessarily inefficient. Personally, introducing this complexity and all the risks it entails to my projects outweighs the benefits and others might feel the same.
The first thing that jumps out is that all of
lodash
is being installed:prettier-plugin-sort-imports/package.json
Line 42 in 97a6c7f
lodash
being used at all is a smell; almost always there is a native way to do the same simple things without introducing a complicated dependency. Any of the more complicated thingslodash
might genuinely help with, like deep comparison and cloning, are also a smell. Almost always there is a more elegant way to write the code to avoid deep comparisons and cloning. If there really is no way around doing those complicated operations, then never install the fulllodash
package to use just a few exports. Install separate lodash packages for each utility used to avoid installing all the unused stuff. Do these things right, and > 1 MB can be shaved off the install size and potentially runtime memory usage could be reduced.It doesn't appear right to have the
@types/lodash
TypeScript types forlodash
installed as a production dependency:prettier-plugin-sort-imports/package.json
Line 40 in 97a6c7f
839 kB could be shaved of the install size by moving it to dev dependencies:
https://packagephobia.com/result?p=@types/[email protected]
A low hanging fruit (which you have already identified in #96) is to prevent all the junk like tests, docs, examples, markdown files, etc. from being published:
https://unpkg.com/browse/@trivago/[email protected]/
Can any of these Babel dependencies be avoided or substituted for lighter options?
prettier-plugin-sort-imports/package.json
Lines 35 to 39 in 97a6c7f
I haven't written a Prettier plugin before so I'm assuming there is no way to use the AST Prettier already generated? Does Prettier not accept an AST and do the string generation itself?
The text was updated successfully, but these errors were encountered: