Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Add bundle analyzer and update React imports #160

Merged
merged 4 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"jsx-a11y/anchor-is-valid": "off",
"import/no-default-export": "off",
"react/forbid-dom-props": "warn",
"@typescript-eslint/require-await": "warn"
"@typescript-eslint/require-await": "warn",
"react/react-in-jsx-scope": "off"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that with React v17 we can disable this.

},
"parserOptions": {
"project": "tsconfig.json"
Expand Down
4 changes: 2 additions & 2 deletions components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import LinkedinIcon from 'mdi-react/LinkedinIcon'
import TwitterIcon from 'mdi-react/TwitterIcon'
import YouTubeIcon from 'mdi-react/YoutubeIcon'
import Link from 'next/link'
import React from 'react'
import { FunctionComponent } from 'react'

import {
StyledFooterWrapper,
Expand All @@ -28,7 +28,7 @@ interface Props {
minimal?: boolean
}

const Footer: React.FunctionComponent<Props> = ({ minimal }) => (
const Footer: FunctionComponent<Props> = ({ minimal }) => (
<StyledFooterWrapper minimal={minimal}>
<StyledFooterContainer>
{!minimal && (
Expand Down
4 changes: 2 additions & 2 deletions components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import HeaderCta from '@components/atoms/HeaderCta'
import Row from '@components/atoms/Row'
import React from 'react'
import { FunctionComponent } from 'react'

import { StyledHeaderImage, StyledHeaderText } from './HeaderStyles'

Expand All @@ -14,7 +14,7 @@ interface Props {
text?: string
}

const Header: React.FunctionComponent<Props> = props => (
const Header: FunctionComponent<Props> = props => (
<>
<Row>
{props.showImage && <StyledHeaderImage src={props.headerImage} alt={props.headerImageAlt} />}
Expand Down
4 changes: 2 additions & 2 deletions components/NavBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Button from '@components/atoms/Button'
import MenuDownIcon from 'mdi-react/MenuDownIcon'
import MenuIcon from 'mdi-react/MenuIcon'
import MenuUpIcon from 'mdi-react/MenuUpIcon'
import React, { useState } from 'react'
import { FunctionComponent, useState } from 'react'

import {
StyledNavBarWrapper,
Expand All @@ -20,7 +20,7 @@ import {
StyledNavBarDropDownItem,
} from './NavBarStyles'

const NavBar: React.FunctionComponent = () => {
const NavBar: FunctionComponent = () => {
const [ expandDropdown, setExpandDropdown ] = useState(false)
const [ expandOnMobile, setExpandOnMobile ] = useState(false)

Expand Down
4 changes: 2 additions & 2 deletions components/atoms/AuthorCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Card from '@components/atoms/Card'
import ContentCard from '@components/atoms/ContentCard'
import React from 'react'
import { FunctionComponent } from 'react'

import { StyledAuthorImage } from './AuthorCardStyles'

Expand All @@ -12,7 +12,7 @@ interface Props {
id: string
}

const AuthorCard: React.FunctionComponent<Props> = props => (
const AuthorCard: FunctionComponent<Props> = props => (
<Card showBorder={true}>
<StyledAuthorImage src="/authors/unisex-avatar.svg" alt="Author Avatar" />
<ContentCard
Expand Down
4 changes: 2 additions & 2 deletions components/atoms/AuthorCardList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import AuthorCard from '@components/atoms/AuthorCard'
import Column from '@components/atoms/Column'
import AuthorCollection from '@interfaces/AuthorCollection'
import React from 'react'
import { FunctionComponent } from 'react'

import { StyledAuthorCardList } from './AuthorCardListStyles'

interface Props {
authors: AuthorCollection[]
}

const AuthorCardList: React.FunctionComponent<Props> = props => (
const AuthorCardList: FunctionComponent<Props> = props => (
<StyledAuthorCardList>
{props.authors.map(author => (
<Column className='flex-medium' width='flex-medium' key={author.id}>
Expand Down
2 changes: 1 addition & 1 deletion components/atoms/Button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode, FunctionComponent } from 'react'
import { ReactNode, FunctionComponent } from 'react'

import { StyledButton } from './ButtonStyles'

Expand Down
2 changes: 1 addition & 1 deletion components/atoms/Card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode, FunctionComponent } from 'react'
import { ReactNode, FunctionComponent } from 'react'

import { StyledCard } from './CardStyles'

Expand Down
4 changes: 2 additions & 2 deletions components/atoms/CollectionView/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Card from '@components/atoms/Card'
import MarkdownFile from '@interfaces/MarkdownFile'
import Link from 'next/link'
import React from 'react'
import { FunctionComponent } from 'react'

import {
StyledCollectionHeader,
Expand All @@ -19,7 +19,7 @@ interface Props {
activeSlug?: string
}

const CollectionView: React.FunctionComponent<Props> = props => (
const CollectionView: FunctionComponent<Props> = props => (
<Card addMargin={true} showBorder={true} leftAlign={true}>
<StyledCollectionHeader>This article is part of a series:</StyledCollectionHeader>
<StyledCollectionBody>
Expand Down
2 changes: 1 addition & 1 deletion components/atoms/Column/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode, FunctionComponent } from 'react'
import { ReactNode, FunctionComponent } from 'react'

import { StyledColumn } from './ColumnStyles'

Expand Down
2 changes: 1 addition & 1 deletion components/atoms/Container/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode, FunctionComponent } from 'react'
import { ReactNode, FunctionComponent } from 'react'

import { StyledContainer } from './ContainerStyles'

Expand Down
4 changes: 2 additions & 2 deletions components/atoms/ContentCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Card from '@components/atoms/Card'
import Link from 'next/link'
import React from 'react'
import { FunctionComponent } from 'react'

import {
StyledCardBody,
Expand All @@ -20,7 +20,7 @@ export interface Props {
contentType?: string | null
}

const ContentCard: React.FunctionComponent<Props> = props => {
const ContentCard: FunctionComponent<Props> = props => {
const isPost = props.contentType === 'post'

return (
Expand Down
4 changes: 2 additions & 2 deletions components/atoms/ContentCardList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import Column from '@components/atoms/Column'
import ContentCard from '@components/atoms/ContentCard'
import Row from '@components/atoms/Row'
import MarkdownFileWithUrl from '@interfaces/MarkdownFileWithUrl'
import React from 'react'
import { FunctionComponent } from 'react'

interface Props {
records: MarkdownFileWithUrl[]
}

const ContentCardList: React.FunctionComponent<Props> = props => (
const ContentCardList: FunctionComponent<Props> = props => (
<Row>
{props.records.map(record => (
<Column className='flex-medium' width='flex-medium' key={record.url}>
Expand Down
4 changes: 2 additions & 2 deletions components/atoms/CreativeCommonsNotice/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import { FunctionComponent } from 'react'

import {
StyledCreativeCommonsNoticeContainer,
Expand All @@ -9,7 +9,7 @@ import {

const creativeCommonsUrl = 'https://creativecommons.org/licenses/by-nc-sa/4.0/'

const CreativeCommonsNotice: React.FunctionComponent = () => (
const CreativeCommonsNotice: FunctionComponent = () => (
<StyledCreativeCommonsNoticeContainer>
<StyledCreativeCommonsNoticeText>
This work is licensed under a{' '}
Expand Down
4 changes: 2 additions & 2 deletions components/atoms/EmbeddedYoutubeVideo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import { FunctionComponent } from 'react'

import { StyledEmbeddedVideoWrapper, StyledEmbeddedVideo } from './EmbeddedYoutubeVideoStyles'

Expand All @@ -9,7 +9,7 @@ interface Props {
id: string
}

const EmbeddedYoutubeVideo: React.FunctionComponent<Props> = props => (
const EmbeddedYoutubeVideo: FunctionComponent<Props> = props => (
<StyledEmbeddedVideoWrapper>
<StyledEmbeddedVideo
title="Embedded Youtube Video"
Expand Down
4 changes: 2 additions & 2 deletions components/atoms/GifLikeVideo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import { FunctionComponent } from 'react'

import { StyledVideo } from './GifLikeVideoStyles'

Expand All @@ -15,7 +15,7 @@ interface Props {
* and accessibility advantages (like being pausable). Use cases include
* screencast demonstrations or animations.
*/
const GifLikeVideo: React.FunctionComponent<Props> = props => (
const GifLikeVideo: FunctionComponent<Props> = props => (
<StyledVideo
autoPlay={true}
loop={true}
Expand Down
6 changes: 3 additions & 3 deletions components/atoms/GoogleTagManager/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import { FunctionComponent } from 'react'

import { StyledIframe } from './GoogleTagManagerStyles'

Expand All @@ -12,7 +12,7 @@ interface Props {
/**
* Google Tag Manager script tag. This should be rendered in the <head>.
*/
export const GoogleTagManagerScriptTag: React.FunctionComponent<Props> = props => (
export const GoogleTagManagerScriptTag: FunctionComponent<Props> = props => (
<script
dangerouslySetInnerHTML={{
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
Expand All @@ -29,7 +29,7 @@ export const GoogleTagManagerScriptTag: React.FunctionComponent<Props> = props =
* script. This should be rendered in the <body> element (ideally right after
* the opening <body> tag).
*/
export const GoogleTagManagerNoscriptFrame: React.FunctionComponent<Props> = props => (
export const GoogleTagManagerNoscriptFrame: FunctionComponent<Props> = props => (
<noscript>
<StyledIframe
title="google-tag-manager-noscript-frame"
Expand Down
4 changes: 2 additions & 2 deletions components/atoms/HeaderCta/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import { FunctionComponent } from 'react'

import Button from '../Button'

Expand All @@ -9,7 +9,7 @@ interface Props {
text?: string
}

const HeaderCta: React.FunctionComponent<Props> = props => (
const HeaderCta: FunctionComponent<Props> = props => (
<StyledHeaderCtaWrapper>
{props.link &&
<Button href={props.link} className="header-cta">
Expand Down
2 changes: 1 addition & 1 deletion components/atoms/Row/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode, FunctionComponent } from 'react'
import { ReactNode, FunctionComponent } from 'react'

import { StyledRow } from './RowStyles'

Expand Down
4 changes: 2 additions & 2 deletions components/atoms/SourcegraphSearch/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Button from '@components/atoms/Button'
import Card from '@components/atoms/Card'
import Column from '@components/atoms/Column'
import React, { useState } from 'react'
import { FunctionComponent, useState } from 'react'

import { StyledSearchBody, StyledSearchInput } from './SourcegraphSearchStyles'

Expand All @@ -10,7 +10,7 @@ interface Props {
patternType?: string
}

const SourcegraphSearch: React.FunctionComponent<Props> = props => {
const SourcegraphSearch: FunctionComponent<Props> = props => {
const [query, setQuery] = useState(props.query)
let modifiedQuery = query

Expand Down
4 changes: 2 additions & 2 deletions components/atoms/TocWrapper/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import { FunctionComponent } from 'react'

import { StyledTocWrapper } from './TocWrapperStyles'

interface Props {
tocContents: string
}

const TocWrapper: React.FunctionComponent<Props> = props => (
const TocWrapper: FunctionComponent<Props> = props => (
<StyledTocWrapper>
<h5>Contents</h5>
{props.tocContents}
Expand Down
7 changes: 3 additions & 4 deletions components/layouts/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GoogleTagManagerScriptTag, GoogleTagManagerNoscriptFrame } from '@compo
import Footer from '@components/Footer'
import NavBar from '@components/NavBar'
import Head from 'next/head'
import * as React from 'react'
import { FunctionComponent } from 'react'

import { googleTagManagerId } from '../../site-config'

Expand Down Expand Up @@ -34,7 +34,7 @@ export interface Props {
metaTags?: MetaTags
}

const Layout: React.FunctionComponent<Props> = props => {
const Layout: FunctionComponent<Props> = props => {
let documentTitle = props.documentTitle
if (!documentTitle) {
documentTitle = SITE_TITLE
Expand All @@ -61,8 +61,7 @@ const Layout: React.FunctionComponent<Props> = props => {
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
rel="stylesheet preload prefetch"
as="style"
rel="stylesheet"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will hopefully address a console warning I was seeing in prod (but not dev while working on CSS refactor): <link rel=preload> has an invalid href value. This should fix that.

href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,700;1,400;1,700&family=PT+Sans:wght@700&display=swap"
/>
{/* Prism theme for syntax highlighting */}
Expand Down
6 changes: 3 additions & 3 deletions components/layouts/PageLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Column from '@components/atoms/Column'
import Row from '@components/atoms/Row'
import Layout, { Props as LayoutProps, MetaTags } from '@components/layouts/Layout'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking MetaTags out here, since this is unused.

import React from 'react'
import Layout, { Props as LayoutProps } from '@components/layouts/Layout'
import { FunctionComponent } from 'react'

interface Props extends LayoutProps {
leftColumn?: React.ReactNode
rightColumn?: React.ReactNode
}

const PageLayout: React.FunctionComponent<Props> = props => (
const PageLayout: FunctionComponent<Props> = props => (
<Layout documentTitle={props.documentTitle} appendSiteTitle={props.appendSiteTitle} metaTags={props.metaTags}>
<Row className='medium'>
<Column className='flex-small' width='flex-small'>{props.leftColumn}</Column>
Expand Down
6 changes: 3 additions & 3 deletions components/templates/ArticleTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import PageLayout from '@components/layouts/PageLayout'
import RecordCollection from '@interfaces/RecordCollection'
import RegexIcon from 'mdi-react/RegexIcon'
import { MDXRemote, MDXRemoteSerializeResult } from 'next-mdx-remote'
import React from 'react'
import { FunctionComponent, createElement } from 'react'
import rehypeReact from 'rehype-react'
import unified from 'unified'
import { Node } from 'unist'
Expand Down Expand Up @@ -38,7 +38,7 @@ export interface Props {

const components = { SourcegraphSearch, EmbeddedYoutubeVideo, GifLikeVideo, RegexIcon, CollectionView }

const ArticleTemplate: React.FunctionComponent<Props> = props => {
const ArticleTemplate: FunctionComponent<Props> = props => {
const metaTags: MetaTags = {
image: props.socialImage ?? props.image,
description: props.description,
Expand All @@ -54,7 +54,7 @@ const ArticleTemplate: React.FunctionComponent<Props> = props => {

let tocFragment
if (props.toc) {
tocFragment = unified().use(rehypeReact, { createElement: React.createElement }).stringify(props.toc)
tocFragment = unified().use(rehypeReact, { createElement }).stringify(props.toc)
tocFragment = (
<>
<TocWrapper tocContents={tocFragment} />
Expand Down
2 changes: 1 addition & 1 deletion components/templates/ErrorTemplate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SignDirectionIcon from 'mdi-react/SignDirectionIcon'
import React, { FunctionComponent } from 'react'
import { FunctionComponent } from 'react'

import { StyledErrorPageWrapper, StyledErrorPageText } from './ErrorTemplateStyles'

Expand Down
8 changes: 6 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// @ts-check
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
})

/** @type {import("next/dist/next-server/server/config-shared").NextConfig} */
module.exports = {

module.exports = withBundleAnalyzer({
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],
future: {
// Enable webpack5
Expand All @@ -10,4 +14,4 @@ module.exports = {
env: {
NEXT_PUBLIC_URL: process.env.DEPLOY_URL,
}
}
})
Loading