Tutorial: publishing ESM-based npm packages with TypeScript

During the last two years, ESM support in TypeScript, Node.js and browsers has made a lot of progress. In this blog post, I explain my modern setup that is relatively simple – compared to what we had to do in the past:

It is intended for packages that…

During the last two years, ESM support in TypeScript, Node.js and browsers has made a lot of progress. In this blog post, I explain my modern setup that is relatively simple – compared to what we had to do in the past:

  • It is intended for packages that can afford to ignore backward compatibility. The setup has worked well for me for a while – since TypeScript 4.7 (2022-05-24).
    • It helps that Node.js now supports “require(esm)” – requiring ESM libraries from CommonJS modules.
  • I’m only using tsc, but mention how to support other tools via tsconfig.json in section “Compiling TypeScript with tools other than tsc”.

Print Share Comment Cite Upload Translate Updates
APA

Dr. Axel Rauschmayer | Sciencx (2025-02-04T00:00:00+00:00) Tutorial: publishing ESM-based npm packages with TypeScript. Retrieved from https://www.scien.cx/2025/02/04/tutorial-publishing-esm-based-npm-packages-with-typescript/

MLA
" » Tutorial: publishing ESM-based npm packages with TypeScript." Dr. Axel Rauschmayer | Sciencx - Tuesday February 4, 2025, https://www.scien.cx/2025/02/04/tutorial-publishing-esm-based-npm-packages-with-typescript/
HARVARD
Dr. Axel Rauschmayer | Sciencx Tuesday February 4, 2025 » Tutorial: publishing ESM-based npm packages with TypeScript., viewed ,<https://www.scien.cx/2025/02/04/tutorial-publishing-esm-based-npm-packages-with-typescript/>
VANCOUVER
Dr. Axel Rauschmayer | Sciencx - » Tutorial: publishing ESM-based npm packages with TypeScript. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/02/04/tutorial-publishing-esm-based-npm-packages-with-typescript/
CHICAGO
" » Tutorial: publishing ESM-based npm packages with TypeScript." Dr. Axel Rauschmayer | Sciencx - Accessed . https://www.scien.cx/2025/02/04/tutorial-publishing-esm-based-npm-packages-with-typescript/
IEEE
" » Tutorial: publishing ESM-based npm packages with TypeScript." Dr. Axel Rauschmayer | Sciencx [Online]. Available: https://www.scien.cx/2025/02/04/tutorial-publishing-esm-based-npm-packages-with-typescript/. [Accessed: ]
rf:citation
» Tutorial: publishing ESM-based npm packages with TypeScript | Dr. Axel Rauschmayer | Sciencx | https://www.scien.cx/2025/02/04/tutorial-publishing-esm-based-npm-packages-with-typescript/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.