From 566052ce134ed97e288e8d47bd0b010517c03e1a Mon Sep 17 00:00:00 2001 From: Yaroslav Admin Date: Mon, 20 May 2024 21:57:30 +0200 Subject: [PATCH] Make @fortawesome/fontawesome-svg-core a regular dependency Fixes #230 --- .github/workflows/check.yml | 2 +- README.md | 2 -- docs/upgrading/0.14.0-0.15.0.md | 15 +++++++++++++++ ng-package.json | 3 ++- package.json | 5 ++--- projects/schematics/src/ng-add/index.spec.ts | 2 -- projects/schematics/src/ng-add/index.ts | 6 ------ projects/schematics/src/ng-add/versions.ts | 1 - src/lib/public_api.ts | 12 ++++++++++++ src/lib/shared/models/props.model.ts | 15 +-------------- yarn.lock | 20 +++++++++++++------- 11 files changed, 46 insertions(+), 37 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 9f27399..e762c23 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -15,7 +15,7 @@ jobs: key: ${{ hashFiles('yarn.lock') }} - run: corepack enable - run: yarn - - run: yarn add -D @fortawesome/fontawesome-svg-core@1.2.36 @fortawesome/free-regular-svg-icons@5.15.4 @fortawesome/free-solid-svg-icons@5.15.4 + - run: yarn add -D @fortawesome/free-regular-svg-icons@5.15.4 @fortawesome/free-solid-svg-icons@5.15.4 - run: yarn format:enforce - run: yarn lint - run: yarn test diff --git a/README.md b/README.md index a2eb525..bd7d8dd 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,6 @@ $ ng add @fortawesome/angular-fontawesome@ Using [Yarn](https://yarnpkg.com) ``` -$ yarn add @fortawesome/fontawesome-svg-core $ yarn add @fortawesome/free-solid-svg-icons # See Compatibility table below to choose a correct version $ yarn add @fortawesome/angular-fontawesome@ @@ -29,7 +28,6 @@ $ yarn add @fortawesome/angular-fontawesome@ Using [NPM](https://www.npmjs.com/) ``` -$ npm install @fortawesome/fontawesome-svg-core $ npm install @fortawesome/free-solid-svg-icons # See Compatibility table below to choose a correct version $ npm install @fortawesome/angular-fontawesome@ diff --git a/docs/upgrading/0.14.0-0.15.0.md b/docs/upgrading/0.14.0-0.15.0.md index 686cb43..a0a527e 100644 --- a/docs/upgrading/0.14.0-0.15.0.md +++ b/docs/upgrading/0.14.0-0.15.0.md @@ -30,3 +30,18 @@ export class AppComponent { ``` Not doing this should not cause any issues, but it will lead to same styles being added twice to the page. + +## @fortawesome/fontawesome-svg-core became a regular dependency + +Previously, `@fortawesome/fontawesome-svg-core` was a peer dependency. Now it is a regular dependency. This means that you don't have to add it to your `package.json` file anymore. Unless you use it directly for [advanced cases](https://github.com/FortAwesome/angular-fontawesome/blob/main/docs/guide/advanced-uses.md), you can remove the dependency: + +```bash +$ npm uninstall @fortawesome/fontawesome-svg-core +``` + +If you import any types from `@fortawesome/fontawesome-svg-core`, you should import them from `@fortawesome/angular-fontawesome` instead, e.g: + +```diff +-import { IconDefinition } from '@fortawesome/fontawesome-svg-core'; ++import { IconDefinition } from '@fortawesome/angular-fontawesome'; +``` diff --git a/ng-package.json b/ng-package.json index 698c7f8..5f236b1 100644 --- a/ng-package.json +++ b/ng-package.json @@ -4,5 +4,6 @@ "entryFile": "src/lib/public_api.ts", "flatModuleFile": "angular-fontawesome" }, - "dest": "./dist/angular-fontawesome" + "dest": "./dist/angular-fontawesome", + "allowedNonPeerDependencies": ["@fortawesome/fontawesome-svg-core"] } diff --git a/package.json b/package.json index 99562c0..9386dc7 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "@angular/platform-server": "^17.0.0", "@angular/router": "^17.0.0", "@angular/ssr": "^17.0.0", - "@fortawesome/fontawesome-svg-core": "^6.4.2", "@fortawesome/free-regular-svg-icons": "^6.4.2", "@fortawesome/free-solid-svg-icons": "^6.4.2", "@types/express": "^4.17.17", @@ -79,6 +78,7 @@ "zone.js": "~0.14.2" }, "dependencies": { + "@fortawesome/fontawesome-svg-core": "^6.5.2", "tslib": "^2.6.2" }, "keywords": [ @@ -90,8 +90,7 @@ "svg" ], "peerDependencies": { - "@angular/core": "^17.0.0", - "@fortawesome/fontawesome-svg-core": "~1.2.27 || ~1.3.0-beta2 || ^6.1.0" + "@angular/core": "^17.0.0" }, "schematics": "./schematics/collection.json", "packageManager": "yarn@4.0.1" diff --git a/projects/schematics/src/ng-add/index.spec.ts b/projects/schematics/src/ng-add/index.spec.ts index 3438ac1..a3173c4 100644 --- a/projects/schematics/src/ng-add/index.spec.ts +++ b/projects/schematics/src/ng-add/index.spec.ts @@ -17,7 +17,6 @@ describe('ng-add', () => { const dependencies = packageJson.dependencies; - expect(dependencies['@fortawesome/fontawesome-svg-core']).toBe(iconPackVersion); expect(dependencies['@fortawesome/free-solid-svg-icons']).toBe(iconPackVersion); expect(dependencies['@fortawesome/angular-fontawesome']).toBe(angularFontawesomeVersion); }); @@ -32,7 +31,6 @@ describe('ng-add', () => { const dependencies = packageJson.dependencies; - expect(dependencies['@fortawesome/fontawesome-svg-core']).toBe(v5.svgCoreVersion); expect(dependencies['@fortawesome/free-solid-svg-icons']).toBe(v5.iconPackVersion); expect(dependencies['@fortawesome/angular-fontawesome']).toBe(angularFontawesomeVersion); }); diff --git a/projects/schematics/src/ng-add/index.ts b/projects/schematics/src/ng-add/index.ts index 99bceb8..d49b5d1 100644 --- a/projects/schematics/src/ng-add/index.ts +++ b/projects/schematics/src/ng-add/index.ts @@ -17,12 +17,6 @@ import { angularFontawesomeVersion, iconPackVersion, v5 } from './versions'; export default function (options: Schema): Rule { return chain([ (tree: Tree, context: SchematicContext) => { - addPackageJsonDependency(tree, { - type: NodeDependencyType.Default, - name: '@fortawesome/fontawesome-svg-core', - version: options.version === '6' ? iconPackVersion : v5.svgCoreVersion, - }); - addPackageJsonDependency(tree, { type: NodeDependencyType.Default, name: '@fortawesome/angular-fontawesome', diff --git a/projects/schematics/src/ng-add/versions.ts b/projects/schematics/src/ng-add/versions.ts index 877759d..9b16f91 100644 --- a/projects/schematics/src/ng-add/versions.ts +++ b/projects/schematics/src/ng-add/versions.ts @@ -2,6 +2,5 @@ export const angularFontawesomeVersion = '~0.14.0'; export const iconPackVersion = '^6.4.2'; export const v5 = { - svgCoreVersion: '~1.2.36', iconPackVersion: '^5.15.4', }; diff --git a/src/lib/public_api.ts b/src/lib/public_api.ts index d9b69fb..bd02a60 100644 --- a/src/lib/public_api.ts +++ b/src/lib/public_api.ts @@ -10,3 +10,15 @@ export { FaStackComponent } from './stack/stack.component'; export { FaStackItemSizeDirective } from './stack/stack-item-size.directive'; export { FaIconLibrary, FaIconLibraryInterface } from './icon-library'; export { IconPrefix, IconName, IconLookup, IconDefinition, IconPack } from './types'; + +export { + IconParams, + CounterParams, + TextParams, + FaSymbol, + FlipProp, + PullProp, + RotateProp, + SizeProp, + Transform, +} from '@fortawesome/fontawesome-svg-core'; diff --git a/src/lib/shared/models/props.model.ts b/src/lib/shared/models/props.model.ts index 5d65e89..90e234b 100644 --- a/src/lib/shared/models/props.model.ts +++ b/src/lib/shared/models/props.model.ts @@ -1,19 +1,9 @@ -import { - FaSymbol, - FlipProp, - PullProp, - RotateProp, - SizeProp, - Styles, - Transform, -} from '@fortawesome/fontawesome-svg-core'; -import { IconProp } from '../../types'; +import { FlipProp, PullProp, RotateProp, SizeProp } from '@fortawesome/fontawesome-svg-core'; /** * Fontawesome props. */ export interface FaProps { - mask?: IconProp; className?: string; animation?: AnimationProp; border?: boolean; @@ -24,9 +14,6 @@ export interface FaProps { size?: SizeProp; pull?: PullProp; rotate?: RotateProp; - transform?: string | Transform; - symbol?: FaSymbol; - style?: Styles; stackItemSize?: '1x' | '2x'; } diff --git a/yarn.lock b/yarn.lock index 2dfc6a8..2925c1e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2779,7 +2779,7 @@ __metadata: "@angular/platform-server": "npm:^17.0.0" "@angular/router": "npm:^17.0.0" "@angular/ssr": "npm:^17.0.0" - "@fortawesome/fontawesome-svg-core": "npm:^6.4.2" + "@fortawesome/fontawesome-svg-core": "npm:^6.5.2" "@fortawesome/free-regular-svg-icons": "npm:^6.4.2" "@fortawesome/free-solid-svg-icons": "npm:^6.4.2" "@types/express": "npm:^4.17.17" @@ -2812,7 +2812,6 @@ __metadata: zone.js: "npm:~0.14.2" peerDependencies: "@angular/core": ^17.0.0 - "@fortawesome/fontawesome-svg-core": ~1.2.27 || ~1.3.0-beta2 || ^6.1.0 languageName: unknown linkType: soft @@ -2823,12 +2822,19 @@ __metadata: languageName: node linkType: hard -"@fortawesome/fontawesome-svg-core@npm:^6.4.2": - version: 6.4.2 - resolution: "@fortawesome/fontawesome-svg-core@npm:6.4.2" +"@fortawesome/fontawesome-common-types@npm:6.5.2": + version: 6.5.2 + resolution: "@fortawesome/fontawesome-common-types@npm:6.5.2" + checksum: 12104e93a0056ad1077f7350826f52aa26465bb1d6b4ce75dab0307072a3871301ec750c3a34d89d05e7338c9b446fa2793150cf58a5167217021943ef877d77 + languageName: node + linkType: hard + +"@fortawesome/fontawesome-svg-core@npm:^6.5.2": + version: 6.5.2 + resolution: "@fortawesome/fontawesome-svg-core@npm:6.5.2" dependencies: - "@fortawesome/fontawesome-common-types": "npm:6.4.2" - checksum: 1d53c9f3c47aba71718dc701c97df356407f55d702f104f4fe685688a76d07706df6d0eca6307a33c62705c90051f63faeb483b5e2f89f0588ed441fa9c36d4c + "@fortawesome/fontawesome-common-types": "npm:6.5.2" + checksum: 91695dd375623988d16e6f0dc69d20350ef3fa3296fe40aa08877aae7beaf64378134656a2227419fe648dcd27a81c03fe1fd9a6c87956d863164b0380ba77d0 languageName: node linkType: hard