Skip to content
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

Add a way to get the enabled conditions #55824

Open
sapphi-red opened this issue Nov 12, 2024 · 0 comments
Open

Add a way to get the enabled conditions #55824

sapphi-red opened this issue Nov 12, 2024 · 0 comments
Labels
feature request Issues that request new features to be added to Node.js.

Comments

@sapphi-red
Copy link
Contributor

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 and process.execArgv which is not robust. It should be noted that although it is an edge case, the process.env.NODE_OPTIONS check should be done before any code that modifies that variable.

Some concrete cases:

  1. Give custom resolvers to imitate Node.js's resolution (this one can be solved if parent parameter of import.meta.resolve is out of experimental, but I guess exposing conditions is less controversial than graduating that API from experimental)
  2. Let frameworks to show a warning when the user didn't set required / expected conditions.
    • For example, if frameworks expect users to set 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 in node:module.

Example code:

// node -C development ./foo.mjs
import { conditions } from 'node:module';
console.log(conditions) // ['development']

I didn't add node to conditions in the example above, but maybe it makes sense to add that too.
But for import and require, 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?

@sapphi-red sapphi-red added the feature request Issues that request new features to be added to Node.js. label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js.
Projects
Status: Awaiting Triage
Development

No branches or pull requests

2 participants
@sapphi-red and others