diff --git a/docs/docs/browser-apis.md b/docs/docs/browser-apis.md index dec29a2cc5273..50ce6683ff094 100644 --- a/docs/docs/browser-apis.md +++ b/docs/docs/browser-apis.md @@ -1,7 +1,7 @@ --- title: Gatsby Browser APIs description: Documentation about leveraging standard browser APIs within Gatsby -jsdoc: ["gatsby/src/utils/api-browser-docs.ts"] +jsdoc: ["gatsby/src/utils/api-browser-docs.js"] apiCalls: BrowserAPI showTopLevelSignatures: true --- diff --git a/docs/docs/node-apis.md b/docs/docs/node-apis.md index b9ca8266f41aa..e416df6bb403e 100644 --- a/docs/docs/node-apis.md +++ b/docs/docs/node-apis.md @@ -1,7 +1,7 @@ --- title: Gatsby Node APIs description: Documentation on Node APIs used in Gatsby build process for common uses like creating pages -jsdoc: ["gatsby/src/utils/api-node-docs.ts"] +jsdoc: ["gatsby/src/utils/api-node-docs.js"] apiCalls: NodeAPI --- diff --git a/packages/gatsby/scripts/output-api-file.js b/packages/gatsby/scripts/output-api-file.js index 95c7ce26dde09..3395c4db09c17 100644 --- a/packages/gatsby/scripts/output-api-file.js +++ b/packages/gatsby/scripts/output-api-file.js @@ -7,8 +7,8 @@ const OUTPUT_FILE_NAME = `apis.json` async function outputFile() { const apis = await Promise.all([ path.join('cache-dir', 'api-ssr-docs.js'), - path.join('src', 'utils', 'api-browser-docs.ts'), - path.join('src', 'utils', 'api-node-docs.ts') + path.join('src', 'utils', 'api-browser-docs.js'), + path.join('src', 'utils', 'api-node-docs.js') ] .map(filePath => { const resolved = path.resolve(filePath) diff --git a/packages/gatsby/src/bootstrap/load-plugins/index.js b/packages/gatsby/src/bootstrap/load-plugins/index.js index a1f3daad5e845..a5afe4ddb708f 100644 --- a/packages/gatsby/src/bootstrap/load-plugins/index.js +++ b/packages/gatsby/src/bootstrap/load-plugins/index.js @@ -1,8 +1,8 @@ const _ = require(`lodash`) const { store } = require(`../../redux`) -import * as nodeAPIs from "../../utils/api-node-docs" -import * as browserAPIs from "../../utils/api-browser-docs" +const nodeAPIs = require(`../../utils/api-node-docs`) +const browserAPIs = require(`../../utils/api-browser-docs`) const ssrAPIs = require(`../../../cache-dir/api-ssr-docs`) const { loadPlugins } = require(`./load`) const { diff --git a/packages/gatsby/src/utils/api-browser-docs.ts b/packages/gatsby/src/utils/api-browser-docs.js similarity index 91% rename from packages/gatsby/src/utils/api-browser-docs.ts rename to packages/gatsby/src/utils/api-browser-docs.js index d62059c43ea47..d9196a80578ef 100644 --- a/packages/gatsby/src/utils/api-browser-docs.ts +++ b/packages/gatsby/src/utils/api-browser-docs.js @@ -18,7 +18,7 @@ * callAnalyticsAPI() * } */ -export const onClientEntry = true +exports.onClientEntry = true /** * Called when the initial (but not subsequent) render of Gatsby App is done on the client. @@ -29,7 +29,7 @@ export const onClientEntry = true * console.log("ReactDOM.render has executed") * } */ -export const onInitialClientRender = true +exports.onInitialClientRender = true /** * Called when changing location is started. @@ -43,7 +43,7 @@ export const onInitialClientRender = true * console.log("Gatsby started to change location from", prevLocation ? prevLocation.pathname : null) * } */ -export const onPreRouteUpdate = true +exports.onPreRouteUpdate = true /** * Called when changing location is longer than 1 second. @@ -56,7 +56,7 @@ export const onPreRouteUpdate = true * console.log("We can show loading indicator now") * } */ -export const onRouteUpdateDelayed = true +exports.onRouteUpdateDelayed = true /** * Called when the user changes routes, including on the initial load of the app @@ -70,7 +70,7 @@ export const onRouteUpdateDelayed = true * console.log('old pathname', prevLocation ? prevLocation.pathname : null) * } */ -export const onRouteUpdate = true +exports.onRouteUpdate = true /** * Allows a plugin to influence scrolling behavior on navigation. @@ -102,7 +102,7 @@ export const onRouteUpdate = true * return false * } */ -export const shouldUpdateScroll = true +exports.shouldUpdateScroll = true /** * Allow a plugin to register a Service Worker. Should be a function that returns true. @@ -112,7 +112,7 @@ export const shouldUpdateScroll = true * @example * exports.registerServiceWorker = () => true */ -export const registerServiceWorker = true +exports.registerServiceWorker = true /** * Allow a plugin to replace the page component renderer. @@ -123,7 +123,7 @@ export const registerServiceWorker = true * @param {pluginOptions} pluginOptions * @returns {ReactNode} Replaced default page renderer */ -export const replaceComponentRenderer = true +exports.replaceComponentRenderer = true /** * Allow a plugin to wrap the page element. @@ -150,7 +150,7 @@ export const replaceComponentRenderer = true * return {element} * } */ -export const wrapPageElement = true +exports.wrapPageElement = true /** * Allow a plugin to wrap the root element. @@ -181,7 +181,7 @@ export const wrapPageElement = true * ) * } */ -export const wrapRootElement = true +exports.wrapRootElement = true /** * Called when prefetching for a pathname is triggered. Allows @@ -191,7 +191,7 @@ export const wrapRootElement = true * @param {function} $0.loadPage Function for fetching resources related to pathname * @param {pluginOptions} pluginOptions */ -export const onPrefetchPathname = true +exports.onPrefetchPathname = true /** * Called when prefetching for a pathname is successful. Allows @@ -200,7 +200,7 @@ export const onPrefetchPathname = true * @param {string} $0.pathname The pathname whose resources have now been prefetched * @param {pluginOptions} pluginOptions */ -export const onPostPrefetchPathname = true +exports.onPostPrefetchPathname = true /** * Plugins can take over prefetching logic. If they do, they should call this @@ -211,7 +211,7 @@ export const onPostPrefetchPathname = true * @example * exports.disableCorePrefetching = () => true */ -export const disableCorePrefetching = true +exports.disableCorePrefetching = true /** * Allow a plugin to replace the `ReactDOM.render`/`ReactDOM.hydrate` function call by a custom renderer. @@ -228,7 +228,7 @@ export const disableCorePrefetching = true * }; * }; */ -export const replaceHydrateFunction = true +exports.replaceHydrateFunction = true /** * Inform plugins when a service worker has been installed. @@ -236,7 +236,7 @@ export const replaceHydrateFunction = true * @param {object} $0.serviceWorker The service worker instance. * @param {pluginOptions} pluginOptions */ -export const onServiceWorkerInstalled = true +exports.onServiceWorkerInstalled = true /** * Inform plugins of when a service worker has an update available. @@ -244,7 +244,7 @@ export const onServiceWorkerInstalled = true * @param {object} $0.serviceWorker The service worker instance. * @param {pluginOptions} pluginOptions */ -export const onServiceWorkerUpdateFound = true +exports.onServiceWorkerUpdateFound = true /** * Inform plugins when a service worker has been updated in the background @@ -253,7 +253,7 @@ export const onServiceWorkerUpdateFound = true * @param {object} $0.serviceWorker The service worker instance. * @param {pluginOptions} pluginOptions */ -export const onServiceWorkerUpdateReady = true +exports.onServiceWorkerUpdateReady = true /** * Inform plugins when a service worker has become active. @@ -261,7 +261,7 @@ export const onServiceWorkerUpdateReady = true * @param {object} $0.serviceWorker The service worker instance. * @param {pluginOptions} pluginOptions */ -export const onServiceWorkerActive = true +exports.onServiceWorkerActive = true /** * Inform plugins when a service worker is redundant. @@ -269,4 +269,4 @@ export const onServiceWorkerActive = true * @param {object} $0.serviceWorker The service worker instance. * @param {pluginOptions} pluginOptions */ -export const onServiceWorkerRedundant = true +exports.onServiceWorkerRedundant = true diff --git a/packages/gatsby/src/utils/api-node-docs.ts b/packages/gatsby/src/utils/api-node-docs.js similarity index 95% rename from packages/gatsby/src/utils/api-node-docs.ts rename to packages/gatsby/src/utils/api-node-docs.js index d2b138f977d40..9b342df105d76 100644 --- a/packages/gatsby/src/utils/api-node-docs.ts +++ b/packages/gatsby/src/utils/api-node-docs.js @@ -3,7 +3,7 @@ * of "resolvable" file extensions. Gatsby supports `.js` and `.jsx` by default. * @returns {Array} array of extensions */ -export const resolvableExtensions = true +exports.resolvableExtensions = true /** * Tell plugins to add pages. This extension point is called only after the initial @@ -60,7 +60,7 @@ export const resolvableExtensions = true * } */ -export const createPages = true +exports.createPages = true /** * Like `createPages` but for plugins who want to manage creating and removing @@ -76,7 +76,7 @@ export const createPages = true * Gatsby, it needs to keep its own state about its world to know when to * add and remove pages. */ -export const createPagesStatefully = true +exports.createPagesStatefully = true /** * Extension point to tell plugins to source nodes. This API is called during @@ -116,7 +116,7 @@ export const createPagesStatefully = true * createNode(node) * } */ -export const sourceNodes = true +exports.sourceNodes = true /** * Called when a new node is created. Plugins wishing to extend or @@ -131,7 +131,7 @@ export const sourceNodes = true * // create a new node field. * } */ -export const onCreateNode = true +exports.onCreateNode = true /** * Called when a new page is created. This extension API is useful @@ -144,7 +144,7 @@ export const onCreateNode = true * See the guide [Creating and Modifying Pages](/docs/creating-and-modifying-pages/) * for more on this API. */ -export const onCreatePage = true +exports.onCreatePage = true /** * Called during the creation of the GraphQL schema. Allows plugins @@ -196,7 +196,7 @@ export const onCreatePage = true * return {} * } */ -export const setFieldsOnGraphQLNodeType = true +exports.setFieldsOnGraphQLNodeType = true /** * Customize Gatsby's GraphQL schema by creating type definitions, field @@ -245,7 +245,7 @@ export const setFieldsOnGraphQLNodeType = true * createTypes(typeDefs) * } */ -export const createSchemaCustomization = true +exports.createSchemaCustomization = true /** * Add custom field resolvers to the GraphQL schema. @@ -316,27 +316,27 @@ export const createSchemaCustomization = true * createResolvers(resolvers) * } */ -export const createResolvers = true +exports.createResolvers = true /** * Ask compile-to-js plugins to process source to JavaScript so the query * runner can extract out GraphQL queries for running. */ -export const preprocessSource = true +exports.preprocessSource = true /** * Tell plugins with expensive "side effects" from queries to start running * those now. This is a soon-to-be-replaced API only currently in use by * `gatsby-plugin-sharp`. */ -export const generateSideEffects = true +exports.generateSideEffects = true /** * Let plugins extend/mutate the site's Babel configuration. * This API will change before 2.0 as it needs still to be converted to use * Redux actions. */ -export const onCreateBabelConfig = true +exports.onCreateBabelConfig = true /** * Let plugins extend/mutate the site's webpack configuration. @@ -367,33 +367,33 @@ export const onCreateBabelConfig = true * }); * } */ -export const onCreateWebpackConfig = true +exports.onCreateWebpackConfig = true /** * The first API called during Gatsby execution, runs as soon as plugins are loaded, before cache initialization and bootstrap preparation. */ -export const onPreInit = true +exports.onPreInit = true /** * Called once Gatsby has initialized itself and is ready to bootstrap your site. */ -export const onPreBootstrap = true +exports.onPreBootstrap = true /** * Called at the end of the bootstrap process after all other extension APIs have been called. */ -export const onPostBootstrap = true +exports.onPostBootstrap = true /** * The first extension point called during the build process. Called after the bootstrap has completed but before the build steps start. */ -export const onPreBuild = true +exports.onPreBuild = true /** * The last extension point called after all other parts of the build process * are complete. */ -export const onPostBuild = true +exports.onPostBuild = true /** * Run before GraphQL queries/fragments are extracted from JavaScript files. Useful for plugins @@ -401,7 +401,7 @@ export const onPostBuild = true * * See gatsby-transformer-sharp and gatsby-source-contentful for examples. */ -export const onPreExtractQueries = true +exports.onPreExtractQueries = true /** * Run when gatsby develop server is started, its useful to add proxy and middleware @@ -415,4 +415,4 @@ export const onPreExtractQueries = true * }) * } */ -export const onCreateDevServer = true +exports.onCreateDevServer = true