Skip to content

Commit a9b55ad

Browse files
authored
chore(clerk-js): Avoid bundling swr in the main chunk (#5551)
1 parent 9b0faec commit a9b55ad

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

.changeset/true-tables-sleep.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/clerk-js/bundlewatch.config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"files": [
33
{ "path": "./dist/clerk.js", "maxSize": "590kB" },
4-
{ "path": "./dist/clerk.browser.js", "maxSize": "81KB" },
4+
{ "path": "./dist/clerk.browser.js", "maxSize": "72.5KB" },
55
{ "path": "./dist/clerk.headless*.js", "maxSize": "55KB" },
6-
{ "path": "./dist/ui-common*.js", "maxSize": "96KB" },
7-
{ "path": "./dist/vendors*.js", "maxSize": "35KB" },
6+
{ "path": "./dist/ui-common*.js", "maxSize": "98KB" },
7+
{ "path": "./dist/vendors*.js", "maxSize": "36KB" },
88
{ "path": "./dist/coinbase*.js", "maxSize": "35.5KB" },
99
{ "path": "./dist/createorganization*.js", "maxSize": "5KB" },
1010
{ "path": "./dist/impersonationfab*.js", "maxSize": "5KB" },

packages/clerk-js/src/ui/Components.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useSafeLayoutEffect } from '@clerk/shared/react';
21
import { createDeferredPromise } from '@clerk/shared/utils';
32
import type {
43
__experimental_CheckoutProps,
@@ -48,6 +47,11 @@ import {
4847
} from './lazyModules/providers';
4948
import type { AvailableComponentProps } from './types';
5049

50+
/**
51+
* Avoid importing from `@clerk/shared/react` to prevent extra dependencies being added to the bundle.
52+
*/
53+
export const useSafeLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
54+
5155
const ROOT_ELEMENT_ID = 'clerk-components';
5256

5357
export type ComponentControls = {

packages/clerk-js/src/ui/elements/Drawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useSafeLayoutEffect } from '@clerk/shared/react/index';
1+
import { useSafeLayoutEffect } from '@clerk/shared/react';
22
import type { UseDismissProps, UseFloatingOptions, UseRoleProps } from '@floating-ui/react';
33
import {
44
FloatingFocusManager,

0 commit comments

Comments
 (0)