-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Can you opt-out of webpackCompilationHash (to improve Netlify build times) #15872
Comments
Guessing lines such as this
|
Just double checking but are you on the latest version? We recently made a change where the goal was to address this exact issue #11982 It's possible however we haven't completely nailed the solution still. |
I've re-tried this morning with Happy to help working on a resolution for this. May need some guidance on the best place to start though. |
Just spoke with Alex and on preliminary investigation, it appears that |
A thought on an approach for this. @KyleAMathews @sidharthachatterjee I appreciate that this is still desirable functionality and from reading the comments in #13004 could an option be to use a That way the browser could still figure out if the individual page/template had been updated on the server, and build change blast radius would be scoped to just those pages that have been updated. In the example given in this issue, updating the 404 template would result in the hash for that page chunk changing, but not the hash for index page or any other generated pages. Thus meaning features such as those offered by Netlify are accessible. |
After thinking more about this today through doing PR #16389 I think the problem may be better resolved by keeping
Thoughts on this approach? |
The webpackCompilationHash is loaded in a new app-data.json file to reduce the blast radius of src changes on generated files gatsbyjs#15872
The webpackCompilationHash is loaded in a new app-data.json file to reduce the blast radius of src changes on generated files gatsbyjs#15872
Interesting idea! Maybe build-data.json? Thoughts @Moocar? We could throttle fetching this to say every 15 seconds to avoid littering people's network tabs with repeated fetches. |
@afenton90 This is a really interesting idea. I definitely hear you on the problem of a single change to anything in Without having thought too deeply, I think this could potentially work. One of the downside is that where we once had to only request a single I'll dive in to see if it would work. |
Thanks for your thoughts @KyleAMathews & @Moocar. I went ahead and did PR #16686 to cover this off. I’m going to pair with @sidharthachatterjee on Tuesday to make sure all scenarios for this are covered and the tests are good. |
Published #16686 under |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing! Thanks for being a part of the Gatsby community! 💪💜 |
not stale |
Me and @pauloelias are having a possibly related problem. We build periodically every hour and it seems our webpackCompilationHash is changing no matter what. That’s bad, but it’s more of an optimization problem. Also note that we’re running Fastly in front of our site. We only expire HTML pages on successful builds on the CDN, none of the assets. Could it be that, since Update: This is really bad for us, as transitions from pages to pages with a query string almost always cause a page reload without the query string, breaking site functionality. Downgrading to 2.8 :( |
It looks like this line in navigation.js actually has a bug: Shouldn’t |
Published in |
Hi is there any fix on this as of yet? trying to run gatsby experimental page build and it seems this is the only thing that updates on each page forcing a rebuild i.e |
I am having the same issue. According to this PR from 4 years ago the |
I'm having a similar issue and I'm glad I'm not the only one, so we can discuss a solution or workaround. I've been doing research about this problem for about a day and I can present my findings here. But I suspect that this issue might not be related directly to the TL;DR As you see it's a combination of the structure of the code plus the modification of the hash. More details on my research I was able to cut down the site to 72 HTML pages for troubleshooting, and then I followed the guide for troubleshooting incremental guides. I found out that Gatsby detected that there was a change on those 72 HTML files and that's why it decides to regenerate them. Upon analyzing the diff between incremental builds, I found out that the webpackCompilationHash is the only thing that change, but since it shares the line with a bunch of inline Tailwind CSS stuff, Gatsby thinks (I am guessing here) that a lot of the HTML file was changed, even though when it was only the wepackCompilationHash sharing the same last line of the .html file. Some things I did to support my theory:
CONCLUSSION / POSSIBLE SOLUTION
These are just theories I have. I will continue to do some tests and report back here, but just wanted to share my insights so far. Thanks! |
UPDATE: I can confirm that the Solution 2 worked in my case. I modified these files from the gatsby core (I am using node_modules/gatsby/cache-dir/static-entry.js: lines 366-369 (added a line break at the beginning of that string)
node_modules/gatsby/cache-dir/commonjs/static-entry.js: lines 403-410 (added a line break at the beginning of that string)
After applying those changes, modify a post in WordPress and rebuild incrementally, I was able to see that Gatsby successfully detected the incremental build and only generated one HTML file matching the change made. @sidharthachatterjee Could you please take a look at my previous messages and advice on a long term solution for this? Thanks!! |
@maxthrottleup that's a great find! Not sure if @sidharthachatterjee is working on Gatsby anymore though. Actually I'm not sure on who to ping for support here at all. |
@DennisRosen This issue may be related to this: #33450 (comment) I have not tested the opting out of Webpack cache but I will when I have some time. |
Summary
Within the
gatsby-script-loader
script at the bottom of any page there is awindow.webpackCompilationHash
set. This hash is updated during every change to anything in thesrc
directory.This means deploying onto services such as Netlify take longer than expected. Netlify has advanced features for builds so only assets which content has updated since the last build are transferred to the underlying CDN. However, because the
webpackCompilationHash
is updated if anything changes insrc
this means all files will be transferred for only a small change.For example:
gatsby build
- To give an initial built site.404
template.gatsby build
- Builds site but all outputted pages are changed because a single file has been updated.For larger sites generating 1000s of pages this is a real problem. An update to a fairly static page will result in the dynamic pages also being updated.
Is it possible that we could add an option for the hash to not be generated an inlined in HTML output?
How integral is it to the inner workings of Gatsby?
Relevant information
Mainly affects large sites being deployed on services such as Netlify.
The text was updated successfully, but these errors were encountered: