-
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
feat(gatsby): lazy bundle page components in dev server #27884
Merged
Merged
Changes from 6 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
b78ee23
feat(gatsby): lazy compile page components in dev server
KyleAMathews 636afaf
Fix lint
KyleAMathews b46f680
Cleanup logs
KyleAMathews a47442e
cleanups
KyleAMathews a378040
fix tests
KyleAMathews a268a4d
Don't bother with navigating — if webpack doesn't update — the user p…
KyleAMathews 4d07210
Update packages/gatsby/src/bootstrap/requires-writer.ts
KyleAMathews 59a0385
Update packages/gatsby/cache-dir/dev-loader.js
KyleAMathews 1cef9c0
Fix lint error
KyleAMathews 56d5288
Wait until we know staticQueryHashes are written to page-data.json files
KyleAMathews 29db87e
Disable check in production
KyleAMathews afc77cc
Only trigger compilation/page writing once
KyleAMathews 237d715
Also pull xhr loaded static queries for <StaticQuery>
KyleAMathews d23f5fb
Merge branch 'master' into devjs-lazy
KyleAMathews f87a58c
instance isn't defined in builds apparently
KyleAMathews 208cedf
Work around webpack hot reloading bug
KyleAMathews 94aa19f
For static queries, data pushed from websocket is the most fresh
KyleAMathews 902cf62
Centralize logic and prevent it from repeatedly hitting the backend
KyleAMathews 4bca292
fix ordering of merge
KyleAMathews 36738e3
Comment and add timeout to ensure page-data writes happen after the w…
KyleAMathews 84fb3b0
Only add notInDevBundle during development
KyleAMathews 2cf3a66
Add back mistakenly removed code
KyleAMathews c202cdf
Didn't need this
KyleAMathews 6f55655
Implement @pieh's idea for telling runtime that dev bundle is loaded
KyleAMathews eb88597
Fix tests
KyleAMathews 68236bf
Remove logs
KyleAMathews acfbe67
Merge branch 'master' into devjs-lazy
KyleAMathews a5fcd13
Put changes behind GATSBY_EXPERIMENT_LAZY_DEVJS flag
KyleAMathews 53051e9
Add temporary fork of development-runtime tests for lazy devjs PR
KyleAMathews d140a1b
Remove duplicated tests w/ cleaner method @pieh suggested
KyleAMathews 68efb11
Address @pieh feedback
KyleAMathews 433918f
Update packages/gatsby/src/utils/start-server.ts
KyleAMathews fbd17a9
Remove global middleware
KyleAMathews 3113e12
This isn't true
KyleAMathews 78c0382
Merge branch 'master' into devjs-lazy
KyleAMathews 34151f9
fix lint
KyleAMathews File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { | ||
IGatsbyState, | ||
IDeleteCacheAction, | ||
ICreateClientVisitedPage, | ||
} from "../types" | ||
|
||
// The develop server always wants these page components. | ||
const defaults = new Set<string>() | ||
defaults.add(`component---cache-dev-404-page-js`) | ||
defaults.add(`component---src-pages-404-js`) | ||
|
||
export const clientVisitedPageReducer = ( | ||
state: IGatsbyState["clientVisitedPages"] = new Set<string>(defaults), | ||
action: IDeleteCacheAction | ICreateClientVisitedPage | ||
): IGatsbyState["clientVisitedPages"] => { | ||
switch (action.type) { | ||
case `DELETE_CACHE`: | ||
return new Set<string>(defaults) | ||
|
||
case `CREATE_CLIENT_VISITED_PAGE`: { | ||
state.add(action.payload.componentChunkName) | ||
|
||
return state | ||
} | ||
|
||
default: | ||
return state | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 promise doesn't reject (errors would be lost) and the timeout timer does not call reject nor resolve, meaning I think it ends up in a zombie state once it hits that path, since the interval that would call
resolve
and is the only way to resolve the promise is stopped.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.
There's nothing here to reject on I don't think. We're just telling the server to start compiling the page component and then... waiting. We're not doing anything per se.
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.
Anything can crash.
this.loadComponent
can fail for any number of reasons 🤷