Skip to content

Commit 55f161e

Browse files
committed
chore: remove dependency on semver
1 parent e476957 commit 55f161e

File tree

5 files changed

+8
-36
lines changed

5 files changed

+8
-36
lines changed

package-lock.json

Lines changed: 1 addition & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@
6868
"engines": {
6969
"node": ">=20"
7070
},
71-
"dependencies": {
72-
"semver": "^7.7.2"
73-
},
7471
"peerDependencies": {
7572
"@fortawesome/fontawesome-svg-core": "~6 || ~7",
7673
"react": "^18.0.0 || ^19.0.0"
@@ -96,7 +93,6 @@
9693
"@types/jest": "^30.0.0",
9794
"@types/react": "^19.1.10",
9895
"@types/react-dom": "^19.1.7",
99-
"@types/semver": "^7.7.0",
10096
"browserslist": "^4.25.3",
10197
"caniuse-lite": "^1.0.30001736",
10298
"cross-env": "^10.0.0",

src/components/__tests__/FontAwesomeIcon.test.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ import React from 'react'
33
import * as fontawesome from '@fortawesome/fontawesome-svg-core'
44
import { faBacon, faTimes } from '@fortawesome/free-solid-svg-icons'
55
import { render, screen } from '@testing-library/react'
6-
import semver from 'semver'
76

8-
import {
9-
ICON_PACKS_STARTING_VERSION,
10-
SVG_CORE_VERSION,
11-
} from '../../utils/constants'
7+
import { IS_VERSION_7_OR_LATER } from '../../utils/constants'
128
import { faCoffee, faCircle, faSpartan } from '../__fixtures__/icons'
139
import { FontAwesomeIcon } from '../FontAwesomeIcon'
1410

@@ -241,7 +237,7 @@ describe('FontAwesomeIcon', () => {
241237
expect(element).toHaveClass('fa-border')
242238
})
243239

244-
if (semver.lt(SVG_CORE_VERSION, ICON_PACKS_STARTING_VERSION)) {
240+
if (!IS_VERSION_7_OR_LATER) {
245241
test('using fixedWidth', () => {
246242
render(<FontAwesomeIcon icon={faCoffee} fixedWidth />)
247243

@@ -661,7 +657,7 @@ describe('FontAwesomeIcon', () => {
661657
})
662658
})
663659

664-
if (semver.lt(SVG_CORE_VERSION, ICON_PACKS_STARTING_VERSION)) {
660+
if (!IS_VERSION_7_OR_LATER) {
665661
describe('title', () => {
666662
test('will not add a title element', () => {
667663
render(<FontAwesomeIcon icon={faCoffee} />)
@@ -746,7 +742,7 @@ describe('FontAwesomeIcon', () => {
746742
})
747743
})
748744

749-
if (semver.lt(SVG_CORE_VERSION, ICON_PACKS_STARTING_VERSION)) {
745+
if (!IS_VERSION_7_OR_LATER) {
750746
describe('using titleId', () => {
751747
test('setting titleId prop reflects in the aria-labelledby attribute', () => {
752748
const titleId = 'foo'

src/utils/__tests__/get-class-list-from-props.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import {
33
RotateProp,
44
SizeProp,
55
} from '@fortawesome/fontawesome-svg-core'
6-
import semver from 'semver'
76

87
import { FontAwesomeIconProps } from '../../types/icon-props'
9-
import { ICON_PACKS_STARTING_VERSION, SVG_CORE_VERSION } from '../constants'
8+
import { IS_VERSION_7_OR_LATER } from '../constants'
109
import { getClassListFromProps } from '../get-class-list-from-props'
1110

1211
describe('get class list', () => {
@@ -48,7 +47,7 @@ describe('get class list', () => {
4847
]
4948

5049
// Add version 7 specific classes if using version 7 or later
51-
if (semver.gte(SVG_CORE_VERSION, ICON_PACKS_STARTING_VERSION)) {
50+
if (IS_VERSION_7_OR_LATER) {
5251
expectedClasses.push('fa-rotate-by', 'fa-width-auto')
5352
}
5453

src/utils/constants.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ import {
44
RotateProp,
55
SizeProp,
66
} from '@fortawesome/fontawesome-svg-core'
7-
import semver from 'semver'
8-
9-
export const ICON_PACKS_STARTING_VERSION = '7.0.0'
10-
11-
const FA_VERSION =
12-
(typeof process !== 'undefined' && process.env.FA_VERSION) || '7.0.0'
137

148
// Try to get version from installed package first, fallback to env var, then default
159
export const SVG_CORE_VERSION =
@@ -19,10 +13,7 @@ export const SVG_CORE_VERSION =
1913
('searchPseudoElementsFullScan' in config ? '7.0.0' : '6.0.0') || FA_VERSION
2014

2115
// Cache the version check result since it never changes during runtime
22-
export const IS_VERSION_7_OR_LATER = semver.gte(
23-
SVG_CORE_VERSION,
24-
ICON_PACKS_STARTING_VERSION,
25-
)
16+
export const IS_VERSION_7_OR_LATER = SVG_CORE_VERSION.startsWith('7.')
2617

2718
export const ANIMATION_CLASSES = {
2819
beat: 'fa-beat',

0 commit comments

Comments
 (0)