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

Add bundle analysis tools #279

Merged
merged 5 commits into from
Apr 29, 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
10 changes: 10 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,15 @@ module.exports = {
resolve: `gatsby-plugin-create-client-paths`,
options: { prefixes: [`/edit/*`] },
},
// bundle analysis
`gatsby-plugin-perf-budgets`, // located at /_report.html
{
resolve: "gatsby-plugin-webpack-bundle-analyser-v2",
options: {
// devMode: true,
// disable: true,
analyzerPort: 8001,
},
},
],
}
3 changes: 0 additions & 3 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,6 @@ exports.createPages = async ({ graphql, actions }) => {
}

exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
actions.setWebpackConfig({
node: { fs: "empty" },
})
if (stage === "build-html") {
actions.setWebpackConfig({
module: {
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
"dependencies": {
"@mapbox/geo-viewport": "^0.4.1",
"@mapbox/mapbox-gl-draw": "^1.2.0",
"@quickbaseoss/babel-plugin-styled-components-css-namespace": "^1.0.1",
"@reach/accordion": "^0.12.1",
"@reach/listbox": "^0.12.1",
"@reach/visually-hidden": "^0.12.0",
"@turf/turf": "^5.1.6",
"@turf/area": "^6.3.0",
"@turf/bbox": "^6.3.0",
"@turf/boolean-disjoint": "^6.3.0",
"date-fns": "^2.16.1",
"feedback-fish": "^0.2.3",
"gatsby": "^3.2.1",
Expand All @@ -30,7 +31,6 @@
"gatsby-transformer-json": "^3.2.0",
"gatsby-transformer-sharp": "^3.2.0",
"lodash.debounce": "^4.0.8",
"mapbox": "^1.0.0-beta10",
"mapbox-gl": "^1.13.0",
"nuka-carousel": "^4.7.4",
"path-browserify": "^1.0.1",
Expand All @@ -47,6 +47,7 @@
},
"devDependencies": {
"@cypress/code-coverage": "^3.9.4",
"@quickbaseoss/babel-plugin-styled-components-css-namespace": "^1.0.1",
"@testing-library/cypress": "^7.0.5",
"@testing-library/react-hooks": "^5.1.1",
"axe-core": "^4.1.4",
Expand All @@ -66,6 +67,8 @@
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"gatsby-plugin-perf-budgets": "^0.0.17",
"gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.22",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.6.3",
"jest-styled-components": "^7.0.3",
Expand Down Expand Up @@ -112,4 +115,4 @@
"bugs": {
"url": "http://github.com/developmentseed/airborne-metadata-catalog-internal/issues"
}
}
}
10 changes: 6 additions & 4 deletions src/components/explore/explore-map.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useState, useEffect } from "react"
import PropTypes from "prop-types"
import * as turf from "@turf/turf"
import turfArea from "@turf/area"
import turfBbox from "@turf/bbox"
import turfBooleanDisjoint from "@turf/boolean-disjoint"
import parse from "wellknown"

import Map from "../map"
Expand All @@ -13,7 +15,7 @@ const sortFeaturesBySize = (a, b) => {
// this is required by the hover effect:
// to be able to select small features contained within others,
// they need to be added to the map last
return turf.area(b.geometry) - turf.area(a.geometry)
return turfArea(b.geometry) - turfArea(a.geometry)
}

const ExploreMap = ({ allData, filteredData, setGeoFilter, aoi, setAoi }) => {
Expand All @@ -32,7 +34,7 @@ const ExploreMap = ({ allData, filteredData, setGeoFilter, aoi, setAoi }) => {
}))
.sort(sortFeaturesBySize),
}))
const [bbox] = useState(() => turf.bbox(geojson))
const [bbox] = useState(() => turfBbox(geojson))

useEffect(() => {
// updates the map after a filter was changed
Expand Down Expand Up @@ -65,7 +67,7 @@ const ExploreMap = ({ allData, filteredData, setGeoFilter, aoi, setAoi }) => {
shortname: d.shortname,
},
}))
.filter(feature => (aoi ? !turf.booleanDisjoint(feature, aoi) : true))
.filter(feature => (aoi ? !turfBooleanDisjoint(feature, aoi) : true))
.map(f => f.properties.id)
)
}, [aoi])
Expand Down
16 changes: 0 additions & 16 deletions src/pages/edit.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/templates/campaign/hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from "prop-types"
import { graphql } from "gatsby"
import styled from "styled-components"
import { GatsbyImage } from "gatsby-plugin-image"
import * as turf from "@turf/turf"
import turfBbox from "@turf/bbox"
import parse from "wellknown"

import { HeroStats } from "../../components/hero"
Expand Down Expand Up @@ -50,7 +50,7 @@ const CampaignHero = ({
type: "Feature",
geometry: parse(bounds),
}
const bbox = turf.bbox(geojson)
const bbox = turfBbox(geojson)

const containerRef = useRef()
const { height } = useContainerDimensions(containerRef)
Expand Down
Loading