remix
remix copied to clipboard
old build files not cleaned up automatically in dev mode
What version of Remix are you using?
1.1.3
Steps to Reproduce
Create a project with remix and continue to make changes in the projects. New build files with new hashes are generated on every code change. Build folder size continues to increase drastically over time as the old build files are not cleaned up.
Expected Behavior
Old and unused build files should be automatically removed to avoid a drastic increase in the build folder size
Actual Behavior
In #2425 discussion, @sergiodxa mentioned that this issue was fixed in #252 I tried stopping the remix dev server and re-started it. But the build folder is not cleaned up automatically.
Currently, my build folder size is 24 GB.
I have the same behavior, build folder is not cleaned up automatically.
I have encountered the same issue. My workaround is to remove the two Remix output directories before starting the dev server.

I am running into the same issue. Just cleaned out almost 10GB of files. 😱 Was there any progress on this?
For the contributors who would start on this, I did some testing and came up with following observation I posted in my duplicate ticket:
Been testing the watch function from the CLI Commands. It seems like the
exitHook
can't be triggered properly. See: https://github.com/remix-run/remix/blob/main/packages/remix-dev/cli/commands.ts#L222When testing the
exitHook
inside the dev function, it does get triggered, so I'm afraid the watch function can't be run async and maybe should return a callback function instead closes everything correctly inside the dev function.Not sure if that's a solid solution though.
The issue is that exit-hook
package doesn't support async code (yet), so as soon as resolve
is called the process exits without waiting for the then
block to execute. https://github.com/remix-run/remix/blob/15213866f8dca94e6164c46028f410625226599f/packages/remix-dev/cli/commands.ts#L226-L237
@dmarkow the exit-hook package now support async code.
any solution?

I just add a "clean" script that runs before "dev" that deletes the build folders.
"clean": "rimraf build public/build",
"dev": "npm run clean && remix dev",
You'll need to add the rimraf
package
I just add a "clean" script that runs before "dev" that deletes the build folders.
"clean": "rimraf build public/build", "dev": "npm run clean && remix dev",
You'll need to add the
rimraf
package
but what about hot reload ? problem is every time source file got changed , remix bundler regenerate new version of JS(or css) file , but not clear build dir, it build different file to build dir over and over again.
True. This is primarily so my build folders are not unbounded.
This issue can be solved by using esbuild in-memory ("write: false" option).
https://github.com/evanw/esbuild/issues/139 https://github.com/evanw/esbuild/commit/268f8331f5b3840e659c600b9ddf797b3a147018 https://esbuild.github.io/api/#write
When content is served by the remix request handlers, remix can lookup the resource within the in memory compilation and in case one is not found look for the resource in the file system...
Using an in-memory would most likely result in faster compilations.
WDYT?
not sure what the downsides are but what if the hashing of file names is disabled in dev mode?
Fixed by #5223
🤖 Hello there,
We just published version v0.0.0-nightly-8346ace-20230124
which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!
Thanks!
🤖 Hello there,
We just published version 1.12.0
which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!
Thanks!