@@ -3,8 +3,6 @@ import prefetchHelper from "./prefetch"
3
3
import { match } from "@reach/router/lib/utils"
4
4
import normalizePagePath from "./normalize-page-path"
5
5
import stripPrefix from "./strip-prefix"
6
- // Generated during bootstrap
7
- import matchPaths from "./match-paths.json"
8
6
9
7
const preferDefault = m => ( m && m . default ) || m
10
8
@@ -13,6 +11,7 @@ const pageNotFoundPaths = new Set()
13
11
let apiRunner
14
12
let syncRequires = { }
15
13
let asyncRequires = { }
14
+ let matchPaths = { }
16
15
17
16
const fetchedPageData = { }
18
17
const pageDatas = { }
@@ -194,12 +193,21 @@ const loadComponent = componentChunkName => {
194
193
}
195
194
196
195
const queue = {
196
+ // gatsby-link can be used as a standalone library. Since it depends
197
+ // on window.___loader, we have to assume the code calls loader.js
198
+ // but without a gatsby build having occured. In this case,
199
+ // `async-requires.js, match-paths.json` etc won't exist. Therefore,
200
+ // we import those assets in production-app.js, and then dynamically
201
+ // set them onto the loader
197
202
addDevRequires : devRequires => {
198
203
syncRequires = devRequires
199
204
} ,
200
205
addProdRequires : prodRequires => {
201
206
asyncRequires = prodRequires
202
207
} ,
208
+ addMatchPaths : _matchPaths => {
209
+ matchPaths = _matchPaths
210
+ } ,
203
211
// Hovering on a link is a very strong indication the user is going to
204
212
// click on it soon so let's start prefetching resources for this
205
213
// pathname.
0 commit comments