Skip to content

Latest commit

 

History

History
143 lines (90 loc) · 4.1 KB

CONTRIBUTING.md

File metadata and controls

143 lines (90 loc) · 4.1 KB

Rslib Contributing Guide

Thanks for that you are interested in contributing to Rslib. Before starting your contribution, please take a moment to read the following guidelines.

Install Node.js

Use fnm or nvm to run the command below. This will switch to the Node.js version (currently 18) specified in the project's .nvmrc file.

# with fnm
fnm use

# with nvm
nvm use

Install Dependencies

Enable pnpm with corepack:

corepack enable

Install dependencies:

pnpm install

What this will do:

  • Install all dependencies.
  • Create symlinks between packages in the monorepo
  • Run the prepare script to build all packages, powered by nx.

Making Changes and Building

Once you have set up the local development environment in your forked repo, we can start development.

Checkout A New Branch

It is recommended to develop on a new branch, as it will make things easier later when you submit a pull request:

git checkout -b MY_BRANCH_NAME

Build the Package

Use nx build to build the package you want to change:

npx nx build @rslib/core

Build all packages:

pnpm run build

You can also use the watch mode to automatically rebuild the package when you make changes:

npx nx build @rslib/core --watch

Testing

Add New Tests

If you've fixed a bug or added code that should be tested, then add some tests.

You can add unit test cases in the <PACKAGE_DIR>/tests folder. The test runner is based on Vitest.

Run Unit Tests

Before submitting a pull request, it's important to make sure that the changes haven't introduced any regressions or bugs. You can run the unit tests for the project by executing the following command:

pnpm run test:unit

You can also run the unit tests of single package:

pnpm run test:unit packages/core

Run artifact tests

Rslib will also verify the correctness of generated artifacts. You can run the artifact tests by executing the following command:

pnpm run test:artifact

If you need to run a specified test, you can add keywords to filter:

# Only run test cases which contains `dts` keyword in file path
pnpm test:artifact dts
# Only run test cases which contains `dts` keyword in test name
pnpm test:artifact -t dts

Linting

To help maintain consistency and readability of the codebase, we use Biome to lint the codes.

You can run the linters by executing the following command:

pnpm run lint

For VS Code users, you can install the Biome VS Code extension to see lints while typing.

Versioning

We use changesets to manage version. Currently, all rslib packages will use a fixed unified version.

The release notes are automatically generated by GitHub releases.

Releasing

Repository maintainers can publish a new version of all packages to npm.

Here are the steps to publish (we generally use CI for releases and avoid publishing npm packages locally):

  1. Create release pull request.
  2. Run the release action.
  3. Generate the release notes.
  4. Merge the release pull request.

Caveats

The project is still in its early stages and under active development, so it possible dependents on Rsbuild or Rspack canary versions to test the latest features. The current versions are:

Package Link
@rspack/core https://github.com/web-infra-dev/rspack/commit/bb0219fd3eaee45d9957b4c29a176f2ac67a84ee