Skip to content

Commit b3a98ba

Browse files
authored
Use import for focus-visible instead of require (#2149)
1 parent e5be3db commit b3a98ba

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

.changeset/rude-buckets-fold.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
Converted commonjs `require` of `focus-visible` to an esm `import`

@types/focus-visible/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module 'focus-visible'

src/BaseStyles.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import {COMMON, SystemCommonProps, SystemTypographyProps, TYPOGRAPHY} from './co
44
import {useTheme} from './ThemeProvider'
55
import {ComponentProps} from './utils/types'
66

7+
// load polyfill for :focus-visible
8+
import 'focus-visible'
9+
710
const GlobalStyle = createGlobalStyle<{colorScheme?: 'light' | 'dark'}>`
811
* { box-sizing: border-box; }
912
body { margin: 0; }
@@ -36,9 +39,6 @@ function BaseStyles(props: BaseStylesProps) {
3639
const {children, ...rest} = props
3740
const {colorScheme} = useTheme()
3841

39-
// load polyfill for :focus-visible
40-
require('focus-visible')
41-
4242
return (
4343
<Base {...rest} data-portal-root>
4444
<GlobalStyle colorScheme={colorScheme?.includes('dark') ? 'dark' : 'light'} />

0 commit comments

Comments
 (0)