# Keen: a minimal npm package boilerplate using TypeScript and esbuild

DevFeed: [Keen: a minimal npm package boilerplate using TypeScript and esbuild](<https://devfeed.tech/articles/introducing-keen-37291.md>)

Original publisher: [Read original article](<https://muffinman.io/blog/introducing-keen-npm-package-boilerplate/>)

Author: Stanko

Published: 2022-06-20T00:00:00Z

Content type: tutorial

Language: en

Sources: [Stanko Tadić](<https://devfeed.tech/sources/stanko-tadic.md>)

Topics: [Boilerplate](<https://devfeed.tech/topics/boilerplate.md>), [npm packages](<https://devfeed.tech/topics/npm-packages.md>), [TypeScript](<https://devfeed.tech/topics/typescript.md>), [CommonJS](<https://devfeed.tech/topics/commonjs.md>)

Tags: [boilerplate](<https://devfeed.tech/tags/boilerplate.md>), [commonjs](<https://devfeed.tech/tags/commonjs.md>), [npm-packages](<https://devfeed.tech/tags/npm-packages.md>), [typescript](<https://devfeed.tech/tags/typescript.md>)

## AI overview

Keen is a minimal, opinionated npm package boilerplate that uses esbuild and TypeScript to provide local development, a demo page, ESM and CommonJS builds, and type definitions with two dependencies.

## Source excerpt

As someone who maintains a couple of npm packages, I got frustrated by all of the notifications about security issues in my dev dependencies. In 99.99% I wasn't even using the vulnerable code, and usually it would be buried deep in the dependency tree. Therefore, I decided to revisit and simplify my workflow. These were the main things I wanted to have: Use TypeScript and generate type definitions Generate both ESM and CJS modules Reduce the number of dev dependencies Have an easy way to develop and deploy a demo page Less dependencies makes maintenance easier and code is less prone to the security issues. Keen # So without further ado I present you keen, my npm package boilerplate. It does all of the things mentioned above with only two dependencies, esbuild and typescript. These are all of the keen dependencies. esbuild handles local development and builds a demo page. TypeScript takes care of building ESM and CJS modules as well as type definitions. Disclaimer # Keen is minimal and opinionated on purpose, and it might not fit your workflow. If you want something more robust and don't mind having more dependencies, check tools like tsup or unbuild. ESM and CJS modules # It helps your users to have both types of modules available. The main blocker is that you can't use ESM packages in CJS. That's why I have two builds which are using different TypeScript configurations. Both config files extend tsconfig-base.json and they just define the appropriate module type and transpile target: { "extends": "./tsconfig-base.json", "compilerOptions": { "module": "ES2020", "outDir": "dist/esm", "target": "ES2015" } } Show tsconfig-esm.jsonHide tsconfig-esm.json { "extends": "./tsconfig-base.json", "compilerOptions": { "module": "commonjs", "outDir": "dist/cjs", "target": "ES2015" } } Show tsconfig-cjs.jsonHide tsconfig-cjs.json I won't go into more details, but there are a couple of other things I had to setup. The code I ended up using is heavily based on these two articles. If