diff --git a/packages/gatsby/src/internal-plugins/query-runner/__tests__/pages-writer.js b/packages/gatsby/src/internal-plugins/query-runner/__tests__/pages-writer.js index c43686aabba16..4ab64bf7933ce 100644 --- a/packages/gatsby/src/internal-plugins/query-runner/__tests__/pages-writer.js +++ b/packages/gatsby/src/internal-plugins/query-runner/__tests__/pages-writer.js @@ -37,8 +37,7 @@ jest.mock(`../../../redux/`, () => { jest.mock(`../../../utils/cache`, () => { return { - cachePath: filePath => - require(`path`).join(`my`, `gatsby`, `project`, `.cache`, filePath), + cachePath: () => `my/gatsby/project/.cache`, } }) diff --git a/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js b/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js index f7d7830e8ec84..63778673c602b 100644 --- a/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js +++ b/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js @@ -59,6 +59,8 @@ const writePages = async () => { return Promise.resolve() } + const cacheDirectory = cachePath() + lastHash = newHash // Get list of components, and json files. @@ -102,12 +104,13 @@ const preferDefault = m => m && m.default || m .join(`,\n`)} }\n\n` - asyncRequires += `exports.data = () => import(/* webpackChunkName: "pages-manifest" */ "${cachePath( + asyncRequires += `exports.data = () => import(/* webpackChunkName: "pages-manifest" */ "${joinPath( + cacheDirectory, `data.json` )}")\n\n` const writeAndMove = (file, data) => { - const destination = cachePath(file) + const destination = joinPath(cacheDirectory, file) const tmp = `${destination}.${Date.now()}` return fs .writeFile(tmp, data)