{"id":17702428,"url":"https://github.com/teppeis/typescript-subpath-exports-workaround","last_synced_at":"2025-07-09T09:15:21.247Z","repository":{"id":48139694,"uuid":"335991315","full_name":"teppeis/typescript-subpath-exports-workaround","owner":"teppeis","description":"Workaround for Node.js subpath exports in TypeScript","archived":false,"fork":false,"pushed_at":"2021-02-04T15:51:54.000Z","size":14,"stargazers_count":40,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-06T21:08:16.318Z","etag":null,"topics":["nodejs","typescript"],"latest_commit_sha":null,"homepage":"","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/teppeis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-04T15:10:17.000Z","updated_at":"2024-09-05T01:21:21.000Z","dependencies_parsed_at":"2022-07-29T01:18:03.797Z","dependency_job_id":null,"html_url":"https://github.com/teppeis/typescript-subpath-exports-workaround","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teppeis%2Ftypescript-subpath-exports-workaround","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teppeis%2Ftypescript-subpath-exports-workaround/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teppeis%2Ftypescript-subpath-exports-workaround/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teppeis%2Ftypescript-subpath-exports-workaround/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teppeis","download_url":"https://codeload.github.com/teppeis/typescript-subpath-exports-workaround/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252769423,"owners_count":21801378,"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":["nodejs","typescript"],"created_at":"2024-10-24T19:07:17.976Z","updated_at":"2025-05-06T21:08:25.831Z","avatar_url":"https://github.com/teppeis.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# typescript-subpath-exports-workaround\n\nWorkaround for Node.js subpath exports in TypeScript\n\n[![npm version][npm-image]][npm-url]\n![license][license]\n\n\n## Why?\n\nNode.js v12+ extends [package entry points features](https://nodejs.org/api/packages.html#packages_package_entry_points) like [subpath exports](https://nodejs.org/api/packages.html#packages_subpath_exports) or [conditional exports](https://nodejs.org/api/packages.html#packages_conditional_exports) but TypeScript doesn't support them yet.\n\n\u003e [Support for NodeJS 12.7+ package exports · Issue #33079 · microsoft/TypeScript · GitHub](https://github.com/microsoft/TypeScript/issues/33079)\n\n## How?\n\nUse [`typesVersions`](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#version-selection-with-typesversions) to workaround.\n\n#### package.json\n\n```json\n{\n  \"main\": \"dist/index.js\",\n  \"types\": \"dist-types/index.d.ts\",\n  \"exports\": {\n    \".\": \"./dist/index.js\",\n    \"./exported\": \"./dist/exported.js\"\n  },\n  \"typesVersions\": {\n    \"*\": {\n      \"exported\": [\"dist-types/exported\"]\n    }\n  }\n}\n```\n\nUsers can import only the package root and the exported subpath `/exported`.\n\n```ts\n// Pass\nimport \"typescript-subpath-exports-workaround\"\nimport \"typescript-subpath-exports-workaround/exported\"\n\n// Error\nimport \"typescript-subpath-exports-workaround/not-exported\"\nimport \"typescript-subpath-exports-workaround/dist/exported\"\nimport \"typescript-subpath-exports-workaround/dist/not-exported\"\n```\n\n## Demo\n\nYou can install and try this package.\n\n```console\n$ npm i typescript-subpath-exports-workaround\n```\n\n## License\n\nMIT\n\n[npm-image]: https://badgen.net/npm/v/typescript-subpath-exports-workaround?icon=npm\u0026label=\n[npm-url]: https://npmjs.org/package/typescript-subpath-exports-workaround\n[npm-downloads-image]: https://badgen.net/npm/dm/typescript-subpath-exports-workaround\n[ts-version]: https://badgen.net/badge/typescript/%3E=4.1?icon=typescript\n[license]: https://badgen.net/npm/license/typescript-subpath-exports-workaround\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteppeis%2Ftypescript-subpath-exports-workaround","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteppeis%2Ftypescript-subpath-exports-workaround","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteppeis%2Ftypescript-subpath-exports-workaround/lists"}