Examples

Copy-and-paste starter projects for common library setups with Packem

Examples

Each example is a complete, working project you can use as a starting point. Pick the one closest to what you are building.

Library starters

ExampleWhat it builds
Basic TypeScript LibraryA simple utility package with ESM output and .d.ts declarations
TypeScript LibraryA TypeScript library with ESM + CJS output and declarations
JavaScript PackageA modern, zero-config JavaScript package
Dual Package (ESM + CJS)A library that ships both ESM and CJS for maximum compatibility
CLI ToolA package with bin executables and auto hashbang insertion
Multiple ExportsMultiple entry points via package.json#exports subpaths
React Component LibraryReact components with CSS Modules, Server Components, and Storybook
MonorepoMultiple packages in a single workspace with shared configuration

Transformers

ExampleWhat it covers
esbuildFast bundling with the esbuild transformer
swcRust-powered compilation with swc (decorators, legacy TS)
OXCThe experimental next-generation OXC toolchain
sucraseLightweight, fast alternative to Babel

CSS

ExampleWhat it covers
Basic CSSPlain CSS with PostCSS, injection and extraction
Sass/SCSSSass preprocessing with variables and mixins
LessLess compilation
StylusStylus preprocessing
CSS ModulesScoped class names with automatic CSS Modules
PostCSSAdvanced PostCSS configuration with plugins
Lightning CSSFast CSS processing/minification with Lightning CSS

React

ExampleWhat it covers
React LibraryA React component library with TypeScript
CSS ModulesReact components with scoped CSS Modules
Server ComponentsRSC and client components with directive handling
Tailwind CSSReact components with Tailwind CSS via PostCSS

Configuration recipes

ExampleWhat it covers
Extra ConditionsCustom export conditions in package.json validation
Bundle Size LimitsBundle size validation and per-file limits
Package.json ValidationFull package.json field validation setup
Dependency ValidationDetect unused, hoisted, and duplicated dependencies

Advanced

ExampleWhat it covers
Multi-RuntimeConditional exports for node, browser, edge, and react-server
Dynamic ImportsCode splitting via dynamic import()
Shared ModulesShared chunks between bundles
WebAssemblyBundling .wasm modules
Custom PluginsAdding custom Rollup plugins via the plugins option
Bundle AnalysisVisualize and analyze bundle size
Minify HTML LiteralsAutomatically minify HTML and CSS inside template literals
require-cjs-transformerTransform ESM imports of CJS packages for better runtime performance

Quick start

Copy one of these to bootstrap a new project:

# TypeScript library
npx degit visulima/packem/examples/basic-library my-lib
cd my-lib && npm install && npm run build

# React component library
npx degit visulima/packem/examples/react-library my-components
cd my-components && npm install && npm run build
Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues