Socket
Book a DemoInstallSign in
Socket

babel-plugin-jsx-expressions

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-jsx-expressions

Plugin to automatically wrap JSX expressions and spread attributes containing any member access with a computed [signal](https://preactjs.com/guide/v10/signals/).

0.4.0
latest
npmnpm
Version published
Maintainers
0
Created
Source

babel-plugin-jsx-expressions

Plugin to automatically wrap JSX expressions and spread attributes containing any member access with a computed signal.

This enables signal-safe expressions in JSX when using Preact with the Signals library.

Installation

npm install --save-dev @babel/core @preact/signals

Also install this plugin (locally or from your project):

npm install --save-dev babel-plugin-jsx-expressions

Usage with Babel

const { transformSync } = require("@babel/core");
const plugin = require("babel-plugin-jsx-expressions");

const result = transformSync(code, {
  filename: "file.tsx",
  plugins: [plugin],
  parserOpts: { sourceType: "module" },
  sourceMaps: true
});

Or in your babel.config.js:

module.exports = {
  plugins: ["babel-plugin-jsx-expressions"]
};

What it does

This plugin transforms JSX like:

<div>{foo.bar}</div>

into:

import { computed } from "@preact/signals";
<div>{computed(() => foo.bar)}</div>

It also works for JSX spread attributes:

<Component {...some.obj} />
// becomes
<Component {...computed(() => some.obj)} />

Notes

  • The plugin ensures the Babel parser supports both jsx and typescript by injecting those parser plugins via manipulateOptions().
  • Only expressions containing a MemberExpression (e.g. a.b) are wrapped.
  • Nested JSX containers are handled correctly.

License

MIT

FAQs

Package last updated on 22 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.