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

chore: Upgrade gatsby #887

Merged
merged 5 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
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
],
"license": "MIT",
"peerDependencies": {
"gatsby": "^3.1.1"
"gatsby": "^3.11.1"
},
"devDependencies": {
"@types/fs-extra": "^9.0.4",
"@types/json-schema": "^7.0.6",
"cross-env": "^7.0.2",
"gatsby": "^3.1.1",
"gatsby": "^3.11.1",
"typescript": "^4.2.4"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-google-tag-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"devDependencies": {
"@vtex/gatsby-theme-store": "^0.373.8",
"cross-env": "^7.0.2",
"gatsby": "^3.1.1",
"gatsby": "^3.11.1",
"typescript": "^4.2.4"
},
"peerDependencies": {
"@vtex/gatsby-theme-store": "^0.255.6-alpha.0",
"gatsby": "^3.1.1"
"gatsby": "^3.11.1"
}
}
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
],
"license": "MIT",
"peerDependencies": {
"gatsby": "^3.1.1",
"gatsby": "^3.11.1",
"graphql": "^14.0.0 || ^15.0.0"
},
"devDependencies": {
"@types/fs-extra": "^9.0.1",
"cross-env": "^7.0.2",
"gatsby": "^3.1.1",
"gatsby": "^3.11.1",
"typescript": "^4.2.4"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
},
"devDependencies": {
"cross-env": "^7.0.2",
"gatsby": "^3.1.1",
"gatsby": "^3.11.1",
"typescript": "^4.2.4"
},
"peerDependencies": {
"gatsby": "^3.1.1",
"gatsby": "^3.11.1",
"react": "*"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-nginx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
"gatsby-plugin-nginx"
],
"peerDependencies": {
"gatsby": "^3.5.0"
"gatsby": "^3.11.1"
},
"devDependencies": {
"@size-limit/preset-small-lib": "^4.10.2",
"@types/webpack-assets-manifest": "^5.0.0",
"gatsby": "^3.5.0",
"gatsby": "^3.11.1",
"size-limit": "^4.10.2",
"tsdx": "^0.14.1",
"tslib": "^2.2.0",
Expand Down
32 changes: 19 additions & 13 deletions packages/gatsby-plugin-performance/cache-dir/find-path.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// This file is copied from gatsby's cache-dir folder. The only part we change is the code related to path matching with matchPaths variable. We leave all unecessary code commented up to make it easier for future PRs to support newer versions of gatsby
// import { pick } from "@gatsbyjs/reach-router/lib/utils"
import stripPrefix from "./strip-prefix"
import normalizePagePath from "./normalize-page-path"
import { pick } from '@gatsbyjs/reach-router/lib/utils'
import stripPrefix from './strip-prefix'
import normalizePagePath from './normalize-page-path'
import { maybeGetBrowserRedirect } from './redirect-utils.js'

const pathCache = new Map()
// let matchPaths = []

const trimPathname = rawPathname => {
const trimPathname = (rawPathname) => {
const pathname = decodeURIComponent(rawPathname)
// Remove the pathPrefix from the pathname.
const trimmedPathname = stripPrefix(pathname, __BASE_PATH__)
const trimmedPathname = stripPrefix(
pathname,
decodeURIComponent(__BASE_PATH__)
)
// Remove any hashfragment
.split(`#`)[0]
// Remove search query
Expand Down Expand Up @@ -40,7 +43,7 @@ function absolutify(path) {
*
* @param {Array<{path: string, matchPath: string}>} value collection of matchPaths
*/
export const setMatchPaths = value => {
export const setMatchPaths = (value) => {
// matchPaths = value
}

Expand All @@ -52,7 +55,7 @@ export const setMatchPaths = value => {
* @param {string} rawPathname A raw pathname
* @return {string|null}
*/
export const findMatchPath = rawPathname => {
export const findMatchPath = (rawPathname) => {
const trimmedPathname = cleanPath(rawPathname)

// const pickPaths = matchPaths.map(({ path, matchPath }) => {
Expand All @@ -68,8 +71,6 @@ export const findMatchPath = rawPathname => {
// return normalizePagePath(path.route.originalPath)
// }

// return null

return trimmedPathname
}

Expand All @@ -82,7 +83,7 @@ export const findMatchPath = rawPathname => {
* @param {string} rawPathname A raw pathname
* @return {object}
*/
export const grabMatchParams = rawPathname => {
export const grabMatchParams = (rawPathname) => {
// const trimmedPathname = cleanPath(rawPathname)

// const pickPaths = matchPaths.map(({ path, matchPath }) => {
Expand All @@ -109,12 +110,17 @@ export const grabMatchParams = rawPathname => {
//
// Or if `match-paths.json` contains `{ "/foo*": "/page1", ...}`, then
// `/foo?bar=far` => `/page1`
export const findPath = rawPathname => {
export const findPath = (rawPathname) => {
const trimmedPathname = trimPathname(absolutify(rawPathname))
if (pathCache.has(trimmedPathname)) {
return pathCache.get(trimmedPathname)
}

const redirect = maybeGetBrowserRedirect(rawPathname)
if (redirect) {
return findPath(redirect.toPath)
}

let foundPath = findMatchPath(trimmedPathname)

if (!foundPath) {
Expand All @@ -133,7 +139,7 @@ export const findPath = rawPathname => {
* @param {string} rawPathname A raw pathname
* @return {string}
*/
export const cleanPath = rawPathname => {
export const cleanPath = (rawPathname) => {
const trimmedPathname = trimPathname(absolutify(rawPathname))

let foundPath = trimmedPathname
Expand Down
59 changes: 29 additions & 30 deletions packages/gatsby-plugin-performance/cache-dir/production-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,35 @@
* React 17's Concurrent Mode
*/

import { setZeroTimeout } from './zero-timeout'
import { setZeroTimeout } from './zero-timeout'

const scheduleTask = cb =>
new Promise(resolve => setZeroTimeout(() => resolve(cb())))
const scheduleTask = (cb) =>
new Promise((resolve) => setZeroTimeout(() => resolve(cb())))

scheduleTask(() => {
// evaluate React in a single task
require(`react-dom`)
})
.then(() =>
scheduleTask(() => {
// evaluate Gatsby dependencies
require(`@mikaelkristiansson/domready`)
require(`@gatsbyjs/reach-router`)
require(`gatsby-react-router-scroll`)
})
)
.then(() =>
scheduleTask(() => {
// evaluate Gatsby framework
require(`gatsby`)
})
)
.then(() =>
scheduleTask(() => {
const plugins = require(`./api-runner-browser-plugins`)
scheduleTask(() => {
// evaluate React in a single task
require(`react-dom`)
})
.then(() =>
scheduleTask(() => {
// evaluate Gatsby dependencies
require(`@gatsbyjs/reach-router`)
require(`gatsby-react-router-scroll`)
})
)
.then(() =>
scheduleTask(() => {
// evaluate Gatsby framework
require(`gatsby`)
})
)
.then(() =>
scheduleTask(() => {
const plugins = require(`./api-runner-browser-plugins`)

// Evaluate each plugin on its own task
return Promise.all(plugins.map(plugin => scheduleTask(plugin.plugin)))
})
)
// finally evaluate and run the app
.then(() => scheduleTask(() => require(`./production-app-upstream`)))
// Evaluate each plugin on its own task
return Promise.all(plugins.map((plugin) => scheduleTask(plugin.plugin)))
})
)
// finally evaluate and run the app
.then(() => scheduleTask(() => require(`./production-app-upstream`)))
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-performance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"lint": "tsdx lint"
},
"peerDependencies": {
"gatsby": "3.1.1"
"gatsby": "3.11.1"
},
"devDependencies": {
"gatsby": "3.1.1",
"gatsby": "3.11.1",
"tsdx": "^0.14.1",
"tslib": "^2.2.0",
"typescript": "^4.2.4"
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-pixel-facebook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"devDependencies": {
"@vtex/gatsby-theme-store": "^0.373.8",
"cross-env": "^7.0.2",
"gatsby": "^3.1.1",
"gatsby": "^3.11.1",
"typescript": "^4.2.4"
},
"peerDependencies": {
"@vtex/gatsby-theme-store": "^0.255.6-alpha.0",
"gatsby": "^3.1.1"
"gatsby": "^3.11.1"
}
}
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-theme-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"devDependencies": {
"@types/node": "^14.6.0",
"cross-env": "^7.0.2",
"gatsby": "^3.1.1",
"gatsby": "^3.11.1",
"typescript": "^4.2.4"
},
"peerDependencies": {
"gatsby": "^3.1.1"
"gatsby": "^3.11.1"
},
"dependencies": {
"@babel/core": "^7.11.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-source-vtex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"slugify": "^1.4.6"
},
"peerDependencies": {
"gatsby": "^3.1.1",
"gatsby": "^3.11.1",
"graphql": "^15.0.0"
},
"devDependencies": {
"gatsby": "^3.1.1",
"gatsby": "^3.11.1",
"tsdx": "^0.14.1",
"tslib": "^2.3.0",
"typescript": "^4.3.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,26 @@
import 'requestidlecallback-polyfill'

import React, { StrictMode } from 'react'
import { UIProvider } from '@vtex/store-sdk'
import ReactDOM from 'react-dom'
import type { WrapRootElementBrowserArgs } from 'gatsby'
import type { ReactChild } from 'react'
import { UIProvider } from '@vtex/store-sdk'

import ErrorBoundary from './components/Error/ErrorBoundary'
import { Provider as OrderFormProvider } from './sdk/orderForm/Provider'
import { Provider as VTEXRCProvider } from './sdk/pixel/vtexrc/Provider'
import ErrorBoundary from './src/components/Error/ErrorBoundary'
import { Provider as OrderFormProvider } from './src/sdk/orderForm/Provider'
import { Provider as VTEXRCProvider } from './src/sdk/pixel/vtexrc/Provider'
import {
onRouteUpdate as progressOnRouteUpdate,
Progress,
} from './sdk/progress'
import { Provider as RegionProvider } from './sdk/region/Provider'
import { Provider as ToastProvider } from './sdk/toast/Provider'
} from './src/sdk/progress'
import { Provider as RegionProvider } from './src/sdk/region/Provider'
import { Provider as ToastProvider } from './src/sdk/toast/Provider'

export const onClientEntry = async () => {
if (typeof IntersectionObserver === 'undefined') {
await import('intersection-observer')
}
}

export const replaceHydrateFunction = () => (
element: ReactChild,
container: Element
) => {
export const replaceHydrateFunction = () => (element, container) => {
let hydrate = true

// This part will be removed by webpack on production builds since this only
Expand All @@ -42,13 +37,12 @@ export const replaceHydrateFunction = () => (
}

// There are versions of React currently exporting createRoot and others exporting unstable_createRoot
const createRoot =
ReactDOM.createRoot || (ReactDOM as any).unstable_createRoot
const createRoot = ReactDOM.createRoot || ReactDOM.unstable_createRoot

createRoot(container, { hydrate }).render(element)
}

export const wrapRootElement = ({ element }: WrapRootElementBrowserArgs) => {
export const wrapRootElement = ({ element }) => {
const root = (
<ErrorBoundary>
<VTEXRCProvider>
Expand All @@ -74,10 +68,7 @@ export const onInitialClientRender = () => {
globalThis.__REACT_HYDRATED__ = true
}

export const wrapPageElement = ({
element,
props: { location },
}: WrapRootElementBrowserArgs | any) => (
export const wrapPageElement = ({ element, props: { location } }) => (
<Progress location={location}>{element}</Progress>
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { Options } from './gatsby-node'

const root = process.cwd()

module.exports = ({ locales, defaultLocale }: Options) => ({
module.exports = ({ locales, defaultLocale }) => ({
plugins: [
{
resolve: require.resolve('gatsby-plugin-bundle-stats'),
Expand Down
Loading