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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@proscenium/component-manager

v0.4.2

Published

Dynamic React component islands

Downloads

6

Readme

Proscenium / Component Manager

Lazy load islands of React components.

Install

npm add @proscenium/component-manager or

yarn add @proscenium/component-manager or

pnpm add @proscenium/component-manager

Usage

NOTE: component-manager is designed to be used with proscenium

Wherever you want to render a component, simply create an HTML element with the class componentManagedByProscenium, and a data-component attribute. The init() function will then find these elements you created, and will lazily load and render the matching component in their place.

The data-component attribute should be a stringified JSON object and defines where the component module should be imported from, the props it should be given, and any other options.

{
  "path": "my/component",
  "props": {
    "name": "Joel"
  },
  "lazy": true // default
}

At a minimum, the path to the component should be given, and will be used to import the component.

By default, components are only loaded and rendered when coming into view using the browser's IntersectionObserver. You can disable this and render a component immediately by passing lazy: false.

Example

<div
  class="componentManagedByProscenium"
  data-component="{\"path\":\"my/component\",\"lazy\":true,\"props\":{\"name\":\"Joel\"}}">
  loading...
</div>
import init from '@proscenium/component-manager'

init({
  // Wrap all components with this component.
  //
  // If a String, it should be a path to a module that will be dynamically imported and wrapped with
  // React's `lazy` helper. If a function, that function should return a dynamic `import()` of the
  // component you want to wrap with. If a promise, it should be the result of a dynamic `import()`.
  wrapWithComponent: '/my/application/component.jsx',

  // Wrap each components with this component.
  //
  // If a String, it should be a path to a module that will be dynamically imported and wrapped with
  // React's `lazy` helper. If a function, that function should return a dynamic `import()` of the
  // component you want to wrap with. If a promise, it should be the result of a dynamic `import()`.
  wrapEachWithComponent: '/my/each/component.jsx',

  // The Node selector to use for querying for components.
  selector: '.componentManagedByProscenium',

  // A function that accepts the component path, and should return a new path. This allows you to
  // rewrite the import path to your components.
  //
  // Example
  //  my/component -> /components/my/component.jsx
  buildComponentPath(component) {
    return `/components/${component}.jsx`
  },

  debug: false
})