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

fix: add writeToDisk support for clean: true #1472

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Mortaro
Copy link

@Mortaro Mortaro commented Mar 6, 2023

This PR contains a:

  • [x ] bugfix
  • new feature
  • code refactor
  • [x ] test update
  • documentation update
  • typo fix
  • metadata update

Motivation / Use-Case

I'm the author of Nullstack, one of its build modes targets chrome extensions.
I use the writeToDisk option in development mode to preview the extensions with HMR, but the middleware was never cleaning up the real FS when MemFS unlinked files, causing the output folder to become bloated over time.

Breaking Changes

There are no breaking changes.

Additional Info

The solution I added might be a bit hacky, but it does solve this issue that has been open for a minute: #861

I have temporarily moved the unstable branch of Nullstack to use my fork, but would love to have this fix merged so i can rollback to the official package 💜

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 6, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Mortaro / name: Christian Mortaro (ff90a3a)

@codecov
Copy link

codecov bot commented Mar 6, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.04 🎉

Comparison is base (6f7b8da) 97.34% compared to head (ff90a3a) 97.39%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1472      +/-   ##
==========================================
+ Coverage   97.34%   97.39%   +0.04%     
==========================================
  Files           9        9              
  Lines         377      384       +7     
  Branches      112      114       +2     
==========================================
+ Hits          367      374       +7     
  Misses          9        9              
  Partials        1        1              
Impacted Files Coverage Δ
src/index.js 97.91% <100.00%> (ø)
src/utils/setupWriteToDisk.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

/** @type {String} */ originalPath,
/** @type {(arg0?: null | NodeJS.ErrnoException) => void} */ originalCallback
) => {
fs.unlink(originalPath, () => {});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, there is racing you should wait the first operation finished, also using fs.unlink is not safe, because some developer use custom outputFileSystem to avoid file removing, but we remove them and break application, we nee to think deeply how we can handle such case. In theiry we can apply clean plugin before watch and it will with original fs

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.

None yet

2 participants