gsoft-inc / wl-web-configs

Shared configurations for building web applications at Workleap.
https://gsoft-inc.github.io/wl-web-configs/
Apache License 2.0
3 stars 2 forks source link

tsup setup #17

Closed patricklafrance closed 1 year ago

patricklafrance commented 1 year ago

Similarly to our other tools, tsup should have it's own tsup.config.js or tsup.config.json file instead of being configured in the package.json file.

Furthermore, since we are using PNPM, devDependencies should be declared in every package instead of the monorepo root. tsup dependency is currently problematic.

alexasselin008 commented 1 year ago

Similarly to our other tools, tsup should have it's own tsup.config.js or tsup.config.json file instead of being configured in the package.json file.

No problem

Furthermore, since we are using PNPM, devDependencies should be declared in every package instead of the monorepo root. tsup dependency is currently problematic.

I'm not so sure about that. I was looking at Chakra UI, and they have tsup at the root only, instead of in each packages.

I would prefer having it at the root only, since i want this dependency to be the same across all my packages

patricklafrance commented 1 year ago

I'm not so sure about that. I was looking at Chakra UI, and they have tsup at the root only, instead of in each packages.

I would prefer having it at the root only, since i want this dependency to be the same across all my packages

I get it, it's faster to bumb the version this way. I am not sure why Chakra UI is doing it this way thought as it's not how PNPM is intended to work.

When installing dependencies with npm or Yarn Classic, all packages are hoisted to the root of the modules directory. As a result, source code has access to dependencies that are not added as dependencies to the project.

By default, pnpm uses symlinks to add only the direct dependencies of the project into the root of the modules directory.

Source: https://pnpm.io/motivation#creating-a-non-flat-node_modules-directory

Adding devDependencies at the root of the monorepo has always caused ambiguity IMO as developpers must remember to make a conscious decision about whether the dependency is used by all the packages and should be added at the root of the monorepo or the dependency is only used by a single or a few packages and should be added as direct devDependencies of a single or few packages.

It's seem trivial for tsup but for other dependencies it might not be.

When a devDependencies is added at the root of the monorepo, as time goes by, it becomes harder to say if the dependency is still used or not because the dependency is not attached to a specific package. If that specific project is not using the dependency anymore but no one knows for sure that it was the only project using the dependency, the project end up with an unused dependency to install because no one wants to remove the dependency and break something.

Overall, adding tsup as a direct devDependencies might be more painful short term but I believe it will pay off overtime.

patricklafrance commented 1 year ago

I searched to find other popular project repos using PNPM to find out what they are doing. While it's not all black or white, most seems to be adding devDependencies per package.