Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gatsby 5 upgrade release #946

Merged
merged 36 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
60db122
feat: Upgrade node and packages
LizBaker Jul 31, 2023
27ffb09
chore: Run query codemod
LizBaker Jul 31, 2023
5a1cd1f
switch to gatsby-plugin-portal
sunnyzanchi Jul 31, 2023
f445e49
fix: make Tabs.Pages index prop not required
tabathadelane Jul 31, 2023
d60aa36
fix: make Button `variant` not required
sunnyzanchi Jul 31, 2023
d11a777
fix: use 'value' prop instead of 'selected' on option element
tabathadelane Jul 31, 2023
8684650
upgrade `gatsby-plugin-emotion`
sunnyzanchi Aug 1, 2023
1fee639
add `clean` script to top-level
sunnyzanchi Aug 1, 2023
e64e4d5
upgrade `gatsby-plugin-layout`
sunnyzanchi Aug 1, 2023
14580a3
upgrade `gatsby-plugin-react-helmet`
sunnyzanchi Aug 1, 2023
e12482a
upgrade `gatsby-plugin-robots-txt`
sunnyzanchi Aug 1, 2023
2fcc0cf
upgrade `gatsby-plugin-sitemap`
sunnyzanchi Aug 1, 2023
586d8f7
upgrade `gatsby-plugin-use-dark-mode`
sunnyzanchi Aug 1, 2023
c1b6383
feat!: Upgrade to Gatsby v5
tabathadelane Aug 1, 2023
a18084d
fix: bump github workflows to node 18
tabathadelane Aug 1, 2023
175f473
upgrade `gatsby-plugin-mdx` and fix most query errors
sunnyzanchi Aug 1, 2023
9bac64c
fix `slug` query
sunnyzanchi Aug 2, 2023
42ec26f
fix: Create mdxAST field
clarkmcadoo Aug 2, 2023
80cc35a
fix: Update slugify function
clarkmcadoo Aug 3, 2023
2addd31
chore: Update createPages and template per docs
LizBaker Aug 4, 2023
5789bf5
add `fallback: false` for crypto and url modules
sunnyzanchi Aug 21, 2023
0bc2c8d
make `externals` an array to not overwrite Gatsby's
sunnyzanchi Aug 24, 2023
86911a2
remove conflicting `gatsby-plugin-mdx` deps
sunnyzanchi Aug 24, 2023
be632c0
add `eslint-plugin-graphql`
sunnyzanchi Aug 24, 2023
8ff206d
fix lint errors
sunnyzanchi Aug 24, 2023
d956fc2
upgrade testing libraries and config for Gatsby 5
sunnyzanchi Aug 24, 2023
049374d
ugrade `@emotion/{react,styled}` and `jest-emotion`
sunnyzanchi Aug 24, 2023
1426d64
replace `jest-emotion` with `@emotion/jest`
sunnyzanchi Aug 25, 2023
444400c
update snapshots
sunnyzanchi Aug 25, 2023
0150a4a
simplify conditional
sunnyzanchi Aug 29, 2023
27d9f77
simplify 404 conditionals
sunnyzanchi Aug 29, 2023
0cbdb30
style fix: switch from `css` to `styled`
sunnyzanchi Aug 30, 2023
e202af2
update inline code and codeblocks for MDX v2
sunnyzanchi Aug 30, 2023
5bb8442
use custom class name for header anchors
sunnyzanchi Aug 30, 2023
8653f03
upgrade `gatsby-remark-images`, fix missing margin
sunnyzanchi Aug 30, 2023
b3a4aae
Merge pull request #941 from newrelic/campfire/gatsby-v5
sunnyzanchi Sep 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr_merged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 17
node-version: 18
cache: 'yarn'

