An advanced starter template for creating modern, universal build plugins that work seamlessly across Vite, Rollup, Webpack, esbuild, and other bundlers using unplugin. Built with TypeScript and featuring comprehensive tooling for testing, formatting, type-checking, and automated releases.
- π Universal Plugin Architecture - Write once, run everywhere with unplugin
- π¦ Dual Package Exports - ESM and CommonJS support out of the box
- π― TypeScript First - Strict mode enabled with comprehensive type safety
- β Testing Ready - Vitest with 80%+ coverage requirements
- π¨ Code Quality - ESLint, Prettier, and automated formatting
- π Automated Releases - Conventional commits with release-it
- π Type Checking - Continuous type validation with watch mode
- π Bundle Size Tracking - Monitor your package size with size-limit
- πͺ Git Hooks - Pre-commit checks with Husky and Lefthook
- Node.js 18+
- pnpm (recommended) or npm/yarn
# Clone this template
git clone https://github.com/yeasin2002/npm-starter.git my-plugin
cd my-plugin
# Install dependencies
pnpm install
# Start development
pnpm devpnpm dev # Run tests in watch mode
pnpm typecheck # Type check without emitting
pnpm typecheck:watch # Type check in watch modepnpm build # Build for production (ESM + CJS)
pnpm clean # Clean build artifacts and cachepnpm test # Run tests once
pnpm test:coverage # Run tests with coverage report
pnpm test:watch # Run tests in watch modepnpm lint # Lint source code
pnpm lint:fix # Lint and auto-fix issues
pnpm format:check # Check code formatting
pnpm format:write # Format code with Prettierpnpm ci # Run full CI pipeline
pnpm check-exports # Verify package exports
pnpm size # Check bundle size
pnpm size:why # Analyze bundle size
pnpm audit # Security auditpnpm release # Create a new release with conventional changelogsrc/
βββ core/ # Core functionality
β βββ options.ts # Plugin options and resolution
βββ index.ts # Main plugin export (default)
βββ api.ts # Public API functions
βββ vite.ts # Vite-specific plugin
βββ webpack.ts # Webpack-specific plugin
βββ rollup.ts # Rollup-specific plugin
βββ rspack.ts # Rspack-specific plugin
test/
βββ *.test.ts # Vitest test files
dist/ # Build output (auto-generated)
βββ index.js # ESM build
βββ index.cjs # CommonJS build
βββ index.d.ts # TypeScript declarations
Strict mode enabled with additional checks:
- Framework: Vitest
- Coverage: 80% minimum (lines, functions, branches, statements)
- Provider: v8
- ESLint with TypeScript ESLint recommended rules
- Prettier (single quotes, no semicolons, 100 char width)
- EditorConfig for consistent formatting
- Pre-commit: Lint staged files
- Commit message: Conventional commits validation
-
Update
package.jsonwith your package details:namedescriptionauthorrepositoryhomepagekeywords
-
Run pre-publish checks:
pnpm run ci- Create a release:
pnpm releaseContributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
MIT Β© Md Kawsar Islam Yeasin
- Keep your plugin focused on a single responsibility
- Always resolve options with defaults before using them
- Write tests for all public APIs
- Use TypeScript strict mode for better type safety
- Follow conventional commits for automated changelog generation
- Monitor bundle size to keep your plugin lightweight
Made with β€οΈ by Yeasin