Licence
MIT
Version
2.0.0
Deps
1
Size
18 kB
Vulns
0
Weekly
121
node-imports-info 
Info about node imports field support: version ranges, categories, etc.
The imports field (subpath imports, with specifiers prefixed by #) shares most of its resolution behavior with the exports field, but its features arrived on a different timeline. This package tracks imports-specific syntax support; for exports, see node-exports-info.
imports resolution also uses conditions (node, node-addons, require, import, module-sync, default); these are field-agnostic, so getConditionsForCategory/getCategoryInfo share their implementation (in node-package-field-info) with node-exports-info.
Categories
pre-imports: versions that do not support theimportsfield (< 12.19 || 13 - 14.5). The field was added in 14.6.0 and backported to 12.19.0, so the 13.x line and 14.0 - 14.5 never received it, despite being newer than 12.19imports: the first versions to support theimportsfield, including conditions and trailing-slash folder mappings, but not*patterns (~12.19 || 14.6 - 14.12)patterns: support for*subpath patterns was added in these versions (^12.20 || 14.13 - 14.18 || 15.x || 16.0 - 16.9)pattern-trailers: support for “pattern trailers” (a suffix after the*) was added in these versions (^14.19 || 16.10 - 16)pattern-trailers-no-dir-slash: support for trailing-slash folder mappings (ending in/) was removed for these versions (17 - 20.18 || ^21 || 22.0 - 22.11)pattern-trailers-no-dir-slash+module-sync: same syntax support, but themodule-synccondition was added in these versions (^20.19 || 22.12 - 24.13 || 25 - 25.3)subpath-imports-slash: these versions support subpath imports keys starting with#/, e.g."#/*": "./src/*.js"(^24.14 || >= 25.4)
Entry points
node-imports-info/getCategoriesForRange: takes a node semver version range; returns an array of categories that overlap itnode-imports-info/getCategory: takes an optional node semver version (defaults to the current node version); returns the latest category that matches itnode-imports-info/getCategoryFlags: takes a category; returns an object with boolean flags{ patterns, patternTrailers, dirSlash, subpathSlash }indicating whichimportsfeatures are supportednode-imports-info/getConditionsForCategory: takes a category and an optionalmoduleSystem('require'or'import'); returns the array of supported conditions, ornullif theimportsfield is unsupportednode-imports-info/getCategoryInfo: takes a category and an optionalmoduleSystem; returns an object withconditionsandflagsnode-imports-info/getRange: takes a category; returns the node semver version range that matches itnode-imports-info/getRangePairs: returns an array of entries - each a tuple of “semver range” and “category”node-imports-info/isCategory: takes a category; returns true if it’s a known category
Related packages
node-exports-info: the same, for theexportsfieldhas-package-imports: feature-detect your node version’simportssupport
Tests
Simply clone the repo, npm install, and run npm test
