Typescript ile npm package olusturmak ve yayinlamak

typescript, programming, npm

Typescript ile npm package olusturmak ve yayinlamak

Baslangic Kurulumu

Typescript ile npm paketi yayinlamak icin:

  • Burada scope kullanici adimiz olacak, benim icin yemreak

  • Package name ise alfred5 olarak alindi kendi package name’inizi kullanmayi unutmayin

  • Eger jest ile test yapacaksaniz

Projenin Kurulmasi

`package.json` ornegi
`tsconfig` ornegi

- `out` (`dist`) yerine secilmistir - `decleration` ile `.d.ts` yani `typescript` tip dosyalari tanimlanir

`.gitignore`

- GitHub ve git uzerinde gereksiz ve kisisel verileri gizlemek icin kullaniyoruz

`.npmignore`

- Bu `.gitignore` icerisinde yer alan `out` dizinini `npm`'e yuklemek icin konur - Icini bos birakabiliriz, tek amacimiz `.gitignore`'un etkisini `npm` icin iptal etmek

`jest.config.js` ornegi (test olacaksa)

Projenin Yayinlanmasi

Ilk olarak `npm` uzerine giris yapin
Paketini yayinlamadan once `build` etmeyi unutmayin

- `package.json` icerisinde `scripts` adi altinda `build` komutunuzu kontrol edin - Eger yoksa `package.json` ornek dosyama bakin

Gerekiyorsa `test` islemlerinizi de yapin
`publish` etmeden once localde test edin
Herkese acik olarak `publish` etmek

Ornek Proje

link_preview

References

  • ChatGPT

Last updated

Was this helpful?