{"id":17941130,"url":"https://github.com/chuhoman/unplugin-monorepo","last_synced_at":"2026-01-30T15:33:12.197Z","repository":{"id":244762198,"uuid":"812217699","full_name":"ChuHoMan/unplugin-monorepo","owner":"ChuHoMan","description":"Require the least configuration for support bundling of local packages within a monorepo.使用最少的配置来支持在 monorepo 中打包本地包。","archived":false,"fork":false,"pushed_at":"2024-06-17T08:14:04.000Z","size":177,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-24T00:36:42.729Z","etag":null,"topics":["monorepo","unplugin","vite"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChuHoMan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-08T09:13:03.000Z","updated_at":"2025-10-13T08:53:48.000Z","dependencies_parsed_at":"2024-06-17T09:39:53.468Z","dependency_job_id":"5b2cee24-0e55-4dfe-b03c-f061a1370dec","html_url":"https://github.com/ChuHoMan/unplugin-monorepo","commit_stats":null,"previous_names":["chuhoman/unplugin-monorepo"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ChuHoMan/unplugin-monorepo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChuHoMan%2Funplugin-monorepo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChuHoMan%2Funplugin-monorepo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChuHoMan%2Funplugin-monorepo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChuHoMan%2Funplugin-monorepo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChuHoMan","download_url":"https://codeload.github.com/ChuHoMan/unplugin-monorepo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChuHoMan%2Funplugin-monorepo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28914905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T12:13:43.263Z","status":"ssl_error","status_checked_at":"2026-01-30T12:13:22.389Z","response_time":66,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["monorepo","unplugin","vite"],"created_at":"2024-10-29T01:05:37.576Z","updated_at":"2026-01-30T15:33:12.166Z","avatar_url":"https://github.com/ChuHoMan.png","language":"TypeScript","readme":"# unplugin-monorepo\n\n[![npm](https://img.shields.io/npm/v/unplugin-monorepo?color=91B2D4\u0026label=)](https://npmjs.com/package/unplugin-monorepo)\n\n\u003cp align='center'\u003e\n\u003cb\u003eEnglish\u003c/b\u003e | \u003ca href=\"https://github.com/ChuHoMan/unplugin-monorepo/blob/main/README.zh-CN.md\"\u003e简体中文\u003c/a\u003e\n\u003c/p\u003e\n\n\nRequire the least configuration for support bundling of local packages within a monorepo.\n\n\u003e Inspired by [vite-ts-monorepo-rfc](https://github.com/vitejs/vite-ts-monorepo-rfc/blob/main/RFC-v1.md#5-vitebundler-packagejson-configuration)\n\n## Installation\n\n```bash\nnpm i unplugin-monorepo -D\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eVite\u003c/summary\u003e\u003cbr\u003e\n\n```ts\n// vite.config.ts\nimport { viteMonorepo } from 'unplugin-monorepo/vite';\n\nexport default defineConfig({\n  plugins: [\n    viteMonorepo({ /* options */ }),\n  ],\n});\n```\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eRollup [🚧Working in process]\u003c/summary\u003e\u003cbr\u003e\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWebpack [🚧Working in process]\u003c/summary\u003e\u003cbr\u003e\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eRspack [🚧Working in process]\u003c/summary\u003e\u003cbr\u003e\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eNuxt\u003c/summary\u003e\u003cbr\u003e\n\n\u003e Currently, only VITE is supported\n\n```ts\n// nuxt.config.js\nexport default defineNuxtConfig({\n  modules: [\n    ['unplugin-monorepo/nuxt', { /* options */ }],\n  ],\n});\n```\n\n\u003e This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eVue CLI [🚧Working in process]\u003c/summary\u003e\u003cbr\u003e\n\n\u003cbr\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eesbuild [🚧Working in process]\u003c/summary\u003e\u003cbr\u003e\n\n\u003cbr\u003e\u003c/details\u003e\n\n## Usage\n\nFirst, install and import `unplugin-monorepo` as described above.\n\nNext, let's take the simplest `monorepo` as an example. The directory structure is as follows:\n\n```\nmonorepo\n├── app # Application\n└── lib # Library\n    └── src\n        └── index.ts\n```\n\nIn this structure, app depends on lib.\n\n```json\n{\n  \"name\": \"app\",\n  \"devDependencies\": {\n    \"lib\": \"workspace:*\"\n  }\n}\n```\n\n### Configuring Sub-Projects\n\nWhen registering `unplugin-monorepo`, the `bundler` will prioritize reading the file corresponding to the `bundler.sourceDir` field of the sub-project during the bundling process. Therefore, you need to configure the `bundler.sourceDir` field in the package.json file of the sub-project and point to the source file path.\n\nFor example, in the following example, when referencing a `lib` package, it will read the `./src/index.ts` file to build:\n\n```json\n{\n  \"name\": \"lib\",\n  \"bundler\": {\n    \"sourceDir\": \"src\"\n  }\n}\n```\n\n### TypeScript Projects\n\nIn TypeScript projects, you need to use TypeScript's `Project Reference` feature, which can help you use source code development in combination with `unplugin-monorepo`.\n\nProject reference provides the following capabilities:\n\n- Allows TypeScript to correctly recognize the types of other sub-projects without needing to build the sub-projects.\n- When navigating code in VS Code, VS Code can automatically jump to the source code files of the corresponding modules.\n\nBased on the above example, where app references the lib sub-project, we need to configure `composite` and `references` in app's `tsconfig.json`, pointing to the relative directory of lib:\n\napp/tsconfig.json:\n\n```json\n{\n  \"compilerOptions\": {\n    \"composite\": true\n  },\n  \"references\": [\n    {\n      \"path\": \"../lib\"\n    }\n  ]\n}\n```\n\nAdditionally, you need to configure `rootDir` in the lib sub-project:\n\nlib/tsconfig.json:\n\n```json\n{\n  \"compilerOptions\": {\n    \"rootDir\": \"src\"\n  }\n}\n```\n\nAfter adding the above configuration, the project reference is configured. You can restart VS Code to see the effect of the configuration.\n\nThe above is just a simple example. In actual monorepo projects, there may be more complex dependencies, and you need to add complete `references` configurations to make the above features work correctly.\n\n**If the above configuration doesn't solve your problem, feel free to open an ISSUE**\n\n## Options Configuration\n\n```ts\nexport interface Options {\n  /**\n   * package.json special meta key\n   * @zh 读取 `package.json` 自定义字段，用于配置源代码文件对应的解析字段。\n   * @default 'bundler'\n   */\n  packageMetaKey?: string\n  /**\n   * package.json special meta default value\n   * @zh 读取 `package.json` 自定义字段 `packageMetaKey` 后，解析字段值的默认值。\n   * */\n  packageMetaDefaultValue?: {\n    sourceDir: string\n  }\n}\n```\n\n## Examples\n\nThere are examples in the [playgrounds](https://github.com/ChuHoMan/unplugin-monorepo/tree/main/playgrounds) of this repository, which you can refer to.\n\n## Credits\n\n- [vite-ts-monorepo-rfc](https://github.com/vitejs/vite-ts-monorepo-rfc) is the main inspiration for this project. Before implementing this solution, I only used the `conditions` field in `vite.config.ts`, but after recognizing the pain points mentioned in the RFC, I decided to develop this plugin.\n- [@rsbuild/plugin-source-build](https://github.com/web-infra-dev/rsbuild/tree/main/packages/plugin-source-build) provided inspiration for configuring TypeScript Project Reference in this project.\n- [vite](https://github.com/vitejs/vite) Most of the utility functions are derived from Vite.\n\n## License\n\nMade with 💙\n\nPublished under [MIT License](./LICENSE).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchuhoman%2Funplugin-monorepo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchuhoman%2Funplugin-monorepo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchuhoman%2Funplugin-monorepo/lists"}