preconstruct / preconstruct

🎁 Dev and build your code painlessly in monorepos
https://preconstruct.tools
MIT License
1.17k stars 61 forks source link

Tracking issue for dependency optimization #608

Open VanTanev opened 1 month ago

VanTanev commented 1 month ago

The starting point of @preconstruct/cli@2.8.9 - https://npmgraph.js.org/?q=%40preconstruct%2Fcli%402.8.9 - 164 dependencies

VanTanev commented 1 month ago

There are two options for chalk - we can either migrate to picocolors, but then the tests must include color codes - see https://github.com/preconstruct/preconstruct/pull/606/commits/664680e74b529439afe0f8756f5c412085cecc3e#diff-6e2e2a1851648938b325ba84de634407a4e69a644ea61102df15ca4a8a7a9758

Or, we could upgrade to the latest chalk which bundles its dependencies, but is ESM-only, with all the problems that brings. At the very least, we would need to do some changes to the jest config because it chokes on the chalk import statement, not sure what else.

VanTanev commented 1 month ago

parse-json is another ESM-only dependency in its latest version, so it might be worth considering making @preconstruct/cli ESM, and maybe migrating from jest to vitest? If the maintainers think this is worth pursuing, I will work on the related PRs.

VanTanev commented 1 month ago

btw, in terms of dependency-optimization, moving from babel to either esbuild-register or tsx, both of which use esbuild under the hood to do the live transpilation would bring the biggest benefit.

Another nice side-effect of the above is that live transpilation will follow the rules in tsconfig.json, instead of needing a separate babel.config.js

The second biggest would be to upgrade rollup plugins.