jscc is a tiny, fast preprocessor for conditional compilation and compile-time variable replacement in text files, inspired by the C preprocessor. It supports conditional inclusion/exclusion of blocks using directives like #if, #ifdef, #else, and #endif, and can replace variables with their values at compile-time. Written in JavaScript with TypeScript definitions, it works in Node.js >=6.0 and has minimal dependencies. Unlike general-purpose preprocessors, jscc is optimized for small to medium codebases, processes entirely in memory, and generates sourcemaps. Current stable version is 1.1.1, with no major updates since 2020, indicating a maintenance status.
npm install jsccNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
This example shows synchronous conditional compilation with a compile-time variable _DEBUG. The #if block is included because _DEBUG is true.
Ensure all compile-time variables follow the regex pattern (e.g., _VERSION, _BUILD).
Remove any '$' characters from your variables.
Pass { map: false } in options to skip sourcemap.Ensure directives are inside comments (e.g., /*#if _DEBUG*/).
Use `const jscc = require('jscc');` (without .default).Pass `variables: { _DEBUG: true }` in options.Write directive inside a comment: /*#if _VER*/ or //#if _VER.
No dependency data recorded yet.