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

react-umd-demo

v1.0.28

Published

将 react 组件打包成 umd,支持 script 引入和 React 组件两种使用方式

Downloads

18

Readme

React UMD Demo

  • 借助 webpack 能力,将 react 组件打包成 umd 供接入方使用,支持 script 引入和 React 组件两种使用方式,不受接入方技术栈限制的方案调研
  • iframe 的痛点:Why Not Iframe
  • 打包成 umd 或组件有类型提示,对接更友好

使用场景

  • 例如公司里使用 cocos 开发的一个小游戏项目,需要接入使用 react 开发的通用组件时
  • 公司各个前端项目使用了不同的技术栈,需要接入通用组件时
  • 封装 js sdk

使用示例

安装和使用

方式一:script 引入(推荐)

引入

<script src="//cdn.jsdelivr.net/npm/react-umd-demo@latest/dist/react-umd-demo.js"></script>

添加一个容器

<div id="container"></div>

生成

const instance = new ReactUmdDemo({
  container: 'container' // 容器元素 id
});

instance.render({
  type: 'Page1'
});

方式二:npm 安装

npm install react-umd-demo
import ReactUmdDemo from 'react-umd-demo';

const instance = new ReactUmdDemo({
  container: 'container' // 容器元素 id
});

instance.render({
  type: 'Page1'
});

React 组件形式:

import ReactUmdDemo from 'react-umd-demo/dist/react-umd-demo-component';

export default function App() {
  return (
    <div className="App">
      <ReactUmdDemo
        type="Page1"
        // ...其他配置
      />
    </div>
  );
}

存在的问题

  • 鉴权方案
  • 全局样式污染接入方
  • 使用 react 组件形式接入,接入方 react 版本太低,无法使用某些 react api

其他

  • 使用了 preact/compat 代替 react 以减小打包体积