javascript - Sane approach to build and deploy typescript/node.js application -
i'm working on node.js app written in typescript, means needs compiled js before running. i'm coming java/jvm background ship prebuilt package server , gets run there i'm bit afraid of way of deployment push code git , it's being built/compiled on server first , run.
i don't 2 main reasons:
- dev dependencies need installed on server
- deployment depends on external resources availability (npm etc).
i found nar https://github.com/h2non/nar more or less wanted has drawbacks (doesn't work deps have native extensions).
my question is: there other "sane" way of doing deployment node.js deployment risky combination of npm install
, tsc
on server? or should let sink in , way?
to honest don't believe there no more sane/reliable options that.
what can (but there other valid approaches) building project locally (or on ci service), , deploy built version when consider valid (tests, etc.).
this way, if bad happens, npm fails, or compilation error, don't deploy anything, , have time resolve situation.
for example, used have gulp task (but can else: grunt, simple npm script...) clone production repository , build project directory.
that way, can check build valid. if is, make new commit , push production repo, served way need (on heroku instance example).
pros
- clear separation of dev , non-dev dependencies
- deployment when know build valid
- no built files on source control on development repository
- no "live" dependency on external tasks
npm install
ortsc
build
cons
- you have 2 separated git repositories (one source code, 1 built version of project)
- production process little bit heavier committing master
- (from comment) doesn't handle case of npm package relies on native extensions have (re)built
Comments
Post a Comment