简体   繁体   English

使用devDependencies部署NPM包时,何时进行构建?

[英]When does a build happen when you deploy a NPM package with devDependencies?

I see that most package.json have webpack and babel in their devDependency list. 我看到大多数package.json在他们的devDependency列表中都有webpackbabel So if these aren't needed in order to use that package, that must mean these devDependencies must be used before a project installs that package, right? 因此,如果不需要这些来使用该包,那必须意味着在项目安装该包之前必须使用这些devDependencies,对吧? When does this happen? 这是什么时候发生的? Does it look like any one of the below steps? 它看起来像下面的任何一个步骤?

  1. deploy package 部署包
  2. package gets built 包构建
  3. bundle along with dependencies are hosted online 捆绑包以及依赖项在线托管
  4. npm install $package will only get bundle and dependencies npm install $ package只会获得bundle和依赖项

OR 要么

  1. deploy package 部署包
  2. package along with dependencies and devDependencies are hosted online 包以及依赖项和devDependencies在线托管
  3. npm install $package will cause package to be built and and resulting bundle will be downloaded along with dependencies npm install $ package将导致生成包,并且生成的包将与依赖项一起下载

If devDependencies aren't in the picture at all, how does a package that relies on webpack and babel to transcompile its es6 into es5 work with a project that is only in es5? 如果devDependencies完全不在图片中,那么依赖webpack和babel将其es6转换为es5的包如何与仅在es5中的项目一起工作?

Dev dependencies are needed to modify the given library, they are not needed to use the library. 修改给定库需要Dev依赖项,使用库不需要它们。 When the library maintainer uploads the library to npm, they build the library using these dev dependencies first and then upload the files that were built. 当库维护者将库上传到npm时,他们首先使用这些dev依赖项构建库,然后上载构建的文件。 So you don't need to dev dependencies to use the library, the maintainer already did this build for you. 所以你不需要开发依赖项来使用库,维护者已经为你做了这个构建。

So to give your answer . 所以给你答案。 Lets talk about devdependency 让我们谈谈失去联系

babel is use for converting latest es6 uncomputable code to node.js uncomputable code . babel用于将最新的es6不可编译代码转换为node.js不可编译代码。 as the same way webpack use on development cycle 与webpack在开发周期中使用的方式相同

They are used at development time to easy the development code. 它们在开发时用于简化开发代码。

To give your question answer. 给你的问题答案。

that must mean these devDependencies must be used before a project installs that package, right? 这必须意味着必须在项目安装该软件包之前使用这些devDependencies,对吧?

Yes they are used when the package is develop by it developer . 是的,它们是在开发人员开发包时使用的。

When does this happen? 这是什么时候发生的?

when any person develop the package . 当任何人开发包装时。 for example you create a project and want to minify the js file the include the js minifier on the process of development . 例如,您创建一个项目,并希望缩小js文件,包括开发过程中的js minifier。

Does it look like any one of the below steps? 它看起来像下面的任何一个步骤?

deploy package (create a package)
package gets built 
bundle along with dependencies are hosted online
npm install $package will only get bundle and dependencies

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

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