DEV Community

loading...

Correct Way to Deploy Typescript Express Project to Heroku ?

Philip Purwoko
Self-taught Machine Learning X Software Developer. Confidence with Python, Nodejs, and Flutter
・1 min read

Hello. I have a Github repository for my Typescript Express project. In my project structure, I have src folder to save my .ts file and a dist folder for the output of tsc compiler, and there will be the .js file, just like typical typescript structure.

I used expressjs to create a webserver, everything is working ok. I add the dist folder into .gitignore file, so the only file that got pushed to github repository is the src folder which mean the typescript file. And I want to connect Heroku and my github repository. The problem is, the file that should be in Heroku is the .js file, not the .ts.

What is the correct way to deploy a typescript project to Heroku ?
I really appreciate all of your response. Thank you

Discussion (2)

Collapse
soorajjose profile image
Sooraj Jose

Ts files are not supported browers , so we need to compile js, In your case dist forlder have js . So everything is okay .

For Herku depolyment first you need to commit all changes to github. In Herku there is one option to connect with guthub use that , so it is every easy to build and depolyment

Collapse
philippurwoko profile image
Philip Purwoko Author

I add the dist folder to .gitignore, and this mean I will have the .ts file in Heroku. Heroku would not install devDependencies, also the .ts file is not supposed to be pushed into the server. In this case I know I can upload the js file manually, but I prefer to use CI/CD or Devops method if possible.