2

I want to build a private library for my organisation and install it by git url. I also want to build this library using Typescript.

The common way to use Typescript for NPM-published libraries is to add the folders that will contain compiled Javascript files to .gitignore, and then to run npm publish before publishing it to NPM registry. This way, library users will download a package that contains git-tracked source files as well as compiled Javascript and type definition files.

However, if I install this library using git, I will not be able to install files other than tracked by git. I don't want to track the compiled files by git, because it goes against the basic principle of version control: track only source files and ignore all automatically generated artefacts.

What's the common approach to structure and set up build scripts for the library in this case?

Max Yankov
  • 12,551
  • 12
  • 67
  • 135
  • If you download the source directly from the git repository, it seems you'll need to compile it yourself. – Alejandro Oct 01 '20 at 15:38
  • Yes, it does seem so, this I get. My question is about the exact way to do it, and all the unknown unknowns that I may encounter. – Max Yankov Oct 01 '20 at 15:40
  • I suppose that depends upon each specific library you download, hopefully they provide compilation instructions that you should follow. By using NPM they do that part for you, but skiping it and going directly to the source you need to do those steps by yourself. – Alejandro Oct 01 '20 at 16:10
  • I'm asking it as someone who is writing such a library. – Max Yankov Oct 02 '20 at 18:11

0 Answers0