gatsby 2.10.3 → 2.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.11.1](https://github.com/gatsbyjs/gatsby/compare/gatsby@2.11.0...gatsby@2.11.1) (2019-06-28)
7
+
8
+ ### Features
9
+
10
+ - **gatsby:** Rewrite resource loading - retry mechanism ([#14889](https://github.com/gatsbyjs/gatsby/issues/14889)) ([68e15e7](https://github.com/gatsbyjs/gatsby/commit/68e15e7))
11
+
12
+ # [2.11.0](https://github.com/gatsbyjs/gatsby/compare/gatsby@2.10.5...gatsby@2.11.0) (2019-06-27)
13
+
14
+ ### Bug Fixes
15
+
16
+ - **gatsby:** update tsc definition of cache in NodePluginArgs ([#14955](https://github.com/gatsbyjs/gatsby/issues/14955)) ([65b42e9](https://github.com/gatsbyjs/gatsby/commit/65b42e9))
17
+
18
+ ### Features
19
+
20
+ - **gatsby:** enable babel-loader for all dependencies ([#14111](https://github.com/gatsbyjs/gatsby/issues/14111)) ([268ed27](https://github.com/gatsbyjs/gatsby/commit/268ed27))
21
+ - **gatsby:** Support absolute certificate paths for developme… ([#14932](https://github.com/gatsbyjs/gatsby/issues/14932)) ([7694c0c](https://github.com/gatsbyjs/gatsby/commit/7694c0c))
22
+
23
+ ## [2.10.5](https://github.com/gatsbyjs/gatsby/compare/gatsby@2.10.4...gatsby@2.10.5) (2019-06-25)
24
+
25
+ **Note:** Version bump only for package gatsby
26
+
27
+ ## [2.10.4](https://github.com/gatsbyjs/gatsby/compare/gatsby@2.10.3...gatsby@2.10.4) (2019-06-24)
28
+
29
+ ### Bug Fixes
30
+
31
+ - **gatsby:** Fix client side routing match paths regression ([#15010](https://github.com/gatsbyjs/gatsby/issues/15010)) ([f52bbac](https://github.com/gatsbyjs/gatsby/commit/f52bbac))
32
+
6
33
  ## [2.10.3](https://github.com/gatsbyjs/gatsby/compare/gatsby@2.10.2...gatsby@2.10.3) (2019-06-24)
7
34
 
8
35
  **Note:** Version bump only for package gatsby
@@ -0,0 +1,15 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`BaseLoader loadPage should be successful when component can be loaded 1`] = `
4
+ Object {
5
+ "component": "instance",
6
+ "json": Object {
7
+ "pageContext": "something something",
8
+ },
9
+ "page": Object {
10
+ "componentChunkName": "chunk",
11
+ "path": "/mypage/",
12
+ "webpackCompilationHash": "123",
13
+ },
14
+ }
15
+ `;
@@ -0,0 +1,428 @@
1
+ // This is by no means a full test file for loader.js so feel free to add more tests.
2
+ import mock from "xhr-mock"
3
+ import { BaseLoader } from "../loader"
4
+ import emitter from "../emitter"
5
+
6
+ jest.mock(`../emitter`)
7
+
8
+ describe(`BaseLoader`, () => {
9
+ describe(`loadPageDataJson`, () => {
10
+ let originalBasePath
11
+ let originalPathPrefix
12
+ let xhrCount
13
+
14
+ /**
15
+ * @param {string} path
16
+ * @param {number} status
17
+ * @param {boolean} json
18
+ */
19
+ const mockPageData = (path, status, json) => {
20
+ mock.get(`/page-data${path}/page-data.json`, (req, res) => {
21
+ xhrCount++
22
+ if (json) {
23
+ res.header(`content-type`, `application/json`)
24
+ }
25
+ return res.status(status).body(json ? `{ "path": "${path}/" }` : ``)
26
+ })
27
+ }
28
+
29
+ // replace the real XHR object with the mock XHR object before each test
30
+ beforeEach(() => {
31
+ originalBasePath = global.__BASE_PATH__
32
+ originalPathPrefix = global.__PATH_PREFIX__
33
+ global.__BASE_PATH__ = ``
34
+ global.__PATH_PREFIX__ = ``
35
+ xhrCount = 0
36
+ mock.setup()
37
+ })
38
+
39
+ // put the real XHR object back and clear the mocks after each test
40
+ afterEach(() => {
41
+ global.__BASE_PATH__ = originalBasePath
42
+ global.__PATH_PREFIX__ = originalPathPrefix
43
+ mock.teardown()
44
+ })
45
+
46
+ it(`should return a pageData json on success`, async () => {
47
+ const baseLoader = new BaseLoader(null, [])
48
+
49
+ mockPageData(`/mypage`, 200, true)
50
+
51
+ const expectation = {
52
+ status: `success`,
53
+ pagePath: `/mypage`,
54
+ payload: { path: `/mypage/` },
55
+ }
56
+ expect(await baseLoader.loadPageDataJson(`/mypage/`)).toEqual(expectation)
57
+ expect(baseLoader.pageDataDb.get(`/mypage`)).toEqual(expectation)
58
+ expect(xhrCount).toBe(1)
59
+ })
60
+
61
+ it(`should load a 404 page when page-path file is not a json`, async () => {
62
+ const baseLoader = new BaseLoader(null, [])
63
+
64
+ mockPageData(`/unknown-page`, 200, false)
65
+ mockPageData(`/404.html`, 200, true)
66
+
67
+ const expectation = {
68
+ status: `success`,
69
+ pagePath: `/404.html`,
70
+ notFound: true,
71
+ payload: {
72
+ path: `/404.html/`,
73
+ },
74
+ }
75
+ expect(await baseLoader.loadPageDataJson(`/unknown-page/`)).toEqual(
76
+ expectation
77
+ )
78
+ expect(baseLoader.pageDataDb.get(`/unknown-page`)).toEqual(expectation)
79
+ expect(xhrCount).toBe(2)
80
+ })
81
+
82
+ it(`should load a 404 page when path returns a 404`, async () => {
83
+ const baseLoader = new BaseLoader(null, [])
84
+
85
+ mockPageData(`/unknown-page`, 200, false)
86
+ mockPageData(`/404.html`, 200, true)
87
+
88
+ const expectation = {
89
+ status: `success`,
90
+ pagePath: `/404.html`,
91
+ notFound: true,
92
+ payload: {
93
+ path: `/404.html/`,
94
+ },
95
+ }
96
+ expect(await baseLoader.loadPageDataJson(`/unknown-page/`)).toEqual(
97
+ expectation
98
+ )
99
+ expect(baseLoader.pageDataDb.get(`/unknown-page`)).toEqual(expectation)
100
+ expect(xhrCount).toBe(2)
101
+ })
102
+
103
+ it(`should return a failure when status is 404 and 404 page is fetched`, async () => {
104
+ const baseLoader = new BaseLoader(null, [])
105
+
106
+ mockPageData(`/unknown-page`, 404, false)
107
+ mockPageData(`/404.html`, 404, false)
108
+
109
+ const expectation = {
110
+ status: `failure`,
111
+ pagePath: `/404.html`,
112
+ notFound: true,
113
+ }
114
+ expect(await baseLoader.loadPageDataJson(`/unknown-page/`)).toEqual(
115
+ expectation
116
+ )
117
+ expect(baseLoader.pageDataDb.get(`/unknown-page`)).toEqual(expectation)
118
+ expect(xhrCount).toBe(2)
119
+ })
120
+
121
+ it(`should return an error when status is 500`, async () => {
122
+ const baseLoader = new BaseLoader(null, [])
123
+
124
+ mockPageData(`/error-page`, 500, false)
125
+
126
+ const expectation = {
127
+ status: `error`,
128
+ pagePath: `/error-page`,
129
+ }
130
+ expect(await baseLoader.loadPageDataJson(`/error-page/`)).toEqual(
131
+ expectation
132
+ )
133
+ expect(baseLoader.pageDataDb.get(`/error-page`)).toEqual(expectation)
134
+ expect(xhrCount).toBe(1)
135
+ })
136
+
137
+ it(`should retry 3 times before returning an error`, async () => {
138
+ const baseLoader = new BaseLoader(null, [])
139
+
140
+ mockPageData(`/blocked-page`, 0, false)
141
+
142
+ const expectation = {
143
+ status: `error`,
144
+ retries: 3,
145
+ pagePath: `/blocked-page`,
146
+ }
147
+ expect(await baseLoader.loadPageDataJson(`/blocked-page/`)).toEqual(
148
+ expectation
149
+ )
150
+ expect(baseLoader.pageDataDb.get(`/blocked-page`)).toEqual(expectation)
151
+ expect(xhrCount).toBe(4)
152
+ })
153
+
154
+ it(`should recover if we get 1 failure`, async () => {
155
+ const baseLoader = new BaseLoader(null, [])
156
+
157
+ let xhrCount = 0
158
+ mock.get(`/page-data/blocked-page/page-data.json`, (req, res) => {
159
+ if (xhrCount++ === 0) {
160
+ return res.status(0).body(``)
161
+ } else {
162
+ res.header(`content-type`, `application/json`)
163
+ return res.status(200).body(`{ "path": "/blocked-page/" }`)
164
+ }
165
+ })
166
+
167
+ const expectation = {
168
+ status: `success`,
169
+ retries: 1,
170
+ pagePath: `/blocked-page`,
171
+ payload: {
172
+ path: `/blocked-page/`,
173
+ },
174
+ }
175
+ expect(await baseLoader.loadPageDataJson(`/blocked-page/`)).toEqual(
176
+ expectation
177
+ )
178
+ expect(baseLoader.pageDataDb.get(`/blocked-page`)).toEqual(expectation)
179
+ expect(xhrCount).toBe(2)
180
+ })
181
+
182
+ it(`shouldn't load pageData multiple times`, async () => {
183
+ const baseLoader = new BaseLoader(null, [])
184
+
185
+ mockPageData(`/mypage`, 200, true)
186
+
187
+ const expectation = await baseLoader.loadPageDataJson(`/mypage/`)
188
+ expect(await baseLoader.loadPageDataJson(`/mypage/`)).toBe(expectation)
189
+ expect(xhrCount).toBe(1)
190
+ })
191
+ })
192
+ describe(`loadPage`, () => {
193
+ beforeEach(() => emitter.emit.mockReset())
194
+
195
+ it(`should be successful when component can be loaded`, async () => {
196
+ const baseLoader = new BaseLoader(() => Promise.resolve(`instance`), [])
197
+ const pageData = {
198
+ path: `/mypage/`,
199
+ componentChunkName: `chunk`,
200
+ webpackCompilationHash: `123`,
201
+ result: {
202
+ pageContext: `something something`,
203
+ },
204
+ }
205
+ baseLoader.loadPageDataJson = jest.fn(() =>
206
+ Promise.resolve({
207
+ payload: pageData,
208
+ status: `success`,
209
+ })
210
+ )
211
+
212
+ const expectation = await baseLoader.loadPage(`/mypage/`)
213
+ expect(expectation).toMatchSnapshot()
214
+ expect(Object.keys(expectation)).toEqual([`component`, `json`, `page`])
215
+ expect(baseLoader.pageDb.get(`/mypage`)).toEqual(
216
+ expect.objectContaining({
217
+ payload: expectation,
218
+ status: `success`,
219
+ })
220
+ )
221
+ expect(emitter.emit).toHaveBeenCalledTimes(1)
222
+ expect(emitter.emit).toHaveBeenCalledWith(`onPostLoadPageResources`, {
223
+ page: expectation,
224
+ pageResources: expectation,
225
+ })
226
+ })
227
+
228
+ it(`should set not found on finalResult`, async () => {
229
+ const baseLoader = new BaseLoader(() => Promise.resolve(`instance`), [])
230
+ const pageData = {
231
+ path: `/mypage/`,
232
+ componentChunkName: `chunk`,
233
+ webpackCompilationHash: `123`,
234
+ }
235
+ baseLoader.loadPageDataJson = jest.fn(() =>
236
+ Promise.resolve({
237
+ payload: pageData,
238
+ status: `success`,
239
+ notFound: true,
240
+ })
241
+ )
242
+
243
+ await baseLoader.loadPage(`/mypage/`)
244
+ const expectation = baseLoader.pageDb.get(`/mypage`)
245
+ expect(expectation).toHaveProperty(`notFound`, true)
246
+ expect(emitter.emit).toHaveBeenCalledTimes(1)
247
+ expect(emitter.emit).toHaveBeenCalledWith(`onPostLoadPageResources`, {
248
+ page: expectation.payload,
249
+ pageResources: expectation.payload,
250
+ })
251
+ })
252
+
253
+ it(`should return an error when component cannot be loaded`, async () => {
254
+ const baseLoader = new BaseLoader(() => Promise.resolve(false), [])
255
+ const pageData = {
256
+ path: `/mypage/`,
257
+ componentChunkName: `chunk`,
258
+ webpackCompilationHash: `123`,
259
+ }
260
+ baseLoader.loadPageDataJson = jest.fn(() =>
261
+ Promise.resolve({
262
+ payload: pageData,
263
+ status: `success`,
264
+ })
265
+ )
266
+
267
+ await baseLoader.loadPage(`/mypage/`)
268
+ const expectation = baseLoader.pageDb.get(`/mypage`)
269
+ expect(expectation).toHaveProperty(`status`, `error`)
270
+ expect(emitter.emit).toHaveBeenCalledTimes(0)
271
+ })
272
+
273
+ it(`should return an error pageData contains an error`, async () => {
274
+ const baseLoader = new BaseLoader(() => Promise.resolve(`instance`), [])
275
+ const pageData = {
276
+ path: `/mypage/`,
277
+ componentChunkName: `chunk`,
278
+ webpackCompilationHash: `123`,
279
+ }
280
+ baseLoader.loadPageDataJson = jest.fn(() =>
281
+ Promise.resolve({
282
+ payload: pageData,
283
+ status: `error`,
284
+ })
285
+ )
286
+
287
+ expect(await baseLoader.loadPage(`/mypage/`)).toEqual({ status: `error` })
288
+ expect(baseLoader.pageDb.size).toBe(0)
289
+ expect(emitter.emit).toHaveBeenCalledTimes(0)
290
+ })
291
+
292
+ it(`should throw an error when 404 cannot be fetched`, async () => {
293
+ const baseLoader = new BaseLoader(() => Promise.resolve(`instance`), [])
294
+
295
+ baseLoader.loadPageDataJson = jest.fn(() =>
296
+ Promise.resolve({
297
+ status: `failure`,
298
+ })
299
+ )
300
+
301
+ try {
302
+ await baseLoader.loadPage(`/404.html/`)
303
+ } catch (err) {
304
+ expect(err.message).toEqual(
305
+ expect.stringContaining(`404 page could not be found`)
306
+ )
307
+ }
308
+ expect(baseLoader.pageDb.size).toBe(0)
309
+ expect(emitter.emit).toHaveBeenCalledTimes(0)
310
+ })
311
+
312
+ it(`should cache the result of loadPage`, async () => {
313
+ const baseLoader = new BaseLoader(() => Promise.resolve(`instance`), [])
314
+ baseLoader.loadPageDataJson = jest.fn(() =>
315
+ Promise.resolve({
316
+ payload: {},
317
+ status: `success`,
318
+ })
319
+ )
320
+
321
+ const expectation = await baseLoader.loadPage(`/mypage/`)
322
+ expect(await baseLoader.loadPage(`/mypage/`)).toBe(expectation)
323
+ expect(baseLoader.loadPageDataJson).toHaveBeenCalledTimes(1)
324
+ })
325
+
326
+ it(`should only run 1 network request even when called multiple times`, async () => {
327
+ const baseLoader = new BaseLoader(() => Promise.resolve(`instance`), [])
328
+ baseLoader.loadPageDataJson = jest.fn(() =>
329
+ Promise.resolve({
330
+ payload: {},
331
+ status: `success`,
332
+ })
333
+ )
334
+
335
+ const loadPagePromise = baseLoader.loadPage(`/test-page/`)
336
+ expect(baseLoader.inFlightDb.size).toBe(1)
337
+ expect(baseLoader.loadPage(`/test-page/`)).toBe(loadPagePromise)
338
+ expect(baseLoader.inFlightDb.size).toBe(1)
339
+
340
+ const expectation = await loadPagePromise
341
+
342
+ expect(baseLoader.inFlightDb.size).toBe(0)
343
+ expect(emitter.emit).toHaveBeenCalledTimes(1)
344
+ expect(emitter.emit).toHaveBeenCalledWith(`onPostLoadPageResources`, {
345
+ page: expectation,
346
+ pageResources: expectation,
347
+ })
348
+ })
349
+ })
350
+
351
+ describe(`loadPageSync`, () => {
352
+ it(`returns page resources when already fetched`, () => {
353
+ const baseLoader = new BaseLoader(null, [])
354
+
355
+ baseLoader.pageDb.set(`/mypage`, { payload: true })
356
+ expect(baseLoader.loadPageSync(`/mypage/`)).toBe(true)
357
+ })
358
+
359
+ it(`returns page resources when already fetched`, () => {
360
+ const baseLoader = new BaseLoader(null, [])
361
+
362
+ expect(baseLoader.loadPageSync(`/mypage/`)).toBeUndefined()
363
+ })
364
+ })
365
+
366
+ describe(`prefetch`, () => {
367
+ const flushPromises = () => new Promise(resolve => setImmediate(resolve))
368
+
369
+ it(`shouldn't prefetch when shouldPrefetch is false`, () => {
370
+ const baseLoader = new BaseLoader(null, [])
371
+ baseLoader.shouldPrefetch = jest.fn(() => false)
372
+ baseLoader.doPrefetch = jest.fn()
373
+
374
+ expect(baseLoader.prefetch(`/mypath/`)).toBe(false)
375
+ expect(baseLoader.shouldPrefetch).toHaveBeenCalledWith(`/mypath/`)
376
+ expect(baseLoader.doPrefetch).not.toHaveBeenCalled()
377
+ })
378
+
379
+ it(`should prefetch when not yet triggered`, async () => {
380
+ jest.useFakeTimers()
381
+ const baseLoader = new BaseLoader(null, [])
382
+ baseLoader.shouldPrefetch = jest.fn(() => true)
383
+ baseLoader.apiRunner = jest.fn()
384
+ baseLoader.doPrefetch = jest.fn(() => Promise.resolve({}))
385
+
386
+ expect(baseLoader.prefetch(`/mypath/`)).toBe(true)
387
+
388
+ // wait for doPrefetchPromise
389
+ await flushPromises()
390
+
391
+ expect(baseLoader.apiRunner).toHaveBeenCalledWith(`onPrefetchPathname`, {
392
+ pathname: `/mypath/`,
393
+ })
394
+ expect(baseLoader.apiRunner).toHaveBeenNthCalledWith(
395
+ 2,
396
+ `onPostPrefetchPathname`,
397
+ {
398
+ pathname: `/mypath/`,
399
+ }
400
+ )
401
+ })
402
+
403
+ it(`should only run apis once`, async () => {
404
+ const baseLoader = new BaseLoader(null, [])
405
+ baseLoader.shouldPrefetch = jest.fn(() => true)
406
+ baseLoader.apiRunner = jest.fn()
407
+ baseLoader.doPrefetch = jest.fn(() => Promise.resolve({}))
408
+
409
+ expect(baseLoader.prefetch(`/mypath/`)).toBe(true)
410
+ expect(baseLoader.prefetch(`/mypath/`)).toBe(true)
411
+
412
+ // wait for doPrefetchPromise
413
+ await flushPromises()
414
+
415
+ expect(baseLoader.apiRunner).toHaveBeenCalledTimes(2)
416
+ expect(baseLoader.apiRunner).toHaveBeenNthCalledWith(
417
+ 1,
418
+ `onPrefetchPathname`,
419
+ expect.anything()
420
+ )
421
+ expect(baseLoader.apiRunner).toHaveBeenNthCalledWith(
422
+ 2,
423
+ `onPostPrefetchPathname`,
424
+ expect.anything()
425
+ )
426
+ })
427
+ })
428
+ })
package/cache-dir/app.js CHANGED
@@ -5,12 +5,17 @@ import domReady from "@mikaelkristiansson/domready"
5
5
  import socketIo from "./socketIo"
6
6
  import emitter from "./emitter"
7
7
  import { apiRunner, apiRunnerAsync } from "./api-runner-browser"
8
- import loader, { setApiRunnerForLoader } from "./loader"
8
+ import { setLoader } from "./loader"
9
+ import DevLoader from "./dev-loader"
9
10
  import syncRequires from "./sync-requires"
11
+ // Generated during bootstrap
10
12
  import matchPaths from "./match-paths.json"
11
13
 
12
14
  window.___emitter = emitter
13
- setApiRunnerForLoader(apiRunner)
15
+
16
+ const loader = new DevLoader(syncRequires, matchPaths)
17
+ setLoader(loader)
18
+ loader.setApiRunner(apiRunner)
14
19
 
15
20
  // Let the site/plugins run code very early.
16
21
  apiRunnerAsync(`onClientEntry`).then(() => {
@@ -49,8 +54,6 @@ apiRunnerAsync(`onClientEntry`).then(() => {
49
54
  ReactDOM.render
50
55
  )[0]
51
56
 
52
- loader.addDevRequires(syncRequires)
53
- loader.addMatchPaths(matchPaths)
54
57
  Promise.all([
55
58
  loader.loadPage(`/dev-404-page/`),
56
59
  loader.loadPage(`/404.html`),
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
7
5
  var _react = _interopRequireDefault(require("react"));
@@ -16,14 +14,19 @@ var _emitter = _interopRequireDefault(require("./emitter"));
16
14
 
17
15
  var _apiRunnerBrowser = require("./api-runner-browser");
18
16
 
19
- var _loader = _interopRequireWildcard(require("./loader"));
17
+ var _loader = require("./loader");
18
+
19
+ var _devLoader = _interopRequireDefault(require("./dev-loader"));
20
20
 
21
21
  var _syncRequires = _interopRequireDefault(require("./sync-requires"));
22
22
 
23
23
  var _matchPaths = _interopRequireDefault(require("./match-paths.json"));
24
24
 
25
+ // Generated during bootstrap
25
26
  window.___emitter = _emitter.default;
26
- (0, _loader.setApiRunnerForLoader)(_apiRunnerBrowser.apiRunner); // Let the site/plugins run code very early.
27
+ const loader = new _devLoader.default(_syncRequires.default, _matchPaths.default);
28
+ (0, _loader.setLoader)(loader);
29
+ loader.setApiRunner(_apiRunnerBrowser.apiRunner); // Let the site/plugins run code very early.
27
30
 
28
31
  (0, _apiRunnerBrowser.apiRunnerAsync)(`onClientEntry`).then(() => {
29
32
  // Hook up the client to socket.io on server
@@ -52,12 +55,7 @@ window.___emitter = _emitter.default;
52
55
 
53
56
  const rootElement = document.getElementById(`___gatsby`);
54
57
  const renderer = (0, _apiRunnerBrowser.apiRunner)(`replaceHydrateFunction`, undefined, _reactDom.default.render)[0];
55
-
56
- _loader.default.addDevRequires(_syncRequires.default);
57
-
58
- _loader.default.addMatchPaths(_matchPaths.default);
59
-
60
- Promise.all([_loader.default.loadPage(`/dev-404-page/`), _loader.default.loadPage(`/404.html`), _loader.default.loadPage(window.location.pathname)]).then(() => {
58
+ Promise.all([loader.loadPage(`/dev-404-page/`), loader.loadPage(`/404.html`), loader.loadPage(window.location.pathname)]).then(() => {
61
59
  const preferDefault = m => m && m.default || m;
62
60
 
63
61
  let Root = preferDefault(require(`./root`));
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+
6
+ var _loader = require("./loader");
7
+
8
+ class DevLoader extends _loader.BaseLoader {
9
+ constructor(syncRequires, matchPaths) {
10
+ const loadComponent = chunkName => Promise.resolve(syncRequires.components[chunkName]);
11
+
12
+ super(loadComponent, matchPaths);
13
+ }
14
+
15
+ loadPage(pagePath) {
16
+ const realPath = this.pathFinder.find(pagePath);
17
+ return super.loadPage(realPath).then(result => {
18
+ require(`./socketIo`).getPageData(realPath);
19
+
20
+ return result;
21
+ });
22
+ }
23
+
24
+ loadPageDataJson(rawPath) {
25
+ return super.loadPageDataJson(rawPath).then(data => {
26
+ // when we can't find a proper 404.html we fallback to dev-404-page
27
+ if (data.status === `failure`) {
28
+ return this.loadPageDataJson(`/dev-404-page/`);
29
+ }
30
+
31
+ return data;
32
+ });
33
+ }
34
+
35
+ doPrefetch(pagePath) {
36
+ return Promise.resolve(require(`./socketIo`).getPageData(pagePath));
37
+ }
38
+
39
+ }
40
+
41
+ var _default = DevLoader;
42
+ exports.default = _default;