Skip to content

chore: replace fs-extra with native Node.js fs#510

Open
roli-lpci wants to merge 1 commit intopostcss:masterfrom
roli-lpci:chore/replace-fs-extra-with-native-fs
Open

chore: replace fs-extra with native Node.js fs#510
roli-lpci wants to merge 1 commit intopostcss:masterfrom
roli-lpci:chore/replace-fs-extra-with-native-fs

Conversation

@roli-lpci
Copy link

Summary

  • Replace fs-extra with native node:fs/promises and node:fs APIs
  • All replacements available on supported Node >= 18
  • Removes 1 runtime dependency (fs-extra + 3 transitive deps)

Follows the same pattern as #489 (globby → tinyglobby).

Changes

Source (1 file):

  • index.jsfs.pathExists()fs.access(), fs.outputFile()fs.mkdir() + fs.writeFile()

Tests (10 files):

  • test/helpers/clean.jsfs.emptyDir()fs.rm() + fs.mkdir(), fs.remove()fs.rm()
  • test/helpers/env.jsfs.copy()fs.copyFile(), fs.outputFile()fs.writeFile()
  • test/helpers/read.js — import swap only
  • test/stdin.js, test/stdout.jsfs.createReadStream() → named import from node:fs
  • test/ext.js, test/map.jsfs.pathExists()fs.access()
  • test/replace.jsfs.copy()fs.copyFile()
  • test/unchanged.js, test/watch.js — import swap only

package.json — removed fs-extra from dependencies

Replacement mapping

fs-extra Native (Node >= 18)
pathExists() access().then(() => true, () => false)
outputFile() mkdir({ recursive: true }) + writeFile()
copy() copyFile() (glob ensures file-only results)
emptyDir() rm({ recursive, force }) + mkdir({ recursive })
remove() rm({ recursive, force })
createReadStream() Named import from node:fs

Testing

All 39 tests pass. ESLint and Prettier clean.

Replace fs-extra with native Node.js fs APIs (node:fs/promises,
node:fs). All replacements are available on the supported Node >= 18:

- fs.pathExists() → fs.access() with boolean resolution
- fs.outputFile() → fs.mkdir({ recursive: true }) + fs.writeFile()
- fs.copy() → fs.copyFile() (glob ensures file-only results)
- fs.emptyDir() → fs.rm({ recursive, force }) + fs.mkdir({ recursive })
- fs.remove() → fs.rm({ recursive, force })
- fs.createReadStream() → named import from node:fs

This removes 1 runtime dependency (fs-extra + 3 transitive deps).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant