简体   繁体   English

在 angular 材料中从桶进口迁移到单个进口有什么好处 9

[英]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".无法再通过“@angular/material”导入组件。 Use the individual secondary entry-points, such as @angular/material/button.使用单独的辅助入口点,例如 @angular/material/button。

source: https://github.com/angular/components/blob/master/CHANGELOG.md#material-14来源: 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.当您只使用 10% 的导入代码并且库很大时,这尤其痛苦。

For this reason, lot's of libraries designed to support individual imports (like above) to allow you to use only things you really need.出于这个原因,许多库旨在支持单独的导入(如上),以允许您只使用您真正需要的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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