简体   繁体   中英

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. 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? 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

OR

  1. deploy package
  2. package along with dependencies and devDependencies are hosted online
  3. npm install $package will cause package to be built and and resulting bundle will be downloaded along with dependencies

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?

Dev dependencies are needed to modify the given library, they are not needed to use the library. 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. 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 . as the same way webpack use on development cycle

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?

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 .

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

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