Title: Missing documentation for exports alternative paths · Issue #58600 · nodejs/node · GitHub
Open Graph Title: Missing documentation for exports alternative paths · Issue #58600 · nodejs/node
X Title: Missing documentation for exports alternative paths · Issue #58600 · nodejs/node
Description: Affected URL(s) https://nodejs.org/api/packages.html Description of the problem Packages documentation is really helpful to understand motivations and practical usage of exports, from the simplest setup to nested conditions, wildcards, e...
Open Graph Description: Affected URL(s) https://nodejs.org/api/packages.html Description of the problem Packages documentation is really helpful to understand motivations and practical usage of exports, from the simplest ...
X Description: Affected URL(s) https://nodejs.org/api/packages.html Description of the problem Packages documentation is really helpful to understand motivations and practical usage of exports, from the simplest ...
Opengraph URL: https://github.com/nodejs/node/issues/58600
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Missing documentation for exports alternative paths","articleBody":"### Affected URL(s)\n\nhttps://nodejs.org/api/packages.html\n\n### Description of the problem\n\nPackages documentation is really helpful to understand motivations and practical usage of `exports`, from the simplest setup to nested conditions, wildcards, etc. However, it seems to lack a description and examples of \"alternative paths\" within `exports`, which I think is really powerful stuff, but currently underrated and not very popular (maybe because of the lack in documentation).\n\nWith \"alternative paths\" what I mean is using arrays as follows:\n\n```json\n{\n \"exports\": {\n \".\": {\n \"development\": {\n \"types\": \"./src/index.ts\",\n \"import\": \"./src/index.js\",\n \"require\": \"./src/index.cjs\",\n \"default\": \"./src/index.cjs\"\n },\n \"import\": {\n \"types\": \"./types/index.d.ts\",\n \"default\": [\n \"./src/index.js\",\n \"./esm/index.js\"\n ]\n },\n \"require\": [\n \"./src/index.cjs\",\n \"./cjs/index.cjs\"\n ],\n \"default\": [\n \"./src/index.cjs\",\n \"./cjs/index.cjs\"\n ]\n }\n }\n}\n```\n\nThe only hint I found in the documentation, is `string[]` syntax under [exports](https://nodejs.org/api/packages.html#exports).\n\nBeside that, there are some mentions around:\n- Webpack's official docs citing Node.js behaviour: https://webpack.js.org/guides/package-exports/#alternatives.\n- Notable TypeScript issue requesting aligning to Node.js behaviour: https://github.com/nodejs/node/issues/37928\n\nI think that \"alternative paths\" is the perfect solution for situations like using your own package without having to build it first during development (e.g., TypeScript, transpiling, polyfilling, etc.)\n\nIf there is a spec I would love to update the docs myself.\n","author":{"url":"https://github.com/ernestostifano","@type":"Person","name":"ernestostifano"},"datePublished":"2025-06-06T11:04:03Z","url":"https://github.com/nodejs/node/issues/58600"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c053175b-de2f-65cc-6dd6-9e667e331777 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 969E:1CF733:1F602A:2C5E79:6AFBFF94 |
| html-safe-nonce | d4150a3a1e775917ab8f894368ec48fec663c3dfa45bc481b2906e504399a53a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjlFOjFDRjczMzoxRjYwMkE6MkM1RTc5OjZBRkJGRjk0IiwidmlzaXRvcl9pZCI6IjcwMDgwMjcwNzMxMjM0NDk4MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c06e82606b854d8f789541aedaee11f9510271386d1d1ec7b0c9ffc01da042da |
| hovercard-subject-tag | issue:3124450498 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/58600/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cf55a9d512eb078405a49f46bd4b9d7d8cc5cecce66c53e608d9379e93510862/nodejs/node/issues/58600 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cf55a9d512eb078405a49f46bd4b9d7d8cc5cecce66c53e608d9379e93510862/nodejs/node/issues/58600 |
| og:image:alt | Affected URL(s) https://nodejs.org/api/packages.html Description of the problem Packages documentation is really helpful to understand motivations and practical usage of exports, from the simplest ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ernestostifano |
| hostname | github.com |
| expected-hostname | github.com |
| None | fa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b3b5633a74535d9c23385512d534c66c8fde1907 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width