Skip to content

Commit

Permalink
separate chunk for head, remove default
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinjude authored and wardpeet committed Sep 5, 2022
1 parent 7fe8e51 commit 85b4ea7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions packages/gatsby/cache-dir/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,15 +573,15 @@ const createComponentUrls = componentChunkName =>

export class ProdLoader extends BaseLoader {
constructor(asyncRequires, matchPaths, pageData) {
const loadComponent = chunkName => {
if (!asyncRequires.components[chunkName]) {
const loadComponent = (chunkName, exportType = `components`) => {
if (!asyncRequires[exportType][chunkName]) {
throw new Error(
`We couldn't find the correct component chunk with the name ${chunkName}`
`We couldn't find the correct component chunk with the name "${chunkName}"`
)
}

return (
asyncRequires.components[chunkName]()
asyncRequires[exportType][chunkName]()
// loader will handle the case when component is error
.catch(err => err)
)
Expand Down
5 changes: 4 additions & 1 deletion packages/gatsby/src/bootstrap/requires-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ const preferDefault = m => (m && m.default) || m
// Create file with async requires of components/json files.
let asyncRequires = ``

if (process.env.gatsby_executing_command === `develop`) {
if (
process.env.gatsby_executing_command === `develop` ||
(_CFLAGS_.GATSBY_MAJOR === `5` && process.env.GATSBY_PARTIAL_HYDRATION)
) {
asyncRequires = `exports.components = {\n${components
.map((c: IGatsbyPageComponent): string => {
// we need a relative import path to keep contenthash the same if directory changes
Expand Down

0 comments on commit 85b4ea7

Please sign in to comment.