-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Expose getOptionValue via process.getOptionValue #36935
Comments
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment. For more information on how the project manages feature requests, please consult the feature request management document. |
This is still of interest to us. |
Add `process.getOptionValue` that exposes `getOptionValue` in `internal/options`. Fixes: nodejs#36935
Add `process.getOptionValue` that exposes `getOptionValue` in `internal/options`. Fixes: nodejs#36935
Reopening because of #46404. However, is providing access to the raw options really the best approach here? This appears to introduce fragility. What if node changes If it is relevant for applications to determine this particular value and if it is infeasible to parse |
Yes, but a) we’re very unlikely to change this, as it’s been stable for a few years now (right @guybedford ?) and b) the benefit to users of being able to parse this would feel to me to outweigh our need to possibly change the schema of |
It’s been on our to-do list for a long time to provide a utility function to expose Node’s internal |
The availability of that function would also help me add exports support to |
This is iteration umpteen of the age old discussion of whether node should expose its internal convenience functions. IMO, we've regretted doing that more often than not because it ossifies what was an inconsequential implementation detail before. Sometimes user JS code simply doesn't have the means to emulate node's internals but it does here; it could be an npm package. |
There are already countless implementation of Node-like resolve algorithms, all with their own little (or big) discrepancies with the algorithms used by Node - sometimes because of shortcuts, sometimes because the maintainer went AWOL, sometimes because implementation is difficult, sometimes because [...]. From my perspective, it's rather the other way around: Node should strive to make more of its internal algorithms available as generic libraries (possibly by publishing them on npm), as otherwise it's very difficult for tooling authors to provide an experience that matches the stock Node one. In my mind, Node should conceptually be just one more consumer of the "@nodejs/resolution-algorithms" package, using dependency injection to provide I/O support.
For reference, these are the functions that we more or less copy-paste from the Node codebase (that doesn't include the @merceyz is kind of our resident expert on the ESM loader, he might have a couple more utilities in mind. |
But that's not what this issue is about. OP already mentions that the alternative to exposing
And that could very well be an npm package. |
Oh, the comment by @GeoffreyBooth changed the discussion towards resolve helpers, so I thought you were commenting about that. Regarding
|
For my usecase (Vite's config loader), exposing the parsed conditions value is sufficient. Exposing the parsed result instead of
This would be helpful for many JS-based libraries. But for my usecase, I cannot use that function because Vite relies on esbuild for that part. I need to pass the parsed condition value to esbuild. |
There’s no reason we couldn’t do both, something like |
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment. For more information on how the project manages feature requests, please consult the feature request management document. |
Is your feature request related to a problem? Please describe.
Use case: I'm trying to implement
"exports"
support inside the PnP resolver which patches the Node resolution algorithm and I want it to be as Node-compliant as possible. For that, I need to implement the resolving user conditions part via the--conditions
flag. The problem is that Node gives me no easy way to access the resolved value of a flag (as far as I'm aware).Problem:
Node option values can come from 2 different places (as far as I'm aware): the arguments passed to the node binary and
NODE_OPTIONS
.Node currently has an internal function called
getOptionValue
that returns the value of an option, resolving both the arguments passed to the node binary andNODE_OPTIONS
.getOptionValue
is only exported ininternal/options
, so it can't be accessed.Also,
getOptionValue
uses a native implementation viagetOptions
from theoptions
internal binding which isn't whitelisted, so modules can't access it viaprocess.binding
to reimplementgetOptionValue
.Describe the solution you'd like
I'd like a way to be able use
getOptionValue
, and the most straightforward way I could think of is exposing it onprocess
viaprocess.getOptionValue
.Describe alternatives you've considered
Manually parse both
process.execArgv
andprocess.env.NODE_OPTIONS
.The text was updated successfully, but these errors were encountered: