Registry / web-framework / rollup-plugin-react-compat

rollup-plugin-react-compat

JSON →
library0.1.1jsnpmunverified

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.

npm install rollup-plugin-react-compat
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-REAC
R
rollup-plugin-react-compat
web-frameworkjavascriptv0.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

default
import reactCompat from 'rollup-plugin-react-compat'
const reactCompat = require('rollup-plugin-react-compat').default
CommonJS require works but no .default needed; ESM import is default.

Configures Rollup to alias React modules to Preact's compat layer with custom aliases.

// rollup.config.js import reactCompat from 'rollup-plugin-react-compat'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'esm' }, plugins: [ reactCompat({ useReactCompat: true, usePreactX: false, noPropTypes: true, resolvePreactCompat: true, aliasModules: { 'react-css-styled': 'preact-css-styled' } }) ] };
Debug
Known issues
gotchaThe plugin does not install preact or preact-compat for you; you must add them as dependencies.
fix
npm install preact preact-compat
affects: all
gotchaIf you enable both usePreactX and resolvePreactCompat, the plugin may double-alias, causing unexpected behavior.
fix
Set only one of them to true, or ensure your configuration is mutually exclusive.
affects: >=0.1.0
breakingWhen '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.
fix
Ensure your codebase is compatible with Preact's compat layer.
affects: >=0.1.0
deprecatedThe option 'usePreactCompat' (boolean) is deprecated in favor of 'useReactCompat' and may be removed in future versions.
fix
Replace 'usePreactCompat: true' with 'useReactCompat: true'.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'preact-compat' while using rollup-plugin-react-compat
The plugin expects 'preact-compat' to be installed as a dependency in your project.
fix
Run 'npm install preact-compat' and ensure it's listed in your package.json.
TypeError: reactCompat is not a function
You imported the plugin incorrectly (e.g., using named import instead of default).
fix
Use 'import reactCompat from 'rollup-plugin-react-compat'' (default import).
(!) Plugin rollup-plugin-react-compat: options.usePreactCompat is deprecated. Use useReactCompat instead.
The option 'usePreactCompat' is deprecated.
fix
Change 'usePreactCompat: true' to 'useReactCompat: true' in the plugin options.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
@rollup/plugin-aliasrequiredUsed under the hood to perform module resolution aliasing
@rollup/plugin-node-resolveoptionalRequired for resolving node_modules, especially when using resolvePreactCompat or other resolution options
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-react-compat — npm install rollup-plugin-react-compat · libregistry