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

sfmic

v0.0.7

Published

micro frontend

Downloads

6

Readme

Feature

  • shadow dom

  • scoped css

  • proxy sandbox

  • mixins

  • react合成事件支持

Use

<one-app></one-app>

<two-app></two-app>
import { register, start } from 'sfmic'

register(
  'one-app',
  'http://localhost:3000/one.html',
  (location) => location.hash === '#/app1',
  {
    prop1: 'props'
  }
)
register(
  'two-app',
  'http://localhost:3000/two.html',
  (location) => location.hash === '#/app2'
)
// want to reuse the same app?
register(
  'two-app',
  'http://localhost:3000/two.html',
  (location) => location.hash === '#/app3'
).alias('other-name')
//.allowList({}) // sandbox allowList
    // you can put your vuex store in allowList,then child can use it!
//.fixReactEvent(true)
    // hack: react<=16 合成事件兼容问题
start()

child

// in vue, for webcomponents
Vue.config.ignoredElements = ['one-app', 'two-app']

export async function bootstrap() {}

export async function mount({ host, props }) {}

export async function unmount({ host }) {}

if (!window.IS_SFMIC_SANDBOX) {
  // mount
}
// webpack
 library: 'one-app',
 libraryTarget: 'umd',
 umdNamedDefine: true,

mixins

import { mixin } from 'sfmic'

mixin({
  bootstrap: () => {},
  mount: () => {},
  unmount: () => {}
})

shadow DOM 的问题

如果使用的基础依赖的组件库,并没有设计让 Dialog 等弹出层在指定的 dom 节点中插入结构的话,弹出层都是会逃离你当前的 shadow DOM。逃离之后,它就是一个无样式的弹框。这种无样式的弹框对于业务上来说是不可以接受的,因此弹框逻辑需要去做一些兼容,更甚至需要对底层组件去做改造。

在 React 场景下,shadow DOM 的使用会涉及到事件机制的问题,因为 React 的事件机制是代理到 document 的,但基于 shadow DOM 处理的话,它可能会阻断事件到它的 host 层,也就是你渲染 shadow DOM 的那一层。虽然说社区也有对应的包去做一些兼容处理,但它对业务上来说还是会有一些实现成本。当然,本框架开启fixReactEvent(true)配置即可内置解决。

除此之外还包括其它的问题。比如 CSS @font-face,或者说一些字体属性,svg 都会有一个不兼容的场景