From f6075065c42c634a186477763cb11fcf15d8e71f Mon Sep 17 00:00:00 2001 From: Kohei Ueno Date: Tue, 10 Mar 2020 03:52:29 +0900 Subject: [PATCH] chore(gatsby): Migrate utils/get-cache.js to ts (#22094) * migrate get-cache.js to ts * fix using named export --- .../src/utils/__tests__/{get-cache.js => get-cache.ts} | 2 +- packages/gatsby/src/utils/api-runner-node.js | 2 +- packages/gatsby/src/utils/{get-cache.js => get-cache.ts} | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) rename packages/gatsby/src/utils/__tests__/{get-cache.js => get-cache.ts} (92%) rename packages/gatsby/src/utils/{get-cache.js => get-cache.ts} (53%) 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()