| 1 | # node-exports-info <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
|---|
| 2 |
|
|---|
| 3 | [![github actions][actions-image]][actions-url]
|
|---|
| 4 | [![coverage][codecov-image]][codecov-url]
|
|---|
| 5 | [![License][license-image]][license-url]
|
|---|
| 6 | [![Downloads][downloads-image]][downloads-url]
|
|---|
| 7 |
|
|---|
| 8 | [![npm badge][npm-badge-png]][package-url]
|
|---|
| 9 |
|
|---|
| 10 | Info about node `exports` field support: version ranges, categories, etc.
|
|---|
| 11 |
|
|---|
| 12 | ## Categories
|
|---|
| 13 | - `pre-exports`: versions before node supported `exports` in any way (`< 12.17`)
|
|---|
| 14 | - `broken`: versions that have a broken `exports` implementation. These only support the string form, and array fallbacks. (`13.0 - 13.2`)
|
|---|
| 15 | - `experimental`: versions where `exports` support was experimental. These only support the “default” condition in the object form. (`13.3 - 13.6`)
|
|---|
| 16 | - `conditions`: the first versions where `exports` support was unflagged. (`13.7 - 13.12`)
|
|---|
| 17 | - `broken-dir-slash-conditions`: `conditions`, but directory exports (ending in `./`) are broken in these versions (`12.17 - 12.19 || ^13.13 || 14.0 - 14.12`)
|
|---|
| 18 | - `patterns`: support for “patterns” was added in these versions, and directory exports (ending in `./`) are broken (`^12.20 || 14.13 - 14.18 || 15.x || 16.0 - 16.8`)
|
|---|
| 19 | - `pattern-trailers`: support for “pattern trailers” was added in these versions (`^14.19 || 16.9 - 16.13`)
|
|---|
| 20 | - `pattern-trailers+json-imports`: `pattern-trailers`, and JSON can be `import`ed (`^16.14`)
|
|---|
| 21 | - `pattern-trailers-no-dir-slash`: support for directory exports (ending in `./`) was removed for these versions (`17.0`)
|
|---|
| 22 | - `pattern-trailers-no-dir-slash+json-imports`: `pattern-trailers-no-dir-slash`, and JSON can be `import`ed (`17.1 - 19 || 20 - 20.18 || ^21 || 22 - 22.11`)
|
|---|
| 23 | - `require-esm`: ESM files can be `require`d (`23 - 23.5 || 22.12 - 22.17 || ^20.19`)
|
|---|
| 24 | - `strips-types`: these versions also automatically strip types from typescript files, for both `require` and `import` (`23.6 - 25.3 || ^22.18`)
|
|---|
| 25 | - `subpath-imports-slash`: these versions support `#/` subpath imports patterns in the `imports` field, e.g. `"#/*": "./src/*.js"` (`>= 25.4`)
|
|---|
| 26 |
|
|---|
| 27 | ## Entry points
|
|---|
| 28 | - `node-exports-info/getCategoriesForRange`: takes a node semver version range; returns an array of categories that overlap it
|
|---|
| 29 | - `node-exports-info/getCategory`: takes an optional node semver version (defaults to the current node version); returns the latest category that matches it
|
|---|
| 30 | - `node-exports-info/getCategoryFlags`: takes a category; returns an object with boolean flags `{ patterns, patternTrailers, dirSlash }` indicating which `exports` features are supported
|
|---|
| 31 | - `node-exports-info/getCategoryInfo`: takes a category and an optional `moduleSystem` (`'require'` or `'import'`); returns an object with `conditions` (array or null) and `flags` (from `getCategoryFlags`)
|
|---|
| 32 | - `node-exports-info/getConditionsForCategory`: takes a category and an optional `moduleSystem` (`'require'` or `'import'`); returns an array of `exports` "conditions" that is supported, or `null` if `exports` itself is not supported
|
|---|
| 33 | - `node-exports-info/getRange`: takes a category; returns the node semver version range that matches it
|
|---|
| 34 | - `node-exports-info/getRangePairs`: returns an array of entries - each a tuple of “semver range” and “category”
|
|---|
| 35 | - `node-exports-info/isCategory`: takes a category; returns true if it’s a known category
|
|---|
| 36 |
|
|---|
| 37 | ## Related packages
|
|---|
| 38 | - [`has-package-exports`](https://www.npmjs.com/package/has-package-exports): feature-detect your node version’s `exports` support
|
|---|
| 39 |
|
|---|
| 40 | ## Tests
|
|---|
| 41 | Simply clone the repo, `npm install`, and run `npm test`
|
|---|
| 42 |
|
|---|
| 43 | [package-url]: https://npmjs.org/package/node-exports-info
|
|---|
| 44 | [npm-version-svg]: https://versionbadg.es/inspect-js/node-exports-info.svg
|
|---|
| 45 | [deps-svg]: https://david-dm.org/inspect-js/node-exports-info.svg
|
|---|
| 46 | [deps-url]: https://david-dm.org/inspect-js/node-exports-info
|
|---|
| 47 | [dev-deps-svg]: https://david-dm.org/inspect-js/node-exports-info/dev-status.svg
|
|---|
| 48 | [dev-deps-url]: https://david-dm.org/inspect-js/node-exports-info#info=devDependencies
|
|---|
| 49 | [npm-badge-png]: https://nodei.co/npm/node-exports-info.png?downloads=true&stars=true
|
|---|
| 50 | [license-image]: https://img.shields.io/npm/l/node-exports-info.svg
|
|---|
| 51 | [license-url]: LICENSE
|
|---|
| 52 | [downloads-image]: https://img.shields.io/npm/dm/node-exports-info.svg
|
|---|
| 53 | [downloads-url]: https://npm-stat.com/charts.html?package=node-exports-info
|
|---|
| 54 | [codecov-image]: https://codecov.io/gh/inspect-js/node-exports-info/branch/main/graphs/badge.svg
|
|---|
| 55 | [codecov-url]: https://app.codecov.io/gh/inspect-js/node-exports-info/
|
|---|
| 56 | [actions-image]: https://img.shields.io/github/check-runs/inspect-js/node-exports-info/main
|
|---|
| 57 | [actions-url]: https://github.com/inspect-js/node-exports-info/actions
|
|---|