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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@memberjunction/react-runtime

v5.17.0

Published

Platform-agnostic React component runtime for MemberJunction. Provides core compilation, registry, and execution capabilities for React components in any JavaScript environment.

Readme

@memberjunction/react-runtime

Platform-agnostic React component runtime for MemberJunction. Provides core compilation, registry, dynamic library management, and execution capabilities for React components in any JavaScript environment.

Architecture

graph TD
    subgraph "@memberjunction/react-runtime"
        A[createReactRuntime] --> B[ComponentCompiler]
        A --> C[ComponentRegistry]
        A --> D[ComponentResolver]
        A --> E[ComponentManager]

        B --> F["Babel Standalone<br/>(JSX Compilation)"]

        C --> G[Component Store]
        C --> H[Namespace Support]

        D --> I[Component Resolution]
        D --> J[Dependency Resolution]

        E --> K[Load + Compile + Register]

        subgraph "Utilities"
            L[LibraryLoader]
            M[LibraryRegistry]
            N[CacheManager]
            O[ResourceManager]
            P[ErrorBoundary]
            Q[PropBuilder]
            R[ReactRootManager]
        end
    end

    subgraph "Runtime APIs"
        S[ComponentHierarchyRegistrar]
        T[StandardLibraries]
        U[ComponentErrorAnalyzer]
    end

    style A fill:#2d6a9f,stroke:#1a4971,color:#fff
    style B fill:#2d8659,stroke:#1a5c3a,color:#fff
    style C fill:#2d8659,stroke:#1a5c3a,color:#fff
    style D fill:#7c5295,stroke:#563a6b,color:#fff
    style E fill:#7c5295,stroke:#563a6b,color:#fff
    style L fill:#b8762f,stroke:#8a5722,color:#fff
    style N fill:#b8762f,stroke:#8a5722,color:#fff
    style P fill:#b8762f,stroke:#8a5722,color:#fff

Overview

This package enables dynamic compilation and execution of React components at runtime. Components can be loaded from MemberJunction's database, compiled with Babel, registered into a component registry, and rendered with full dependency resolution.

Key capabilities:

  • Component Compilation: Transpiles JSX/TSX source code using Babel standalone
  • Component Registry: LRU-cached registry with namespace support for up to 1000 components
  • Component Resolution: Resolves component specs against the registry with dependency tracking
  • Component Manager: Unified API for loading, compiling, and registering components in one call
  • Library Management: Dynamic library loading, registration, and dependency resolution
  • Error Boundaries: Configurable error boundary creation with logging
  • Prop Building: Type-safe prop construction with callback normalization and style processing
  • React Root Management: Managed React root lifecycle for mounting/unmounting components
  • Caching: LRU cache with configurable TTL for compiled components
  • UMD Build: Ships both CommonJS and UMD bundles for browser environments

Installation

npm install @memberjunction/react-runtime

Usage

Quick Start

import { createReactRuntime } from '@memberjunction/react-runtime';
import * as Babel from '@babel/standalone';

const runtime = createReactRuntime(Babel, {
    compiler: { minify: false, sourceMaps: true, cache: true },
    registry: { maxComponents: 500 }
});

// Compile a component from source
const compiled = runtime.compiler.compile(`
    function MyComponent({ name }) {
        return <div>Hello, {name}!</div>;
    }
`);

// Register it
runtime.registry.register('MyComponent', compiled);

// Resolve for rendering
const resolved = runtime.resolver.resolve({ name: 'MyComponent' });

Component Manager (Unified API)

const result = await runtime.manager.load({
    componentSpec: { name: 'MyWidget', source: jsxSource },
    autoRegister: true,
    resolveLibraries: true
});

if (result.success) {
    // Component is compiled, registered, and ready to render
    const Component = result.component;
}

Library Management

import { LibraryRegistry, LibraryLoader } from '@memberjunction/react-runtime';

// Register a library for dependency resolution
LibraryRegistry.register({
    name: 'recharts',
    module: rechartsModule,
    version: '2.x'
});

// Load libraries dynamically
const loader = new LibraryLoader();
const result = await loader.load({ name: 'recharts', url: cdnUrl });

Error Boundaries

import { createErrorBoundary, withErrorBoundary } from '@memberjunction/react-runtime';

// Create an error boundary component
const ErrorBoundary = createErrorBoundary({
    fallback: (error) => <div>Something went wrong: {error.message}</div>,
    onError: (error) => logError(error)
});

// Or wrap an existing component
const SafeComponent = withErrorBoundary(MyComponent, { fallback: ErrorFallback });

Prop Building

import { buildComponentProps, normalizeCallbacks } from '@memberjunction/react-runtime';

const props = buildComponentProps(rawData, {
    normalizeStyles: true,
    normalizeCallbacks: true,
    validateProps: true
});

Exported Modules

| Module | Key Exports | |--------|-------------| | Compiler | ComponentCompiler, getBabelConfig, getJSXConfig | | Registry | ComponentRegistry, ComponentResolver, ComponentRegistryService | | Manager | ComponentManager, LoadOptions, LoadResult | | Runtime | createErrorBoundary, buildComponentProps, ComponentHierarchyRegistrar, ReactRootManager | | Utilities | LibraryLoader, LibraryRegistry, CacheManager, ResourceManager, StandardLibraries |

Configuration

const DEFAULT_CONFIGS = {
    compiler: {
        babel: { presets: ['react'], plugins: [] },
        minify: false,
        sourceMaps: false,
        cache: true,
        maxCacheSize: 100
    },
    registry: {
        maxComponents: 1000,
        cleanupInterval: 60000,
        useLRU: true,
        enableNamespaces: true
    }
};

Build Outputs

  • CommonJS: dist/index.js -- for Node.js and bundler environments
  • UMD: dist/umd/ -- for direct browser usage via script tags

Dependencies

| Package | Purpose | |---------|---------| | @memberjunction/core | Core MJ functionality | | @memberjunction/global | MJGlobal utilities | | @memberjunction/interactive-component-types | Component type definitions | | @memberjunction/core-entities | Entity types | | @memberjunction/graphql-dataprovider | GraphQL data access | | @babel/standalone | Runtime JSX compilation | | rxjs | Observable patterns |

License

ISC