We're using NX for our monorepo setup and use a single package.json at the root to manage our dependencies. We're using Vite through the official Vite plugin for build and testing purposes.
Our repo contains some libraries that are published to NPM separately. When I built these libraries Vite generates the package.json using this config:
"build": {
"executor": "@nx/vite:build",
"options": {
"generatePackageJson": true,
}
}
NX automatically detects dependencies and adds them in the dependencies
I encountered an issue because Vite was also bundling the dependencies in my build output. I know I can fix this by listing these dependencies in my vite.config.ts
as external:
build: {
rollupOptions: {
external: [...],
},
},
However I would prefer not having to manually manage this list of exclusions. I found this rollup plugin but it unfortunately only works if those dependencies are listed as peerDependencies
.
So long description short: is there any configuration I can pass to NX/Vite to have the generated package.json of my libraries list the dependencies as peers?