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

support4pack

v0.1.4

Published

为 webpack 打包的应用提供辅助功能

Readme

support4pack

support4pack 是基于 webpack 开发过程中用到的工具封装

目录结构

此包下有以下几个目录,其模块相同,但所用语法不同:

  • lib 此目录下的模块,没有进行编译,包含 ES2017 甚至 ESLast 的语法,webpack 配置中,一般要对此目录的文件进行编译

模块

auto-render-default-vue-component

引入此模块,会自动引入 default-element 模块。

如果 webpack 打包的入口文件的默认导出是 Vue 组件,将会创建此组件的一个实例并挂载在 default-element 模块创建的 div 标签上。

模块的导出为创建的组件的实例(如果入口的默认导出不是 Vue 组件,将是 undefined )的 Promise 封装

注意 不要在入口模块以外的模块中引入此文件,以免产生意料之外的问题

auto-render-default-react-component

auto-render-default-vue-component 类似,只是 auto-render-default-react-component 针对 react 组件

render-vue-component

引入此模块,会自动引入 default-element 模块。

此模块导出以下几个方法:

  • get(expprts?: VueComponentClass | {default?: VueComponentClass} | any): Promise<typeof VueComponentClass>
    异步获取模块默认导出的 Vue 组件,支持 EJS 模块和 ES Module 模块
    如果省略参数,则为获取入口模块的默认导出 别名:getComponentgetVueComponent
  • render(Component: VueComponentClass, props?: object, htmlElement?: HTMLElement): VueComponent
    将 props 作为参数创建 Vue 组件的组件并挂载到 htmlElement 上
    propshtmlElement 均可省略
    注意 只能在启动时,可以省略 htmlElement, 否则会导致页面空白 props 默认为 {}
    htmlElement 默认为 default-element 模块创建的 div 标签
    返回值为创建的实例 别名:renderComponentrenderVueComponent
  • renderDefault(props?: object, htmlElement?: HTMLElement): Promise<VueComponent | undefined>
    类似与 render 函数,区别在于是异步渲染入口模块默认导出的 Vue 组件,如果入口模块默认导出不是 Vue 组件,将返回 Promise<undefined>
    如果入口模块默认导出是 Vue 组件,则相当于 render(away get(), props, htmlElement)
    别名:renderDefaultComponentrenderDefaultVueComponent

render-react-component

render-vue-component 类似,只是 render-react-component 针对 react 组件

注意 导出方法的别名中的 Vue 需要也改为了 React

current-script

此模块的默认导出 webpack 生成的包含入口模块的脚本的标签
用于解决部分浏览器没有 document.currentScript 对象的问题
警告 如果引入此模块,至少需要在脚本启动时引入一次,否则可能会获取错误

main-export

入口模块的导出的 Promise 封装
采用 Promise 封装的原因是解决只能在模块执行完后才能够保证正确获取完整的模块导出的问题

create-element

此模块默认导出以下方法:

createElement(tagName = 'div'): HTMLElement 脚本加载期间,在脚本标签后面创建 HTML 标签
注意 如果调用多次,将会在脚本标签后面依次创建多个标签
注意 只能在脚本启动时执行,否则会导致整个页面空白

default-element

引入此模块,会自动通过 create-element 模块创建的一个 Div 标签
多次引用此模块将只会得到同一个标签
以下模块已自动引入此模块

  • auto-render-default-component
  • auto-render-default-react-component
  • auto-render-default-vue-component

警告 如果引入此模块,至少需要在脚本启动时引入一次,否则可能会导致整个页面空白