This document explains how to quickly bootstrap a new JS / TS package and the best practices to follow. These practices are generally applicable regardless of the type of package you're building (UI component, util library, server client, etc.) and regardless of where you house it.
- Ensure you have run
pnpm installfrom the root of the pyth-crosschain repository. - Run
pnpm create-pyth-packageand answer the prompts. - Find your generated code in the repository, in the folder you chose.
- Happy hacking!
- Put your code in a
src/folder. - Use a very strict TypeScript
tsconfig.jsonthat leverages a common base. - Use Biome for linting and formatting (see style.md).
- Write your code using the most modern syntax.
- Compile your code to both CommonJS (CJS) and ECMAScript Module (ESM).
- Write tests using our internal test configuration (see testing.md).
Locate tests near the file / code you are testing, and ensure the filename ends
with
*.test.ts(or*.test.tsxfor a React component). - Have a
src/index.tsfile as the single place where you export the functions, APIs, etc. that you want your users to use. - Have a readme with steps to guide users through installing the package, getting started, and some samples (if relevant).
- For any dependencies, leverage the
catalog:version instead of declaring your own package-specific dependency version.