@@ -3,8 +3,6 @@ import prefetchHelper from "./prefetch"
33import { match } from "@reach/router/lib/utils"
44import normalizePagePath from "./normalize-page-path"
55import stripPrefix from "./strip-prefix"
6- // Generated during bootstrap
7- import matchPaths from "./match-paths.json"
86
97const preferDefault = m => ( m && m . default ) || m
108
@@ -13,6 +11,7 @@ const pageNotFoundPaths = new Set()
1311let apiRunner
1412let syncRequires = { }
1513let asyncRequires = { }
14+ let matchPaths = { }
1615
1716const fetchedPageData = { }
1817const pageDatas = { }
@@ -194,12 +193,21 @@ const loadComponent = componentChunkName => {
194193}
195194
196195const 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
197202 addDevRequires : devRequires => {
198203 syncRequires = devRequires
199204 } ,
200205 addProdRequires : prodRequires => {
201206 asyncRequires = prodRequires
202207 } ,
208+ addMatchPaths : _matchPaths => {
209+ matchPaths = _matchPaths
210+ } ,
203211 // Hovering on a link is a very strong indication the user is going to
204212 // click on it soon so let's start prefetching resources for this
205213 // pathname.
0 commit comments