摇动树的角度10是‘摇动’出我的AsyncPipe。
角10的发布笔记博客条目为ng new引入了一种新的--strict模式
这样做的一件事是:
将您的应用程序配置为免费的副作用,以启用更高级的树抖动功能。
官方文件说:
当您使用严格模式创建项目和工作区时,您会注意到一个额外的package.json文件,位于src/app/目录中。此文件通知工具和绑定程序,此目录下的代码不存在非本地副作用。
这是那个package.json的内容
{
"name": "heroes",
"private": true,
"description_1": "This is a special package.json file that is not used by package managers.",
"description_2": "It is used to tell the tools and bundlers whether the code under this directory is free of code with non-local side-effect. Any code that does have non-local side-effects can't be well optimized (tree-shaken) and will result in unnecessary increased payload size.",
"description_3": "It should be safe to set this option to 'false' for new applications, but existing code bases could be broken when built with the production config if the application code does contain non-local side-effects that the application depends on.",
"description_4": "To learn more about this file see: https://angular.io/config/app-package-json.",
"sideEffects": false
}太棒了!我想。我喜欢更多的树摇动。
然而,它赶走了AsyncPipe,我不知道为什么。我在一个很大的网站上到处使用它--我不知道它怎么可能被优化掉。
它只在优化的--prod构建中这样做。当我把它改为sideEffects: true时,它又起作用了。
发布于 2020-08-06 12:07:47
发布于 2021-02-11 15:46:40
我只是遇到了这种“太大的树抖动”的问题,我的角度10应用程序和生产构建(使用optimization=true,这使树摇动的东西)。
在我的例子中,这是被破坏的DatePipe ({{value | date}})。
这会导致区域设置未定义的错误,而应该是错误的(如果在没有优化的情况下在开发模式下为应用提供服务也是可以的)
ERROR Error: InvalidPipeArgument: 'Missing locale data for the locale "fr".' for pipe 'e'这里有更多详细信息:角"InvalidPipeArgument:缺少区域数据“在构建或与optimization=true一起使用时(--prod选项)
https://stackoverflow.com/questions/62617305
复制相似问题