NPM Package Template
TIP
This template is used as a starting point for creating NPM packages, and not web projects. Please consult Screaming Guides for more information on creating an NPM package.
Scripts
The following scripts are available in this project's package.json
:
build
: Builds the project for production.watch
: Builds the project for production and rebuilds on subsequent file changes.
Project Structure
project
├── src/
│ └── index.ts (1)
├── .eslintrc.cjs
├── .gitignore
├── .prettierrc
├── LICENSE
├── package.json
├── README.md
├── tsconfig.json (2)
└── tsup.config.ts (3)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Key Items
Entry point to the application.
Configuration file for TypeScript used in
src/
(.ts
or.d.ts
files).Configuration file for tsup (a tool which bundles all of the TypeScript/JavaScript files into a publishable format).
TIP
NPM Packages may be created using JavaScript instead of TypeScript. To enable this, simply change src/index.ts
to src/index.js
, and modify the entry point in tsup.config.ts
as shown below:
ts
import { defineConfig } from 'tsup'
export default defineConfig({
entry: { index: 'src/index.ts' },
entry: { index: 'src/index.js' },
outDir: 'dist',
format: ['cjs', 'esm'],
dts: true,
clean: true,
minify: true
})
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11