Skip to content

nlibjs/tsm

Repository files navigation

@nlib/tsm

Thin .mts loader and test runner

.github/workflows/test.yml codecov

Install

npm install @nlib/tsm

Usage: Run *.ts/*.mts file

node --experimental-loader=@nlib/tsm path/to/your/script.mts

loader.mjs is a Loader to customize the default module resolution. It exports the load function that loads modules with esbuild.

Usage: Run test files

Node.js added the stable node:test in v20. We can run tests with node --test. It searches for test files when a directory is specified as arguments. But it doesn't search for *.mts (even with the --experimental-loader option). So, you must pass the files one by one to run it.

The tsm-test will search for the test file for you and pass it to node --test.

npx tsm-test src