UNPKG

3.91 kBMarkdownView Raw
1# Upgrading Guide
2
3See the [CHANGELOG.md](./CHANGELOG.md) for detailed information about what has changed between versions.
4
5This guide is useful to figure out what you need to do between breaking changes.
6
7As always, [submit issues](https://github.com/FortAwesome/vue-fontawesome/issues/new) that you run into with this guide or with these upgrades to us.
8
9## 0.0.x to 0.1.0
10
11### Renamed packages
12
13The following packages have been renamed as part of 5.1.0 of Font Awesome.
14
15_All packages are in the [@fortawesome NPM scope](https://www.npmjs.com/search?q=scope:fortawesome&page=1&ranking=optimal)_
16
17| Old package(1) | New package |
18|--------------------------|------------------------|
19| fontawesome | fontawesome-svg-core |
20| fontawesome-free-solid | free-solid-svg-icons |
21| fontawesome-free-regular | free-regular-svg-icons |
22| fontawesome-free-brands | free-brands-svg-icons |
23| fontawesome-pro-solid | pro-solid-svg-icons |
24| fontawesome-pro-regular | pro-regular-svg-icons |
25| fontawesome-pro-light | pro-light-svg-icons |
26
27(1) Old packages have now been deprecated. They are still available but will only receive high priority patch release fixes.
28
29**You'll need to update your package.json file with the renamed packages and new versions.**
30
31### No more default imports
32
33Recently we spent a good deal of time supporting TypeScript to enable us to
34create the Angular Font Awesome component. During that adventure we
35[were](https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html)
36[convinced](https://blog.neufund.org/why-we-have-banned-default-exports-and-you-should-do-the-same-d51fdc2cf2ad)
37that we were going to remove default exports from all of our components,
38libraries, and packages. This is complete with the umbrella release of `5.1.0` of Font Awesome.
39
40What does that mean?
41
42~~Old way:~~
43
44```javascript
45import fontawesome from '@fortawesome/fontawesome'
46import solid from '@fortawesome/fontawesome-free-solid'
47import faTwitter from '@fortawesome/fontawesome-free-brands/faTwitter'
48import FontAwesomeIcon from '@fortawesome/vue-fontawesome'
49
50fontawesome.library.add(solid, faTwitter)
51```
52
53New way:
54
55```javascript
56import { library } from '@fortawesome/fontawesome-svg-core'
57import { fas } from '@fortawesome/free-solid-svg-icons'
58import { faTwitter } from '@fortawesome/free-brands-svg-icons'
59import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
60
61library.add(fas, faTwitter)
62```
63
64This is also a valid way to import icons that works if your tool does not support tree shaking:
65
66```javascript
67import { faTwitter } from '@fortawesome/free-brands-svg-icons/faTwitter'
68```
69
70### Improved support for tree shaking
71
72Tree shaking is now functional by default and no additional configuration is required to make it work.
73
74The `shakable.es.js` module has been removed and is no longer needed.
75
76If you've previously configured tree shaking by modifying your webpack or rollup you can safely remove these.
77
78**We recommend that you check your bundle size after upgrading an ensure that file sizes are as you would expect.**
79
80```javascript
81module.exports = {
82 // ...
83 resolve: {
84 alias: {
85 '@fortawesome/fontawesome-free-solid$': '@fortawesome/fontawesome-free-solid/shakable.es.js'
86 }
87 }
88}
89```
90
91```javascript
92const alias = require('rollup-plugin-alias')
93
94rollup({
95 // ...
96 plugins: [
97 alias({
98 '@fortawesome/fontawesome-free-solid': 'node_modules/@fortawesome/fontawesome-free-solid/shakable.es.js'
99 })
100 ]
101})
102```
103
104### Mixed modes with automatic replacement of `<i>` tags to `<svg>`
105
106If you were previously relying on Font Awesome to replace any `<i>` tags in
107your page or app with `<svg>` you'll need to explicitly control that now.
108
109```javascript
110import { dom } from '@fortawesome/fontawesome-svg-core'
111
112dom.watch() // This will kick of the replacement of i tags and configure a MutationObserver
113```