Skip to content

Commit

Permalink
allow loader.loadComponent to accept optional key to fetch modules
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed Jul 14, 2020
1 parent a440c86 commit d558304
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/gatsby/cache-dir/dev-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { findPath } from "./find-path"

class DevLoader extends BaseLoader {
constructor(syncRequires, matchPaths) {
const loadComponent = chunkName =>
Promise.resolve(syncRequires.components[chunkName])
const loadComponent = (chunkName, key = `components`) =>
Promise.resolve(syncRequires[key][chunkName])
super(loadComponent, matchPaths)
}

Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby/cache-dir/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,9 @@ const createComponentUrls = componentChunkName =>

export class ProdLoader extends BaseLoader {
constructor(asyncRequires, matchPaths) {
const loadComponent = chunkName =>
asyncRequires.components[chunkName]
? asyncRequires.components[chunkName]()
const loadComponent = (chunkName, key = `components`) =>
asyncRequires[key][chunkName]
? asyncRequires[key][chunkName]()
.then(preferDefault)
// loader will handle the case when component is null
.catch(() => null)
Expand Down

0 comments on commit d558304

Please sign in to comment.