browserify / browserify/resolve

Support a promise API

Open
#210 2 comments 10 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
796
Forks
188
PR merge metrics
No merged PRs in 30d

Description

(Sorta surprised no-one has opened an issue about this, sorry if one exists and my searching is just bad (there is sorta #151, but this issue is about native promise support, not promisification)).

Node's new ESM resolution supports promises, but not callbacks. If we wanna use `resolve` to implement a [custom linker](https://nodejs.org/api/vm.html#vm_module_link_linker), a [custom loader hook](https://nodejs.org/api/esm.html#esm_code_resolve_code_hook) or the recently landed [`import.meta.resolve`](https://github.com/nodejs/node/pull/31032) we'd need to manually wrap `resolve` in a promise - it would be lovely if `resolve` natively worked with promises out of the box. I realise these APIs are behind experimental flags (or not even in any release), but I don't think there's any reason to believe the functionality these APIs provide will not be available whenever the APIs stabilize, and that they won't be based on promises.

While one can promisify `resolve` manually, the problem is a bit extrapolated when considering the pluggable FS operations (recent versions of Node also ship with a promise based FS API). Based on #151 `util.promisify` doesn't work out of the box either.

If accepted, I'm happy to work on the implementation.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.