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

@ugdu/runtime

v2.0.1

Published

A runtime lib for micro frontends.

Downloads

17

Readme

A runtime lib for micro frontends.

Overview

This runtime lib provide a ur global variable which has some helpful methods like register, load, unload and start. For features, check features. For a simple example, check usage. The phrases like app are terms. Their brief explanation is here. For more detail, check our API docs.

Features

  • Independent deployment.
    • All modules can be deployed independently.
  • Multiple frameworks in one project.
    • Different apps can be based on different frameworks. This means that you can upgrade or refactor your project incrementally. For example, develop new feature with vue3 and the other code remain vue2.
  • Style security.
    • To avoid FOUC, the module will only be evaluated after the css it required is loaded.
    • The css of the apps which should be unload will be removed from the document.
  • Lazy load.
    • Only the modules which are used by the active apps will be loaded.
  • Preload assets
    • When load a module, all modules this module imports will be preload.

Usage

Include @ugdu/runtime with a async attribute on the script, then include an importmap and module scripts normally.

Below is an example for a project that which registers two app, one based on vue2 and the other based on vue2.

Tips: When using our build tool @ugdu/packer, the importmap and the startup script will be generated according to your source code.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>ugdu</title>
    <script async src="https://unpkg.com/@ugdu/runtime/dist/index.js"></script>
    <script type="importmap-shim">
      {
        "imports": {
          "@v2/container": "/assets/@v2/container/index.js",
          "@v2/purchase/src/pages/list.vue": "/assets/@v2/purchase/list.js",
          "@v3/container": "/assets/@v3/container/index.js",
          "@v3/sale/src/pages/list.vue": "/assets/@v2/sale/list.js",
        },
        "scopes": {
          "/assets/@v2/container": {
            "vue": "/assets/[email protected]/index.js"
          },
          "/assets/@v2/purchase": {
            "vue": "/assets/[email protected]/index.js"
          },
          "/assets/@v3/container": {
            "vue": "/assets/[email protected]/index.js"
          },
          "/assets/@v3/sale": {
            "vue": "/assets/[email protected]/index.js"
          }
        }
      }
    </script>
    <script type="module-shim">
      ur.register('@v2/container', pathname => pathname.startsWith('/v2'), () => ur.load('@v2/container'))
      ur.register('@v3/container', pathname => pathname === '/' || pathname.startsWith('/v3'), () => ur.load('@v3/container'))
      const base = '/'
      const rms = [
        {
          id: '@v2/container',
          js: 'assets/@v2/container/index.js',
          css: 'assets/@v2/container/index.css',
          imports: ['[email protected]']
        },
        {
          id: '@v2/purchase/src/pages/list.vue',
          js: 'assets/@v2/purchase/list.js',
          css: 'assets/@v2/purchase/list.css',
          imports: ['[email protected]']
        },
        {
          id: '@v3/container',
          js: 'assets/@v3/container/index.js',
          css: 'assets/@v3/container/index.css',
          imports: ['[email protected]']
        },
        {
          id: '@v3/sale/src/pages/list.vue',
          js: 'assets/@v3/sale/list.js',
          css: 'assets/@v3/sale/list.css',
          imports: ['[email protected]']
        },
        {
          id: '[email protected]',
          js: 'assets/[email protected]/index.js',
          imports: []
        },
        {
          id: '[email protected]',
          js: 'assets/[email protected]/index.js',
          imports: []
        }
      ]
      ur.start(rms, base)
    </script>
  </head>
  <body>
    <div id="app"></div>
  </body>
</html>

Terms

  • app The app can actually be thought of as the entry package. We can register multiple app in one project. And those app could based on different framework.
  • module The js module. The module may import other modules or css.