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

@bricking/runtime

v1.0.4

Published

bricking 运行时

Downloads

52

Readme

@bricking/runtime

Systemjs 运行时模块管理工具,对 Systemjs 进行了封装,支持手动注入运行时模块。

安装

npm install @bricking/runtime

使用

@bricking/runtime 包含了 Systemjs,并扩展了其模块功能。项目引入@bricking/runtime后,可以通过访问 window.$bricking(或者import $bricking from '@bricking/runtime';) 进行基础模块的管理。

import $bricking from '@bricking/runtime';
import React from 'react';
// 注入同步模块
$bricking.set({
  'react': React,
});
// 注入异步模块
$bricking.setDynamic({
  'rxjs': () => import('rxjs')
});

为什么不直接使用 systemjs 提供的 importmap 功能?

因为使用 importmap 功能意味着你需要为你的所有的依赖单独编译一份 js 脚本,这样的话页面加载脚本的数量就比较不可控。 而且依赖与依赖之间本身也可能存在较为复杂的依赖关系,如果要处理这些关系而不借助打包工具进行分析整合,需要耗费大量的精力。

API

$bricking.set

用于注入同步模块

set(maps: Record<string, any>, force?: boolean): void;

  • maps: 模块映射对象
  • force: 是否强制覆盖现有模块

$bricking.setDynamic

用于注入异步模块

setDynamic(maps: Record<string, () => Promise<any>>, force = true)

  • maps: 模块映射对象
  • force: 是否强制覆盖现有模块

$bricking.extendImportMaps

拓展 Systemjs 的 importmap 对象

extendImportMaps(maps: Record<string, string>, force?: boolean): void

  • maps: importmap 对象
  • force: 是否强制覆盖现有模块

$bricking.setMetadata

为特定 ID 的模块的 import.meta.data 写入数据(需要在该模块导入前调用)

setMetadata(id: string, data:Record<string, any>)

  • id: 模块 ID
  • data: 任意数据