{"id":22096,"library":"rollup-plugin-jscc","title":"rollup-plugin-jscc","description":"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.","status":"maintenance","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/aMarCruz/rollup-plugin-jscc","tags":["javascript","rollup","rollup-plugin","typescript","es2019","es2015","es6","modules"],"install":[{"cmd":"npm install rollup-plugin-jscc","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-jscc","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-jscc","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: requires Rollup >=2.0.0","package":"rollup","optional":false}],"imports":[{"note":"Package is ESM-only since v2.0.0. Default export is the plugin function.","wrong":"const jscc = require('rollup-plugin-jscc')","symbol":"jscc","correct":"import jscc from 'rollup-plugin-jscc'"},{"note":"There is no named export; only a default export.","wrong":"import { jscc } from 'rollup-plugin-jscc'","symbol":"jscc","correct":"import jscc from 'rollup-plugin-jscc'"},{"note":"Use import type for TypeScript types to avoid runtime errors.","wrong":"import { JsccOptions } from 'rollup-plugin-jscc'","symbol":"type JsccOptions","correct":"import type { JsccOptions } from 'rollup-plugin-jscc'"}],"quickstart":{"code":"// rollup.config.js\nimport jscc from 'rollup-plugin-jscc'\n\nexport default {\n  input: 'src/main.js',\n  output: { file: 'dist/bundle.js', format: 'esm' },\n  plugins: [\n    jscc({\n      values: {\n        _APPNAME: 'My App',\n        _DEBUG: process.env.DEBUG ? 1 : 0\n      }\n    })\n  ]\n}\n\n// src/main.js\n/*#if _DEBUG\nconsole.log('Debug mode');\n//#else\nconsole.log('Release mode');\n//#endif*/\nconsole.log('$_APPNAME v$_VERSION');\n\n/* Output when DEBUG is truthy:\nconsole.log('Debug mode');\nconsole.log('My App v2.0.0');\n*/","lang":"javascript","description":"Basic setup: use jscc with custom values and conditional compilation. Shows default export and directive syntax."},"warnings":[{"fix":"Update Rollup to v2+ and Node.js to >=10.12.0.","message":"Requires Rollup v2 and Node.js >=10.12.0. Older versions of rollup-plugin-jscc (v1.x) were compatible with Rollup v1.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Remove 'asloader' option from plugin config.","message":"The asloader option is deprecated. Use the default loader behavior instead.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Use uppercase names starting with underscore for custom variables.","message":"Variable names must match regex /^_[0-9A-Z][_0-9A-Z]*$/. Predefined variables like _FILE and _VERSION are automatically available.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Add rollup-plugin-cleanup to remove JavaScript comments.","message":"The removal of non-jscc comments is not supported. Use rollup-plugin-cleanup if needed.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use 'import' syntax to include the plugin in your rollup config.","message":"v2.0.0 removed support for CommonJS output from the plugin itself; it only provides ESM.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure conditional blocks use correct jscc syntax, e.g., /*#if _DEBUG ... //#else ... //#endif*/","cause":"Conditional import not excluded because the preprocessor directive is incorrectly placed or missing.","error":"Error: RollupError: Could not resolve './some-module' from src/main.js"},{"fix":"Update to rollup-plugin-jscc v2.0.0 and ensure variable names match pattern /^_[0-9A-Z][_0-9A-Z]*$/.","cause":"Using an older version of jscc that lacks certain features or using incorrect variable names.","error":"TypeError: Cannot read property 'unset' of undefined"},{"fix":"Set 'prefixes' option to include your chosen comment prefix, e.g., prefixes: ['//#', '/*#'].","cause":"Directives like //#if not recognized because the prefix does not match default (default: ['//', '/*', '<!--']).","error":"SyntaxError: Invalid or unexpected token"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}