简体   繁体   中英

What is the benefit with migration from barrel imports to individual imports in angular material 9

material Breaking changes:

Components can no longer be imported through "@angular/material". Use the individual secondary entry-points, such as @angular/material/button.

source: https://github.com/angular/components/blob/master/CHANGELOG.md#material-14

One main benefit - Performance

When you import like:

import perfrunner from 'perfrunner'

You importing the whole library into your code.

If you don't have tree shaking or it works not good enough - your application bundle might be significantly increased. This will lead to performance issues because bigger bundles load slower and parse slower. This is especially painful when you are using only 10% of the imported code and the library is big.

For this reason, lot's of libraries designed to support individual imports (like above) to allow you to use only things you really need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM