From 9a783f4334aac08e2bd8c1ecf3732c64a6ad7d88 Mon Sep 17 00:00:00 2001 From: Yuki Takemoto Date: Thu, 19 Mar 2020 13:11:04 +0900 Subject: [PATCH] chore(gatsby): Convert create-schema-customization to typescript (#22392) --- packages/gatsby/src/bootstrap/index.js | 3 ++- packages/gatsby/src/commands/develop.ts | 2 +- ...tomization.js => create-schema-customization.ts} | 13 ++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) rename packages/gatsby/src/utils/{create-schema-customization.js => create-schema-customization.ts} (50%) diff --git a/packages/gatsby/src/bootstrap/index.js b/packages/gatsby/src/bootstrap/index.js index a32983bce70ab..471cf5acc7569 100644 --- a/packages/gatsby/src/bootstrap/index.js +++ b/packages/gatsby/src/bootstrap/index.js @@ -12,6 +12,7 @@ const telemetry = require(`gatsby-telemetry`) const apiRunnerNode = require(`../utils/api-runner-node`) import { getBrowsersList } from "../utils/browserslist" +import { createSchemaCustomization } from "../utils/create-schema-customization" const { store, emitter } = require(`../redux`) const loadPlugins = require(`./load-plugins`) const loadThemes = require(`./load-themes`) @@ -434,7 +435,7 @@ module.exports = async (args: BootstrapArgs) => { parentSpan: bootstrapSpan, }) activity.start() - await require(`../utils/create-schema-customization`)({ + await createSchemaCustomization({ parentSpan: bootstrapSpan, }) activity.end() diff --git a/packages/gatsby/src/commands/develop.ts b/packages/gatsby/src/commands/develop.ts index 23253c8d09901..9e89fe1afcc12 100644 --- a/packages/gatsby/src/commands/develop.ts +++ b/packages/gatsby/src/commands/develop.ts @@ -36,7 +36,7 @@ import bootstrapPageHotReloader from "../bootstrap/page-hot-reloader" import { developStatic } from "./develop-static" import withResolverContext from "../schema/context" import sourceNodes from "../utils/source-nodes" -import createSchemaCustomization from "../utils/create-schema-customization" +import { createSchemaCustomization } from "../utils/create-schema-customization" import websocketManager from "../utils/websocket-manager" import getSslCert from "../utils/get-ssl-cert" import { slash } from "gatsby-core-utils" diff --git a/packages/gatsby/src/utils/create-schema-customization.js b/packages/gatsby/src/utils/create-schema-customization.ts similarity index 50% rename from packages/gatsby/src/utils/create-schema-customization.js rename to packages/gatsby/src/utils/create-schema-customization.ts index bdecb11ef7e30..cd4e28be78a93 100644 --- a/packages/gatsby/src/utils/create-schema-customization.js +++ b/packages/gatsby/src/utils/create-schema-customization.ts @@ -1,7 +1,14 @@ -const apiRunnerNode = require(`./api-runner-node`) -const { store } = require(`../redux`) +import apiRunnerNode from "./api-runner-node" +import { store } from "../redux" +import { Span } from "opentracing" -module.exports = async ({ refresh = false, parentSpan }) => { +export const createSchemaCustomization = async ({ + refresh = false, + parentSpan, +}: { + refresh?: boolean + parentSpan?: Span +}): Promise => { if (refresh) { store.dispatch({ type: `CLEAR_SCHEMA_CUSTOMIZATION` }) }