简体   繁体   English

我们真的需要以性能的名义从 devDependencies 中剥离包吗?

[英]Do we really need to strip packages from devDependencies in the name of performance?

We all know, in most of the cases, packages listed under devDependencies won't make it into your build.我们都知道,在大多数情况下,在devDependencies包不会进入您的构建。 So why do we strip them away in the name of performance?那么我们为什么要以性能的名义将它们剥离呢?

Eg I see many posts on Moment.js being replaced with another lightweight alternative, even if Moment.js is in devDependencies .例如,我看到很多关于 Moment.js 的帖子被另一种轻量级替代品所取代,即使 Moment.js 在devDependencies How does it impact, considering all the frameworks (Ember, React, Vue and Angular)?考虑到所有框架(Ember、React、Vue 和 Angular),它有何影响?

devDependencies do not exclude the possibility that the dependency is required to make a bundle during build time --they are within the bundle that webpack generates for a website-- but not required by the package/system that installs it for production: ie the server-package that installs the app-package. devDependencies排除在构建期间需要依赖项来制作包的可能性——它们在 webpack 为网站生成的包中——但安装它用于生产的包/系统不需要:即服务器-package 安装应用程序包。

For example: your package app builds moment.js into its distribution bundle.例如:您的包appmoment.js构建到其分发包中。 When you then install package app as a dependency in a separate server , it does not need to install moment.js , because it is already bundled within the app 's dist - so you explicitly put moment.js as a devDependency in app 's package.然后,当您将包app作为依赖项安装在单独的server ,它不需要安装moment.js ,因为它已经捆绑在app的 dist 中 - 因此您明确地将moment.js作为 devDependency 放在app的包裹。

Performance is a broad term.性能是一个广义的术语。 To some people, performance is only about production code.对某些人来说,性能仅与生产代码有关。 To others, performance of the build system matters.对于其他人来说,构建系统的性能很重要。 Removing unused devDependencies reduces build time and space, since npm needs to do less work.删除未使用的devDependencies可以减少构建时间和空间,因为npm需要做的工作更少。

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

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