Closed ChristopherBiscardi closed 5 years ago
Looks like the issue is in the parseEverything
function . Notably, the variable this.baseDir
is likely the project's root directory, so files from yarn workspace packages, etc would not fall under this category and the StaticQuery
s would not be compiled.
async parseEverything() {
// FIXME: this should all use gatsby's configuration to determine parsable
// files (and how to parse them)
let files = glob.sync(`${this.fragmentsDir}/**/*.+(t|j)s?(x)`, {
nodir: true,
})
files = files.concat(
glob.sync(`${this.baseDir}/**/*.+(t|j)s?(x)`, { nodir: true })
)
files = files.filter(d => !d.match(/\.d\.ts$/))
files = files.map(normalize)
// Ensure all page components added as they're not necessarily in the
// pages directory e.g. a plugin could add a page component. Plugins
// *should* copy their components (if they add a query) to .cache so that
// our babel plugin to remove the query on building is active (we don't
// run babel on code in node_modules). Otherwise the component will throw
// an error in the browser of "graphql is not defined".
files = files.concat(
Array.from(store.getState().components.keys(), c => normalize(c))
)
files = _.uniq(files)
let parser = new FileParser()
return await parser.parseFiles(files)
}
There are other places this assumption that files are located under the current directory exists, such as when hashing static queries and possibly other places.
The FIXME
note is particularly interesting and is probably what the fix is here, since the heuristic of assuming all files exist in a subdirectory no longer applies.
// FIXME: this should all use gatsby's configuration to determine parsable
// files (and how to parse them)
Static queries may cause confusing issues