Add a way to get the enabled conditions #55824
Labels
feature request
Issues that request new features to be added to Node.js.
module
Issues and PRs related to the module subsystem.
What is the problem this feature will solve?
Currently there is no way to get the enabled conditions easily. It requires checking
process.env.NODE_OPTIONS
andprocess.execArgv
which is not robust. It should be noted that although it is an edge case, theprocess.env.NODE_OPTIONS
check should be done before any code that modifies that variable.Some concrete cases:
parent
parameter ofimport.meta.resolve
is out of experimental, but I guess exposingconditions
is less controversial than graduating that API from experimental)require
orimport
so it uses the custom resolver. If Vite usesrequire
orimport
, the resolve result is gets cached and requires the program to be restarted.custom
conditions, to show a warning they have to parse the conditions to do that for now.What is the feature you are proposing to solve the problem?
Add
conditions
variable innode:module
.Example code:
I didn't add
node
toconditions
in the example above, but maybe it makes sense to add that too.But for
import
andrequire
, I'm not sure if those should be added in that case. Probably the option would be to add both or neither.What alternatives have you considered?
getOptionValue
([Feature] Expose getOptionValue via process.getOptionValue #36935): this one got stale because it is difficult to make the API stable.The text was updated successfully, but these errors were encountered: