{"id":22193,"library":"rollup-plugin-react-compat","title":"rollup-plugin-react-compat","description":"Rollup plugin to alias 'react', 'react-dom', and related modules to Preact ('preact/compat' or 'preact-compat') with configurable options like React-like compatibility flags (usePreactX, noPropTypes, etc.). Version 0.1.1 (first stable release), low release cadence. Key differentiator: provides a one-stop Rollup integration for swapping React with Preact's compat layer, supporting aliasModules for custom mappings. Alternatives like @rollup/plugin-alias require manual configuration.","status":"active","version":"0.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/daybrush/rollup-plugin-react-compat","tags":["javascript","rollup","plugin","preact","react","compat","croact"],"install":[{"cmd":"npm install rollup-plugin-react-compat","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-react-compat","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-react-compat","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used under the hood to perform module resolution aliasing","package":"@rollup/plugin-alias","optional":false},{"reason":"Required for resolving node_modules, especially when using resolvePreactCompat or other resolution options","package":"@rollup/plugin-node-resolve","optional":true}],"imports":[{"note":"CommonJS require works but no .default needed; ESM import is default.","wrong":"const reactCompat = require('rollup-plugin-react-compat').default","symbol":"default","correct":"import reactCompat from 'rollup-plugin-react-compat'"}],"quickstart":{"code":"// rollup.config.js\nimport reactCompat from 'rollup-plugin-react-compat';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'esm'\n  },\n  plugins: [\n    reactCompat({\n      useReactCompat: true,\n      usePreactX: false,\n      noPropTypes: true,\n      resolvePreactCompat: true,\n      aliasModules: {\n        'react-css-styled': 'preact-css-styled'\n      }\n    })\n  ]\n};","lang":"javascript","description":"Configures Rollup to alias React modules to Preact's compat layer with custom aliases."},"warnings":[{"fix":"npm install preact preact-compat","message":"The plugin does not install preact or preact-compat for you; you must add them as dependencies.","severity":"gotcha","affected_versions":"all"},{"fix":"Set only one of them to true, or ensure your configuration is mutually exclusive.","message":"If you enable both usePreactX and resolvePreactCompat, the plugin may double-alias, causing unexpected behavior.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure your codebase is compatible with Preact's compat layer.","message":"When 'useReactCompat: true', the plugin aliases 'react' to 'preact/compat' and 'react-dom' to 'preact/compat'. This changes the module resolution and may break code that expects React internals.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Replace 'usePreactCompat: true' with 'useReactCompat: true'.","message":"The option 'usePreactCompat' (boolean) is deprecated in favor of 'useReactCompat' and may be removed in future versions.","severity":"deprecated","affected_versions":">=0.1.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 preact-compat' and ensure it's listed in your package.json.","cause":"The plugin expects 'preact-compat' to be installed as a dependency in your project.","error":"Error: Cannot find module 'preact-compat' while using rollup-plugin-react-compat"},{"fix":"Use 'import reactCompat from 'rollup-plugin-react-compat'' (default import).","cause":"You imported the plugin incorrectly (e.g., using named import instead of default).","error":"TypeError: reactCompat is not a function"},{"fix":"Change 'usePreactCompat: true' to 'useReactCompat: true' in the plugin options.","cause":"The option 'usePreactCompat' is deprecated.","error":"(!) Plugin rollup-plugin-react-compat: options.usePreactCompat is deprecated. Use useReactCompat instead."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}