JavaScript dependency management

JavaScript dependency management



Hello! My name is Slava Fomin, I am a lead developer at DomClick. During my 16 years of practice, I have been at the forefront of the emergence and development of JavaScript as a standard and ecosystem. In our company, we use JavaScript, first of all, for advanced front-end development and have managed to try a fairly large number of different technologies, tools and approaches, and get a lot of shots. The result of this painstaking work was the most valuable experience that I want to share with you.



, , , . , , . , , .



, :



  • , .
  • .
  • semver .
  • , .
  • (resolving).
  • .
  • .
  • , .
  • lock- .
  • , .
  • , .
  • CI/CD.
  • .


, !



… , ; , , , , , , , …



, , -, , . , - , ?



-, - . , , , Angular, React, Express, Lodash, Webpack , .



JavaScript



« », ( jQuery) , . , : . , . .



, , . , , .



Node.js



- Node.js, , , JavaScript-, front-end , , SSR . , Node.js (Node Package Manager, npm), , JavaScript.



, ESM JavaScript : script . Node . CommonJS ( «/ JavaScript», CJS), - . Node (Node.js module resolution algorithm) , .





, Node.js , - JavaScript-.



: npm- — JavaScript. . .



, , , , npm registry. npm registry, registry.npmjs.org. npm registry ( ). , registry. ( npm).



npm.



, . , (, lodash), , (, webpack).



. , . , , , . , :





npm ls — , : HTTP- Express ( ) Lodash ( ). , debug 4 . deduped , npm ( ).



Node Unix, - , . , , . , node_modules, . , JavaScript :







? , , -: package.json. , :



  • , ,
  • ,
  • URL , URL git-, URL -,
  • ,
  • , ,
  • ,
  • ,
  • (scripts) ,
  • . (. ).


package.json.





, :



  • dependencies,
  • devDependencies,
  • peerDependencies,
  • optionalDependencies.


JSON-, , — , .



:



{
  "dependencies": {
    "lodash": "^4.17.15",
    "chalk": "~2.3",
    "debug": ">2 <4",
  },
}


.



dependencies



dependencies , . Node.js. - , import { get } from 'lodash', dependencies. , , .



devDependencies



devDependencies , , . , typescript, webpack, eslint . , .



peerDependencies



peerDependencies . , Webpack, peerDependencies webpack, .



, , , .



peerDependencies , , . , . , , Webpack, .



optionalDependencies



optionalDependencies , . , .



, , , try… require… catch.



front-end



. , Node.js, , , . , front-end .



- , npm- front-end , , : «» , node npm.



front-end . , front-end Node.js.



Node.js- , npm registry, , . dependencies .



front-end npm registry, () , , CDN. -, npm front-end , . private: true, , npm-registry. , . . «» .



front-end dependencies , , : dependencies , , , lodash, react, date-fns . ., devDependencies — , : webpack, eslint, @types . .



, , Node.js! , , , devDependencies. .





npm semver ( Semantic Versioning ( )).



, : (major) , (minor) patch-:





: 3.12.1.



, , , .



patch- , , .



minor- , , .



major- , API, , , , . CHANGELOG .





1.0.0, , 0.0.3 0.1.2, semver : .





JavaScript: , , . , semver, .






All Articles