|
| 1 | +<p> |
| 2 | + <img width="100%" src="https://assets.solidjs.com/banner?type=Ecosystem&background=tiles&project=library-name" alt="solid-create-script"> |
| 3 | +</p> |
| 4 | + |
| 5 | +# Template: SolidJS Library |
| 6 | + |
| 7 | +Template for [SolidJS](https://www.solidjs.com/) library package. Bundling of the library is managed by [tsup](https://tsup.egoist.dev/). |
| 8 | + |
| 9 | +Other things configured include: |
| 10 | + |
| 11 | +- Bun (for dependency management and running scripts) |
| 12 | +- TypeScript |
| 13 | +- ESLint / Prettier |
| 14 | +- Solid Testing Library + Vitest (for testing) |
| 15 | +- Playground app using library |
| 16 | +- Simple Bun server scaffolding for playground app |
| 17 | +- Support for publishing to NPM and JSR |
| 18 | +- GitHub Actions (for all CI/CD) |
| 19 | + |
| 20 | +## Getting Started |
| 21 | + |
| 22 | +Some pre-requisites before install dependencies: |
| 23 | + |
| 24 | +- Install Node Version Manager (NVM) |
| 25 | + ```bash |
| 26 | + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash |
| 27 | + ``` |
| 28 | +- Install Bun |
| 29 | + ```bash |
| 30 | + curl -fsSL https://bun.sh/install | bash |
| 31 | + ``` |
| 32 | + |
| 33 | +### Installing Dependencies |
| 34 | + |
| 35 | +```bash |
| 36 | +nvm use |
| 37 | +bun install |
| 38 | +``` |
| 39 | + |
| 40 | +### Local Development Build |
| 41 | + |
| 42 | +```bash |
| 43 | +bun start |
| 44 | +bun start:server # entirely optional to use |
| 45 | +``` |
| 46 | + |
| 47 | +### Linting & Formatting |
| 48 | + |
| 49 | +```bash |
| 50 | +bun run lint # checks source for lint violations |
| 51 | +bun run format # checks source for format violations |
| 52 | + |
| 53 | +bun run lint:fix # fixes lint violations |
| 54 | +bun run format:fix # fixes format violations |
| 55 | +``` |
| 56 | + |
| 57 | +### Building the Library |
| 58 | + |
| 59 | +This template uses [tsup-preset-solid](https://github.com/solidjs-community/tsup-preset-solid) to build and bundle the library |
| 60 | + |
| 61 | +```bash |
| 62 | +bun run build |
| 63 | +``` |
| 64 | + |
| 65 | +### Publishing the Library |
| 66 | + |
| 67 | +This template also comes with Changeset pre-configured and three utility scripts. You must have Changeset installed to leverage them. |
| 68 | + |
| 69 | +```bash |
| 70 | +bun pkg:changeset # run Changeset CLI |
| 71 | +bun pkg:version # consume any changeset to produce package manifest updates |
| 72 | +bun pkg:publish # git tag and publish the package to NPM via Changeset |
| 73 | +``` |
| 74 | + |
| 75 | +Another thing to note is the template includes a `jsr.json` config to support publishing to JSR alongside NPM if interested. To publish to JSR, you can run: |
| 76 | + |
| 77 | +```bash |
| 78 | +bunx jsr publish # publishes to JSR |
| 79 | +bunx jsr publish --dry-run # checks if library is publishable |
| 80 | +``` |
| 81 | + |
| 82 | +> Note: For JSR publishing, Changeset does not update the jsr.json file after running `bun pkg:publish` so you have to manually update the version by hand after changeset has run. |
| 83 | +
|
| 84 | +### Contributing |
| 85 | + |
| 86 | +The only requirements when contributing are: |
| 87 | + |
| 88 | +- You keep a clean git history in your branch |
| 89 | + - rebasing `main` instead of making merge commits. |
| 90 | +- Using proper commit message formats that adhere to [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) |
| 91 | + - Additionally, squashing (via rebase) commits that are not [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) |
| 92 | +- CI checks pass before merging into `main` |
0 commit comments