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

Always check files recompilation by content #1743

Conversation

mdesantis
Copy link
Contributor

Fix #1439

@gauravtiwari
Copy link
Member

Thanks @mdesantis 🍰

I am wondering if it would make sense to use mtime in development (in other words non-production environments) since here we can depend on mtime, which would be slightly faster.

@mdesantis
Copy link
Contributor Author

@gauravtiwari I thought about that too but I'm worried about CI: it's unlikely that you run tests under production environment. What about doing CI env var check || env.production??

Also, an alternative fix could be just documenting the CI env var in the readme (and maybe renaming that; I don't think it's descriptive enough); developers might just be confused by the fact that this behaviour isn't written loud and clear

@latortuga
Copy link

As someone who is not super familiar with webpacker internals, forgive me if this is a dumb question. Is this codepath even used in development? My impression is that this feature is for when assets are precompiled, which doesn't happen in development mode.

@mdesantis
Copy link
Contributor Author

mdesantis commented Oct 10, 2018

@latortuga (not a Webpacker expert neither) but you can precompile assets even in development if for some reason you don't want to use webpack-dev-server, although it isn't very common I guess; and anyway you precompile them in test mode, if we are considering development as non-produciton

@swrobel
Copy link
Contributor

swrobel commented Oct 10, 2018

I thought about that too but I'm worried about CI: it's unlikely that you run tests under production environment. What about doing CI env var check || env.production??

Please see @gauravtiwari's comment here for an example of what he means. Production & Test (or any env other than Development) would use the file hash method.

@jpickwell
Copy link
Contributor

Is there a reason why the results of watched_files_digest isn't memoized? The function gets called once by stale? and again by record_compilation_digest (if stale? returns true) when calling compile.

@swrobel
Copy link
Contributor

swrobel commented Oct 10, 2018

@jpickwell I raised this with my earlier PR and got the 👍 but didn't get around to implementing it.

@gauravtiwari
Copy link
Member

Thanks everyone 🙏

Lets use mtime in development and file hash for other environments, where most likely we would be precompiling assets.

Why in development?

Mainly because, Webpacker ships with this "naive" on-demand compiler, which works well for simple cases and we don't want to slow it down, even if it's tiny by using file hash. If I am not missing anything, I think mtime should work fine there?


But as I wrote the above paragraph, I realised for simple cases using file hash wouldn't be slow either. So, perhaps just use file hash for everything to keep things simple?

@gauravtiwari gauravtiwari merged commit 95c00e2 into rails:master Oct 11, 2018
@gauravtiwari
Copy link
Member

Thanks @mdesantis :)

@gauravtiwari
Copy link
Member

If you have sometime, could you also port this to 3-x-stable branch, please.

ericboehs added a commit to ericboehs/webpacker that referenced this pull request Oct 11, 2018
@kjleitz
Copy link
Contributor

kjleitz commented Oct 12, 2018

Any chance this will be put into 3.x? This fix would really help our deployment process out. Deployment went from 3-4 minutes to ~15 minutes for us. It's a big pain.

@latortuga
Copy link

@kjleitz looks like this got released on March 6, 2019: 8c25c09

🎉

@mdesantis mdesantis deleted the always-check-file-recompilation-by-content branch September 23, 2020 10:07
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.

Recompile only modified assets in production
6 participants