Jest now uses SWC to transpile the Node SDK tests, with the same ES2022 target and legacy decorator semantics as the SDK. The Node and Arrow compatibility jobs run the existing test TypeScript project through `tsc --noEmit` after building the SDK. Contributors can run that check with `pnpm run typecheck:tests`. Closes #2234. Measured on Windows x64 with Node 22.23.4, Jest 29.7, the default native features and one Jest process (`--runInBand --silent`). Both runs used the same 0.42.0-beta.26 Windows native binary. Times below are wall-clock seconds. | Workload | ts-jest | SWC | | --- | ---: | ---: | | Six suites, empty Jest cache (median of three) | 8.31 | 4.22 | | Same six suites, populated cache (median of three) | 4.45 | 3.52 | | Full default suite, empty Jest cache (one run each) | 50.10 | 38.55 | The six suites were `arrow`, `expr`, `materialized_view`, `package`, `registry` and `sanitize`. Each pair started with a fresh Jest cache directory and immediately reused it on the second run. The separate test type check took 3.39 s, bringing the full SWC run plus type checking to 41.94 s on this machine. Both full runs passed the same 1,882 tests with 28 skipped. The SDK TypeScript build, test type check, Biome checks and TypeDoc build also passed. --------- Co-authored-by: lipeih <lipeihan@eazytec.com>
2.7 KiB
Contributing to LanceDB Typescript
This document outlines the process for contributing to LanceDB Typescript. For general contribution guidelines, see CONTRIBUTING.md.
Project layout
The Typescript package is a wrapper around the Rust library, lancedb. We use
the napi-rs library to create the bindings between Rust and
Typescript.
src/: Rust bindings source codelancedb/: Typescript package source code__test__/: Unit testsexamples/: A pnpm package with the examples shown in the documentation
Development environment
To set up your development environment, you will need to install the following:
- Node.js 22 or later (required by pnpm 11)
- pnpm 11 or later (or run via
corepack enable, which uses thepackageManagerfield inpackage.json) - Rust's package manager, Cargo. Use rustup to install.
- protoc (Protocol Buffers compiler)
Initial setup:
pnpm install
Commit Hooks
It is highly recommended to install the pre-commit hooks to ensure that your code is formatted correctly and passes basic checks before committing:
pre-commit install
Development
Most common development commands can be run using the pnpm scripts.
Build the package
pnpm install
pnpm build
Local SQL computed columns and materialized-view creation/refresh are experimental and disabled in published packages. To opt in when building from this directory:
pnpm build:debug --features experimental-functions
pnpm tsc
pnpm test --runInBand table.test.ts materialized_view.test.ts
Rebuild without --features experimental-functions to test the default package.
The tests detect the compiled feature; remote operations, metadata protections,
and ordinary eager addColumns transforms remain available in both builds.
Lint:
pnpm lint
Format and fix lints:
pnpm lint-fix
Run tests:
pnpm test
Jest uses SWC to transpile TypeScript. Run pnpm run typecheck:tests after
pnpm build to check the test suite's types.
On Linux, if pnpm test fails with ERR_SWC_NATIVE_CACHE before Jest
starts, set SWC_NATIVE_BINDING_CACHE to the absolute path of a private
cache directory. Use a location whose parent directories are under your
control and are not writable by other users, then rerun pnpm test.
To run a single test:
# Single file: table.test.ts
pnpm test -- table.test.ts
# Single test: 'merge insert' in table.test.ts
pnpm test -- table.test.ts --testNamePattern=merge\ insert