Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add tests to static-query filepaths #25978

Merged
merged 2 commits into from
Jul 24, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
fix windows paths
  • Loading branch information
wardpeet committed Jul 23, 2020
commit 96b23a1cbb4dd888cb10cdf0a5661731ad84373d
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { uniqBy, List } from "lodash"
import path from "path"
import { slash } from "gatsby-core-utils"
import { IGatsbyState } from "../redux/types"
import { Stats } from "webpack"

Expand Down Expand Up @@ -107,11 +109,11 @@ export default function mapTemplatesToStaticQueryHashes(

for (const uniqDependent of uniqDependents) {
if (uniqDependent.resource) {
result.add(uniqDependent.resource)
result.add(slash(uniqDependent.resource))
// Queries used in gatsby-browser are global and should be added to all pages
if (isGatsbyBrowser(uniqDependent)) {
if (staticQueryModuleComponentPath) {
globalStaticQueries.add(staticQueryModuleComponentPath)
globalStaticQueries.add(slash(staticQueryModuleComponentPath))
}
} else {
seen.add(uniqDependent.resource)
Expand All @@ -131,10 +133,12 @@ export default function mapTemplatesToStaticQueryHashes(

// For every known static query, we get its dependents.
staticQueryComponents.forEach(({ componentPath }) => {
// componentPaths are slashed by gatsby-core-utils we undo it
const nonSlashedPath = path.resolve(componentPath)

const staticQueryComponentModule = modules.find(
m => m.resource === componentPath
m => m.resource === nonSlashedPath
)

const dependants = staticQueryComponentModule
? getDeps(staticQueryComponentModule)
: new Set()
Expand Down