-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
lib: re-export promises for esm #28466
Conversation
I believe we originally exposed the fs promises API this way. I don't remember why we reverted to |
@targos there were (and still are) unresolved issues about namespacing, but since it seems that's literally never going to be resolved, i thought i would move this forward. |
@devsnek would you mind adding some recap of those issues and how those were fixed? |
@mcollina the issue was |
The reason we had to switch to |
@jasnell that's true of all new modules we add though |
If I understand correctly (and I very much might not):
All of this is, IMO, a mess that would be resolved by simply namespacing modules going forward. If it's a big problem for ESM (which I have not been following closely), that's just all the more reason for the TSC to take this up and make it happen. I would certainly support that. |
@Trott i would definitely appreciate if the TSC took this up currently in esm: import { promises as fsPromises } from 'fs';
const { readFile } = fsPromises; after you write this a few times it really starts to grate on you. |
@@ -3792,7 +3792,7 @@ this API: [`fs.write(fd, string...)`][]. | |||
|
|||
The `fs.promises` API provides an alternative set of asynchronous file system | |||
methods that return `Promise` objects rather than using callbacks. The | |||
API is accessible via `require('fs').promises`. | |||
API is accessible via `require('fs').promises` and `require('fs/promises')`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this constitutes a new core module - and there's not supposed to be any new ones until #21551 (comment) is resolved. that's also why fs/promises
was reverted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is also possible right now. Just add an own |
I personally think it's still not ideal that we went for a new object property instead of choosing to add |
@devsnek how would you feel about making a import {fs} from 'nodejs:promises Thoughts? |
@MylesBorins anything that allows |
@devsnek v cool. Let's see if we can reach agreement in the namespace issue... if we can I'd like to include the promises export in that PR |
fs.promises
,dns.promises
, (and soonreadline.promises
) should all be exposed nicely to esm. This does so.cc @nodejs/modules @addaleax @cjihrig
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes