Skip to content

Latest commit

 

History

History
60 lines (42 loc) · 1.51 KB

File metadata and controls

60 lines (42 loc) · 1.51 KB

@rolldown/plugin-react-signals-transform npm

Rolldown plugin for the React Signals transform.

It applies the Signals React transform during Rolldown builds with Rolldown's native magic string pipeline, so React components and hooks can automatically subscribe to signal reads without wiring Babel up manually.

Install

pnpm add -D @rolldown/plugin-react-signals-transform
pnpm add react @preact/signals-react

Usage

import reactSignalsTransform from '@rolldown/plugin-react-signals-transform'

export default {
  plugins: [
    reactSignalsTransform({
      mode: 'auto',
    }),
  ],
}

Options

This plugin forwards the same options as @preact/signals-react-transform:

  • mode
  • importSource
  • detectTransformedJSX
  • experimental

Example:

reactSignalsTransform({
  detectTransformedJSX: true,
  experimental: {
    debug: true,
  },
})

Notes

  • Run it before other JSX transforms.
  • The generated code imports useSignals from @preact/signals-react/runtime by default.
  • When your code is already compiled to react/jsx-runtime or React.createElement, enable detectTransformedJSX.

License

MIT

Credits

The transform logic is adapted from packages/react-transform in the Preact Signals repository. The test cases are ported from the same package.