{"id":16347678,"url":"https://github.com/privatenumber/pkg-entry-points","last_synced_at":"2025-07-03T00:05:01.685Z","repository":{"id":165867968,"uuid":"641248186","full_name":"privatenumber/pkg-entry-points","owner":"privatenumber","description":"Get all entry-points for an npm package. Supports the `exports` field in `package.json`","archived":false,"fork":false,"pushed_at":"2024-10-24T14:45:10.000Z","size":279,"stargazers_count":24,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-05-19T21:04:14.176Z","etag":null,"topics":["entry-points","exports","nodejs","package-json"],"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/privatenumber.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},"funding":{"github":"privatenumber"}},"created_at":"2023-05-16T04:52:56.000Z","updated_at":"2025-03-28T20:04:27.000Z","dependencies_parsed_at":"2024-02-02T06:30:40.925Z","dependency_job_id":"a01dc4c7-2c2f-472b-b6b2-1019fd9fef04","html_url":"https://github.com/privatenumber/pkg-entry-points","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/privatenumber/pkg-entry-points","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fpkg-entry-points","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fpkg-entry-points/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fpkg-entry-points/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fpkg-entry-points/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/privatenumber","download_url":"https://codeload.github.com/privatenumber/pkg-entry-points/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fpkg-entry-points/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260953709,"owners_count":23088087,"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":["entry-points","exports","nodejs","package-json"],"created_at":"2024-10-11T00:44:45.040Z","updated_at":"2025-07-03T00:05:01.608Z","avatar_url":"https://github.com/privatenumber.png","language":"TypeScript","funding_links":["https://github.com/sponsors/privatenumber","https://github.com/sponsors/privatenumber/sponsorships?tier_id=398771","https://github.com/sponsors/privatenumber/sponsorships?tier_id=397608"],"categories":[],"sub_categories":[],"readme":"# pkg-entry-points\n\nGet all entry-points for an npm package. Supports the [`exports` field](https://nodejs.org/api/packages.html#exports) to expand subpaths and condition combinations.\n\n\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://github.com/sponsors/privatenumber/sponsorships?tier_id=398771\"\u003e\u003cimg width=\"412\" src=\"https://raw.githubusercontent.com/privatenumber/sponsors/master/banners/assets/donate.webp\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://github.com/sponsors/privatenumber/sponsorships?tier_id=397608\"\u003e\u003cimg width=\"412\" src=\"https://raw.githubusercontent.com/privatenumber/sponsors/master/banners/assets/sponsor.webp\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003csup\u003e\u003ci\u003eAlready a sponsor?\u003c/i\u003e Join the discussion in the \u003ca href=\"https://github.com/pvtnbr/pkg-entry-points\"\u003eDevelopment repo\u003c/a\u003e!\u003c/sup\u003e\u003c/p\u003e\n\n## Install\n\n```sh\nnpm install pkg-entry-points\n```\n\n## Usage\n\nTo get all entry-points for a package located at `./node_modules/my-package`:\n\n```ts\nimport { getPackageEntryPoints } from 'pkg-entry-points'\n\nconst packageExports = await getPackageEntryPoints('./node_modules/my-package')\n\nconsole.log(packageExports)\n\n/*\n{\n    '.': [\n        [conditions, internalPath],\n    ],\n    './entry-file': [\n        [['types'], './dist/entry-file.d.ts'],\n        [['import'], './dist/entry-file.mjs'],\n        [['require'], './dist/entry-file.js'],\n    ],\n    ...,\n}\n*/\n```\n\n### Example: `vue` - using `exports` conditions\nEntry-points evaluated from the [`vue` package](https://github.com/vuejs/core/blob/v3.3.2/packages/vue/package.json):\n\n\u003cdetails\u003e\n\t\u003csummary\u003e\u003ccode\u003evue\u003c/code\u003e entry-points\u003c/summary\u003e\n\n```json5\n{\n    \".\": [\n        [[\"types\"], \"./dist/vue.d.ts\"],\n        [[\"require\"], \"./index.js\"],\n        [[\"import\", \"node\"], \"./index.mjs\"],\n        [[\"default\", \"import\"], \"./dist/vue.runtime.esm-bundler.js\"]\n    ],\n    \"./server-renderer\": [\n        [[\"types\"], \"./server-renderer/index.d.ts\"],\n        [[\"import\"], \"./server-renderer/index.mjs\"],\n        [[\"require\"], \"./server-renderer/index.js\"]\n    ],\n    \"./compiler-sfc\": [\n        [[\"types\"], \"./compiler-sfc/index.d.ts\"],\n        [[\"import\"], \"./compiler-sfc/index.mjs\"],\n        [[\"require\"], \"./compiler-sfc/index.js\"]\n    ],\n    \"./dist/vue.cjs.js\": [\n        [[\"default\"], \"./dist/vue.cjs.js\"]\n    ],\n    \"./dist/vue.cjs.prod.js\": [\n        [[\"default\"], \"./dist/vue.cjs.prod.js\"]\n    ],\n    \"./dist/vue.d.ts\": [\n        [[\"default\"], \"./dist/vue.d.ts\"]\n    ],\n    \"./dist/vue.esm-browser.js\": [\n        [[\"default\"], \"./dist/vue.esm-browser.js\"]\n    ],\n    \"./dist/vue.esm-browser.prod.js\": [\n        [[\"default\"], \"./dist/vue.esm-browser.prod.js\"]\n    ],\n    \"./dist/vue.esm-bundler.js\": [\n        [[\"default\"], \"./dist/vue.esm-bundler.js\"]\n    ],\n    \"./dist/vue.global.js\": [\n        [[\"default\"], \"./dist/vue.global.js\"]\n    ],\n    \"./dist/vue.global.prod.js\": [\n        [[\"default\"], \"./dist/vue.global.prod.js\"]\n    ],\n    \"./dist/vue.runtime.esm-browser.js\": [\n        [[\"default\"], \"./dist/vue.runtime.esm-browser.js\"]\n    ],\n    \"./dist/vue.runtime.esm-browser.prod.js\": [\n        [[\"default\"], \"./dist/vue.runtime.esm-browser.prod.js\"]\n    ],\n    \"./dist/vue.runtime.esm-bundler.js\": [\n        [[\"default\"], \"./dist/vue.runtime.esm-bundler.js\"]\n    ],\n    \"./dist/vue.runtime.global.js\": [\n        [[\"default\"], \"./dist/vue.runtime.global.js\"]\n    ],\n    \"./dist/vue.runtime.global.prod.js\": [\n        [[\"default\"], \"./dist/vue.runtime.global.prod.js\"]\n    ],\n    \"./package.json\": [\n        [[\"default\"], \"./package.json\"]\n    ],\n    \"./macros\": [\n        [[\"default\"], \"./macros.d.ts\"]\n    ],\n    \"./macros-global\": [\n        [[\"default\"], \"./macros-global.d.ts\"]\n    ],\n    \"./ref-macros\": [\n        [[\"default\"], \"./ref-macros.d.ts\"]\n    ]\n}\n```\n\u003c/details\u003e\n\n\n### Example: `typescript` - no `exports` (legacy `main` field, etc.)\nEntry-points evaluated from the [`typescript` package](https://github.com/microsoft/TypeScript/blob/v5.0.4/package.json):\n\n\u003cdetails\u003e\n\t\u003csummary\u003e\u003ccode\u003etypescript\u003c/code\u003e entry-points\u003c/summary\u003e\n\n```json5\n{\n    \"./lib/cancellationToken.js\": [\n        [[\"default\"], \"./lib/cancellationToken.js\"]\n    ],\n    \"./lib/cs/diagnosticMessages.generated.json\": [\n        [[\"default\"], \"./lib/cs/diagnosticMessages.generated.json\"]\n    ],\n    \"./lib/de/diagnosticMessages.generated.json\": [\n        [[\"default\"], \"./lib/de/diagnosticMessages.generated.json\"]\n    ],\n    \"./lib/es/diagnosticMessages.generated.json\": [\n        [[\"default\"], \"./lib/es/diagnosticMessages.generated.json\"]\n    ],\n    \"./lib/fr/diagnosticMessages.generated.json\": [\n        [[\"default\"], \"./lib/fr/diagnosticMessages.generated.json\"]\n    ],\n    \"./lib/it/diagnosticMessages.generated.json\": [\n        [[\"default\"], \"./lib/it/diagnosticMessages.generated.json\"]\n    ],\n    \"./lib/ja/diagnosticMessages.generated.json\": [\n        [[\"default\"], \"./lib/ja/diagnosticMessages.generated.json\"]\n    ],\n    \"./lib/ko/diagnosticMessages.generated.json\": [\n        [[\"default\"], \"./lib/ko/diagnosticMessages.generated.json\"]\n    ],\n    \"./lib/pl/diagnosticMessages.generated.json\": [\n        [[\"default\"], \"./lib/pl/diagnosticMessages.generated.json\"]\n    ],\n    \"./lib/pt-br/diagnosticMessages.generated.json\": [\n        [[\"default\"], \"./lib/pt-br/diagnosticMessages.generated.json\"]\n    ],\n    \"./lib/ru/diagnosticMessages.generated.json\": [\n        [[\"default\"], \"./lib/ru/diagnosticMessages.generated.json\"]\n    ],\n    \"./lib/tr/diagnosticMessages.generated.json\": [\n        [[\"default\"], \"./lib/tr/diagnosticMessages.generated.json\"]\n    ],\n    \"./lib/tsc.js\": [\n        [[\"default\"], \"./lib/tsc.js\"]\n    ],\n    \"./lib/tsserver.js\": [\n        [[\"default\"], \"./lib/tsserver.js\"]\n    ],\n    \"./lib/tsserverlibrary.js\": [\n        [[\"default\"], \"./lib/tsserverlibrary.js\"]\n    ],\n    \"./lib/typesMap.json\": [\n        [[\"default\"], \"./lib/typesMap.json\"]\n    ],\n    \"./lib/typescript.js\": [\n        [[\"default\"], \"./lib/typescript.js\"]\n    ],\n    \"./lib/typingsInstaller.js\": [\n        [[\"default\"], \"./lib/typingsInstaller.js\"]\n    ],\n    \"./lib/watchGuard.js\": [\n        [[\"default\"], \"./lib/watchGuard.js\"]\n    ],\n    \"./lib/zh-cn/diagnosticMessages.generated.json\": [\n        [[\"default\"], \"./lib/zh-cn/diagnosticMessages.generated.json\"]\n    ],\n    \"./lib/zh-tw/diagnosticMessages.generated.json\": [\n        [[\"default\"], \"./lib/zh-tw/diagnosticMessages.generated.json\"]\n    ],\n    \"./package.json\": [\n        [[\"default\"], \"./package.json\"]\n    ],\n    \".\": [\n        [[\"default\"], \"./lib/typescript.js\"]\n    ]\n}\n```\n\u003c/details\u003e\n\n## API\n\n### getPackageEntryPoints(packagePath, fs?)\n\nReturns: `Promise\u003cPackageEntryPoints\u003e`\n\nType definitions:\n```ts\ntype PackageEntryPoints = {\n    [subpath: string]: ConditionToPath[]\n}\n\ntype ConditionToPath = [conditions: string[], internalPath: string]\n```\n\n#### Description\nReturns all possible entry-points of an npm package.\n\nIf the package has a `package.json#exports` property, it will return an object where the keys are expanded subpaths and the values are arrays of tuples containing an array of possible import combinations paired with the internal file path it resolves to.\n\nIf the package does not have an `exports` property, it will return an object where the keys are the internal file paths, mapping to arrays of possible import combinations.\n\n#### Parameters\n\n- `packagePath`\n\n    Type: `string`\n\n    Required\n\n    The path to the package to get the exports for.\n\n- `fs`\n\n    Type: `typeof import('fs/promises')`\n\n    Optional\n\n    Default: `fs.promises`\n\n    The file-system to use. Defaults to Node.js's `fs/promises` module.\n\n\n## Sponsors\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://github.com/sponsors/privatenumber\"\u003e\n\t\t\u003cimg src=\"https://cdn.jsdelivr.net/gh/privatenumber/sponsors/sponsorkit/sponsors.svg\"\u003e\n\t\u003c/a\u003e\n\u003c/p\u003e\n\n\n## Related\n\n### [resolve-pkg-maps](https://github.com/privatenumber/resolve-pkg-maps)\n\nUtils to resolve `package.json` subpath \u0026 conditional [`exports`](https://nodejs.org/api/packages.html#exports)/[`imports`](https://nodejs.org/api/packages.html#imports) maps in resolvers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fpkg-entry-points","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprivatenumber%2Fpkg-entry-points","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fpkg-entry-points/lists"}