get-conditions v1.0.0
get-conditions

Get Node import conditions at runtime
Install
npm install get-conditionsWhy?
In Node.js, users can pass in custom import conditions via --conditions to influence which paths are used when export or import maps are resolved.
However, this information is not available at runtime. This makes it difficult when implementing custom resolvers (e.g. statically analyzing an import path).
API
getConditions()
Returns: string[]
Example: ['node', 'node-addons', 'foo', 'bar']
Gets the import conditions for the current Node.js process.
require and import are excluded as their existence varies by how the current module was resolved. But you can add require/import back depending on which resolution type you prefer, before passing in the array into a resolver.
Note, the order of this array does not matter to the resolution algorithm (the order of the condition keys in the map does).
Sponsors
2 years ago