jprichardson / node-fs-extra

Node.js: extra methods for the fs object like copy(), remove(), mkdirs()
MIT License
9.43k stars 775 forks source link

Export fs/promises function for esm like you do for cjs #1008

Closed FreePhoenix888 closed 9 months ago

FreePhoenix888 commented 1 year ago

Export fs/promises function for esm like you do for cjs

RyanZim commented 1 year ago

In CJS mode, we're exporting wrapped versions of graceful-fs which support either callbacks or promises. We can't do this in ESM, since exports are static. See https://github.com/jprichardson/node-fs-extra/issues/746 for detailed discussion.

We could export * from 'fs/promises', but that wouldn't cover native sync methods, which would be confusing, because you'd have to import native sync methods from fs, but fs-extra/esm exports both sync and async methods. Also, this would be inconsistent with the CJS version, since the CJS version exports graceful-fs, not fs.