This document contains links to sample packages to use to help you quickly bootstrap a new JS / TS package, as well as context about best practices.
These practices are generally applicable, regardless of the type of package you’re building (UI component, util library, server client, etc), as well as regardless of the location where you’ll be housing the package.
This guide has code samples and examples for projects related to pyth in the pyth-crosshain repository. Everything in here is generally applicable, except the test configuration, which will be called out separately in the test file section.
- 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.jsonfile that leverages a common base - Use Biome for linting and formatting (helps standardize on code quality)
- For VSCode users, you can install and use the official Biome extension.
- 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
- When writing tests, locate the tests near the file / code you are testing, and ensure the filename ends with
*.test.ts(or*.test.tsxif you are testing a React component) - Have a
src/index.tsfile as a single place where you export any functions, APIs, etc that you want your users to use - Have a readme with steps to guide users to installing the package, getting started and some samples (if relevant)
- For any dependencies, try to leverage the
catalog:version instead of declaring your own package-specific dependency version.