You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
I was experiencing an issue when Brunch detected changes to my files. Sometimes, the dependencies of the file that I saved would permanently disappear. Randomly when I would save saved-file.js, which did require('foo'), I would see the error Uncaught Error: Cannot find module 'foo' from 'saved-file.js'. I also saw, in my terminal, that X had decreased from the previous message when compiled saved-file.js and X cached files into app.js in Y ms was printed.
I did a lot of digging into the brunch, deppack and finally fcache source code and found that sometimes fcache was reading 0-byte files. When it would read these empty files, it would still analyze them, and when it found that dependencies of this momentarily-empty file were no longer referenced by any other file, those files would be "unlinked" and not included in the build any more.
This led me back to the Brunch issues, and I found this: #971 and now awaitWriteFinish has solved my problem.
However, I think Brunch probably could have handled 0-byte files more gracefully - in case someone didn't read the docs and find out about awaitWriteFinish (which should maybe even be on by default), or if awaitWriteFinish ever doesn't work (I expect it will eventually fail, since it's timer-based).
Expected behavior
Even after a file is read with 0 bytes and its dependencies are dropped, those dependencies should be re-added if the same file is read again and found to have the same dependencies. If Brunch at least does that, it may be able to recover from reading these 0-byte files, or at least some less knowledgeable users (like I was) wouldn't need to restart their whole server (they could just re-save).
Also, I think that awaitWriteFinish should be in the docs and recommended for various editors, including Emacs.
Actual behavior
When Brunch reads a saving 0-byte file that has dependencies, it stops including those dependencies in the build forever.
Description
I was experiencing an issue when Brunch detected changes to my files. Sometimes, the dependencies of the file that I saved would permanently disappear. Randomly when I would save
saved-file.js
, which didrequire('foo')
, I would see the errorUncaught Error: Cannot find module 'foo' from 'saved-file.js'
. I also saw, in my terminal, that X had decreased from the previous message whencompiled saved-file.js and X cached files into app.js in Y ms
was printed.I did a lot of digging into the brunch, deppack and finally fcache source code and found that sometimes fcache was reading 0-byte files. When it would read these empty files, it would still analyze them, and when it found that dependencies of this momentarily-empty file were no longer referenced by any other file, those files would be "unlinked" and not included in the build any more.
This led me back to the Brunch issues, and I found this: #971 and now
awaitWriteFinish
has solved my problem.However, I think Brunch probably could have handled 0-byte files more gracefully - in case someone didn't read the docs and find out about
awaitWriteFinish
(which should maybe even be on by default), or ifawaitWriteFinish
ever doesn't work (I expect it will eventually fail, since it's timer-based).Expected behavior
Even after a file is read with 0 bytes and its dependencies are dropped, those dependencies should be re-added if the same file is read again and found to have the same dependencies. If Brunch at least does that, it may be able to recover from reading these 0-byte files, or at least some less knowledgeable users (like I was) wouldn't need to restart their whole server (they could just re-save).
Also, I think that
awaitWriteFinish
should be in the docs and recommended for various editors, including Emacs.Actual behavior
When Brunch reads a saving 0-byte file that has dependencies, it stops including those dependencies in the build forever.
Here's a demo: https://github.com/jacksonrayhamilton/brunch-lost-dependencies-demo
Environment
package.json
contentsbrunch config contents
The text was updated successfully, but these errors were encountered: