This project is built with Preact and bundled with Vite.
- Node.js
- This project uses pnpm. Run
corepack enable
to use pnpm in this project.
This project uses Vite's Library Mode.
- The library code is inside the
lib/
directory. - The example app in the
src/
directory. - Tests and Stories are colocated to embeds inside the
lib/
directory.
To get started with the project, run pnpm i
in the root directory.
pnpm i
The example app demonstrates usage of the library and works as a development playground.
It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild.
To start the development server, run pnpm dev
.
pnpm dev
You can then open the example app in your browser.
To develop with Storybook, run pnpm storybook
.
pnpm storybook
The storybook is used to develop the UI of an embed without having to initialize it. Changes to the library's JavaScript code will be reflected in Storybook without a rebuild.
Make sure your code passes TypeScript and ESLint. Run the following to verify:
pnpm typecheck
pnpm lint
To fix formatting errors, run the following:
pnpm lint --fix
We use Vitest for testing, together with Preact Testing Library to write better tests. Vitest and Preact Testing Library have a compatible interface to Jest and React Testing Library.
Run the unit tests by:
pnpm test