Project setup: creating a Typescript package for nodejs using npm and webpack

I want to create a library in Typescript that I can provide through npm. In particular, I want to use webpack to create a js package along with a definition file for type sharing with js. So I would have a file tree like:

├── lib
│   ├── lib.d.ts
│   └── lib.min.js
├── test
...
├── ts
│   ├── errors
│   │   ├── CannotModifyAlteredObject.ts
│   ├── Lib.ts
│   ├── PostProcessors.ts
│   ├── Serializers.ts
├── tsconfig.json
├── typings.json
├── LICENSE
├── package.json
├── README.md
└── webpack.lib.config.js

And all types exported ts/Lib.tswill be exported to one .d.tsin a directory libto sit next to the js package.

I reviewed the following questions / sources:

, webpack. , ( runjs nodejs) , , webpack . .d.ts, , -. .d.ts - , .d.ts, . ?

+4

Source: https://habr.com/ru/post/1675637/


All Articles