Registry / devops / jscc
library1.1.1jsnpmunverified

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 jscc
INSTALL
IMPORT
SIG · JSCC
J
jscc
devopsjavascriptv1.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jscc
import jscc from 'jscc';
const jscc = require('jscc').default;
The default export is the main synchronous function. CommonJS require() works directly without .default.
jscc.sync
const { sync } = require('jscc');
jscc.sync is not exported. Use the default export for sync calls.
Result type
import type { JsccResult } from 'jscc';
type Result = { code: string; map: object; };
TypeScript users should import the JsccResult type definition for proper typing.

This example shows synchronous conditional compilation with a compile-time variable _DEBUG. The #if block is included because _DEBUG is true.

import jscc from 'jscc'; const source = ` // #if _DEBUG console.log('Debug mode'); // #endif console.log('Hello World'); `; const options = { map: false, variables: { _DEBUG: true } }; const result = jscc(source, options); console.log(result.code); // Output: // console.log('Debug mode'); // console.log('Hello World');
Debug
Known issues
gotchaVariable names must start with underscore and use uppercase: /^_[0-9A-Z][_0-9A-Z]*$/
fix
Ensure all compile-time variables follow the regex pattern (e.g., _VERSION, _BUILD).
affects: >=1.0.0
gotchaThe $ character is reserved and cannot be used in variable names.
fix
Remove any '$' characters from your variables.
affects: >=1.0.0
deprecatedThe `sourcemap` option defaults to true; set `map: false` explicitly to disable sourcemap generation.
fix
Pass { map: false } in options to skip sourcemap.
affects: >=1.0.0
gotchaComment styles are configurable but default to /*, //, and <!--. Directives must appear inside these comments.
fix
Ensure directives are inside comments (e.g., /*#if _DEBUG*/).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: jscc is not a function
Using default import from CommonJS module incorrectly.
fix
Use `const jscc = require('jscc');` (without .default).
ReferenceError: _DEBUG is not defined
Compile-time variable not defined in options.variables.
fix
Pass `variables: { _DEBUG: true }` in options.
SyntaxError: Unexpected token #
Directive not inside a comment or wrong comment style.
fix
Write directive inside a comment: /*#if _VER*/ or //#if _VER.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
packagejscc
jscc — npm install jscc · libregistry