diff --git a/packages/gatsby/src/utils/__tests__/get-cache.js b/packages/gatsby/src/utils/__tests__/get-cache.ts similarity index 92% rename from packages/gatsby/src/utils/__tests__/get-cache.js rename to packages/gatsby/src/utils/__tests__/get-cache.ts index f1e9ce832bdb2..34fc60c8047a3 100644 --- a/packages/gatsby/src/utils/__tests__/get-cache.js +++ b/packages/gatsby/src/utils/__tests__/get-cache.ts @@ -1,4 +1,4 @@ -const getCache = require(`../get-cache`) +import { getCache } from "../get-cache" const CACHE_KEY = `__test__` diff --git a/packages/gatsby/src/utils/api-runner-node.js b/packages/gatsby/src/utils/api-runner-node.js index 1c1ca44dfda1b..4238d3c8c9302 100644 --- a/packages/gatsby/src/utils/api-runner-node.js +++ b/packages/gatsby/src/utils/api-runner-node.js @@ -8,7 +8,7 @@ const reporter = require(`gatsby-cli/lib/reporter`) const stackTrace = require(`stack-trace`) const { codeFrameColumns } = require(`@babel/code-frame`) const fs = require(`fs-extra`) -const getCache = require(`./get-cache`) +const { getCache } = require(`./get-cache`) const createNodeId = require(`./create-node-id`) const { createContentDigest } = require(`gatsby-core-utils`) const { diff --git a/packages/gatsby/src/utils/get-cache.js b/packages/gatsby/src/utils/get-cache.ts similarity index 53% rename from packages/gatsby/src/utils/get-cache.js rename to packages/gatsby/src/utils/get-cache.ts index d27bcb721547c..b37fe9e33059f 100644 --- a/packages/gatsby/src/utils/get-cache.js +++ b/packages/gatsby/src/utils/get-cache.ts @@ -1,8 +1,8 @@ -const Cache = require(`./cache`).default +import Cache from "./cache" -const caches = new Map() +const caches = new Map() -module.exports = function getCache(name) { +export const getCache = (name: string): Cache => { let cache = caches.get(name) if (!cache) { cache = new Cache({ name }).init()