{"id":22177,"library":"rollup-plugin-preprocess","title":"rollup-plugin-preprocess","description":"A Rollup plugin that integrates the Preprocess library to conditionally include or exclude parts of files (HTML, JS, etc.) based on a user-defined context (e.g., DEBUG flags). The latest stable version is 0.0.4 (released November 2016). Development appears to be stalled with no recent releases or maintenance; this plugin is a thin wrapper around the `preprocess` package for Rollup build pipelines. Alternatives include `@rollup/plugin-replace` or direct use of `preprocess` with other Rollup hooks. The plugin supports simple context-based preprocessing but lacks extensive documentation and has limited adoption.","status":"deprecated","version":"0.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/Katochimoto/rollup-plugin-preprocess","tags":["javascript","rollup","plugin","preprocess"],"install":[{"cmd":"npm install rollup-plugin-preprocess","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-preprocess","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-preprocess","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core preprocessing library for evaluating conditional comments in files.","package":"preprocess","optional":false},{"reason":"Provides utility functions like createFilter for Rollup plugins.","package":"rollup-pluginutils","optional":false}],"imports":[{"note":"This package uses a CommonJS default export; with ESM, import default directly. In CJS, use require('rollup-plugin-preprocess')() — note no .default.","wrong":"const preprocess = require('rollup-plugin-preprocess').default","symbol":"default","correct":"import preprocess from 'rollup-plugin-preprocess'"},{"note":"There is no named export; the entire module exports a single function. Using curly braces will result in undefined.","wrong":"import { RollupPluginPreprocess } from 'rollup-plugin-preprocess'","symbol":"RollupPluginPreprocess","correct":"import RollupPluginPreprocess from 'rollup-plugin-preprocess'"}],"quickstart":{"code":"// rollup.config.js\nimport preprocess from 'rollup-plugin-preprocess';\n\nexport default {\n  input: 'src/main.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'iife'\n  },\n  plugins: [\n    preprocess({\n      context: {\n        DEBUG: process.env.DEBUG === 'true',\n        VERSION: '1.0.0'\n      }\n    })\n  ]\n};\n\n// In your source code:\n// @if DEBUG\nconsole.log('Debug mode');\n// @endif\n// @echo VERSION","lang":"javascript","description":"Shows how to configure the plugin with a context object and use preprocess directives in source files."},"warnings":[{"fix":"Migrate to @rollup/plugin-replace or use the preprocess library directly with a custom Rollup plugin.","message":"This package has not been updated since 2016 and is essentially unmaintained. Consider using modern alternatives like @rollup/plugin-replace.","severity":"deprecated","affected_versions":"*"},{"fix":"Manually specify the include and exclude options in the plugin configuration.","message":"The plugin does not handle TypeScript or Vue files out-of-the-box; you may need to adjust the include/exclude filter.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Pass nested values as flat keys or use a string expression that evaluates in the preprocess context.","message":"The context object is not deeply merged; only top-level properties are available in preprocess directives.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"npm install rollup-pluginutils --save-dev","cause":"Missing dependency rollup-pluginutils which is a peer dependency.","error":"Error: Cannot find module 'rollup-pluginutils'"},{"fix":"Use import preprocess from 'rollup-plugin-preprocess' instead of import { preprocess } from 'rollup-plugin-preprocess'","cause":"Using named import when only default export exists.","error":"TypeError: preprocess is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}