Skip to content
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

Replace fs-extra.copy by recursively creating directories and files #81

Closed
paulshryock opened this issue Sep 20, 2023 · 2 comments
Closed
Assignees

Comments

@paulshryock
Copy link
Owner

paulshryock commented Sep 20, 2023

Summary

As of Node v20.8.0, fs.promises.cp is considered Experimental with Stability: 1. For this reason, we're instead using fs-extra.copy. But this dependency adds a lot of extra code to the compiled bundle. Once fs.promises.cp stabilizes, let's switch over.

Screenshot 2023-09-30 at 3 04 45 PM

Benefit

  • Compiled bundle with fs-extra.copy: 54.1kb
  • Compiled bundle without fs-extra.copy: 4.7kb
  • Savings: 49.4kb (over 91%)

Screenshot 2023-09-30 at 5 01 23 PM

Acceptance criteria

  • GIVEN fs.promises.cp is used instead of fs-extra.copy,
  • WHEN this package is compiled with npm run compile,
  • THEN the fs-extra dependency is not included in the compiled bundle
    • AND all tests still pass.
@paulshryock paulshryock changed the title Replace fs-extra with fs.promises.cp Replace fs-extra.copy with fs.promises.cp Sep 30, 2023
@paulshryock
Copy link
Owner Author

paulshryock commented Sep 30, 2023

We're using mock-fs to mock the file system in tests, which does not support fs.promises.cp, and most likely never will.

This seems to be the only thing holding us back from using fs.promises.cp, which actually feels pretty stable at this point, despite the current Experimental status.

Since Node does not natively provide a way to mock the file system, we'll continue to use mock-fs to accomplish this in tests. And for that reason, let's just recursively create directories and files manually, instead of using fs.promises.cp.

If the landscape changes later, we can always revisit.

@paulshryock paulshryock changed the title Replace fs-extra.copy with fs.promises.cp Replace fs-extra.copy by recursively creating directories and files Sep 30, 2023
@paulshryock
Copy link
Owner Author

New acceptance criteria

  • GIVEN FileSystem.copy is accomplished by recursively creating directories and files instead of fs-extra.copy,
  • WHEN this package is compiled with npm run compile,
  • THEN the fs-extra dependency is not included in the compiled bundle
    • AND all tests still pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant