From 56ffa2cdb9e7b303df50bc6fcf36f4a6de45975f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Sirois Date: Thu, 21 May 2020 11:11:32 -0400 Subject: [PATCH 1/2] perf: avoid loading all of ramda --- src/components/ArchivesSidebar/index.tsx | 2 +- src/components/ResourcesList/index.tsx | 2 +- src/components/ResourcesSidebar/index.tsx | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/ArchivesSidebar/index.tsx b/src/components/ArchivesSidebar/index.tsx index 7f4c136..4a30c3e 100644 --- a/src/components/ArchivesSidebar/index.tsx +++ b/src/components/ArchivesSidebar/index.tsx @@ -1,5 +1,5 @@ import { graphql, useStaticQuery } from "gatsby" -import { sort } from "ramda" +import sort from "ramda/es/sort" import React, { FC, HTMLAttributes } from "react" import useBuildTree from "../../hooks/useBuildTree" import { useLockBodyScroll } from "../../hooks/useLockBodyScroll" diff --git a/src/components/ResourcesList/index.tsx b/src/components/ResourcesList/index.tsx index e1987ec..d100f89 100644 --- a/src/components/ResourcesList/index.tsx +++ b/src/components/ResourcesList/index.tsx @@ -1,5 +1,5 @@ import { graphql, useStaticQuery } from "gatsby" -import { sort } from "ramda" +import sort from "ramda/es/sort" import React, { FC, HTMLAttributes, memo } from "react" import "react-perfect-scrollbar/dist/css/styles.css" import { IAllResourcesQuery, IFileOrFolder, IFolder } from "../../types" diff --git a/src/components/ResourcesSidebar/index.tsx b/src/components/ResourcesSidebar/index.tsx index 1163530..1cf6e8d 100644 --- a/src/components/ResourcesSidebar/index.tsx +++ b/src/components/ResourcesSidebar/index.tsx @@ -1,5 +1,7 @@ import { graphql, useStaticQuery } from "gatsby" -import { descend, sort, sortWith } from "ramda" +import descend from "ramda/es/descend" +import sort from "ramda/es/sort" +import sortWith from "ramda/es/sortWith" import React, { FC, HTMLAttributes, memo, useState } from "react" import useBuildTree from "../../hooks/useBuildTree" import { useLockBodyScroll } from "../../hooks/useLockBodyScroll" From 9483ff98fd13ebeb2af61c0ff31f8e3dee310c2d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Sirois Date: Thu, 21 May 2020 11:19:48 -0400 Subject: [PATCH 2/2] perf: install gatsby-plugin-polished to optimize performance --- gatsby-config.js | 1 + package-lock.json | 25 +++++++++++++++++++++++++ package.json | 2 ++ 3 files changed, 28 insertions(+) diff --git a/gatsby-config.js b/gatsby-config.js index f0f7fde..82b9edd 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -7,6 +7,7 @@ module.exports = { plugins: [ `gatsby-plugin-react-helmet`, `gatsby-plugin-styled-components`, + `gatsby-plugin-polished`, { resolve: `gatsby-plugin-prefetch-google-fonts`, options: { diff --git a/package-lock.json b/package-lock.json index acf7c83..40682b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4172,6 +4172,23 @@ "resolve": "^1.12.0" } }, + "babel-plugin-polished": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/babel-plugin-polished/-/babel-plugin-polished-1.1.0.tgz", + "integrity": "sha1-f2kCq46cIPwUy1PVlt2FiIDjV9M=", + "dev": true, + "requires": { + "polished": "^1.0.0" + }, + "dependencies": { + "polished": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/polished/-/polished-1.9.3.tgz", + "integrity": "sha512-4NmSD7fMFlM8roNxs7YXPv7UFRbYzb0gufR5zBxJLRzY54+zFsavxBo6zsQzP9ep6Hh3pC2pTyrpSTBEaB6IkQ==", + "dev": true + } + } + }, "babel-plugin-remove-graphql-queries": { "version": "2.9.1", "resolved": "https://registry.npmjs.org/babel-plugin-remove-graphql-queries/-/babel-plugin-remove-graphql-queries-2.9.1.tgz", @@ -9620,6 +9637,14 @@ "micromatch": "^3.1.10" } }, + "gatsby-plugin-polished": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/gatsby-plugin-polished/-/gatsby-plugin-polished-1.0.4.tgz", + "integrity": "sha512-bpm3TR1b982UOlAhjrcTSTpTXW1G4C8dWDBPDag6WbZ3EbtvvtaOO7q4Z1w+RAmunBeAv5maf0BwFcbO4N5GQw==", + "requires": { + "@babel/runtime": "^7.4.0" + } + }, "gatsby-plugin-prefetch-google-fonts": { "version": "1.4.3", "resolved": "https://registry.npmjs.org/gatsby-plugin-prefetch-google-fonts/-/gatsby-plugin-prefetch-google-fonts-1.4.3.tgz", diff --git a/package.json b/package.json index d212aff..b0c5093 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "gatsby-plugin-anchor-links": "^1.1.1", "gatsby-plugin-layout": "^1.3.1", "gatsby-plugin-manifest": "^2.4.6", + "gatsby-plugin-polished": "^1.0.4", "gatsby-plugin-prefetch-google-fonts": "^1.4.3", "gatsby-plugin-react-helmet": "^3.3.1", "gatsby-plugin-react-svg": "^3.0.0", @@ -69,6 +70,7 @@ "@types/react-dom": "^16.9.8", "@types/react-helmet": "^6.0.0", "@types/styled-components": "^5.1.0", + "babel-plugin-polished": "^1.1.0", "babel-plugin-styled-components": "^1.10.7", "discord.js": "^12.2.0", "gatsby-plugin-remove-trailing-slashes": "^2.3.2",