As I develop my library, my TypeScript files reside in the src
directory. To streamline the process, I have set up the tsc
compiler to generate JavaScript files in a separate js
folder, with the final bundled scripts stored in a dist
folder.
Considering that the js
and dist
folders are essentially derivatives of the TypeScript source code in src
, it may not be necessary to include them in the git repository. By excluding these folders in the .gitignore
file and including them in .npmignore
, they will still be part of the npm release package.
Before each release, I conduct tests using the files from the js
folder. Passing these tests ensures that both js
and dist
directories are properly prepared for publication on npm.
One drawback of this approach is that cloning the repository would not provide access to the compiled files directly; users would need to run npm install
and build the files themselves. However, avoiding bloated commits by omitting pre-compiled files could outweigh this inconvenience.
Is it considered poor practice to exclude js
and dist
folders from version control in git?