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 fix
again, 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