最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

npm - How can I configure NX to add dependencies as peers in my publishable libraries outputted package.json files? - Stack Over

programmeradmin0浏览0评论

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?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论