Registry / devops / rollup-plugin-jscc

rollup-plugin-jscc

JSON →
library2.0.0jsnpmunverified

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-jscc
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-JSCC
R
rollup-plugin-jscc
devopsjavascriptv2.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

jscc
✓ import jscc from 'rollup-plugin-jscc'
✗ const jscc = require('rollup-plugin-jscc')
Package is ESM-only since v2.0.0. Default export is the plugin function.
jscc
✓ import jscc from 'rollup-plugin-jscc'
✗ import { jscc } from 'rollup-plugin-jscc'
There is no named export; only a default export.
type JsccOptions
✓ import type { JsccOptions } from 'rollup-plugin-jscc'
✗ import { JsccOptions } from 'rollup-plugin-jscc'
Use import type for TypeScript types to avoid runtime errors.

Basic setup: use jscc with custom values and conditional compilation. Shows default export and directive syntax.

// rollup.config.js import jscc from 'rollup-plugin-jscc' export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'esm' }, plugins: [ jscc({ values: { _APPNAME: 'My App', _DEBUG: process.env.DEBUG ? 1 : 0 } }) ] } // src/main.js /*#if _DEBUG console.log('Debug mode'); //#else console.log('Release mode'); //#endif*/ console.log('$_APPNAME v$_VERSION'); /* Output when DEBUG is truthy: console.log('Debug mode'); console.log('My App v2.0.0'); */
Debug
Known issues
breakingRequires Rollup v2 and Node.js >=10.12.0. Older versions of rollup-plugin-jscc (v1.x) were compatible with Rollup v1.
fix
Update Rollup to v2+ and Node.js to >=10.12.0.
affects: >=2.0.0
deprecatedThe asloader option is deprecated. Use the default loader behavior instead.
fix
Remove 'asloader' option from plugin config.
affects: >=2.0.0
gotchaVariable names must match regex /^_[0-9A-Z][_0-9A-Z]*$/. Predefined variables like _FILE and _VERSION are automatically available.
fix
Use uppercase names starting with underscore for custom variables.
affects: >=2.0.0
gotchaThe removal of non-jscc comments is not supported. Use rollup-plugin-cleanup if needed.
fix
Add rollup-plugin-cleanup to remove JavaScript comments.
affects: >=2.0.0
breakingv2.0.0 removed support for CommonJS output from the plugin itself; it only provides ESM.
fix
Use 'import' syntax to include the plugin in your rollup config.
affects: >=2.0.0
Errors
Common errors & fixes
Error: RollupError: Could not resolve './some-module' from src/main.js
Conditional import not excluded because the preprocessor directive is incorrectly placed or missing.
fix
Ensure conditional blocks use correct jscc syntax, e.g., /*#if _DEBUG ... //#else ... //#endif*/
TypeError: Cannot read property 'unset' of undefined
Using an older version of jscc that lacks certain features or using incorrect variable names.
fix
Update to rollup-plugin-jscc v2.0.0 and ensure variable names match pattern /^_[0-9A-Z][_0-9A-Z]*$/.
SyntaxError: Invalid or unexpected token
Directives like //#if not recognized because the prefix does not match default (default: ['//', '/*', '<!--']).
fix
Set 'prefixes' option to include your chosen comment prefix, e.g., prefixes: ['//#', '/*#'].
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
rolluprequiredPeer dependency: requires Rollup >=2.0.0
Agent activity
5 hits · last 30 days
node
4
Resources
rollup-plugin-jscc — npm install rollup-plugin-jscc · libregistry