Skip to content

Latest commit

 

History

History
106 lines (75 loc) · 4.61 KB

File metadata and controls

106 lines (75 loc) · 4.61 KB
date version title
2022-03-01
4.9.0
v4.9 Release Notes

Welcome to gatsby@4.9.0 release (March 2022 #1)

Key highlights of this release:

Also check out notable bugfixes.

Bleeding Edge: Want to try new features as soon as possible? Install gatsby@next and let us know if you have any issues.

Previous release notes

Full changelog


Support for TypeScript in gatsby-config and gatsby-node

In the last release we added support for TypeScript in gatsby-browser and gatsby-ssr and as a follow-up we're introducing a much requested feature: Support for TypeScript in gatsby-config and gatsby-node 🎉

When you try it out in your project, please give us feedback in the accompanying RFC on what you like, what doesn't work, and what you like to see in the future. Note: There are currently some limitations that you'll need to be aware of. In the RFC you can also read why we chose Parcel for this feature and how we did it.

You can learn everything about this new feature on the TypeScript and Gatsby documentation page but here are two small examples of gatsby-config and gatsby-node with TypeScript:

import type { GatsbyConfig } from "gatsby"

const config: GatsbyConfig = {
  siteMetadata: {
    title: "Your Title",
  },
  plugins: [],
}

export default config
import type { GatsbyNode } from "gatsby"

type Person = {
  id: number
  name: string
  age: number
}

export const sourceNodes: GatsbyNode["sourceNodes"] = async ({
  actions,
  createNodeId,
  createContentDigest,
}) => {
  const { createNode } = actions

  const data = await getSomeData()

  data.forEach((person: Person) => {
    const node = {
      ...person,
      parent: null,
      children: [],
      id: createNodeId(`person__${person.id}`),
      internal: {
        type: "Person",
        content: JSON.stringify(person),
        contentDigest: createContentDigest(person),
      },
    }

    createNode(node)
  })
}

You can also check out the using-typescript and using-vanilla-extract examples!

Migrating away from old workarounds

This list is probably incomplete. If you've used another workaround in the past, add it to this document by using the "Edit on GitHub" button at the bottom.

  • ts-node: By having both a gatsby-config.js and gatsby-config.ts (where gatsby-config.js registers ts-node) you were able to use TypeScript. You'll need to remove the gatsby-config.js file, ts-node dependency, and address any of the current limitations. When both a gatsby-config.js and gatsby-config.ts exist the .ts file will now always take precedence.

Notable bugfixes & improvements

  • gatsby
    • Cache date formatting in LMDB cache for speed improvements, via PR #34834
    • Batch page dependency actions for speed improvements, via PR #34856

Contributors

A big Thank You to our community who contributed to this release 💜