v4.8 Release Notes
Welcome to gatsby@4.8.0
release (February 2022 #2)
Key highlights of this release:
- Support for TypeScript in
gatsby-browser
andgatsby-ssr
- New TypeScript option when creating Gatsby projects from the CLI
- Significant memory usage reduction when filtering and sorting nodes
- New APIs in
gatsby-core-utils
andgatsby-plugin-utils
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.
Support for TypeScript in gatsby-browser
and gatsby-ssr
In addition to Gatsby’s current TypeScript support for your site’s .ts
/.tsx
files, you can now use TypeScript with your gatsby-browser
and gatsby-ssr
files.
The GatsbyBrowser
and GatsbySSR
types can now be used in gatsby-browser.tsx
and gatsby-ssr.tsx
respectively.
Work is in progress for TypeScript support for gatsby-config
and gatsby-node
files. Check out the RFC to learn how to test it out today.
New TypeScript option when creating Gatsby projects from the CLI
When initializing new Gatsby projects with gatsby new
, npm init gatsby
, or npx create-gatsby
, you can now select JavaScript or TypeScript as an option to start your project with.
After calling one of the above commands with no flags, the third question will now be: “Will you be using JavaScript or TypeScript?“. Selecting JavaScript will start your project with gatsby-starter-minimal
, and selecting TypeScript will start your project with gatsby-starter-minimal-ts
.
A new -ts
flag has been added for use with npm init gatsby
and npx create-gatsby
. Executing npm init gatsby -ts
or npx create-gatsby -ts
will skip the language question and start your project with gatsby-starter-minimal-ts
.
Lastly, arguments for Gatsby initializer commands are now not positional. Any order of your desired site name and flags will work as expected (e.g. npm init gatsby -ts hello-world -y
).
Significant memory usage reduction when filtering and sorting nodes
Gatsby no longer stores whole nodes in memory when executing filtering and sorting processes on your site. Now, Gatsby uses weak references and node partials, resulting in significant memory usage reduction for sites with many large nodes.
See PR #34747 for more information.
New APIs in gatsby-core-utils
and gatsby-plugin-utils
Two new APIs have been added:
Calling createMutex
gives you a mutex that you can use to safely perform processes concurrently in places where that matters, such as in workers.
For example in the code below, one worker can execute while all others wait for it to finish. This is handy in scenarios like writing to the same file to disk.
Calling hasFeature
allows you to check if the current version of Gatsby has a certain feature. This is particularly useful for plugin authors.
Note - The list of features available will be added in future PRs, the above is an example of how it will be used.
Notable bugfixes & improvements
gatsby-plugin-gatsby-cloud
: Improved UX for preview success and error notifications, via PR #34725gatsby
:- Removal of
v8-compile-cache
for better ESM support, via PR #34672 - Support use of
node.slug
to match node manifests to pages for Gatsby Preview, via PR #34790 - Fix Content Sync when using DSG, via PR #34799
- Allow referencing derived types in schema customization, via PR #34787
- Refactor load plugin modules, via PR #34813
- Upgrade from lmdb-store to lmdb, via PR #34576
- Removal of
gatsby-source-wordpress
: Fix Safari image loading bug, via PR #34727gatsby-core-utils
: Improvements tofetch-remote-file
, via PR #34758
Contributors
A big Thank You to our community who contributed to this release 💜
- kyleslie2: Typo fix PR #34749
- angeloashmore: chore(docs): Add Prismic to
using-gatsby-plugin-image
PR #34751 - paulduszak: chore(docs): Update “building a theme” tutorial PR #34732
- jhcao23: docs: update typo Forestry PR #34805
- VividhPandey003: documentation: Add Third Party Schema PR #34820
- axe312ger