nativejs-compiler (also known as hardware.js) is a JavaScript/TypeScript to C transpiler that converts JS/TS code into readable C89 code for low-power microcontrollers and IoT devices. Current version 2.0.0 (released July 2024) supports approximately 50% of ES3 syntax, targeting environments with very limited memory (512 bytes to 120KB RAM). Key differentiators include generating minimal, readable C code without unnecessary overhead, and employing escape analysis for memory management. It supports basic ES3 features like var, if-else, loops, functions, arrays, strings, and some built-in objects, but notably lacks support for float numbers, `this`, `new`, and `typeof`. Releases are occasional, focused on incremental feature coverage. Compared to other JS-to-C transpilers, it prioritizes output readability and small footprint over full language support.
npm install nativejs-compilerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Transpiles a simple JavaScript 'Hello world' console.log to C code using the transpile function.
Use import syntax instead of require().
Replace transpile() with compile().
Use integer values only, or check if float support is added in future versions.
Avoid using `this` or rewrite code to pass context explicitly.
Refer to COVERAGE.md in the GitHub repo for the current list of supported features.
Run `npm install nativejs-compiler` and ensure the package name is 'nativejs-compiler'.
Use `import { transpile } from 'nativejs-compiler'` instead of `const { transpile } = require('nativejs-compiler')`.Remove usage of `this` or refactor code to use explicit parameters.