[Typescript] Get a TypeScript package ready for release to NPM

If you're thinking about putting a TypeScript package up to NPM, you should be considering preconstruct. It makes setup EXTREMELY easy and takes many decisions out of your hands.

Here, we get a package ready for release in under 2 minutes.

https://preconstruct.tools/tutorials/

Install:

yarn add -D @preconstruct/cli

 

Run:

yarn preconstruct fix

 

will add "main"in package.json automaticlly.

 

If we add "module": "",in package.json, then run yarn preconstruct fixagain, it will automiaticlly handle add `.esm.js` file for us.

 

Add script:

"build": "yarn preconstruct build"

 

Run:

yarn build

It will generate /dist folder with all the code you need.

 

Then you can publish your package to NPM

posted @ 2022-10-20 14:31  Zhentiw  阅读(21)  评论(0)    收藏  举报