Skip to content Skip to sidebar Skip to footer

Should Compiled JavaScript Files Be Committed To Git Repo?

New to TypeScript here and just wondering what the community views as best practice. When I compile for production, I use the webpack loader. However, when I run my tests, I need t

Solution 1:

Your assumption is absolutely correct - build artefacts and outputs shouldn't be added to your repository. The main reason for this is that it's easy to end up in a situation where the source .ts file has changed but the compiled .js file differs because it's not been committed at the same time.

You also add complexity to your pull-requests/merge reviews, as there will be a large amount of generated code that isn't really part of the review but is in the changeset.

Finally, merging changes becomes a bit of a pain, because you need to recompile the .js files for every merge you do.

If you only use .ts files in your source directory, you can add /**/*.js to your .gitignore to prevent files from being added accidentally.


Post a Comment for "Should Compiled JavaScript Files Be Committed To Git Repo?"