Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 1.69 KB

File metadata and controls

34 lines (29 loc) · 1.69 KB

Creating a new JavaScript / TypeScript package

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.

Using the create-pyth-package generator

  1. Ensure you have run pnpm install from the root of the pyth-crosschain repository.
  2. Run pnpm create-pyth-package and answer the prompts.
  3. Find your generated code in the repository, in the folder you chose.
  4. Happy hacking!

Best practices

  • Put your code in a src/ folder.
  • Use a very strict TypeScript tsconfig.json that 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.tsx for a React component).
  • Have a src/index.ts file 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.