-
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
refactor(conditional-page-build): tracking PR #29140
Conversation
docs/docs/conditional-page-builds.md
Outdated
|
||
- To enable this build option you will need to set an environment variable, which requires access to do so in your build environment. | ||
|
||
- This feature is not available with `gatsby develop`. | ||
|
||
- You should not try to use this flag alongside Incremental Builds in Gatsby Cloud, as it uses a different process and may conflict with it. | ||
|
||
- You will need to persist the `.cache` and `public` directories between builds. This allows for comparisons and reuse of previously built files. If `.cache` directory was not persisted then a full build will be triggered. If `public` directory was not persisted then you might experience failing builds or builds that are missing certain assets. | ||
|
||
- Any code changes (templates, components, source handling, new plugins etc) will prompt the creation of a new webpack compilation hash and trigger a full build. | ||
|
||
Note: When using the `GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES` flag it is important to do so consistently when building your project. Otherwise, the cache will be cleared and the necessary data for comparison will no longer be available, removing the ability to check for incremental data changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those changes will need to be extracted to separate PR and only applied when stable version including code changes is released
199640c
to
d674bd8
Compare
if (htmlFile.isDeleted || !state.pages.has(path)) { | ||
// FIXME: checking pages state here because pages are not persisted | ||
// and because of that `isDeleted` might not be set ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
72eddde
to
7fdf75f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking 👍
left a few comments
@@ -77,6 +80,20 @@ const getPageData = pagePath => { | |||
} | |||
} | |||
|
|||
// TODO: verify if memoization is safe given that results can change | |||
const getStaticQueryResult = memoize(hash => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be safe for single runs but not in inc builds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's the actual thing to verify ;) depends if ssr bundle is "reloaded" or just kept in memory
@@ -152,6 +162,12 @@ const renderHTMLQueue = async ( | |||
paths: pageSegment, | |||
}) | |||
|
|||
// is this code path used for dev ssr? | |||
store.dispatch({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no it has it's own long-running worker which it sends calls to
const htmlString = await worker.renderHTML({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's good, but I will add test case for it with DEV_SSR enabled to make sure of that (+ shield from potential regressions in future)
91ff577
to
2a15b3d
Compare
da20685
to
a3d2497
Compare
5efa4ae
to
4744d83
Compare
4744d83
to
5a0a714
Compare
This tracking PR served it's purpose and all that actually ment to be tracked with this PR was merged, so it's to close this one |
Description
This is tracking branch for moving
GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES
from experimental to stableChanges are being plucked from this massive PR into smaller ones:
Already merged:
refactor(html-ssr): remove fs from ssr bundle, remove static queries from ssr bundle
refactor(conditional-page-build): explicitly persist status of generated html files
(this just refactor currentGATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES
to structure that will allow us to track additional things and remove some problems of having to constatly useGATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES
and not switch between build and develop)feat(conditional-page-builds): track ssr compilation hash
feat(conditional-page-builds): track static query results
fix(conditional-page-builds): track page data and not page query
chore(build): move html generation to separate function
Ready to review (they are serial - each next one builds on previous and target previous PR branch, so those should be merged in order):
feat(conditional-page-builds): make it default
Future PRs:
fs
,http
,child_process
node builtin modules in SSR bundle and in case of use of those in ssr generating, mark it's not safe to use conditional page builds and fallback to building every page ( :( ). This is somewhat waiting for webpack@5 bump, as it's not straight forward to do in webpack@4 and there are changes in webpack@5 that any efforts made for webpack@4 might be rendered voidrequire.cache
from ssr renderer if it changedsetPageData
action and types