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 react-query-devtools from production build #1121

Merged
merged 14 commits into from
Apr 12, 2023
8 changes: 8 additions & 0 deletions .github/actions/bundle_size_test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: bundlesize
runs:
using: composite
steps:
- name: Check bundle size
run: |-
npm run test:max-file-size
shell: bash
3 changes: 0 additions & 3 deletions .github/actions/unit_tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ runs:
# Note: Each of these test commands need to be exposed on the monorepo
# root and *also* on the PWA package. This section is run on both.

# Ensure bundlesize is in check
npm run test:max-file-size

# Always run fast unit tests
npm run test
shell: bash
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ jobs:
- name: Run unit tests
uses: "./.github/actions/unit_tests"

- name: Run bundlesize test
uses: "./.github/actions/bundle_size_test"

- name: Smoke test scripts
if: env.IS_DEFAULT_NPM == 'true'
uses: "./.github/actions/smoke_tests"
Expand Down
156 changes: 12 additions & 144 deletions packages/commerce-sdk-react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/commerce-sdk-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
},
"devDependencies": {
"@tanstack/react-query": "^4.28.0",
"@tanstack/react-query-devtools": "^4.28.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^12.1.5",
"@testing-library/react-hooks": "^8.0.1",
Expand Down
2 changes: 0 additions & 2 deletions packages/commerce-sdk-react/src/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
} from 'commerce-sdk-isomorphic'
import Auth from './auth'
import {ApiClientConfigParams, ApiClients} from './hooks/types'
import {ReactQueryDevtools} from '@tanstack/react-query-devtools'

export interface CommerceApiProviderProps extends ApiClientConfigParams {
children: React.ReactNode
Expand Down Expand Up @@ -153,7 +152,6 @@ const CommerceApiProvider = (props: CommerceApiProviderProps): ReactElement => {
<CommerceApiContext.Provider value={apiClients}>
<AuthContext.Provider value={auth}>{children}</AuthContext.Provider>
</CommerceApiContext.Provider>
<ReactQueryDevtools />
</ConfigContext.Provider>
)
}
Expand Down
9 changes: 6 additions & 3 deletions packages/pwa-kit-dev/src/configs/webpack/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,12 @@ const withChunking = (config) => {
splitChunks: {
cacheGroups: {
vendor: {
// Anything imported from node_modules lands in
// vendor.js, if we're chunking.
test: /node_modules/,
// Two scenarios that we'd like to chunk vendor.js:
// 1. The package is in node_modules
// 2. The package is one of the monorepo packages.
// This is for local development to ensure the bundle
// composition is the same as a production build
test: /(node_modules)|(packages\/.*\/dist)/,
name: 'vendor',
chunks: 'all'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {withLegacyGetProps} from 'pwa-kit-react-sdk/ssr/universal/components/wit
import {withReactQuery} from 'pwa-kit-react-sdk/ssr/universal/components/with-react-query'
import {useCorrelationId} from 'pwa-kit-react-sdk/ssr/universal/hooks'
import {getAppOrigin} from 'pwa-kit-react-sdk/utils/url'
import {ReactQueryDevtools} from '@tanstack/react-query-devtools'

/**
* Use the AppConfig component to inject extra arguments into the getProps
Expand Down Expand Up @@ -57,6 +58,7 @@ const AppConfig = ({children, locals = {}}) => {
<MultiSiteProvider site={locals.site} locale={locals.locale} buildUrl={locals.buildUrl}>
<ChakraProvider theme={theme}>{children}</ChakraProvider>
</MultiSiteProvider>
<ReactQueryDevtools />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the docs:

By default, React Query Devtools are only included in bundles when process.env.NODE_ENV === 'development', so you don't need to worry about excluding them during a production build.

👌

</CommerceApiProvider>
)
}
Expand Down
Loading