From 0a57f3fe87c64553ee36d153e451fadb859a6e51 Mon Sep 17 00:00:00 2001 From: Ward Peeters Date: Mon, 22 Feb 2021 13:52:03 +0100 Subject: [PATCH 1/2] feat: shim reporter from gatsby --- .../src/__tests__/collection-extract-query-string.ts | 8 ++++++-- .../src/__tests__/derive-path.ts | 2 +- .../__tests__/is-valid-collection-path-implementation.ts | 8 ++++++-- .../src/collection-extract-query-string.ts | 4 +++- .../gatsby-plugin-page-creator/src/create-page-wrapper.ts | 4 +++- .../src/create-pages-from-collection-builder.ts | 4 +++- packages/gatsby-plugin-page-creator/src/derive-path.ts | 4 +++- packages/gatsby-plugin-page-creator/src/error-utils.ts | 4 +++- .../src/is-valid-collection-path-implementation.ts | 4 +++- packages/gatsby-plugin-sharp/src/__tests__/index.js | 2 +- packages/gatsby-plugin-sharp/src/__tests__/utils.js | 5 ++--- packages/gatsby-plugin-sharp/src/image-data.ts | 4 +++- .../gatsby-remark-code-repls/src/__tests__/gatsby-node.js | 4 ++-- .../src/__tests__/create-remote-file-node.js | 2 +- packages/gatsby-source-filesystem/src/__tests__/utils.js | 2 -- packages/gatsby-source-wordpress/src/models/logger.ts | 4 +++- .../gatsby-source-wordpress/src/steps/preview/index.ts | 4 +++- .../src/steps/temp-prevent-multiple-instances.ts | 5 ++++- .../src/__tests__/extend-node.js | 2 +- packages/gatsby/package.json | 2 ++ packages/gatsby/reporter.d.ts | 1 + packages/gatsby/reporter.js | 3 +++ 22 files changed, 57 insertions(+), 25 deletions(-) create mode 100644 packages/gatsby/reporter.d.ts create mode 100644 packages/gatsby/reporter.js diff --git a/packages/gatsby-plugin-page-creator/src/__tests__/collection-extract-query-string.ts b/packages/gatsby-plugin-page-creator/src/__tests__/collection-extract-query-string.ts index 300d199f8265c..c0e13cb3e9833 100644 --- a/packages/gatsby-plugin-page-creator/src/__tests__/collection-extract-query-string.ts +++ b/packages/gatsby-plugin-page-creator/src/__tests__/collection-extract-query-string.ts @@ -1,9 +1,13 @@ import sysPath from "path" import fs from "fs-extra" import { collectionExtractQueryString } from "../collection-extract-query-string" -import reporter from "gatsby-cli/lib/reporter" +import reporter from "gatsby/reporter" -jest.mock(`gatsby-cli/lib/reporter`) +jest.mock(`gatsby/reporter`, () => { + return { + panicOnBuild: jest.fn(), + } +}) // This makes the tests work on windows properly const createPath = (path: string): string => path.replace(/\//g, sysPath.sep) diff --git a/packages/gatsby-plugin-page-creator/src/__tests__/derive-path.ts b/packages/gatsby-plugin-page-creator/src/__tests__/derive-path.ts index 3f857a2a47ef8..bd87e466779da 100644 --- a/packages/gatsby-plugin-page-creator/src/__tests__/derive-path.ts +++ b/packages/gatsby-plugin-page-creator/src/__tests__/derive-path.ts @@ -1,5 +1,5 @@ import { derivePath } from "../derive-path" -import reporter from "gatsby-cli/lib/reporter" +import reporter from "gatsby/reporter" describe(`derive-path`, () => { it(`has basic support`, () => { diff --git a/packages/gatsby-plugin-page-creator/src/__tests__/is-valid-collection-path-implementation.ts b/packages/gatsby-plugin-page-creator/src/__tests__/is-valid-collection-path-implementation.ts index 208a9a1104c84..c306c39eba09c 100644 --- a/packages/gatsby-plugin-page-creator/src/__tests__/is-valid-collection-path-implementation.ts +++ b/packages/gatsby-plugin-page-creator/src/__tests__/is-valid-collection-path-implementation.ts @@ -1,8 +1,12 @@ import { isValidCollectionPathImplementation } from "../is-valid-collection-path-implementation" -import reporter from "gatsby-cli/lib/reporter" +import reporter from "gatsby/reporter" import syspath from "path" -jest.mock(`gatsby-cli/lib/reporter`) +jest.mock(`gatsby/reporter`, () => { + return { + panicOnBuild: jest.fn(), + } +}) // windows and mac have different seperators, all code is written with unix-like // file systems, but the underlying code uses `path.sep`. So when running tests diff --git a/packages/gatsby-plugin-page-creator/src/collection-extract-query-string.ts b/packages/gatsby-plugin-page-creator/src/collection-extract-query-string.ts index a56ff521c38fb..ac46049deda47 100644 --- a/packages/gatsby-plugin-page-creator/src/collection-extract-query-string.ts +++ b/packages/gatsby-plugin-page-creator/src/collection-extract-query-string.ts @@ -1,9 +1,11 @@ import { generateQueryFromString } from "./extract-query" import fs from "fs-extra" -import { Reporter } from "gatsby" +import reporter from "gatsby/reporter" import { extractModel } from "./path-utils" import { CODES, prefixId } from "./error-utils" +type Reporter = typeof reporter + // This Function opens up the actual collection file and extracts the queryString used in the export function collectionExtractQueryString( absolutePath: string, diff --git a/packages/gatsby-plugin-page-creator/src/create-page-wrapper.ts b/packages/gatsby-plugin-page-creator/src/create-page-wrapper.ts index 7bf3186a64d7d..a78a5792e9cd7 100644 --- a/packages/gatsby-plugin-page-creator/src/create-page-wrapper.ts +++ b/packages/gatsby-plugin-page-creator/src/create-page-wrapper.ts @@ -10,7 +10,9 @@ import { createClientOnlyPage } from "./create-client-only-page" import { createPagesFromCollectionBuilder } from "./create-pages-from-collection-builder" import systemPath from "path" import { trackFeatureIsUsed } from "gatsby-telemetry" -import { Reporter } from "gatsby" +import reporter from "gatsby/reporter" + +type Reporter = typeof reporter function pathIsCollectionBuilder(path: string): boolean { return path.includes(`{`) diff --git a/packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts b/packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts index 1fe40032b1a91..0986f880f2912 100644 --- a/packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts +++ b/packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts @@ -1,7 +1,7 @@ // Move this to gatsby-core-utils? import { Actions, CreatePagesArgs } from "gatsby" import { createPath } from "gatsby-page-utils" -import { Reporter } from "gatsby" +import reporter from "gatsby/reporter" import { Options as ISlugifyOptions } from "@sindresorhus/slugify" import { reverseLookupParams } from "./extract-query" import { getMatchPath } from "./get-match-path" @@ -12,6 +12,8 @@ import { collectionExtractQueryString } from "./collection-extract-query-string" import { isValidCollectionPathImplementation } from "./is-valid-collection-path-implementation" import { CODES, prefixId } from "./error-utils" +type Reporter = typeof reporter + export async function createPagesFromCollectionBuilder( filePath: string, absolutePath: string, diff --git a/packages/gatsby-plugin-page-creator/src/derive-path.ts b/packages/gatsby-plugin-page-creator/src/derive-path.ts index 1ee0b13a3b7b6..d352901f709da 100644 --- a/packages/gatsby-plugin-page-creator/src/derive-path.ts +++ b/packages/gatsby-plugin-page-creator/src/derive-path.ts @@ -1,6 +1,6 @@ import _ from "lodash" import slugify, { Options as ISlugifyOptions } from "@sindresorhus/slugify" -import { Reporter } from "gatsby" +import reporter from "gatsby/reporter" import { extractFieldWithoutUnion, extractAllCollectionSegments, @@ -8,6 +8,8 @@ import { stripTrailingSlash, } from "./path-utils" +type Reporter = typeof reporter + const doubleForwardSlashes = /\/\/+/g // Generates the path for the page from the file path diff --git a/packages/gatsby-plugin-page-creator/src/error-utils.ts b/packages/gatsby-plugin-page-creator/src/error-utils.ts index ef267522aa6e7..f9f125a43c415 100644 --- a/packages/gatsby-plugin-page-creator/src/error-utils.ts +++ b/packages/gatsby-plugin-page-creator/src/error-utils.ts @@ -1,4 +1,6 @@ -import { Reporter } from "gatsby" +import reporter from "gatsby/reporter" + +type Reporter = typeof reporter export const CODES = { Generic: `12101`, diff --git a/packages/gatsby-plugin-page-creator/src/is-valid-collection-path-implementation.ts b/packages/gatsby-plugin-page-creator/src/is-valid-collection-path-implementation.ts index bbd9c44dc4db1..7097cb4868f2e 100644 --- a/packages/gatsby-plugin-page-creator/src/is-valid-collection-path-implementation.ts +++ b/packages/gatsby-plugin-page-creator/src/is-valid-collection-path-implementation.ts @@ -1,8 +1,10 @@ import sysPath from "path" -import { Reporter } from "gatsby" +import reporter from "gatsby/reporter" import { CODES, prefixId } from "./error-utils" import { matchAllPolyfill } from "./path-utils" +type Reporter = typeof reporter + // This file is a helper for consumers. It's going to log an error to them if they // in any way have an incorrect filepath setup for us to predictably use collection // querying. diff --git a/packages/gatsby-plugin-sharp/src/__tests__/index.js b/packages/gatsby-plugin-sharp/src/__tests__/index.js index 98e67a3f24f62..56c7504d3c0fe 100644 --- a/packages/gatsby-plugin-sharp/src/__tests__/index.js +++ b/packages/gatsby-plugin-sharp/src/__tests__/index.js @@ -38,7 +38,7 @@ const { setPluginOptions, } = require(`../plugin-options`) -jest.mock(`gatsby-cli/lib/reporter`, () => { +jest.mock(`gatsby/reporter`, () => { return { log: jest.fn(), info: jest.fn(), diff --git a/packages/gatsby-plugin-sharp/src/__tests__/utils.js b/packages/gatsby-plugin-sharp/src/__tests__/utils.js index c6ac9832d7116..82b92839a8c39 100644 --- a/packages/gatsby-plugin-sharp/src/__tests__/utils.js +++ b/packages/gatsby-plugin-sharp/src/__tests__/utils.js @@ -1,8 +1,7 @@ -jest.mock(`gatsby-cli/lib/reporter`) +jest.mock(`gatsby/reporter`) jest.mock(`progress`) const { calculateImageSizes } = require(`../utils`) -const reporter = require(`gatsby-cli/lib/reporter`) -const progress = require(`progress`) +const reporter = require(`gatsby/reporter`) const sharp = require(`sharp`) const file = { diff --git a/packages/gatsby-plugin-sharp/src/image-data.ts b/packages/gatsby-plugin-sharp/src/image-data.ts index 7c46add364945..e4472b586883e 100644 --- a/packages/gatsby-plugin-sharp/src/image-data.ts +++ b/packages/gatsby-plugin-sharp/src/image-data.ts @@ -1,13 +1,15 @@ /* eslint-disable no-unused-expressions */ import { IGatsbyImageData, ISharpGatsbyImageArgs } from "gatsby-plugin-image" import { GatsbyCache, Node } from "gatsby" -import { Reporter } from "gatsby-cli/lib/reporter/reporter" +import reporter from "gatsby/reporter" import { rgbToHex, calculateImageSizes, getSrcSet, getSizes } from "./utils" import { traceSVG, getImageSizeAsync, base64, batchQueueImageResizing } from "." import sharp from "./safe-sharp" import { createTransformObject, mergeDefaults } from "./plugin-options" import { reportError } from "./report-error" +type Reporter = typeof reporter + const DEFAULT_BLURRED_IMAGE_WIDTH = 20 const DEFAULT_BREAKPOINTS = [750, 1080, 1366, 1920] diff --git a/packages/gatsby-remark-code-repls/src/__tests__/gatsby-node.js b/packages/gatsby-remark-code-repls/src/__tests__/gatsby-node.js index 16a5e0e7b3809..dbfeab2cd35ca 100644 --- a/packages/gatsby-remark-code-repls/src/__tests__/gatsby-node.js +++ b/packages/gatsby-remark-code-repls/src/__tests__/gatsby-node.js @@ -5,7 +5,7 @@ jest.mock(`fs`, () => { } }) jest.mock(`recursive-readdir`, () => jest.fn()) -jest.mock(`gatsby-cli/lib/reporter`, () => { +jest.mock(`gatsby/reporter`, () => { return { panic: jest.fn(), } @@ -15,7 +15,7 @@ const fs = require(`fs`) const nodePath = require(`path`) const readdir = require(`recursive-readdir`) -const reporter = require(`gatsby-cli/lib/reporter`) +const reporter = require(`gatsby/reporter`) const { OPTION_DEFAULT_REPL_DIRECTORY, diff --git a/packages/gatsby-source-filesystem/src/__tests__/create-remote-file-node.js b/packages/gatsby-source-filesystem/src/__tests__/create-remote-file-node.js index e473dc20dbda4..3b79ee5a00881 100644 --- a/packages/gatsby-source-filesystem/src/__tests__/create-remote-file-node.js +++ b/packages/gatsby-source-filesystem/src/__tests__/create-remote-file-node.js @@ -27,7 +27,7 @@ jest.mock(`../create-file-node`, () => { createFileNode: jest.fn(), } }) -const reporter = require(`gatsby-cli/lib/reporter`) +const reporter = require(`gatsby/reporter`) const got = require(`got`) const createRemoteFileNode = require(`../create-remote-file-node`) diff --git a/packages/gatsby-source-filesystem/src/__tests__/utils.js b/packages/gatsby-source-filesystem/src/__tests__/utils.js index debb834d5b0e7..9a8ac914f991a 100644 --- a/packages/gatsby-source-filesystem/src/__tests__/utils.js +++ b/packages/gatsby-source-filesystem/src/__tests__/utils.js @@ -1,5 +1,3 @@ -jest.mock(`gatsby-cli/lib/reporter`) -jest.mock(`progress`) const { getRemoteFileExtension, getRemoteFileName } = require(`../utils`) describe(`create remote file node`, () => { diff --git a/packages/gatsby-source-wordpress/src/models/logger.ts b/packages/gatsby-source-wordpress/src/models/logger.ts index 37928e02c6705..741ef89bb642b 100644 --- a/packages/gatsby-source-wordpress/src/models/logger.ts +++ b/packages/gatsby-source-wordpress/src/models/logger.ts @@ -1,7 +1,9 @@ -import { Reporter } from "gatsby" +import reporter from "gatsby/reporter" import { formatLogMessage } from "~/utils/format-log-message" import { IPluginOptions } from "./gatsby-api" +type Reporter = typeof reporter + type ITimerReporter = ReturnType export interface ILoggerState { diff --git a/packages/gatsby-source-wordpress/src/steps/preview/index.ts b/packages/gatsby-source-wordpress/src/steps/preview/index.ts index e2a4454ab4c49..51a50a07c8677 100644 --- a/packages/gatsby-source-wordpress/src/steps/preview/index.ts +++ b/packages/gatsby-source-wordpress/src/steps/preview/index.ts @@ -17,7 +17,9 @@ import { formatLogMessage } from "~/utils/format-log-message" import { touchValidNodes } from "../source-nodes/update-nodes/fetch-node-updates" import { IPluginOptions } from "~/models/gatsby-api" -import { Reporter } from "gatsby" +import reporter from "gatsby/reporter" + +type Reporter = typeof reporter export const inPreviewMode = (): boolean => !!process.env.ENABLE_GATSBY_REFRESH_ENDPOINT && diff --git a/packages/gatsby-source-wordpress/src/steps/temp-prevent-multiple-instances.ts b/packages/gatsby-source-wordpress/src/steps/temp-prevent-multiple-instances.ts index c6e8a3571abcb..44e80740236dc 100644 --- a/packages/gatsby-source-wordpress/src/steps/temp-prevent-multiple-instances.ts +++ b/packages/gatsby-source-wordpress/src/steps/temp-prevent-multiple-instances.ts @@ -1,5 +1,8 @@ -import { Reporter } from "gatsby" +import reporter from "gatsby/reporter" import { formatLogMessage } from "../utils/format-log-message" + +type Reporter = typeof reporter + let isWpSourcePluginInstalled = false /** diff --git a/packages/gatsby-transformer-remark/src/__tests__/extend-node.js b/packages/gatsby-transformer-remark/src/__tests__/extend-node.js index 51729b31ace95..aae314bfdff02 100644 --- a/packages/gatsby-transformer-remark/src/__tests__/extend-node.js +++ b/packages/gatsby-transformer-remark/src/__tests__/extend-node.js @@ -4,7 +4,7 @@ const extendNodeType = require(`../extend-node-type`) const { createContentDigest } = require(`gatsby-core-utils`) const { typeDefs } = require(`../create-schema-customization`) -jest.mock(`gatsby-cli/lib/reporter`, () => { +jest.mock(`gatsby/reporter`, () => { return { log: jest.fn(), info: jest.fn(), diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index 7adbb1809c83f..3246c43e060c4 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -205,6 +205,8 @@ "gatsby-admin-public/", "graphql.js", "graphql.d.ts", + "reporter.js", + "reporter.d.ts", "index.d.ts", "scripts/postinstall.js", "utils.js", diff --git a/packages/gatsby/reporter.d.ts b/packages/gatsby/reporter.d.ts new file mode 100644 index 0000000000000..501da2ea5bd78 --- /dev/null +++ b/packages/gatsby/reporter.d.ts @@ -0,0 +1 @@ +export { default } from "gatsby-cli/lib/reporter" diff --git a/packages/gatsby/reporter.js b/packages/gatsby/reporter.js new file mode 100644 index 0000000000000..f0335bb5c8b90 --- /dev/null +++ b/packages/gatsby/reporter.js @@ -0,0 +1,3 @@ +"use strict" + +module.exports = require('gatsby-cli/lib/reporter/index.js').default; From 69f1916af5e18a4111efb2825a8771dcb5fce095 Mon Sep 17 00:00:00 2001 From: Ward Peeters Date: Mon, 22 Feb 2021 14:48:51 +0100 Subject: [PATCH 2/2] update types --- .../src/collection-extract-query-string.ts | 4 +--- .../gatsby-plugin-page-creator/src/create-page-wrapper.ts | 4 +--- .../src/create-pages-from-collection-builder.ts | 4 +--- packages/gatsby-plugin-page-creator/src/derive-path.ts | 4 +--- packages/gatsby-plugin-page-creator/src/error-utils.ts | 4 +--- .../src/is-valid-collection-path-implementation.ts | 4 +--- packages/gatsby-plugin-sharp/src/image-data.ts | 4 +--- packages/gatsby-source-wordpress/src/models/logger.ts | 4 +--- packages/gatsby-source-wordpress/src/steps/preview/index.ts | 4 +--- .../src/steps/temp-prevent-multiple-instances.ts | 4 +--- packages/gatsby/reporter.d.ts | 5 ++++- 11 files changed, 14 insertions(+), 31 deletions(-) diff --git a/packages/gatsby-plugin-page-creator/src/collection-extract-query-string.ts b/packages/gatsby-plugin-page-creator/src/collection-extract-query-string.ts index ac46049deda47..093dec6e9f5f3 100644 --- a/packages/gatsby-plugin-page-creator/src/collection-extract-query-string.ts +++ b/packages/gatsby-plugin-page-creator/src/collection-extract-query-string.ts @@ -1,11 +1,9 @@ import { generateQueryFromString } from "./extract-query" import fs from "fs-extra" -import reporter from "gatsby/reporter" +import { Reporter } from "gatsby/reporter" import { extractModel } from "./path-utils" import { CODES, prefixId } from "./error-utils" -type Reporter = typeof reporter - // This Function opens up the actual collection file and extracts the queryString used in the export function collectionExtractQueryString( absolutePath: string, diff --git a/packages/gatsby-plugin-page-creator/src/create-page-wrapper.ts b/packages/gatsby-plugin-page-creator/src/create-page-wrapper.ts index a78a5792e9cd7..d5ec631fdb644 100644 --- a/packages/gatsby-plugin-page-creator/src/create-page-wrapper.ts +++ b/packages/gatsby-plugin-page-creator/src/create-page-wrapper.ts @@ -10,9 +10,7 @@ import { createClientOnlyPage } from "./create-client-only-page" import { createPagesFromCollectionBuilder } from "./create-pages-from-collection-builder" import systemPath from "path" import { trackFeatureIsUsed } from "gatsby-telemetry" -import reporter from "gatsby/reporter" - -type Reporter = typeof reporter +import { Reporter } from "gatsby/reporter" function pathIsCollectionBuilder(path: string): boolean { return path.includes(`{`) diff --git a/packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts b/packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts index 0986f880f2912..4700a1a95a863 100644 --- a/packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts +++ b/packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts @@ -1,7 +1,7 @@ // Move this to gatsby-core-utils? import { Actions, CreatePagesArgs } from "gatsby" import { createPath } from "gatsby-page-utils" -import reporter from "gatsby/reporter" +import { Reporter } from "gatsby/reporter" import { Options as ISlugifyOptions } from "@sindresorhus/slugify" import { reverseLookupParams } from "./extract-query" import { getMatchPath } from "./get-match-path" @@ -12,8 +12,6 @@ import { collectionExtractQueryString } from "./collection-extract-query-string" import { isValidCollectionPathImplementation } from "./is-valid-collection-path-implementation" import { CODES, prefixId } from "./error-utils" -type Reporter = typeof reporter - export async function createPagesFromCollectionBuilder( filePath: string, absolutePath: string, diff --git a/packages/gatsby-plugin-page-creator/src/derive-path.ts b/packages/gatsby-plugin-page-creator/src/derive-path.ts index d352901f709da..5487b1e5f04e9 100644 --- a/packages/gatsby-plugin-page-creator/src/derive-path.ts +++ b/packages/gatsby-plugin-page-creator/src/derive-path.ts @@ -1,6 +1,6 @@ import _ from "lodash" import slugify, { Options as ISlugifyOptions } from "@sindresorhus/slugify" -import reporter from "gatsby/reporter" +import { Reporter } from "gatsby/reporter" import { extractFieldWithoutUnion, extractAllCollectionSegments, @@ -8,8 +8,6 @@ import { stripTrailingSlash, } from "./path-utils" -type Reporter = typeof reporter - const doubleForwardSlashes = /\/\/+/g // Generates the path for the page from the file path diff --git a/packages/gatsby-plugin-page-creator/src/error-utils.ts b/packages/gatsby-plugin-page-creator/src/error-utils.ts index f9f125a43c415..c6f48e2951f97 100644 --- a/packages/gatsby-plugin-page-creator/src/error-utils.ts +++ b/packages/gatsby-plugin-page-creator/src/error-utils.ts @@ -1,6 +1,4 @@ -import reporter from "gatsby/reporter" - -type Reporter = typeof reporter +import { Reporter } from "gatsby/reporter" export const CODES = { Generic: `12101`, diff --git a/packages/gatsby-plugin-page-creator/src/is-valid-collection-path-implementation.ts b/packages/gatsby-plugin-page-creator/src/is-valid-collection-path-implementation.ts index 7097cb4868f2e..bfc3192757512 100644 --- a/packages/gatsby-plugin-page-creator/src/is-valid-collection-path-implementation.ts +++ b/packages/gatsby-plugin-page-creator/src/is-valid-collection-path-implementation.ts @@ -1,10 +1,8 @@ import sysPath from "path" -import reporter from "gatsby/reporter" +import { Reporter } from "gatsby/reporter" import { CODES, prefixId } from "./error-utils" import { matchAllPolyfill } from "./path-utils" -type Reporter = typeof reporter - // This file is a helper for consumers. It's going to log an error to them if they // in any way have an incorrect filepath setup for us to predictably use collection // querying. diff --git a/packages/gatsby-plugin-sharp/src/image-data.ts b/packages/gatsby-plugin-sharp/src/image-data.ts index e4472b586883e..1187dbd93e226 100644 --- a/packages/gatsby-plugin-sharp/src/image-data.ts +++ b/packages/gatsby-plugin-sharp/src/image-data.ts @@ -1,15 +1,13 @@ /* eslint-disable no-unused-expressions */ import { IGatsbyImageData, ISharpGatsbyImageArgs } from "gatsby-plugin-image" import { GatsbyCache, Node } from "gatsby" -import reporter from "gatsby/reporter" +import { Reporter } from "gatsby/reporter" import { rgbToHex, calculateImageSizes, getSrcSet, getSizes } from "./utils" import { traceSVG, getImageSizeAsync, base64, batchQueueImageResizing } from "." import sharp from "./safe-sharp" import { createTransformObject, mergeDefaults } from "./plugin-options" import { reportError } from "./report-error" -type Reporter = typeof reporter - const DEFAULT_BLURRED_IMAGE_WIDTH = 20 const DEFAULT_BREAKPOINTS = [750, 1080, 1366, 1920] diff --git a/packages/gatsby-source-wordpress/src/models/logger.ts b/packages/gatsby-source-wordpress/src/models/logger.ts index 741ef89bb642b..6a2e9d252b988 100644 --- a/packages/gatsby-source-wordpress/src/models/logger.ts +++ b/packages/gatsby-source-wordpress/src/models/logger.ts @@ -1,9 +1,7 @@ -import reporter from "gatsby/reporter" +import { Reporter } from "gatsby/reporter" import { formatLogMessage } from "~/utils/format-log-message" import { IPluginOptions } from "./gatsby-api" -type Reporter = typeof reporter - type ITimerReporter = ReturnType export interface ILoggerState { diff --git a/packages/gatsby-source-wordpress/src/steps/preview/index.ts b/packages/gatsby-source-wordpress/src/steps/preview/index.ts index 51a50a07c8677..ab3496ebbd0a2 100644 --- a/packages/gatsby-source-wordpress/src/steps/preview/index.ts +++ b/packages/gatsby-source-wordpress/src/steps/preview/index.ts @@ -17,9 +17,7 @@ import { formatLogMessage } from "~/utils/format-log-message" import { touchValidNodes } from "../source-nodes/update-nodes/fetch-node-updates" import { IPluginOptions } from "~/models/gatsby-api" -import reporter from "gatsby/reporter" - -type Reporter = typeof reporter +import { Reporter } from "gatsby/reporter" export const inPreviewMode = (): boolean => !!process.env.ENABLE_GATSBY_REFRESH_ENDPOINT && diff --git a/packages/gatsby-source-wordpress/src/steps/temp-prevent-multiple-instances.ts b/packages/gatsby-source-wordpress/src/steps/temp-prevent-multiple-instances.ts index 44e80740236dc..2932eea2fcf2b 100644 --- a/packages/gatsby-source-wordpress/src/steps/temp-prevent-multiple-instances.ts +++ b/packages/gatsby-source-wordpress/src/steps/temp-prevent-multiple-instances.ts @@ -1,8 +1,6 @@ -import reporter from "gatsby/reporter" +import { Reporter } from "gatsby/reporter" import { formatLogMessage } from "../utils/format-log-message" -type Reporter = typeof reporter - let isWpSourcePluginInstalled = false /** diff --git a/packages/gatsby/reporter.d.ts b/packages/gatsby/reporter.d.ts index 501da2ea5bd78..fb7e8e5463bcd 100644 --- a/packages/gatsby/reporter.d.ts +++ b/packages/gatsby/reporter.d.ts @@ -1 +1,4 @@ -export { default } from "gatsby-cli/lib/reporter" +import reporter from "gatsby-cli/lib/reporter" + +export default reporter +export type Reporter = typeof reporter