How to contribute to xPack Logger
This page is for the contributors who plan to add new features or fix bugs in the xPack Logger project, and describes how to build and test the package.
Prerequisites
@xpack/logger is a portable Node.js module; development can be conducted on macOS, GNU/Linux, and Windows.
The prerequisites are:
- git
- node >= 22.12
- npm
To check the compatibility with the oldest supported node version, switch to it:
nvm use --lts 22
code
Obtain project sources
The project is hosted on GitHub:
Branches
This project uses multiple branches:
master, containing the latest stable version (default)development, containing the current development versionwebsite, containing the current website content; pushes to this branch automatically trigger publication of the main website
All development is conducted in the development branch, and contributions via
Pull Requests should be directed to this branch.
When new releases are published, the master branch is rebased
onto development.
To contribute Pull Requests, fork the project and make sure the
Copy the master branch only option is disabled, so that
the development branch is also copied and can be used for
contributions.
After making changes, direct the Pull Requests to the
development branch.
The next step would normally be to clone the forked repository.
However, if Pull Requests are not intended, directly clone the
development branch of the original repository:
mkdir -p ~/Work/xpack && \
git clone \
--branch development \
https://github.com/xpack/logger-ts.git \
~/Work/xpack/logger-ts.git
If the repository has already been cloned, update it with:
git -C ~/Work/xpack/logger-ts.git pull
Add links for development
By default, npm dependencies are installed as sub-folders of
node_modules, with filtered content; developer-related files are not
installed. These sub-folders are also overwritten on each npm install,
so any changes made there are lost.
Therefore, during development, if this project is used as a dependency of another project, it is convenient to use the full version of the project and make changes directly in the local development folder.
The mechanism npm uses for this is called linking.
The process has two steps:
- Tell the global npm configuration where the local development folder is located.
- Tell the top project to use the linked development folder instead of the installed read-only dependency.
The first step requires executing the npm link command in the
local development folder, as shown below:
npm --prefix ~/Work/xpack/logger-ts.git link
The result is the creation of a symbolic link in the global npm store pointing to the local development folder.
For the second step, in the top project, instead of adding the dependency by installing it, run the command to link it:
npm link @xpack/logger
Satisfy dependencies
npm install
Start the compile background task
TypeScript requires a compile step to transform the source code into JavaScript that can be executed.
The configuration provides a separate command to perform the compilation:
npm run compile
To avoid recompiling manually, the TypeScript compiler can watch the
source files and recompile them when they change. For this, start it in
watch mode:
npm run compile-watch
Language standard compliance
The current version is compiled with TypeScript 6.0.3:
The compiler is configured to produce ECMAScript 2020 (es2020) files
that can be imported by any other project via import.
For more details on how to configure tsconfig.json, please see:
Style
As style, the project uses typescript-eslint, a set of rules for static analysis of JavaScript and TypeScript code.
For special cases, it is possible to configure or disable some rules.
/* eslint-disable-next-line no-xxx-yyy */
The known rules are documented in the eslint project.
Known and accepted exceptions:
- none
Documentation metadata
The documentation metadata uses the TSDoc tags, without explicit types, as they are provided by TypeScript.
Tests
The tests use the node-tap framework
(A Test-Anything-Protocol library for Node.js, written by Isaac Schlueter).
With recent versions, tests can also be written in TypeScript.
As with any npm package, the standard method to run the project tests
is npm run test:
npm install
npm run test
A typical test result looks like:
% npm test
> @xpack/logger@7.0.0 pretest
> npm run compile && npm run compile-tests
...
> @xpack/logger@7.0.0 pretest-coverage
> npm run lint
...
> @xpack/logger@7.0.0 test-coverage
> tap --show-full-coverage
...
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
src | 100 | 100 | 100 | 100 |
index.ts | 100 | 100 | 100 | 100 |
src/lib | 100 | 100 | 100 | 100 |
logger.ts | 100 | 100 | 100 | 100 |
------------|---------|----------|---------|---------|-------------------
The compilation, the type check of the tests, and the lint must pass, and the coverage must be 100% for statements, branches, functions, and lines.
To run a specific test, without the coverage and with the verbose TAP
output, use npm run test-one:
% npm run test-one -- tests/tap/040-is-level.ts
...
# No coverage generated
Continuous Integration (CI)
The module is subject to CI testing on every push via GitHub Actions, on Ubuntu, Windows and macOS, using Node.js 22, 24 and 26.
Tips and tricks
To trace which files module imports resolve to, enable TypeScript module resolution tracing:
"compile": "tsc --traceResolution -p ./",