- name: Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: Cache dependencies
id: yarn-cache
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: Cache dependencies
id: yarn-cache
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
18
6 changes: 3 additions & 3 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ code, the source code can be found at [https://github.com/newrelic/gatsby-theme-
* [eslint-plugin-jsx-a11y](#eslint-plugin-jsx-a11y)
* [eslint-plugin-react-hooks](#eslint-plugin-react-hooks)
* [eslint](#eslint)
* [jest-emotion](#jest-emotion)
* [@emotion/jest](#emotion-jest)
* [jest-localstorage-mock](#jest-localstorage-mock)
* [jest](#jest)
* [lerna](#lerna)
Expand Down Expand Up @@ -459,9 +459,9 @@ THE SOFTWARE.

```

### jest-emotion
### @emotion/jest

This product includes source derived from [jest-emotion](https://github.com/emotion-js/emotion/tree/master/packages/jest-emotion) ([v10.0.32](https://github.com/emotion-js/emotion/tree/master/packages/jest-emotion/tree/v10.0.32)), distributed under the [MIT License](https://github.com/emotion-js/emotion/tree/master/packages/jest-emotion/blob/v10.0.32/LICENSE):
This product includes source derived from [@emotion/jest](https://github.com/emotion-js/emotion/tree/main/packages/jest) ([v10.0.32](https://github.com/emotion-js/emotion/tree/%40emotion/jest%4011.11.0/packages/jest)), distributed under the [MIT License](https://github.com/emotion-js/emotion/blob/%40emotion/jest%4011.11.0/packages/jest/LICENSE):

```
MIT License
Expand Down
2 changes: 2 additions & 0 deletions demo/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,13 @@ module.exports = {
options: {
maxWidth: 1200,
linkImagesToOriginal: false,
wrapperStyle: 'margin-bottom: var(--paragraph-spacing);',
},
},
{
resolve: 'gatsby-remark-autolink-headers',
options: {
className: 'header-anchor',
icon: '<svg xmlns="http://www.w3.org/2000/svg" focusable="false" width="1rem" height="1rem" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path><line x1="8" y1="12" x2="16" y2="12"></line></svg>',
},
},
Expand Down
19 changes: 14 additions & 5 deletions demo/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
isDefault
}
}
allMdx(filter: { fileAbsolutePath: { regex: "/src/content/" } }) {
allMdx(
filter: { internal: { contentFilePath: { regex: "/src/content/" } } }
) {
nodes {
slug
fields {
fileRelativePath
slug
}
internal {
contentFilePath
}
}
}
Expand All @@ -33,15 +38,17 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
({ isDefault }) => !isDefault
);

const basicTemplate = path.resolve('src/templates/basic.js');

allMdx.nodes.forEach((node) => {
const {
slug,
fields: { fileRelativePath },
fields: { fileRelativePath, slug },
internal: { contentFilePath },
} = node;

createPage({
path: slug,
component: path.resolve('src/templates/basic.js'),
component: `${basicTemplate}?__contentFilePath=${contentFilePath}`,
context: {
slug,
fileRelativePath,
Expand All @@ -65,8 +72,10 @@ exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
resolve: {
fallback: {
crypto: false,
http: false,
https: false,
url: false,
zlib: false,
},
},
Expand Down
18 changes: 9 additions & 9 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"@mdx-js/mdx": "^1.6.16",
"@mdx-js/react": "^1.6.16",
"@newrelic/gatsby-theme-newrelic": "^3.2.0",
"gatsby": "^4.25.2",
"gatsby-plugin-mdx": "^2.10.1",
"gatsby-plugin-sharp": "4.25.0",
"gatsby": "^5.0.0",
"gatsby-plugin-mdx": "^5.11.0",
"gatsby-plugin-sharp": "^5.0.0",
"gatsby-remark-autolink-headers": "^4.7.0",
"gatsby-remark-images": "^5.7.0",
"gatsby-source-filesystem": "^4.25.0",
"gatsby-transformer-sharp": "4.25.0",
"gatsby-remark-images": "^7.12.0",
"gatsby-source-filesystem": "^5.0.0",
"gatsby-transformer-sharp": "^5.0.0",
"github-slugger": "^1.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react": "^18.0.0",
"react-dom": "^18.0.0"
}
}
}
62 changes: 30 additions & 32 deletions demo/src/templates/basic.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { graphql } from 'gatsby';
import {
ContributingGuidelines,
Expand All @@ -15,10 +15,10 @@ import {
import GitHubSlugger from 'github-slugger';
import toString from 'mdast-util-to-string';

const BasicTemplate = ({ data, location }) => {
const BasicTemplate = ({ data, location, children }) => {
const slugger = useMemo(() => new GitHubSlugger(), []);
const {
mdx: { body, frontmatter, fields, relatedResources, mdxAST },
mdx: { frontmatter, fields, relatedResources, mdxAST },
} = data;

const headings = useMemo(() => {
Expand All @@ -39,34 +39,11 @@ const BasicTemplate = ({ data, location }) => {
return (
<>
<SEO location={location} title={frontmatter.title} />
<Layout.Main
css={css`
display: grid;
grid-template-areas:
'page-title page-tools'
'content page-tools';
grid-template-columns: minmax(0, 1fr) 320px;
grid-column-gap: var(--site-content-padding);

@media screen and (max-width: 760px) {
grid-template-areas:
'page-title'
'content'
'page-tools';
grid-template-columns: minmax(0, 1fr);
}
`}
>
<h1
css={css`
grid-area: page-title;
`}
>
{frontmatter.title}
</h1>
<Main>
<Title>{frontmatter.title}</Title>
<Layout.Content>
<MarkdownContainer>
<MDX body={body} />
<MDX>{children}</MDX>
</MarkdownContainer>
</Layout.Content>

Expand All @@ -79,20 +56,41 @@ const BasicTemplate = ({ data, location }) => {
<TableOfContents headings={headings} />
<RelatedResources resources={relatedResources} />
</Layout.PageTools>
</Layout.Main>
</Main>
</>
);
};

BasicTemplate.propTypes = {
children: PropTypes.node.isRequired,
data: PropTypes.object.isRequired,
location: PropTypes.object.isRequired,
};

const Main = styled(Layout.Main)`
display: grid;
grid-template-areas:
'page-title page-tools'
'content page-tools';
grid-template-columns: minmax(0, 1fr) 320px;
grid-column-gap: var(--site-content-padding);

@media screen and (max-width: 760px) {
grid-template-areas:
'page-title'
'content'
'page-tools';
grid-template-columns: minmax(0, 1fr);
}
`;

const Title = styled.h1`
grid-area: page-title;
`;

export const pageQuery = graphql`
query ($slug: String!) {
mdx(slug: { eq: $slug }) {
body
mdx(fields: { slug: { eq: $slug } }) {
mdxAST
frontmatter {
title
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
testEnvironment: 'jsdom',
transform: {
'^.+\\.js$': '<rootDir>/jest-preprocess.js',
},
Expand All @@ -13,6 +14,5 @@ module.exports = {
setupFilesAfterEnv: ['<rootDir>/setup-test-env.js'],
moduleNameMapper: {
'^@reach/router(.*)': '<rootDir>/node_modules/@gatsbyjs/reach-router$1',
'^gatsby-page-utils/(.*)$': `gatsby-page-utils/dist/$1`,
},
};
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"packages/*"
],
"scripts": {
"clean": "yarn workspace demo clean",
"start": "yarn workspace demo develop",
"release": "lerna publish --no-verify-access --conventional-commits --create-release github --no-private",
"test": "jest",
Expand All @@ -14,21 +15,24 @@
"extract-i18n": "yarn workspace @newrelic/gatsby-theme-newrelic extract-i18n"
},
"devDependencies": {
"@emotion/jest": "^11.11.0",
"@newrelic/eslint-plugin-newrelic": "^0.3.1",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.2.6",
"@testing-library/react-hooks": "^5.1.1",
"babel-jest": "^26.3.0",
"@testing-library/dom": "^9.3.1",
"@testing-library/jest-dom": "^6.1.2",
"@testing-library/react": "^14.0.0",
"@testing-library/react-hooks": "^8.0.1",
"babel-jest": "^29.6.4",
"babel-preset-gatsby": "^0.5.16",
"eslint": "^7.4.0",
"eslint-plugin-graphql": "^4.0.0",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-react-hooks": "^4.0.8",
"jest": "^26.4.0",
"jest-emotion": "^10.0.32",
"jest": "^29.6.4",
"jest-environment-jsdom": "^29.6.4",
"jest-fetch-mock": "^3.0.3",
"jest-localstorage-mock": "^2.4.3",
"lerna": "^5.6.2",
"prettier": "^2.0.5",
"react-test-renderer": "^16.13.1"
"react-test-renderer": "^18.2.0"
}
}
12 changes: 6 additions & 6 deletions packages/gatsby-theme-newrelic/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = ({ layout, newrelic, robots = {}, sitemap = true }) => {
plugins: [
'gatsby-plugin-emotion',
'gatsby-plugin-react-helmet',
'gatsby-plugin-portal',
sitemap && {
resolve: 'gatsby-plugin-sitemap',
options: {
Expand All @@ -18,13 +19,12 @@ module.exports = ({ layout, newrelic, robots = {}, sitemap = true }) => {
defaults: {},
},
},
layout &&
layout.component && {
resolve: `gatsby-plugin-layout`,
options: {
component: layout.component,
},
layout?.component && {
resolve: `gatsby-plugin-layout`,
options: {
component: layout.component,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
Expand Down
Loading
Loading