Skip to content

Commit 5250a02

Browse files
authoredJul 3, 2020
Revert "feat(gatsby): Track static queries by template (#25120)" (#25493)
This reverts commit 6b39645.
1 parent 473d2c8 commit 5250a02

35 files changed

+8
-785
lines changed
 

‎.circleci/config.yml

-8
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,6 @@ jobs:
281281
- e2e-test:
282282
test_path: integration-tests/structured-logging
283283

284-
integration_tests_artifacts:
285-
executor: node
286-
steps:
287-
- e2e-test:
288-
test_path: integration-tests/artifacts
289-
290284
e2e_tests_path-prefix:
291285
<<: *e2e-executor
292286
environment:
@@ -576,8 +570,6 @@ workflows:
576570
<<: *e2e-test-workflow
577571
- integration_tests_structured_logging:
578572
<<: *e2e-test-workflow
579-
- integration_tests_artifacts:
580-
<<: *e2e-test-workflow
581573
- integration_tests_gatsby_cli:
582574
requires:
583575
- bootstrap

‎integration-tests/artifacts/LICENSE

-21
This file was deleted.

‎integration-tests/artifacts/README.md

-3
This file was deleted.

‎integration-tests/artifacts/__tests__/static-queries.js

-173
This file was deleted.

‎integration-tests/artifacts/gatsby-browser.js

-9
This file was deleted.

‎integration-tests/artifacts/gatsby-config.js

-9
This file was deleted.

‎integration-tests/artifacts/gatsby-ssr.js

Whitespace-only changes.

‎integration-tests/artifacts/jest.config.js

-3
This file was deleted.

‎integration-tests/artifacts/package.json

-32
This file was deleted.

‎integration-tests/artifacts/src/components/author.js

-15
This file was deleted.

‎integration-tests/artifacts/src/components/github.js

-15
This file was deleted.

‎integration-tests/artifacts/src/components/title.js

-7
This file was deleted.

‎integration-tests/artifacts/src/components/twitter.js

-15
This file was deleted.

‎integration-tests/artifacts/src/hooks/use-title.js

-14
This file was deleted.

‎integration-tests/artifacts/src/pages/dynamic-dynamic.js

-17
This file was deleted.

‎integration-tests/artifacts/src/pages/dynamic-import.js

-17
This file was deleted.

‎integration-tests/artifacts/src/pages/dynamic.js

-17
This file was deleted.

‎integration-tests/artifacts/src/pages/import-dynamic.js

-12
This file was deleted.

‎integration-tests/artifacts/src/pages/import-import.js

-12
This file was deleted.

‎integration-tests/artifacts/src/pages/import.js

-7
This file was deleted.

‎integration-tests/artifacts/src/pages/inline.js

-15
This file was deleted.

‎integration-tests/artifacts/src/pages/jsx.jsx

-7
This file was deleted.

‎integration-tests/artifacts/src/pages/tsx.tsx

-7
This file was deleted.

‎integration-tests/artifacts/src/pages/typescript.ts

-7
This file was deleted.

‎packages/babel-plugin-remove-graphql-queries/src/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -432,5 +432,4 @@ export {
432432
StringInterpolationNotAllowedError,
433433
EmptyGraphQLTagError,
434434
GraphQLSyntaxError,
435-
murmurhash,
436435
}

‎packages/gatsby/src/commands/build-javascript.ts

+1-41
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import { Span } from "opentracing"
22
import webpack from "webpack"
3-
import { isEqual } from "lodash"
43
import flatMap from "lodash/flatMap"
54

65
import webpackConfig from "../utils/webpack.config"
7-
import { store } from "../redux"
8-
import { mapTemplatesToStaticQueryHashes } from "../utils/map-pages-to-static-query-hashes"
96

107
import { IProgram } from "./types"
118

@@ -26,44 +23,7 @@ export const buildProductionBundle = async (
2623
)
2724

2825
return new Promise((resolve, reject) => {
29-
const compiler = webpack(compilerConfig)
30-
31-
compiler.hooks.compilation.tap(`webpack-dep-tree-plugin`, compilation => {
32-
compilation.hooks.seal.tap(`webpack-dep-tree-plugin`, () => {
33-
const state = store.getState()
34-
const mapOfTemplatesToStaticQueryHashes = mapTemplatesToStaticQueryHashes(
35-
state,
36-
compilation
37-
)
38-
39-
mapOfTemplatesToStaticQueryHashes.forEach(
40-
(staticQueryHashes, componentPath) => {
41-
if (
42-
!isEqual(
43-
state.staticQueriesByTemplate.get(componentPath),
44-
staticQueryHashes.map(String)
45-
)
46-
) {
47-
store.dispatch({
48-
type: `ADD_PENDING_TEMPLATE_DATA_WRITE`,
49-
payload: {
50-
componentPath,
51-
},
52-
})
53-
store.dispatch({
54-
type: `SET_STATIC_QUERIES_BY_TEMPLATE`,
55-
payload: {
56-
componentPath,
57-
staticQueryHashes,
58-
},
59-
})
60-
}
61-
}
62-
)
63-
})
64-
})
65-
66-
compiler.run((err, stats) => {
26+
webpack(compilerConfig).run((err, stats) => {
6727
if (err) {
6828
return reject(err)
6929
}

‎packages/gatsby/src/commands/develop-process.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ module.exports = async (program: IProgram): Promise<void> => {
204204
})
205205
queryWatcher.startWatchDeletePage()
206206

207-
await startWebpackServer({ program, app, workerPool, store })
207+
await startWebpackServer({ program, app, workerPool })
208208
},
209209
},
210210
},

‎packages/gatsby/src/redux/__tests__/__snapshots__/index.js.snap

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ Object {
5858
"pagePaths": Set {},
5959
"templatePaths": Set {},
6060
},
61-
"staticQueriesByTemplate": Map {},
6261
"staticQueryComponents": Map {},
6362
"status": Object {
6463
"PLUGINS_HASH": "",

‎packages/gatsby/src/redux/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export const saveState = (): void => {
8686
pageDataStats: state.pageDataStats,
8787
pageData: state.pageData,
8888
pendingPageDataWrites: state.pendingPageDataWrites,
89-
staticQueriesByTemplate: state.staticQueriesByTemplate,
9089
})
9190
}
9291

‎packages/gatsby/src/redux/reducers/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { flattenedPluginsReducer } from "./flattened-plugins"
2525
import { pendingPageDataWritesReducer } from "./pending-page-data-writes"
2626
import { schemaCustomizationReducer } from "./schema-customization"
2727
import { inferenceMetadataReducer } from "./inference-metadata"
28-
import { staticQueriesByTemplateReducer } from "./static-queries-by-template"
2928

3029
/**
3130
* @property exports.nodesTouched Set<string>
@@ -58,5 +57,4 @@ export {
5857
pageDataStatsReducer as pageDataStats,
5958
pageDataReducer as pageData,
6059
pendingPageDataWritesReducer as pendingPageDataWrites,
61-
staticQueriesByTemplateReducer as staticQueriesByTemplate,
6260
}

‎packages/gatsby/src/redux/reducers/static-queries-by-template.ts

-22
This file was deleted.

‎packages/gatsby/src/redux/types.ts

-11
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ export interface IGatsbyState {
199199
IGatsbyStaticQueryComponents["id"],
200200
IGatsbyStaticQueryComponents
201201
>
202-
staticQueriesByTemplate: Map<SystemPath, Identifier[]>
203202
pendingPageDataWrites: {
204203
pagePaths: Set<string>
205204
templatePaths: Set<SystemPath>
@@ -256,7 +255,6 @@ export interface ICachedReduxState {
256255
webpackCompilationHash: IGatsbyState["webpackCompilationHash"]
257256
pageDataStats: IGatsbyState["pageDataStats"]
258257
pageData: IGatsbyState["pageData"]
259-
staticQueriesByTemplate: IGatsbyState["staticQueriesByTemplate"]
260258
pendingPageDataWrites: IGatsbyState["pendingPageDataWrites"]
261259
}
262260

@@ -306,7 +304,6 @@ export type ActionsUnion =
306304
| ICreateJobAction
307305
| ISetJobAction
308306
| IEndJobAction
309-
| ISetStaticQueriesByTemplateAction
310307
| IAddPendingPageDataWriteAction
311308
| IAddPendingTemplateDataWriteAction
312309
| IClearPendingPageDataWritesAction
@@ -582,14 +579,6 @@ export interface IRemoveTemplateComponentAction {
582579
}
583580
}
584581

585-
export interface ISetStaticQueriesByTemplateAction {
586-
type: `SET_STATIC_QUERIES_BY_TEMPLATE`
587-
payload: {
588-
componentPath: string
589-
staticQueryHashes: Identifier[]
590-
}
591-
}
592-
593582
export interface IAddPendingPageDataWriteAction {
594583
type: `ADD_PENDING_PAGE_DATA_WRITE`
595584
payload: {

‎packages/gatsby/src/services/start-webpack-server.ts

+3-42
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import report from "gatsby-cli/lib/reporter"
33
import formatWebpackMessages from "react-dev-utils/formatWebpackMessages"
44
import chalk from "chalk"
55
import { Compiler } from "webpack"
6-
import { isEqual } from "lodash"
76

87
import {
98
reportWebpackWarnings,
@@ -21,19 +20,17 @@ import {
2120
markWebpackStatusAsDone,
2221
} from "../utils/webpack-status"
2322
import { enqueueFlush } from "../utils/page-data"
24-
import { mapTemplatesToStaticQueryHashes } from "../utils/map-pages-to-static-query-hashes"
2523

2624
export async function startWebpackServer({
2725
program,
2826
app,
2927
workerPool,
30-
store,
3128
}: Partial<IBuildContext>): Promise<{
3229
compiler: Compiler
3330
websocketManager: WebsocketManager
3431
}> {
35-
if (!program || !app || !store) {
36-
report.panic(`Missing required params`)
32+
if (!program || !app) {
33+
throw new Error(`Missing required params`)
3734
}
3835
let { compiler, webpackActivity, websocketManager } = await startServer(
3936
program,
@@ -112,45 +109,9 @@ export async function startWebpackServer({
112109
webpackActivity.end()
113110
webpackActivity = null
114111
}
115-
116-
if (isSuccessful) {
117-
const state = store.getState()
118-
const mapOfTemplatesToStaticQueryHashes = mapTemplatesToStaticQueryHashes(
119-
state,
120-
stats.compilation
121-
)
122-
123-
mapOfTemplatesToStaticQueryHashes.forEach(
124-
(staticQueryHashes, componentPath) => {
125-
if (
126-
!isEqual(
127-
state.staticQueriesByTemplate.get(componentPath),
128-
staticQueryHashes.map(String)
129-
)
130-
) {
131-
store.dispatch({
132-
type: `ADD_PENDING_TEMPLATE_DATA_WRITE`,
133-
payload: {
134-
componentPath,
135-
},
136-
})
137-
store.dispatch({
138-
type: `SET_STATIC_QUERIES_BY_TEMPLATE`,
139-
payload: {
140-
componentPath,
141-
staticQueryHashes,
142-
},
143-
})
144-
}
145-
}
146-
)
147-
148-
enqueueFlush()
149-
}
150-
112+
enqueueFlush()
151113
markWebpackStatusAsDone()
152114
done()
153-
154115
resolve({ compiler, websocketManager })
155116
})
156117
})

‎packages/gatsby/src/utils/map-pages-to-static-query-hashes.ts

-199
This file was deleted.

‎packages/gatsby/src/utils/page-data.ts

+3-22
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ interface IPageData {
1111
componentChunkName: IGatsbyPage["componentChunkName"]
1212
matchPath?: IGatsbyPage["matchPath"]
1313
path: IGatsbyPage["path"]
14-
staticQueryHashes: string[]
1514
}
1615

1716
export interface IPageDataWithQueryResult extends IPageData {
@@ -56,12 +55,7 @@ export async function removePageData(
5655

5756
export async function writePageData(
5857
publicDir: string,
59-
{
60-
componentChunkName,
61-
matchPath,
62-
path: pagePath,
63-
staticQueryHashes,
64-
}: IPageData
58+
{ componentChunkName, matchPath, path: pagePath }: IPageData
6559
): Promise<IPageDataWithQueryResult> {
6660
const inputFilePath = path.join(
6761
publicDir,
@@ -77,7 +71,6 @@ export async function writePageData(
7771
path: pagePath,
7872
matchPath,
7973
result,
80-
staticQueryHashes,
8174
}
8275
const bodyStr = JSON.stringify(body)
8376
// transform asset size to kB (from bytes) to fit 64 bit to numbers
@@ -109,13 +102,7 @@ export async function flush(): Promise<void> {
109102
}
110103
isFlushPending = false
111104
isFlushing = true
112-
const {
113-
pendingPageDataWrites,
114-
components,
115-
pages,
116-
program,
117-
staticQueriesByTemplate,
118-
} = store.getState()
105+
const { pendingPageDataWrites, components, pages, program } = store.getState()
119106

120107
const { pagePaths, templatePaths } = pendingPageDataWrites
121108

@@ -140,15 +127,9 @@ export async function flush(): Promise<void> {
140127
// them, a page might not exist anymore щ(゚Д゚щ)
141128
// This is why we need this check
142129
if (page) {
143-
const staticQueryHashes =
144-
staticQueriesByTemplate.get(page.componentPath)?.map(String) || []
145-
146130
const result = await writePageData(
147131
path.join(program.directory, `public`),
148-
{
149-
...page,
150-
staticQueryHashes,
151-
}
132+
page
152133
)
153134

154135
if (program?._?.[0] === `develop`) {

0 commit comments

Comments
 (0)
Please sign in to comment.