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

Remove custom browser config from package.json #667

Merged
merged 10 commits into from
May 10, 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
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.325.0",
"version": "0.326.3-alpha.4",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
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
@@ -1,6 +1,6 @@
{
"name": "@vtex/gatsby-plugin-google-tag-manager",
"version": "0.325.0",
"version": "0.326.3-alpha.4",
"description": "Gatsby plugin for using Google Tag Manager with SFJ",
"main": "index.js",
"browser": "src/index.ts",
Expand All @@ -18,7 +18,7 @@
],
"license": "MIT",
"devDependencies": {
"@vtex/gatsby-theme-store": "^0.325.0",
"@vtex/gatsby-theme-store": "^0.326.3-alpha.4",
"cross-env": "^7.0.2",
"gatsby": "^3.1.1",
"typescript": "^4.1.2"
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
@@ -1,6 +1,6 @@
{
"name": "@vtex/gatsby-plugin-pixel-facebook",
"version": "0.325.0",
"version": "0.326.3-alpha.4",
"description": "Gatsby plugin for using Facebook Pixel with Store Framework Jamstack",
"main": "index.js",
"browser": "src/index.ts",
Expand All @@ -18,7 +18,7 @@
],
"license": "MIT",
"devDependencies": {
"@vtex/gatsby-theme-store": "^0.325.0",
"@vtex/gatsby-theme-store": "^0.326.3-alpha.4",
"cross-env": "^7.0.2",
"gatsby": "^3.1.1",
"typescript": "^4.1.2"
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-theme-store/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vtex/gatsby-theme-store",
"version": "0.325.0",
"version": "0.326.3-alpha.4",
"description": "Gatsby theme for building ecommerce websites",
"main": "index.js",
"module": "src/index.ts",
Expand Down Expand Up @@ -61,7 +61,7 @@
"@vtex/gatsby-plugin-theme-ui": "^0.325.0",
"@vtex/order-items": "^0.6.1",
"@vtex/order-manager": "^0.5.2",
"@vtex/store-ui": "^0.325.0",
"@vtex/store-ui": "^0.326.3-alpha.3",
"gatsby-plugin-bundle-stats": "^2.7.2",
"html-loader": "^2.1.2",
"intersection-observer": "^0.11.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ interface SiteLinksSearchBoxJSONLD {
}
}

