From 98a75758343d7b6ceb2988799dfc37456beb7c6a Mon Sep 17 00:00:00 2001 From: kawamataryou Date: Wed, 11 Mar 2020 08:05:56 +0900 Subject: [PATCH] chore(gatsby): Convert utils/worker/page-data to typescript --- packages/gatsby/src/utils/worker/child.js | 4 +++- .../src/utils/worker/{page-data.js => page-data.ts} | 11 +++++------ 2 files changed, 8 insertions(+), 7 deletions(-) rename packages/gatsby/src/utils/worker/{page-data.js => page-data.ts} (52%) diff --git a/packages/gatsby/src/utils/worker/child.js b/packages/gatsby/src/utils/worker/child.js index 4fee51c9bbe0f..d8f378a435058 100644 --- a/packages/gatsby/src/utils/worker/child.js +++ b/packages/gatsby/src/utils/worker/child.js @@ -1,5 +1,7 @@ // Note: this doesn't check for conflicts between module exports +import { getFilePath } from "./page-data" + module.exports = { - ...require(`./page-data`), + getFilePath, ...require(`./render-html`), } diff --git a/packages/gatsby/src/utils/worker/page-data.js b/packages/gatsby/src/utils/worker/page-data.ts similarity index 52% rename from packages/gatsby/src/utils/worker/page-data.js rename to packages/gatsby/src/utils/worker/page-data.ts index 83c4acf9b8b67..9aee01ea1e2c0 100644 --- a/packages/gatsby/src/utils/worker/page-data.js +++ b/packages/gatsby/src/utils/worker/page-data.ts @@ -1,10 +1,9 @@ -const path = require(`path`) +import path from "path" -const getFilePath = ({ publicDir }, pagePath) => { +export const getFilePath = ( + { publicDir }: { publicDir: string }, + pagePath: string +): string => { const fixedPagePath = pagePath === `/` ? `index` : pagePath return path.join(publicDir, `page-data`, fixedPagePath, `page-data.json`) } - -module.exports = { - getFilePath, -}