{"id":13417364,"url":"https://github.com/zheeeng/vite-plugin-shared-modules","last_synced_at":"2025-10-19T04:02:14.131Z","repository":{"id":57393184,"uuid":"414362383","full_name":"zheeeng/vite-plugin-shared-modules","owner":"zheeeng","description":"Share node_modules in monorepos. Best friend for pnpm's module isolation and module singletons sharing.","archived":false,"fork":false,"pushed_at":"2024-12-10T22:45:15.000Z","size":258,"stargazers_count":33,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-18T02:51:57.752Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vite-plugin-shared-modules","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zheeeng.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2021-10-06T20:36:08.000Z","updated_at":"2025-03-06T17:08:02.000Z","dependencies_parsed_at":"2023-12-21T05:12:26.650Z","dependency_job_id":"558d4b58-b387-4873-87ab-f3593b75f5ca","html_url":"https://github.com/zheeeng/vite-plugin-shared-modules","commit_stats":{"total_commits":19,"total_committers":3,"mean_commits":6.333333333333333,"dds":"0.21052631578947367","last_synced_commit":"3e37353502936b7e2848b50078c81e52b0967b76"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/zheeeng/vite-plugin-shared-modules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zheeeng%2Fvite-plugin-shared-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zheeeng%2Fvite-plugin-shared-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zheeeng%2Fvite-plugin-shared-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zheeeng%2Fvite-plugin-shared-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zheeeng","download_url":"https://codeload.github.com/zheeeng/vite-plugin-shared-modules/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zheeeng%2Fvite-plugin-shared-modules/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260633551,"owners_count":23039375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-07-30T22:00:35.813Z","updated_at":"2025-10-19T04:02:14.047Z","avatar_url":"https://github.com/zheeeng.png","language":"TypeScript","readme":"# vite-plugin-shared-modules\n\n\u003cdiv align=\"center\"\u003e\n\n[![Known Vulnerabilities][known-vulnerabilities-image]][known-vulnerabilities-url]\n[![Maintainability][maintainability-image]][maintainability-url]\n![publish workflow][publish-workflow-image]\n[![license][license-image]][license-url]\n[![GitHub issues][github-issues-image]][github-issues-url]\n![NPM bundle size(minified + gzip)][bundle-size-image]\n\n[known-vulnerabilities-image]: https://snyk.io/test/github/zheeeng/vite-plugin-shared-modules/badge.svg\n[known-vulnerabilities-url]: https://snyk.io/test/github/zheeeng/vite-plugin-shared-modules\n\n[maintainability-image]: https://api.codeclimate.com/v1/badges/d3eaf22221bf57742429/maintainability\n[maintainability-url]: https://codeclimate.com/github/zheeeng/vite-plugin-shared-modules/maintainability\n\n[publish-workflow-image]: https://github.com/zheeeng/vite-plugin-shared-modules/actions/workflows/publish.yml/badge.svg\n\n[license-image]: https://img.shields.io/github/license/mashape/apistatus.svg\n[license-url]: https://github.com/zheeeng/vite-plugin-shared-modules/blob/master/LICENSE\n\n[github-issues-image]: https://img.shields.io/github/issues/zheeeng/vite-plugin-shared-modules\n[github-issues-url]: https://github.com/zheeeng/vite-plugin-shared-modules/issues\n\n[bundle-size-image]: https://img.shields.io/bundlephobia/minzip/vite-plugin-shared-modules.svg\n\n[![NPM](https://nodei.co/npm/vite-plugin-shared-modules.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/vite-plugin-shared-modules/)\n\n\u003c/div\u003e\n\n\u003e Share node_modules in monorepos. Best friend for pnpm's module isolation and module singletons sharing.\n\nUse it as simple as:\n\n```ts\n// vite.config.ts\nimport { defineConfig } from 'vite';\nimport sharedModulesPlugin from 'vite-plugin-shared-modules'\nimport tsconfigPaths from 'rollup-plugin-tsconfig-paths';\n\nexport default defineConfig({\n  plugins: [\n    sharedModulesPlugin({\n      packageName: '@monorepo/shared',\n    }),\n    // necessary for resolving modules in `node_modules`\n    tsconfigPaths({\n      // specify the project's tsconfig.json, which configured paths mapping.\n      tsConfigPath: join(__dirname, '../../tsconfig.json')\n    }),\n  ]\n});\n```\n\nthen you can import singletons by this way:\n\n```ts\nimport foo from '@monorepo/shared/foo'\nimport bar from '@monorepo/shared/bar'\n```\n\nis equivalent to\n\n```ts\nimport foo from '@monorepo/shared/node_modules/foo'\nimport bar from '@monorepo/shared/node_modules/bar'\n```\n\nmoreover for getting type-safe, add tsconfig paths mapping:\n\n```json\n// tsconfig.json\n{\n    \"compilerOptions\": {\n        \"baseUrl\": \".\",\n            \"paths\": {\n                \"@monorepo/shared/*\": [\"./packages/shared/node_modules/*\", \"./packages/shared/node_modules/@types/*\"]\n            }\n    }\n}\n```\n\nthe example above we assume the package `@monorepo/shared` is located under `./packages/shared`.\n\n---\n\n## Full Option\n\nThe plugin options signatures:\n\n```ts\nexport type SharedModulesPluginOption = {\n  packageName: string,\n  subpath?: string,\n  nodeModules?: string,\n  sourceMap?: boolean,\n}\n```\n\nThe default options:\n\n```ts\nexport const defaultSharedModules = {\n  subpath: '',\n  nodeModules: 'node_modules',\n  sourceMap: true,\n}\n```\n","funding_links":[],"categories":["Plugins","TypeScript","others"],"sub_categories":["Framework-agnostic Plugins"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzheeeng%2Fvite-plugin-shared-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzheeeng%2Fvite-plugin-shared-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzheeeng%2Fvite-plugin-shared-modules/lists"}