node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »


Build Status Coverity Scan Build Status Coverage npm License


Featuring some of the C preprocessor characteristics through special, configurable comments, jscc can be used in any type of files to build multiple versions of your software from the same code base.

With jscc, you have:

  • Conditional inclusion/exclusion of code, based on compile-time variables*
  • Compile-time variables with all the power of JavaScript expressions
  • Replacement of variables inside the source (by value at compile-time)
  • Source Map support

* This feature allows you the conditional declaration of ES6 imports (See the example).

jscc is not a minifier tool, it only does well that it does...

jscc is derived on jspreproc, the tiny source file preprocessor in JavaScript, enhanced with Source Map support but without the file importer (rollup and other bundlers does this better).


npm i jscc -D


import jscc from 'jscc';
import { fs } from 'fs';
const source = fs.readFileSync('myfile.js', 'utf8')
const result = jscc(source)


//#set _DEBUG 1 
/*#if _DEBUG
import mylib from 'mylib-debug';
//#else */
import mylib from 'mylib';
mylib.log('Starting v$_VERSION...');


import mylib from 'mylib-debug';
mylib.log('Starting v1.0.0...');

That's it.

* jscc has the predefined _VERSION varname, in addition to _FILE.


You can read in the Wiki about:


This is work in progress, so please update jscc constantly, I hope the first stable version does not take too long.


  • Explanatory error messages, with location of the error
  • Async mode
  • Better documentation*
  • Syntax hilighter for some editores
  • You tell me...

* For me, write in english is 10x harder than coding JS, so contributions are welcome...

Don't forget to give me your star!