Package Exports
- rollup-plugin-jscc
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rollup-plugin-jscc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
rollup-plugin-jscc
Conditional compilation (and declaration of ES6 imports) for rollup.
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).
Because this plugin is a preprocessor, it is implemented as a file loader.
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 does this better).
NOTE:
v0.2.0 is a complete rewrite and there's breaking changes, please read the specs in the wiki. Also, removal of comments is not included, but you can use rollup-plugin-cleanup, which brings compaction and normalization of lines, in addition to the conditional removal of JS comments.
Install
npm i rollup-plugin-jscc -DUsage
import { rollup } from 'rollup';
import jscc from 'rollup-plugin-jscc';
rollup({
entry: 'src/main.js',
plugins: [
jscc()
]
}).then(...)Example
//#set _DEBUG 1
/*#if _DEBUG
import mylib from 'mylib-debug';
//#else */
import mylib from 'mylib';
//#endif
mylib.log('Starting v$_VERSION...');output:
import mylib from 'mylib-debug';
mylib.log('Starting v1.0.0...');That's it.
* jscc has the predefined _VERSION varname, in addition to _FILE.
Documentation
You can read in the jscc Wiki about:
What's New
Jump from v0.2.2 to v0.3.2, to stay in sync with jscc.
The staring sequence of HTML comments (
'<!--') is included in the predefined prefixes.
From v0.2.2, the jscc codebase was moved to its own github repository and has 100% coverage. Test for node v0.12 is not included in this plugin, but it is in the jscc repo.
* For me, write in english is 10x harder than coding JS, so contributions are welcome...
Don't forget to give me your star!