This repository contains a small Svelte 5 component library.
What's included
- A neutral, mac-inspired Button component at
src/lib/components/Button.svelte. - An in-app demo route at
/components-demoto preview components during development. - A Vite library build config (
vite.lib.config.ts) to build distributable artifacts. - Unit tests with Vitest and @testing-library/svelte (basic Button tests).
How to run locally
- Install with pnpm (preferred):
pnpm install - Dev server:
pnpm run dev
This repo can be installed directly from GitHub without publishing to the npm registry. The repository root contains a package.json that limits files to src/lib so consumers only download component sources.
Install directly from GitHub (replace with your username/repo if different):
# pnpm
pnpm add github:ricardojvsoares/Components
# npm
npm install github:ricardojvsoares/ComponentsImporting
After installing the package from GitHub, import the Svelte files directly from the package path. Because this repo ships src/lib files, an import looks like:
<script>
import { Button } from 'rjcomponents/ui';
</script>
<Button>Click me</Button>If you'd like nicer top-level paths (for example rjcomponents/Button), I can update package.json exports to map those names to the correct files.
Recommended: pnpm.
Install and run the demo locally:
pnpm install
pnpm run devBuild the distributable library:
pnpm run build:libRun tests:
pnpm testIf you later want to publish a packaged artifact to npm, the PUBLISHING.md file includes steps. For local or private usage, installing from GitHub is a lightweight alternative.
Add a GitHub Actions workflow to build & publish on new tag pushes. Use an NPM_AUTH_TOKEN secret to authenticate.
- Update
package.jsonexportsfor nicer import paths (recommended). - Add
tsconfig.build.jsonand abuild:typesscript to emit declaration files. - Inspect and, if needed, update
vite.lib.config.tsto produce ESM + CJS outputs and a cleandist/layout. - Add a GitHub Actions workflow to publish on tag.