-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
cleanup(js): replace fs-extra
with node:fs
#27932
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 0f65580. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 4 targets
Sent with 💌 from NxCloud. |
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.
Thank you for this @ziebam.
It could possibly cause issues for any in flight branches/PRs. To help make things easier to both figure out and enforce, please add something like the following ESLint rule to the js package .eslintrc.json
"no-restricted-imports": ["error", {
"name": "fs-extra",
"message": "Please use equivalent utilties from `node:fs` instead."
}]
Done. I also merged with |
@ziebam So you tested this catches cases of importing from fs-extra, yeah? |
Yup, here's a screenshot for the record. Not sure about the CI failure, investigating right now. |
Thanks @ziebam |
This PR is a suggestion to replace
fs-extra
with the nativenode:fs
to reduce the dependency count and the bundle size.Current Behavior
@nx/js
usesfs-extra
which, at present, mostly wraps the nativenode:fs
API.The biggest change is
fs-extra.copySync
->fs.cpSync
. The latter has been added in Node 16.7.0, and has been marked as "experimental" since, dropping that status in Node 22. The API seems stable across the releases though, and the affected tests pass, so this change might be acceptable. Other possible solutions:fs-extra
just for this function, and eventually remove it in the distant future where Node version older than 22 are deemed obsolete.cpSync
behavior by writing a utility that uses stable methodsfs.writeFile
,fs.stat
, etc.Expected Behavior
Reduced dependency count and bundle size by replacing
fs-extra
withnode:fs
.Related Issue(s)
N/A