-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby): make dev ssr bundling lazy (#28149)
* feat(gatsby): make dev ssr bundling lazy * fix tests * fix race condition * typescript 😅 * await getPageData to ensure it's been created before SSRing * instance isn't set in SSR * Fix a few more instances of this env var * Avoid setting anything for experimental features Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
- Loading branch information
1 parent
4148877
commit 70b81a6
Showing
9 changed files
with
229 additions
and
55 deletions.
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 was deleted.
Oops, something went wrong.
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,56 @@ | ||
import { | ||
IGatsbyState, | ||
IDeleteCacheAction, | ||
ICreateClientVisitedPage, | ||
ICreateServerVisitedPage, | ||
} from "../types" | ||
|
||
type StateMap = Map<"client" | "server", Set<string>> | ||
|
||
// The develop server always wants these page components. | ||
const createDefault = (): StateMap => { | ||
const defaults = new Set<string>() | ||
defaults.add(`component---cache-dev-404-page-js`) | ||
defaults.add(`component---src-pages-404-js`) | ||
|
||
const state: StateMap = new Map([ | ||
[`client`, new Set(defaults)], | ||
[`server`, new Set(defaults)], | ||
]) | ||
|
||
return state | ||
} | ||
|
||
export const visitedPagesReducer = ( | ||
state: IGatsbyState["visitedPages"] = createDefault(), | ||
action: | ||
| IDeleteCacheAction | ||
| ICreateClientVisitedPage | ||
| ICreateServerVisitedPage | ||
): IGatsbyState["visitedPages"] => { | ||
switch (action.type) { | ||
case `DELETE_CACHE`: | ||
return createDefault() | ||
|
||
case `CREATE_CLIENT_VISITED_PAGE`: { | ||
const client = state.get(`client`) | ||
if (client) { | ||
client.add(action.payload.componentChunkName) | ||
} | ||
|
||
return state | ||
} | ||
|
||
case `CREATE_SERVER_VISITED_PAGE`: { | ||
const server = state.get(`server`) | ||
if (server) { | ||
server.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
Oops, something went wrong.