Rollup plugin for conditional compilation and compile-time variable replacement using jscc. Current stable version is 2.0.0, released 2020-08-28, with a maintenance cadence (last major release). Key differentiators: runs before transpilers as a file loader (or optionally as transformer), supports TypeScript definitions, sourcemaps, and uses full JavaScript expressions for conditional blocks. Unlike other preprocessors, it is language agnostic and tightly integrated with Rollup v2+, requiring Node >=10.12.0.
npm install rollup-plugin-jsccVerified import paths — ran on the pinned version, not inferred.
Basic setup: use jscc with custom values and conditional compilation. Shows default export and directive syntax.
Update Rollup to v2+ and Node.js to >=10.12.0.
Remove 'asloader' option from plugin config.
Use uppercase names starting with underscore for custom variables.
Add rollup-plugin-cleanup to remove JavaScript comments.
Use 'import' syntax to include the plugin in your rollup config.
Ensure conditional blocks use correct jscc syntax, e.g., /*#if _DEBUG ... //#else ... //#endif*/
Update to rollup-plugin-jscc v2.0.0 and ensure variable names match pattern /^_[0-9A-Z][_0-9A-Z]*$/.
Set 'prefixes' option to include your chosen comment prefix, e.g., prefixes: ['//#', '/*#'].