From 4f72e371cd6c6085ec0c111e8c32e1c1c1407cb9 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Fri, 2 Oct 2020 13:42:15 -0500 Subject: [PATCH 01/13] Updated types --- lib/bigcommerce/api/operations/get-all-product-paths.ts | 1 - lib/bigcommerce/api/operations/get-all-products.ts | 1 - lib/bigcommerce/api/operations/get-product.ts | 1 - 3 files changed, 3 deletions(-) diff --git a/lib/bigcommerce/api/operations/get-all-product-paths.ts b/lib/bigcommerce/api/operations/get-all-product-paths.ts index ebb196eb2..96ab111c4 100644 --- a/lib/bigcommerce/api/operations/get-all-product-paths.ts +++ b/lib/bigcommerce/api/operations/get-all-product-paths.ts @@ -23,7 +23,6 @@ export interface GetAllProductPathsResult { } async function getAllProductPaths(opts?: { - query?: string config?: BigcommerceConfig }): Promise> diff --git a/lib/bigcommerce/api/operations/get-all-products.ts b/lib/bigcommerce/api/operations/get-all-products.ts index a43a92747..8dc85b7fd 100644 --- a/lib/bigcommerce/api/operations/get-all-products.ts +++ b/lib/bigcommerce/api/operations/get-all-products.ts @@ -47,7 +47,6 @@ export type ProductVariables = Images & Omit async function getAllProducts(opts?: { - query?: string variables?: ProductVariables config?: BigcommerceConfig }): Promise> diff --git a/lib/bigcommerce/api/operations/get-product.ts b/lib/bigcommerce/api/operations/get-product.ts index ae601d7c0..86ddc34ad 100644 --- a/lib/bigcommerce/api/operations/get-product.ts +++ b/lib/bigcommerce/api/operations/get-product.ts @@ -43,7 +43,6 @@ export type ProductVariables = Images & ({ path: string; slug?: never } | { path?: never; slug: string }) async function getProduct(opts: { - query?: string variables: ProductVariables config?: BigcommerceConfig }): Promise> From 667f36c101e9580e96fc0c98c9a266300ad83f8f Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Fri, 2 Oct 2020 17:59:26 -0500 Subject: [PATCH 02/13] test fix --- pages/index.tsx | 2 +- pages/product/[slug].tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index c89c02ce6..cf117da5b 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,5 +1,5 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import getAllProducts from '@lib/bigcommerce/api/operations/get-all-products' +import getAllProducts from 'lib/bigcommerce/api/operations/get-all-products' import { Layout } from '@components/core' import { ProductGrid } from '@components/product' diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index 1342968a5..65a605613 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -3,7 +3,7 @@ import { useRouter } from 'next/router' import getProduct from 'lib/bigcommerce/api/operations/get-product' import { Layout } from '@components/core' import { ProductView } from '@components/product' -import getAllProductPaths from '@lib/bigcommerce/api/operations/get-all-product-paths' +import getAllProductPaths from 'lib/bigcommerce/api/operations/get-all-product-paths' export async function getStaticProps({ params, @@ -42,7 +42,7 @@ export async function getStaticPaths() { // Exclude the slashes: `/slug/` -> `slug` return { params: { slug: path.substring(1, path.length - 1) } } }), - fallback: 'unstable_blocking', + fallback: false, } } From 75464c951fb2bfdcb4de6c1ccf544b4e51488e34 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Fri, 2 Oct 2020 18:57:43 -0500 Subject: [PATCH 03/13] Switch to webpack 4 --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index 2fb6e1aa1..4377dd720 100644 --- a/package.json +++ b/package.json @@ -42,8 +42,5 @@ "prettier": "^2.1.2", "tailwindcss": "^1.8.10", "typescript": "^4.0.3" - }, - "resolutions": { - "webpack": "^5.0.0-beta.30" } } From 3cedd7ea97c07b713f34edeff8d3d2894ce48bb9 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Fri, 2 Oct 2020 19:03:37 -0500 Subject: [PATCH 04/13] Go back to webpack 5 --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 4377dd720..2fb6e1aa1 100644 --- a/package.json +++ b/package.json @@ -42,5 +42,8 @@ "prettier": "^2.1.2", "tailwindcss": "^1.8.10", "typescript": "^4.0.3" + }, + "resolutions": { + "webpack": "^5.0.0-beta.30" } } From 6309713c04120adf328e6968728ff29e085cb365 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Sat, 3 Oct 2020 04:10:08 -0500 Subject: [PATCH 05/13] Test build --- pages/product/[slug].tsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index 65a605613..4baa0d8a3 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -1,14 +1,14 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' import { useRouter } from 'next/router' -import getProduct from 'lib/bigcommerce/api/operations/get-product' +// import getProduct from 'lib/bigcommerce/api/operations/get-product' import { Layout } from '@components/core' import { ProductView } from '@components/product' -import getAllProductPaths from 'lib/bigcommerce/api/operations/get-all-product-paths' +// import getAllProductPaths from '@lib/bigcommerce/api/operations/get-all-product-paths' export async function getStaticProps({ params, }: GetStaticPropsContext<{ slug: string }>) { - const { product } = await getProduct({ variables: { slug: params!.slug } }) + // const { product } = await getProduct({ variables: { slug: params!.slug } }) const productData = { name: 'T-Shirt', description: ` @@ -26,7 +26,7 @@ export async function getStaticProps({ } return { props: { - product, + // product, productData, }, revalidate: 200, @@ -34,15 +34,12 @@ export async function getStaticProps({ } export async function getStaticPaths() { - const { products } = await getAllProductPaths() + // const { products } = await getAllProductPaths() return { - paths: products.map((product) => { - const { path } = product!.node - // Exclude the slashes: `/slug/` -> `slug` - return { params: { slug: path.substring(1, path.length - 1) } } - }), - fallback: false, + paths: [], + // paths: products.map((product) => `/product${product!.node.path}`), + fallback: 'unstable_blocking', } } From d9ee4086b94d41335f269389199fe6474d788aa7 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Sat, 3 Oct 2020 04:17:41 -0500 Subject: [PATCH 06/13] Undo changes --- pages/index.tsx | 2 +- pages/product/[slug].tsx | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index cf117da5b..c89c02ce6 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,5 +1,5 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import getAllProducts from 'lib/bigcommerce/api/operations/get-all-products' +import getAllProducts from '@lib/bigcommerce/api/operations/get-all-products' import { Layout } from '@components/core' import { ProductGrid } from '@components/product' diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index 4baa0d8a3..295fc65a8 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -1,14 +1,14 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' import { useRouter } from 'next/router' -// import getProduct from 'lib/bigcommerce/api/operations/get-product' +import getProduct from 'lib/bigcommerce/api/operations/get-product' import { Layout } from '@components/core' import { ProductView } from '@components/product' -// import getAllProductPaths from '@lib/bigcommerce/api/operations/get-all-product-paths' +import getAllProductPaths from '@lib/bigcommerce/api/operations/get-all-product-paths' export async function getStaticProps({ params, }: GetStaticPropsContext<{ slug: string }>) { - // const { product } = await getProduct({ variables: { slug: params!.slug } }) + const { product } = await getProduct({ variables: { slug: params!.slug } }) const productData = { name: 'T-Shirt', description: ` @@ -26,7 +26,7 @@ export async function getStaticProps({ } return { props: { - // product, + product, productData, }, revalidate: 200, @@ -34,11 +34,10 @@ export async function getStaticProps({ } export async function getStaticPaths() { - // const { products } = await getAllProductPaths() + const { products } = await getAllProductPaths() return { - paths: [], - // paths: products.map((product) => `/product${product!.node.path}`), + paths: products.map((product) => `/product${product!.node.path}`), fallback: 'unstable_blocking', } } From aebc275303e6d26dd1d3657199cad645d26f3b56 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Sat, 3 Oct 2020 04:20:22 -0500 Subject: [PATCH 07/13] Testing potential reason --- lib/bigcommerce/api/operations/get-all-product-paths.ts | 4 ++-- lib/bigcommerce/api/operations/get-all-products.ts | 4 ++-- lib/bigcommerce/api/operations/get-product.ts | 4 ++-- pages/_app.tsx | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/bigcommerce/api/operations/get-all-product-paths.ts b/lib/bigcommerce/api/operations/get-all-product-paths.ts index 96ab111c4..0f6c39658 100644 --- a/lib/bigcommerce/api/operations/get-all-product-paths.ts +++ b/lib/bigcommerce/api/operations/get-all-product-paths.ts @@ -1,5 +1,5 @@ -import type { GetAllProductPathsQuery } from 'lib/bigcommerce/schema' -import type { RecursivePartial, RecursiveRequired } from '../utils/types' +import { GetAllProductPathsQuery } from 'lib/bigcommerce/schema' +import { RecursivePartial, RecursiveRequired } from '../utils/types' import { BigcommerceConfig, getConfig } from '..' export const getAllProductPathsQuery = /* GraphQL */ ` diff --git a/lib/bigcommerce/api/operations/get-all-products.ts b/lib/bigcommerce/api/operations/get-all-products.ts index 8dc85b7fd..1c29226a4 100644 --- a/lib/bigcommerce/api/operations/get-all-products.ts +++ b/lib/bigcommerce/api/operations/get-all-products.ts @@ -1,8 +1,8 @@ -import type { +import { GetAllProductsQuery, GetAllProductsQueryVariables, } from 'lib/bigcommerce/schema' -import type { RecursivePartial, RecursiveRequired } from '../utils/types' +import { RecursivePartial, RecursiveRequired } from '../utils/types' import { productInfoFragment } from '../fragments/product' import { BigcommerceConfig, getConfig, Images, ProductImageVariables } from '..' diff --git a/lib/bigcommerce/api/operations/get-product.ts b/lib/bigcommerce/api/operations/get-product.ts index 86ddc34ad..40a5b71d1 100644 --- a/lib/bigcommerce/api/operations/get-product.ts +++ b/lib/bigcommerce/api/operations/get-product.ts @@ -1,8 +1,8 @@ -import type { +import { GetProductQuery, GetProductQueryVariables, } from 'lib/bigcommerce/schema' -import type { RecursivePartial, RecursiveRequired } from '../utils/types' +import { RecursivePartial, RecursiveRequired } from '../utils/types' import { productInfoFragment } from '../fragments/product' import { BigcommerceConfig, getConfig, Images } from '..' diff --git a/pages/_app.tsx b/pages/_app.tsx index c84409786..4e34741d2 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,5 +1,5 @@ import { FC } from 'react' -import type { AppProps } from 'next/app' +import { AppProps } from 'next/app' import '@assets/global.css' const Noop: FC = ({ children }) => <>{children} From f46d122b8821da83f8d4abc80ce0b3137e9c69f1 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Sat, 3 Oct 2020 04:54:28 -0500 Subject: [PATCH 08/13] Revert "Testing potential reason" This reverts commit aebc275303e6d26dd1d3657199cad645d26f3b56. --- lib/bigcommerce/api/operations/get-all-product-paths.ts | 4 ++-- lib/bigcommerce/api/operations/get-all-products.ts | 4 ++-- lib/bigcommerce/api/operations/get-product.ts | 4 ++-- pages/_app.tsx | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/bigcommerce/api/operations/get-all-product-paths.ts b/lib/bigcommerce/api/operations/get-all-product-paths.ts index 0f6c39658..96ab111c4 100644 --- a/lib/bigcommerce/api/operations/get-all-product-paths.ts +++ b/lib/bigcommerce/api/operations/get-all-product-paths.ts @@ -1,5 +1,5 @@ -import { GetAllProductPathsQuery } from 'lib/bigcommerce/schema' -import { RecursivePartial, RecursiveRequired } from '../utils/types' +import type { GetAllProductPathsQuery } from 'lib/bigcommerce/schema' +import type { RecursivePartial, RecursiveRequired } from '../utils/types' import { BigcommerceConfig, getConfig } from '..' export const getAllProductPathsQuery = /* GraphQL */ ` diff --git a/lib/bigcommerce/api/operations/get-all-products.ts b/lib/bigcommerce/api/operations/get-all-products.ts index 1c29226a4..8dc85b7fd 100644 --- a/lib/bigcommerce/api/operations/get-all-products.ts +++ b/lib/bigcommerce/api/operations/get-all-products.ts @@ -1,8 +1,8 @@ -import { +import type { GetAllProductsQuery, GetAllProductsQueryVariables, } from 'lib/bigcommerce/schema' -import { RecursivePartial, RecursiveRequired } from '../utils/types' +import type { RecursivePartial, RecursiveRequired } from '../utils/types' import { productInfoFragment } from '../fragments/product' import { BigcommerceConfig, getConfig, Images, ProductImageVariables } from '..' diff --git a/lib/bigcommerce/api/operations/get-product.ts b/lib/bigcommerce/api/operations/get-product.ts index 40a5b71d1..86ddc34ad 100644 --- a/lib/bigcommerce/api/operations/get-product.ts +++ b/lib/bigcommerce/api/operations/get-product.ts @@ -1,8 +1,8 @@ -import { +import type { GetProductQuery, GetProductQueryVariables, } from 'lib/bigcommerce/schema' -import { RecursivePartial, RecursiveRequired } from '../utils/types' +import type { RecursivePartial, RecursiveRequired } from '../utils/types' import { productInfoFragment } from '../fragments/product' import { BigcommerceConfig, getConfig, Images } from '..' diff --git a/pages/_app.tsx b/pages/_app.tsx index 4e34741d2..c84409786 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,5 +1,5 @@ import { FC } from 'react' -import { AppProps } from 'next/app' +import type { AppProps } from 'next/app' import '@assets/global.css' const Noop: FC = ({ children }) => <>{children} From 5cb579efe4b1eac7a417e678abbb1362e61ce49c Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Sat, 3 Oct 2020 04:56:23 -0500 Subject: [PATCH 09/13] Updated module paths --- pages/index.tsx | 2 +- pages/product/[slug].tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index c89c02ce6..f0f046ef6 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,5 +1,5 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import getAllProducts from '@lib/bigcommerce/api/operations/get-all-products' +import getAllProducts from '../lib/bigcommerce/api/operations/get-all-products' import { Layout } from '@components/core' import { ProductGrid } from '@components/product' diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index 295fc65a8..9d858cc8a 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -1,9 +1,9 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' import { useRouter } from 'next/router' -import getProduct from 'lib/bigcommerce/api/operations/get-product' +import getProduct from '../../lib/bigcommerce/api/operations/get-product' import { Layout } from '@components/core' import { ProductView } from '@components/product' -import getAllProductPaths from '@lib/bigcommerce/api/operations/get-all-product-paths' +import getAllProductPaths from '../../lib/bigcommerce/api/operations/get-all-product-paths' export async function getStaticProps({ params, From 19a32f2a3039273a0682dc4dd4efb324750be1dd Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Sat, 3 Oct 2020 05:10:08 -0500 Subject: [PATCH 10/13] Undo last change --- pages/index.tsx | 2 +- pages/product/[slug].tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index f0f046ef6..c89c02ce6 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,5 +1,5 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import getAllProducts from '../lib/bigcommerce/api/operations/get-all-products' +import getAllProducts from '@lib/bigcommerce/api/operations/get-all-products' import { Layout } from '@components/core' import { ProductGrid } from '@components/product' diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index 9d858cc8a..4e6af3308 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -1,9 +1,9 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' import { useRouter } from 'next/router' -import getProduct from '../../lib/bigcommerce/api/operations/get-product' +import getProduct from '@lib/bigcommerce/api/operations/get-product' import { Layout } from '@components/core' import { ProductView } from '@components/product' -import getAllProductPaths from '../../lib/bigcommerce/api/operations/get-all-product-paths' +import getAllProductPaths from '@lib/bigcommerce/api/operations/get-all-product-paths' export async function getStaticProps({ params, From 0182b4151e773ac284746ea56cd6899fe1a2d723 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Sat, 3 Oct 2020 05:20:19 -0500 Subject: [PATCH 11/13] Downgraded canary version, tsconfig changes --- package.json | 2 +- tsconfig.json | 4 ++-- yarn.lock | 44 +++++++++++++++++++------------------------- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 2fb6e1aa1..2202cc1ed 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@types/classnames": "^2.2.10", "classnames": "^2.2.6", "lodash": "^4.17.20", - "next": "^9.5.4-canary.23", + "next": "9.5.4-canary.20", "postcss-nested": "^5.0.1", "postcss-nesting": "^7.0.1", "react": "^16.13.1", diff --git a/tsconfig.json b/tsconfig.json index faa489c13..ec924f865 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "baseUrl": ".", - "target": "es5", + "target": "esnext", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, @@ -20,6 +20,6 @@ "@components/*": ["components/*"] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"], "exclude": ["node_modules"] } diff --git a/yarn.lock b/yarn.lock index 858e9c246..1b63d2fed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1390,20 +1390,15 @@ is-promise "4.0.0" tslib "~2.0.1" -"@next/env@9.5.4-canary.23": - version "9.5.4-canary.23" - resolved "https://registry.yarnpkg.com/@next/env/-/env-9.5.4-canary.23.tgz#2078ce80a1d9424bab7ec169dcf98b8d684bc845" - integrity sha512-uP9GV9QU+QODyYM9ueV1E4tocrAeAsvT1+x11mbQWYhC4lv9EXA85S5dUpJp4dbv1WwM+qJQaoEe7yL/exCkng== +"@next/polyfill-module@9.5.4-canary.20": + version "9.5.4-canary.20" + resolved "https://registry.yarnpkg.com/@next/polyfill-module/-/polyfill-module-9.5.4-canary.20.tgz#1de6f1a5924c6dc1998d8a3e0dbd685f413203bc" + integrity sha512-9C/RQIiXA62TheJLatVRR6UVOBZVIMZ5J7DJIn2WRxgT2srRI0Ku6C+tgPJekjHp9XjbWRzc0JCKG1mYwkmdtA== -"@next/polyfill-module@9.5.4-canary.23": - version "9.5.4-canary.23" - resolved "https://registry.yarnpkg.com/@next/polyfill-module/-/polyfill-module-9.5.4-canary.23.tgz#5fd54f33889a6f605337168c94b0fbac779dc107" - integrity sha512-nyvVpt8mb2IGoAqsCucrOk88/nU2c+Xv/Iuaxfyex1qv2g1ZK1KUSojLVSIfqOPa5toP1gCgU+xsz8jXVgmpEg== - -"@next/react-dev-overlay@9.5.4-canary.23": - version "9.5.4-canary.23" - resolved "https://registry.yarnpkg.com/@next/react-dev-overlay/-/react-dev-overlay-9.5.4-canary.23.tgz#8f856f0b1db2fad6f7a2bdf6b15d487541484bdc" - integrity sha512-Ls00yEPvtTkXxipRfprMGJLn9mlmyDozYiIzvZqafkxuZ9KhII/aLu1Xx4W4o6muwEnxPBKW1knsHvWzStsjQA== +"@next/react-dev-overlay@9.5.4-canary.20": + version "9.5.4-canary.20" + resolved "https://registry.yarnpkg.com/@next/react-dev-overlay/-/react-dev-overlay-9.5.4-canary.20.tgz#dd3dcd3898b8684e3768a1018822041e0e304fb7" + integrity sha512-Q8/iSvIJuLQnF3KQ4lV15wAm2j3ZFgT6Hn6y4+rj6p0DU9bB/Cp4XqDbVh3VIo+yyGNsw0cT/vmcimFe1MSqFg== dependencies: "@babel/code-frame" "7.10.4" ally.js "1.4.1" @@ -1416,10 +1411,10 @@ stacktrace-parser "0.1.10" strip-ansi "6.0.0" -"@next/react-refresh-utils@9.5.4-canary.23": - version "9.5.4-canary.23" - resolved "https://registry.yarnpkg.com/@next/react-refresh-utils/-/react-refresh-utils-9.5.4-canary.23.tgz#a0a5c3b10108dc6ef1e17ff68e09bd7dcae76278" - integrity sha512-9Bne33O1uveH7YRjfX0UCJLfsUcP/lIZMc1JDmTkZuQOIFcTg8wuWOXC2mwQIAVtPZ8S9Lg37vK/c0ngZO9omw== +"@next/react-refresh-utils@9.5.4-canary.20": + version "9.5.4-canary.20" + resolved "https://registry.yarnpkg.com/@next/react-refresh-utils/-/react-refresh-utils-9.5.4-canary.20.tgz#2eac9bbf1cb19303b6e9690ec49c6355ab055e2f" + integrity sha512-5B9/GLFqnv6/lx/7kySB8EiqB/R/mXWmH53pcbHKVNdXvoD4oi2fT7PWHXA05JQdr0P1cYIPA1ytrrnIf8F1EQ== "@nodelib/fs.scandir@2.1.3": version "2.1.3" @@ -5039,10 +5034,10 @@ next-tick@~1.0.0: resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" integrity sha1-yobR/ogoFpsBICCOPchCS524NCw= -next@^9.5.4-canary.23: - version "9.5.4-canary.23" - resolved "https://registry.yarnpkg.com/next/-/next-9.5.4-canary.23.tgz#ce0e7b9e284b5f9b718610ff5363827d3dfecd44" - integrity sha512-uNMIonQUZr5uZvmuMJ1Pq2akfzEQa60mQPVkMUUe12eHcE3efsA1M3W+SZfcSnSkCna53qU9Km1pNdGbVLe1Cg== +next@9.5.4-canary.20: + version "9.5.4-canary.20" + resolved "https://registry.yarnpkg.com/next/-/next-9.5.4-canary.20.tgz#041ae6c400b8ab7b7aabba3d66bdcda428f241c3" + integrity sha512-rQvdk3NDYyrB1KvQv2SzAoZlcpOJV2GA93l7BVbByp0l006d3dkFDML7XKEqqtYcvtDlzdKS/V9hde0psKFkAg== dependencies: "@ampproject/toolbox-optimizer" "2.6.0" "@babel/code-frame" "7.10.4" @@ -5062,10 +5057,9 @@ next@^9.5.4-canary.23: "@babel/preset-typescript" "7.10.4" "@babel/runtime" "7.11.2" "@babel/types" "7.11.5" - "@next/env" "9.5.4-canary.23" - "@next/polyfill-module" "9.5.4-canary.23" - "@next/react-dev-overlay" "9.5.4-canary.23" - "@next/react-refresh-utils" "9.5.4-canary.23" + "@next/polyfill-module" "9.5.4-canary.20" + "@next/react-dev-overlay" "9.5.4-canary.20" + "@next/react-refresh-utils" "9.5.4-canary.20" ast-types "0.13.2" babel-plugin-transform-define "2.0.0" babel-plugin-transform-react-remove-prop-types "0.4.24" From d5c761a44d99c6759ef48f258da0482757b3ea11 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Sat, 3 Oct 2020 05:29:55 -0500 Subject: [PATCH 12/13] Removed vercelignore and moved again to latest canary --- .vercelignore | 1 - package.json | 2 +- yarn.lock | 44 +++++++++++++++++++++++++------------------- 3 files changed, 26 insertions(+), 21 deletions(-) delete mode 100644 .vercelignore diff --git a/.vercelignore b/.vercelignore deleted file mode 100644 index a65b41774..000000000 --- a/.vercelignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/package.json b/package.json index 2202cc1ed..2fb6e1aa1 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@types/classnames": "^2.2.10", "classnames": "^2.2.6", "lodash": "^4.17.20", - "next": "9.5.4-canary.20", + "next": "^9.5.4-canary.23", "postcss-nested": "^5.0.1", "postcss-nesting": "^7.0.1", "react": "^16.13.1", diff --git a/yarn.lock b/yarn.lock index 1b63d2fed..858e9c246 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1390,15 +1390,20 @@ is-promise "4.0.0" tslib "~2.0.1" -"@next/polyfill-module@9.5.4-canary.20": - version "9.5.4-canary.20" - resolved "https://registry.yarnpkg.com/@next/polyfill-module/-/polyfill-module-9.5.4-canary.20.tgz#1de6f1a5924c6dc1998d8a3e0dbd685f413203bc" - integrity sha512-9C/RQIiXA62TheJLatVRR6UVOBZVIMZ5J7DJIn2WRxgT2srRI0Ku6C+tgPJekjHp9XjbWRzc0JCKG1mYwkmdtA== +"@next/env@9.5.4-canary.23": + version "9.5.4-canary.23" + resolved "https://registry.yarnpkg.com/@next/env/-/env-9.5.4-canary.23.tgz#2078ce80a1d9424bab7ec169dcf98b8d684bc845" + integrity sha512-uP9GV9QU+QODyYM9ueV1E4tocrAeAsvT1+x11mbQWYhC4lv9EXA85S5dUpJp4dbv1WwM+qJQaoEe7yL/exCkng== -"@next/react-dev-overlay@9.5.4-canary.20": - version "9.5.4-canary.20" - resolved "https://registry.yarnpkg.com/@next/react-dev-overlay/-/react-dev-overlay-9.5.4-canary.20.tgz#dd3dcd3898b8684e3768a1018822041e0e304fb7" - integrity sha512-Q8/iSvIJuLQnF3KQ4lV15wAm2j3ZFgT6Hn6y4+rj6p0DU9bB/Cp4XqDbVh3VIo+yyGNsw0cT/vmcimFe1MSqFg== +"@next/polyfill-module@9.5.4-canary.23": + version "9.5.4-canary.23" + resolved "https://registry.yarnpkg.com/@next/polyfill-module/-/polyfill-module-9.5.4-canary.23.tgz#5fd54f33889a6f605337168c94b0fbac779dc107" + integrity sha512-nyvVpt8mb2IGoAqsCucrOk88/nU2c+Xv/Iuaxfyex1qv2g1ZK1KUSojLVSIfqOPa5toP1gCgU+xsz8jXVgmpEg== + +"@next/react-dev-overlay@9.5.4-canary.23": + version "9.5.4-canary.23" + resolved "https://registry.yarnpkg.com/@next/react-dev-overlay/-/react-dev-overlay-9.5.4-canary.23.tgz#8f856f0b1db2fad6f7a2bdf6b15d487541484bdc" + integrity sha512-Ls00yEPvtTkXxipRfprMGJLn9mlmyDozYiIzvZqafkxuZ9KhII/aLu1Xx4W4o6muwEnxPBKW1knsHvWzStsjQA== dependencies: "@babel/code-frame" "7.10.4" ally.js "1.4.1" @@ -1411,10 +1416,10 @@ stacktrace-parser "0.1.10" strip-ansi "6.0.0" -"@next/react-refresh-utils@9.5.4-canary.20": - version "9.5.4-canary.20" - resolved "https://registry.yarnpkg.com/@next/react-refresh-utils/-/react-refresh-utils-9.5.4-canary.20.tgz#2eac9bbf1cb19303b6e9690ec49c6355ab055e2f" - integrity sha512-5B9/GLFqnv6/lx/7kySB8EiqB/R/mXWmH53pcbHKVNdXvoD4oi2fT7PWHXA05JQdr0P1cYIPA1ytrrnIf8F1EQ== +"@next/react-refresh-utils@9.5.4-canary.23": + version "9.5.4-canary.23" + resolved "https://registry.yarnpkg.com/@next/react-refresh-utils/-/react-refresh-utils-9.5.4-canary.23.tgz#a0a5c3b10108dc6ef1e17ff68e09bd7dcae76278" + integrity sha512-9Bne33O1uveH7YRjfX0UCJLfsUcP/lIZMc1JDmTkZuQOIFcTg8wuWOXC2mwQIAVtPZ8S9Lg37vK/c0ngZO9omw== "@nodelib/fs.scandir@2.1.3": version "2.1.3" @@ -5034,10 +5039,10 @@ next-tick@~1.0.0: resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" integrity sha1-yobR/ogoFpsBICCOPchCS524NCw= -next@9.5.4-canary.20: - version "9.5.4-canary.20" - resolved "https://registry.yarnpkg.com/next/-/next-9.5.4-canary.20.tgz#041ae6c400b8ab7b7aabba3d66bdcda428f241c3" - integrity sha512-rQvdk3NDYyrB1KvQv2SzAoZlcpOJV2GA93l7BVbByp0l006d3dkFDML7XKEqqtYcvtDlzdKS/V9hde0psKFkAg== +next@^9.5.4-canary.23: + version "9.5.4-canary.23" + resolved "https://registry.yarnpkg.com/next/-/next-9.5.4-canary.23.tgz#ce0e7b9e284b5f9b718610ff5363827d3dfecd44" + integrity sha512-uNMIonQUZr5uZvmuMJ1Pq2akfzEQa60mQPVkMUUe12eHcE3efsA1M3W+SZfcSnSkCna53qU9Km1pNdGbVLe1Cg== dependencies: "@ampproject/toolbox-optimizer" "2.6.0" "@babel/code-frame" "7.10.4" @@ -5057,9 +5062,10 @@ next@9.5.4-canary.20: "@babel/preset-typescript" "7.10.4" "@babel/runtime" "7.11.2" "@babel/types" "7.11.5" - "@next/polyfill-module" "9.5.4-canary.20" - "@next/react-dev-overlay" "9.5.4-canary.20" - "@next/react-refresh-utils" "9.5.4-canary.20" + "@next/env" "9.5.4-canary.23" + "@next/polyfill-module" "9.5.4-canary.23" + "@next/react-dev-overlay" "9.5.4-canary.23" + "@next/react-refresh-utils" "9.5.4-canary.23" ast-types "0.13.2" babel-plugin-transform-define "2.0.0" babel-plugin-transform-react-remove-prop-types "0.4.24" From 7273c4deb3eeccc17be1f5bcc2b5b5656ef4b513 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Sat, 3 Oct 2020 06:45:09 -0500 Subject: [PATCH 13/13] Updated hooks --- lib/bigcommerce/cart.tsx | 14 ++++---------- lib/bigcommerce/index.tsx | 18 ++++++++++-------- lib/commerce/cart.tsx | 28 ++++++++++++---------------- lib/commerce/index.tsx | 20 +++++++++----------- 4 files changed, 35 insertions(+), 45 deletions(-) diff --git a/lib/bigcommerce/cart.tsx b/lib/bigcommerce/cart.tsx index bc3563807..d57736e91 100644 --- a/lib/bigcommerce/cart.tsx +++ b/lib/bigcommerce/cart.tsx @@ -1,21 +1,15 @@ +import { FC } from 'react' import { CartProvider as CommerceCartProvider, useCart as useCommerceCart, } from 'lib/commerce/cart' -import { FunctionComponent } from 'react' export type Cart = any -interface Props { - children?: any +export const CartProvider: FC = ({ children }) => { + return {children} } -function useCart() { +export function useCart() { return useCommerceCart() } - -const CartProvider: FunctionComponent = ({ children }) => { - return {children} -} - -export { CartProvider, useCart } diff --git a/lib/bigcommerce/index.tsx b/lib/bigcommerce/index.tsx index 4170deb87..006d5389c 100644 --- a/lib/bigcommerce/index.tsx +++ b/lib/bigcommerce/index.tsx @@ -1,9 +1,9 @@ +import { ReactNode } from 'react' import { + CommerceConfig, CommerceProvider as CoreCommerceProvider, - Connector, useCommerce as useCoreCommerce, } from 'lib/commerce' -import { ReactNode } from 'react' async function getText(res: Response) { try { @@ -31,19 +31,21 @@ async function fetcher(url: string, query: string) { throw await getError(res) } -export const bigcommerce: Connector = { +export const bigcommerceConfig: CommerceConfig = { locale: 'en-us', fetcher, } -interface Props { - children?: ReactNode | any +export type BigcommerceConfig = Partial + +export type BigcommerceProps = { + children?: ReactNode + config: BigcommerceConfig } -// TODO: The connector should be extendable when a developer is using it -export function CommerceProvider({ children }: Props) { +export function CommerceProvider({ children, config }: BigcommerceProps) { return ( - + {children} ) diff --git a/lib/commerce/cart.tsx b/lib/commerce/cart.tsx index ab9d6f70a..8c1335780 100644 --- a/lib/commerce/cart.tsx +++ b/lib/commerce/cart.tsx @@ -1,31 +1,27 @@ -import { createContext, useContext, FunctionComponent } from 'react' +import { createContext, useContext, FC } from 'react' import useSWR, { responseInterface } from 'swr' import { useCommerce } from '.' -interface Props { - children?: any -} -export type Cart = any - -export type CartResponse = responseInterface & { +export type CartResponse = responseInterface & { isEmpty: boolean } -const CartContext = createContext | any>(null) +export type CartProviderProps = + | { query: string; url?: string } + | { query?: string; url: string } + +const CartContext = createContext | null>(null) function getCartCookie() { // TODO: Figure how the cart should be persisted return null } -const CartProvider: FunctionComponent = ({ children }) => { - const { hooks, fetcher } = useCommerce() - const { useCart } = hooks +const CartProvider: FC = ({ children, query, url }) => { + const { fetcher } = useCommerce() const cartId = getCartCookie() - const response = useSWR( - () => (cartId ? [useCart.url, useCart.query, useCart.resolver] : null), - fetcher - ) + const response = useSWR(() => (cartId ? [url, query] : null), fetcher) + // TODO: Do something to make this prop work const isEmpty = true return ( @@ -35,7 +31,7 @@ const CartProvider: FunctionComponent = ({ children }) => { ) } -function useCart() { +function useCart() { return useContext(CartContext) as CartResponse } diff --git a/lib/commerce/index.tsx b/lib/commerce/index.tsx index 6849ed0b3..2659def45 100644 --- a/lib/commerce/index.tsx +++ b/lib/commerce/index.tsx @@ -1,29 +1,27 @@ import { createContext, ReactNode, useContext } from 'react' -const Commerce = createContext(null) +const Commerce = createContext(null) export type CommerceProps = { - children?: ReactNode | any - connector: Connector + children?: ReactNode + config: CommerceConfig } -export type Connector = { +export type CommerceConfig = { fetcher: Fetcher locale: string } export type Fetcher = (...args: any) => T | Promise -export function CommerceProvider({ children, connector }: CommerceProps) { - if (!connector) { - throw new Error( - 'CommerceProvider requires a valid headless commerce connector' - ) +export function CommerceProvider({ children, config }: CommerceProps) { + if (!config) { + throw new Error('CommerceProvider requires a valid config object') } - return {children} + return {children} } -export function useCommerce() { +export function useCommerce() { return useContext(Commerce) as T }