Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a npm library with only typescript model classes?

I am developing a large scale (multi-module, multi-repo) web application. All modules are being developed as separate Angular projects.

These Angular projects share some common ui components, services, and models, which I am publishing to npm (company maintained private npm repository - sinopia) and then install them in necessary modules.

I have used Angular libraries for ui components and services. Creating a whole new angular library project for models feels like a overkill since models contain class definition only (no logic).

Is there any framework or a common practise to develop these types of libraries?

(Link to a similar Git repository is highly appreciated)

like image 297
charith.arumapperuma Avatar asked Oct 14 '25 03:10

charith.arumapperuma


1 Answers

Just some days back I had exactly same requirement where I need to refer classes and interfaces in multiple projects. You need to create node module which will be referred by all other projects.

Please refer my github repo https://github.com/Plochie/pacify.

This repo contains all classes in typescript and after building it you will get js files in dist folder. Please check tsconfig.json in each directory.

like image 149
Plochie Avatar answered Oct 17 '25 20:10

Plochie