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

react-browser-loader

v1.0.2

Published

在前端编译react多文件代码,包含插件机制,基于此定制开发专属你的前端物料平台

Downloads

9

Readme

react-browser-loader

在前端浏览器环境内编译react多文件代码,包含插件机制,可基于此定制开发专属你的前端在线编码平台或者前端物料平台

Demo

import loader from 'react-browser-loader'
import React from 'react';
import ReactDOM from 'react-dom';
const config = {
  el: document.getElementById('app') as HTMLElement,
  React: React,
  ReactDOM: ReactDOM,
  entry: '/app.js',
  addStyle: (str) => {
    console.log(`you should add style, content:${str}`)
  },
  files: {
      '/demo.jpg': `https://upload.wikimedia.org/wikipedia/commons/a/a7/React-icon.svg`,
      '/style.scss': `div{
        h1{
          color: red
        }
      }`,
      '/a/a.jsx': `
      export default function (props) {
        return <div> render a/a/.jsx</div>
      }
        `,
        '/a/b.jsx': `
        import B from './a.jsx';
        export default function (props) {
          return <div> render a/b/.jsx
          <br />
          Child: <B />
          </div>
        }
          `,
      '/app.js': `
        import CompA from './a.js';
        import  {useState} from 'react';
        import demo from './demo.jpg';
        import Ab from '/a/b.jsx';
        import './style.scss'
        const a = <div style={{color: 'red'}}>456</div>
        export const b = 3;
        export default function (props) {
          console.log(props, '----')
          const [count, setCount] = useState(0)
          return <div>
          <h1 >Count: {count}</h1>
          <img src={demo} style={{width: 200}}/>
          <h1 style={{color: 'red', cursor: 'pointer'}} onClick={() => setCount(count + 1)}>这是appjs组件 点我++</h1>
          <CompA />
          <Ab />
          </div>
        }
      `,
      '/a.js': `
        import  {useState} from 'react';
        import CompA from './CompA.jsx'
        export default function () {
          const [count, setCount] = useState(0)
          return <div  onClick={() =>setCount(count + 1)}>a.js CompA counter: {count}
          <CompA a='123'/>
          </div>
        }
      `,
    '/index.jsx': `
      import CompA from './CompA.jsx';
      export default function () {
        return (
          <div>
            <h1> Render React Mode </h1>
          </div>
        )
      }
    `,
    '/CompA.jsx': `
    export default function (props) {
      console.log(props, '================================')
      return (
        <div>
          <h1> ./CompA.jsx </h1>
        </div>
      )
    }
    `
  },
  parser: {
    moduleParser (path, config) { // 处理非编译情况下的代码, 即除去js, ts, jsx, tsx之外的
      if(path.endsWith('.jpg')) {
        return config.files[path]
      }
    }
  },
  module: {
    scss: (path, source) => {
      console.log(path, source)
    },
    stylus: () => {

    }
  }
}
const App = loader(config)
window.ReactDOM.render(window.React.createElement(App.default,  {a: 1}), config.el)