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

Seems to re-browserify everything after restarting dev server #216

Open
johnolek opened this issue Aug 26, 2019 · 5 comments
Open

Seems to re-browserify everything after restarting dev server #216

johnolek opened this issue Aug 26, 2019 · 5 comments

Comments

@johnolek
Copy link

Maybe this is expected behavior but I wasn't able to find anything in my searching.

I have it configured to use browserifyinc, and I can see that the cache file is getting created, and when I leave the server running it only ever re-processes files when they get changed. However, if I just restart the server, it seems to process everything all over again, even though I haven't changed any JavaScript files, cleared any assets, etc.

Is this the way it's intended to work? If not, does anyone have any ideas for what could be causing this?

I'm currently using:
browserify-rails 3.1.0
browserify 16.1.0
browserify-incremental 3.0.1

I tried updating the packages but it didn't seem to make a difference, and we're kind of stuck on the 3.x version of browserify-rails due to another dependency.

@cymen
Copy link
Member

cymen commented Nov 23, 2019

I seem to recall that being normal. I realize that's probably not the answer you were hoping.

@johnolek
Copy link
Author

Hey thanks for the reply. It's good just to know it's normal and that there's no way around it right now. I wonder if it would even be feasible to check the cache on startup? Maybe something I'll look into contributing myself if I can. Right now one of our apps spends about 2 minutes browserifying everything every time we restart the dev server, which can be pretty annoying.

@cymen
Copy link
Member

cymen commented Dec 6, 2019

I'm on really shaky ground here as it has been a while since I looked into that part of the code and debugged it but...

I think the issue is that the browsery-incremental cache is put in a temporary directory related to the assets pipeline. So it's not hard coded to an external directory. And I think that temporary directory name/path changes on restart. So what you might look to do is to make an option to set browserify-incremental, if it supports it, to always put the cache in a given directory. Or do some magic around stop and restart to somehow persist the cache. That might get you what you want?

@cymen
Copy link
Member

cymen commented Dec 6, 2019

I had to look, so browserify-incremental has a cache_file_path parameter and we are indeed setting that:

https://github.com/browserify-rails/browserify-rails/blob/master/lib/browserify-rails/browserify_processor.rb#L193-L196

cache_file_path = rails_path(tmp_path, "browserifyinc-cache.json")
command_options << " --cachefile=#{Shellwords.escape(cache_file_path)}"

So one could indeed add a configuration option with an external path (perhaps called persistent cache directory or something like that) and if that is set, use that. I'd suggest starting by examining the paths that are in use now for the cache -- I seem to recall while it looks like from the code they might be reasonable, that there was some server-start-random-value in it that would cause the symptoms you're describing (of not persisting between restarts).

@gnclmorais
Copy link

We’re experiencing this as well, after having upgraded sprockets from 3.7.2 to 4.0.0. Everything gets compiled again and again.

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

No branches or pull requests

3 participants