npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@wix/babel-plugin-jsx-dynamic-data

v1.0.11

Published

A Babel plugin that automatically adds a `data-dynamic` attribute to primitive HTML elements within your React components when their attributes or text content contain dynamic expressions.

Readme

@wix/babel-plugin-jsx-dynamic-data

A Babel plugin that automatically adds a data-dynamic attribute to primitive HTML elements within your React components when their attributes or text content contain dynamic expressions.

This helps in identifying parts of the DOM that are reactive to dynamic data and disabling styling of elements that have dynamic attributes in the editor.

How it Works

The plugin traverses the JSX in your components and performs the following:

  1. Identifies Dynamic Expressions: It detects expressions (variables, function calls, object access, etc.) used in JSX attributes and text content.
  2. Tags Primitive Elements: If a primitive HTML element (e.g., div, span, img) has an attribute or text content that contains dynamic expressions, the plugin adds a data-dynamic attribute to that element.
    • The value of data-dynamic is a space-separated string containing the names of the attributes that are dynamic.
    • If text content is dynamic, "text" is included in the data-dynamic value.
    • For Tailwind CSS classes, the plugin maps class names to their corresponding CSS properties.
  3. Exclusions:
    • It does not add data-dynamic to custom React components (e.g., <MyCustomButton />).
    • It ignores elements inside custom components.
    • It ignores key attributes and event handlers (e.g., onClick, onChange).
    • For the style attribute, if any part of the style object is dynamic, data-dynamic="style" is added.
    • For dangerouslySetInnerHTML, if its content is dynamic, data-dynamic="text" is added.
  4. Component Processing: Only exported components are processed to optimize performance.

Installation

npm install --save-dev @wix/babel-plugin-jsx-dynamic-data
# or
yarn add --dev @wix/babel-plugin-jsx-dynamic-data

Usage

Add the plugin to your Babel configuration (e.g., .babelrc.js or babel.config.js):

// .babelrc.js or babel.config.js
module.exports = {
  plugins: [
    // Other plugins...
    "@wix/babel-plugin-jsx-dynamic-data",
  ],
};

Or if using JSON configuration:

{
  "plugins": ["@wix/babel-plugin-jsx-dynamic-data"]
}

Examples

Here are some examples of how the plugin transforms your code:

1. Dynamic Attributes & Text Content

Before:

function UserGreeting({ name, id, userColor }) {
  return (
    <div id={id} className="user-greeting" style={{ color: userColor }}>
      Hello, {name}!
    </div>
  );
}

After:

function UserGreeting({ name, id, userColor }) {
  return (
    <div id={id} className="user-greeting" style={{ color: userColor }} data-dynamic="id style text">
      Hello, {name}!
    </div>
  );
}

2. Dynamic Style Attribute

Before:

function HighlightBox({ isActive, highlightColor }) {
  const styles = {
    padding: '10px',
    backgroundColor: isActive ? highlightColor : 'transparent',
  };
  return <div style={styles}>Important content</div>;
}

After:

function HighlightBox({ isActive, highlightColor }) {
  const styles = {
    padding: '10px',
    backgroundColor: isActive ? highlightColor : 'transparent',
  };
  return <div style={styles} data-dynamic="style">Important content</div>;
}

3. Dynamic Text Content

Before:

function ItemCount({ count }) {
  return <p>Total items: {count}</p>;
}

After:

function ItemCount({ count }) {
  return <p data-dynamic="text">Total items: {count}</p>;
}