Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/gatsby/src/bootstrap/__tests__/requires-writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const generatePagesState = pages => {
jest.mock(`fs-extra`, () => {
return {
writeFile: () => Promise.resolve(),
outputFileSync: () => {},
move: () => {},
}
})
Expand Down
5 changes: 5 additions & 0 deletions packages/gatsby/src/utils/gatsby-webpack-virtual-modules.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import VirtualModulesPlugin from "webpack-virtual-modules"
import * as path from "path"
import * as fs from "fs-extra"
/*
* This module allows creating virtual (in memory only) modules / files
* that webpack compilation can access without the need to write module
Expand Down Expand Up @@ -46,6 +47,10 @@ export function writeModule(filePath: string, fileContents: string): void {
return
}

// workaround webpack marking virtual modules as deleted because those files don't really exist
// so we create those files just so watchpack doesn't mark them as initially missing
fs.outputFileSync(adjustedFilePath, fileContents)

fileContentLookup[adjustedFilePath] = fileContents

instances.forEach(instance => {
Expand Down
9 changes: 5 additions & 4 deletions packages/gatsby/src/utils/start-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ export async function startServer(
})
webpackActivity.start()

// loading indicator
// write virtual module always to not fail webpack compilation, but only add express route handlers when
// query on demand is enabled and loading indicator is not disabled
writeVirtualLoadingIndicatorModule()

const THIRTY_SECONDS = 30 * 1000
let cancelDevJSNotice: CancelExperimentNoticeCallbackOrUndefined
if (
Expand Down Expand Up @@ -486,10 +491,6 @@ module.exports = {
route({ app, program, store })
}

// loading indicator
// write virtual module always to not fail webpack compilation, but only add express route handlers when
// query on demand is enabled and loading indicator is not disabled
writeVirtualLoadingIndicatorModule()
if (
process.env.GATSBY_EXPERIMENTAL_QUERY_ON_DEMAND &&
process.env.GATSBY_QUERY_ON_DEMAND_LOADING_INDICATOR === `true`
Expand Down