你好!我叫Slava Fomin,我是DomClick的首席开发人员。在我的16年实践中,我一直处于JavaScript作为标准和生态系统的出现和开发的最前沿。首先,在我们公司中,我们使用JavaScript进行高级前端开发,并且已经设法尝试了相当多种不同的技术,工具和方法,并且获得了很多收获。这项艰苦工作的结果是我想与您分享的最宝贵的经验。
, , , . , , . , , .
, :
- , .
- .
- 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. , :
, :
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 : .