cmake-ts v1.0.2 is a CMake-based build system for native Node.js and Electron addons, written in TypeScript. It is loosely inspired by cmake-js but fixes several design flaws, focusing on prebuilt addons and advanced build configurations. It ships TypeScript type definitions and supports cross-compilation for multiple architectures (arm64, x64, etc.) and runtimes (node, electron, iojs). The project is actively maintained with frequent releases on GitHub. Key differentiators include built-in support for cross-compilation via named configs, a manifest system for runtime addon loading, and compatibility with modern Node versions (12+).
npm install cmake-tsVerified import paths — ran on the pinned version, not inferred.
Shows how to build a native addon with cmake-ts and load it at runtime using the ESM loader. Demonstrates loader usage and CLI build command.
Use the loader's manifest to resolve paths dynamically instead of hardcoding.
Ensure you use the public API and the loader from 'cmake-ts/build/loader.mjs'.
Replace 'downloadZip' calls with the updated download utilities from '@aminya/node-gyp-build' or similar.
Use dynamic import() or switch to an ESM project. If running CommonJS, consider using import('cmake-ts/build/loader.mjs').Use dynamic import: const { loadAddon } = await import('cmake-ts/build/loader.mjs');Run `cmake-ts build --config release` to build for the current runtime, or ensure cross-compilation config is correct.
Install CMake from https://cmake.org/download/ or use a package manager (apt, brew, choco) and add to PATH.
Run `cmake-ts build` to generate the manifest. Ensure you are using cmake-ts v0.6.0+.