I'm really confused about the dependencies in monorepo.
if there is a monorepo project like this
package/A
{
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"script": {
"build": "rimraf && tsup src/index.ts --format esm,cjs"
},
// tsup,rimraf should be placed here?
"devDependencies": {
"tsup": "xxx",
"rimraf": "xxx"
}
}
root package.json
{
// or tsup,rimraf should be placed here?
"devDependencies": {
"tsup": "xxx",
"rimraf": "xxx"
}
}
In common case, we will use yarn , lerna, pnpm in a monorepo project, yarn / lerna will hosit all dependencies in root node_modules, so you can use the package(rimraf, tsup) in sub package although the devDependencies is not specified in a sub package.json , as long as they are specified in root package.json.
In yarn's website
Be careful when publishing packages in a workspace. If you are preparing your next release and you decided to use a new dependency but forgot to declare it in the package.json file, your tests might still pass locally if another package already downloaded that dependency into the workspace root. However, it will be broken for consumers that pull it from a registry, since the dependency list is now incomplete so they have no way to download the new dependency. Currently there is no way to throw a warning in this scenario.
It seems that it's ok if you specified the devDenpencies in root in a library , because no one will run the script defined in package.json, main or module field was used only?
So, how to handle the devDependencies in monorepo?
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too