{"id":22175,"library":"rollup-plugin-preact","title":"rollup-plugin-preact","description":"Rollup plugin that automatically resolves and aliases React imports to Preact/Preact Compat in Rollup bundles. Current stable version 0.5.2. Configurable options include usePreactX for Preact X, noPropTypes, noReactIs, noEnv flags to remove unnecessary compat code, and custom aliasModules. It simplifies migrating from React to Preact by handling module resolution and compat aliasing.","status":"active","version":"0.5.2","language":"javascript","source_language":"en","source_url":"https://github.com/daybrush/rollup-plugin-preact","tags":["javascript","rollup","plugin","preact","react","compat"],"install":[{"cmd":"npm install rollup-plugin-preact","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-preact","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-preact","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package defaults to default export; CJS require works directly, but ESM import is preferred.","wrong":"const preact = require('rollup-plugin-preact').default","symbol":"preact","correct":"import preact from 'rollup-plugin-preact'"},{"note":"No default property needed; the default export is the plugin function.","symbol":"preact (CommonJS)","correct":"const preact = require('rollup-plugin-preact')"},{"note":"preact is a function, not an object with a default method.","wrong":"export default { plugins: [preact.default()] }","symbol":"plugin usage in rollup.config.js","correct":"import preact from 'rollup-plugin-preact';\nexport default { plugins: [preact({ usePreactX: true })] }"}],"quickstart":{"code":"// rollup.config.js\nimport preact from 'rollup-plugin-preact';\n\nexport default {\n  input: 'src/main.js',\n  output: {\n    file: 'bundle.js',\n    format: 'iife',\n  },\n  plugins: [\n    preact({\n      usePreactX: true,\n      noPropTypes: true,\n      noReactIs: true,\n      noEnv: true,\n      resolvePreactCompat: true,\n      aliasModules: {\n        'react-dom': 'preact/compat',\n      },\n    }),\n  ],\n};","lang":"javascript","description":"Configure Rollup to replace React imports with Preact/Preact Compat and remove unnecessary compat code."},"warnings":[{"fix":"Upgrade Node to >=10 and Rollup to >=1.0.","message":"Version 0.5.x drops support for Node < 10; requires Rollup >= 1.0","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Replace 'usePreactX: true' with 'resolvePreactCompat: true'.","message":"Option 'usePreactX' is deprecated in favor of using 'resolvePreactCompat: true' with Preact X+.","severity":"deprecated","affected_versions":"<0.5.0"},{"fix":"Run 'npm install preact' and use 'aliasModules: { \"react\": \"preact/compat\" }'.","message":"Plugin does not automatically install Preact; you must install 'preact' and optionally 'preact/compat'.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Remove PropTypes imports or set 'noPropTypes: false' if needed.","message":"When using 'noPropTypes', ensure your code does not rely on PropTypes (runtime removal may cause errors).","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'npm install rollup-plugin-preact' or 'yarn add rollup-plugin-preact'.","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'rollup-plugin-preact'"},{"fix":"Use 'import preact from \"rollup-plugin-preact\"' or 'const preact = require(\"rollup-plugin-preact\")'.","cause":"Importing incorrectly (e.g., preact.default()).","error":"TypeError: preact is not a function"},{"fix":"Install preact-compat or set alias properly, e.g., 'aliasModules: { \"react\": \"preact/compat\" }'.","cause":"Preact Compat not installed or alias not configured correctly.","error":"Error: No version of preact/compat found in node_modules"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}