Your detailed guide to the five types of addiction
Hello, Khabrovites. For future students on the course "JavaScript Developer. Professional" prepared a translation of the material.
We also invite everyone to an open webinar on the topic "Vue 3 - the capabilities of the new version of one of the most popular front-end frameworks . " In the lesson, the participants, together with an expert:
- Consider the key differences in the syntax of vue2 from vue3;
- will understand how to work with vue-router and VueX in the new version of the framework;
- create a Vue 3 project from scratch using Vue-cli.
Whether you're a back-end developer working with Node.js or a front-end developer using Node.js only as a packaging and bundling tool, you've probably stumbled upon a dependency system.
5 (, , 5 ), ? , , .
. . .
Normal (runtime) dependencies (c ( ) )
, ?
β , "dependencies" package.json
. ( ) (), NPM (node package manager ) ( npmjs.org
).
, . :
. , (.. >1.2.0 ), (.. <=1.2.0 ), (.. >= , > , <) . ~ (.. "lodash":"~1.2.2, 1.2.2 1.3.0 , , ). "" , semver (.. "lodash": "^1.2.0", , - ).
URL-. , URL, - (, Github tarball-).
. , . , , NPM. " " . , , , -
file://
.
?
, , .
, , , , , . , React Babel, , , , , , ( , ).
, , , , , .
. . .
Peer dependencies ( )
Peer dependencies β , , , , , , . , .
, , ? , , Babel, Babel , , , , Babel -.
, , Babel , , , Babel. , , NPM, , β Babel -, .
Peer dependencies?
Peer dependencies , , , , .
:
, . peer dependency.
, . peer dependency.
, peerDependencies, :
Babel . , Babel, (peer dependency).
Express middleware packages (- ): NPM, peer dependencies. Express , , (middleware) .
Micro Frontend (), , ( ), . Peer dependencies .
Bit components. front-end , , React- Bit (Github), react peer dependency. , .
, React , : , ( , ).
component, Bitβs component hub.
, , package.json, peer dependencies:
, , , React-.
(1KB) β .
. . .
Dev Dependencies (Dev )
, ? , , , , ? .
(Development dependencies) , , .
, , , (linting tools), .
, , dev dependency.
, npm install
npm link
.
, , . , dev dependencies.
dev dependencies?
, , , dev dependencies ( ).
, , -.
- dev- , , npm install
-, dev- .
Dev , .
. . .
(Bundled Dependencies)
, . npm pack
, (tarball-).
, bundledDependencies
( : bundleDependencies
, ), .
{
...
"dependencies": {
"lodash": "1.0.2",
"request": "4.0.1"
},
"bundledDependencies": ["lodash"]
...
}
package.json
, , npm pack
tarball
, lodash
.
(, URL ).
. . .
(Optional dependencies)
, , , . ? NPM , , .
, npm install
- ( - , , - ), .
NPM . , , , :
let foo = null;
try {
foo = require("foo-dep");
} catch (e) {
foo = require("./local-polyfill")
}
//... use foo from here on out
(optional dependencies)?
β . , ? . , , , , , .
, (optional dependencies). , , , CI(Continuous Integration)-. , , , , .
npm install
, , npm install --no-optional
, . , .
. . .
, - NPM , dev-. 3, , .
, , .
, ? , , !
"JavaScript Developer. Professional".