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 async alternative to import.meta.resolve() with additional options #54051

Open
justinfagnani opened this issue Jul 26, 2024 · 0 comments
Open
Labels
feature request Issues that request new features to be added to Node.js. loaders Issues and PRs related to ES module loaders

Comments

@justinfagnani
Copy link

What is the problem this feature will solve?

Tools often need to resolve imports of files they are analyzing, which requires a resolve API that import.meta.resolve() isn't suited for.

  • The resolve() call needs a referrer path, which is only available with a flag and is non standard
  • The tool might want to specify import conditions, which are non-standard
  • The call should be async, so that file system access isn't blocking. This is especially important for online resolution in servers.

Node might be able to add non-standard options via a second argument, though I'm a bit dubious of this approach because it might preclude import.meta.resolve() from adding a standard second argument.

So currently, we have complex user land resolvers that try to emulate what Node does, like Rollup's.

What is the feature you are proposing to solve the problem?

I think node:module should provide a function to perform built-in resolution, given a referrer path and import conditions.

This API would be free from having to conform to the import.meta.resolve() standard. import.meta.resolve() would still exist for cross-platform needs of resolving from within the referrer only.

What alternatives have you considered?

No response

@justinfagnani justinfagnani added the feature request Issues that request new features to be added to Node.js. label Jul 26, 2024
@RedYetiDev RedYetiDev added the loaders Issues and PRs related to ES module loaders label Aug 4, 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. loaders Issues and PRs related to ES module loaders
Projects
Status: Awaiting Triage
Development

No branches or pull requests

2 participants