export const useSiteLinksSearchBoxJsonLd = (_: Options): SiteLinksSearchBoxJSONLD => {
export const useSiteLinksSearchBoxJsonLd = (
_: Options
): SiteLinksSearchBoxJSONLD => {
const { host } = useLocation()
const url = `https://${host}`

Expand Down
24 changes: 9 additions & 15 deletions packages/gatsby-theme-store/src/gatsby-browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,16 @@ import ReactDOM from 'react-dom'
import type { WrapRootElementBrowserArgs } from 'gatsby'
import type { ElementType } from 'react'

// Webpack + TS magic to make this work
const {
Provider: OrderFormProvider,
} = require('./src/sdk/orderForm/LazyProvider')
const { Provider: RegionProvider } = require('./src/sdk/region/Provider')
const { Provider: MinicartProvider } = require('./src/sdk/minicart/Provider')
const { default: VTEXRCProvider } = require('./src/sdk/pixel/vtexrc/index')
const {
default: ErrorBoundary,
} = require('./src/components/Error/ErrorBoundary')
// eslint-disable-next-line padding-line-between-statements
const {
import { Provider as OrderFormProvider } from './sdk/orderForm/LazyProvider'
import { Provider as RegionProvider } from './sdk/region/Provider'
import { Provider as MinicartProvider } from './sdk/minicart/Provider'
import { Provider as ToastProvider } from './sdk/toast/Provider'
import { Provider as VTEXRCProvider } from './sdk/pixel/vtexrc/Provider'
import ErrorBoundary from './components/Error/ErrorBoundary'
import {
Progress,
onRouteUpdate: progressOnRouteUpdate,
} = require('./src/sdk/progress')
const { Provider: ToastProvider } = require('./src/sdk/toast/Provider')
onRouteUpdate as progressOnRouteUpdate,
} from './sdk/progress'

export const replaceHydrateFunction = () => async (
element: ElementType,
Expand Down
20 changes: 16 additions & 4 deletions packages/gatsby-theme-store/src/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,15 @@ const resolveToTS = (
file: 'gatsby-browser' | 'gatsby-ssr' | 'gatsby-node'
): Record<string, string> => {
const root = `${process.cwd()}/.cache`
const nextSeoFrom = relative(root, require.resolve(`${pkg}/${file}.js`))
const nextSeoTo = nextSeoFrom.replace(`/${file}.js`, `/src/${file}`)
const cjs = relative(
root,
require.resolve(`${pkg}/${file}.js`, { paths: [process.cwd()] })
)

const ts = cjs.replace(`/${file}.js`, `/src/${file}`)

return {
[nextSeoFrom]: nextSeoTo,
[cjs]: ts,
}
}

Expand Down Expand Up @@ -226,14 +230,22 @@ export const onCreateWebpackConfig = (
// it can tree shake it or not. This points the webpack directly to the source file so everything is imported
// using es6 and only the used packages are used
'gatsby-plugin-next-seo$': resolve(
require.resolve('gatsby-plugin-next-seo'),
require.resolve('gatsby-plugin-next-seo', { paths: [process.cwd()] }),
stage === 'build-javascript' || stage === 'develop'
? '../../src/index'
: ''
),
'@vtex/store-ui$': resolve(
require.resolve('@vtex/store-ui', { paths: [process.cwd()] }),
stage === 'build-javascript' || stage === 'develop'
? '../../src/index'
: ''
),
// Resolve to the .ts versions of gatsby-(browser|ssr) so we don't end up by adding the whole lib.
...resolveToTS('gatsby-plugin-next-seo', 'gatsby-browser'),
...resolveToTS('gatsby-plugin-next-seo', 'gatsby-ssr'),
...resolveToTS('@vtex/gatsby-theme-store', 'gatsby-browser'),
...resolveToTS('@vtex/gatsby-theme-store', 'gatsby-ssr'),
'@vtex/order-manager': require.resolve(
'@vtex/order-manager/src/index.tsx'
),
Expand Down
14 changes: 6 additions & 8 deletions packages/gatsby-theme-store/src/sdk/orderForm/LazyProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC, PropsWithChildren } from 'react'
import React, { Fragment, lazy, Suspense } from 'react'
import type { FC } from 'react'

const isOfflinePage = window.location.pathname.startsWith('/offline')

Expand All @@ -19,10 +19,8 @@ const LazyProvider = lazy(() =>
})
)

export const Provider = ({ children }: PropsWithChildren<null>) => {
return (
<Suspense fallback={null}>
<LazyProvider>{children}</LazyProvider>
</Suspense>
)
}
export const Provider: FC = ({ children }) => (
<Suspense fallback={null}>
<LazyProvider>{children}</LazyProvider>
</Suspense>
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (!window.vtexrca) {
})
}

const Provider: FC = ({ children }) => {
export const Provider: FC = ({ children }) => {
useLazyScript({
src: 'https://io.vtex.com.br/rc/rc.js',
id: 'async-vtex-rc',
Expand All @@ -39,5 +39,3 @@ const Provider: FC = ({ children }) => {

return <Fragment>{children}</Fragment>
}

export default Provider
3 changes: 1 addition & 2 deletions packages/store-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"name": "@vtex/store-ui",
"version": "0.325.0",
"version": "0.326.3-alpha.3",
"description": "Next store component library",
"author": "emersonlaurentino",
"license": "MIT",
"repository": "vtex/gatsby-vtex",
"main": "dist/index.js",
"browser": "src/index.tsx",
"module": "dist/store-ui.esm.js",
"typings": "dist/index.d.ts",
"sideEffects": false,
Expand Down