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

lodash-miniprogram-polyfill

v1.0.1

Published

小程序的lodash polyfill,需在lodash或lodash-es前导入,也可用于支持npm构建的其他小程序框架(uniapp,taro)

Readme

背景

抹平lodash(lodash-es)在各类小程序环境下的报错问题。原理众所周知,小程序的全局对象跟browser的全局对象不同。出发点是在uniapp cli vue3+ts的工程里写小程序平台的lodash polyfill,因为不是npm包,引入执行始终会在npm包的lodash的引入执行之后,这样polyfill就失效了。所以需要构建一个npm包的ployfill,并在导入lodash前导入。

使用

import _ from 'lodash-es' 之前 import 'lodash-miniprogram-polyfill',(建议使用lodash-es可以按需导入减少打包后的体积)

推荐使用方式

定义一个文件提前导入polyfill,在这之后导入导出npm包中的lodash,在项目中使用就直接从这个文件导入lodash对应的api即可,ts的类型推断也能保持

示例

-/src/utils/lodashFix.ts

// #ifdef MP-WEIXIN
import 'lodash-miniprogram-polyfill'
// #endif
export * from 'lodash-es'

-/src/pages/index/index.vue

<script setup lang="ts">
import { throttle } from '@/utils/lodashFix'
</script>

这里的示例是uniapp中的使用,使用条件编译在编译阶段去掉不必要的导入,不过polyfill副作用执行前会先判断是否在小程序的环境中,即使导入了也无问题只是体积稍微大了一点(500+bytes)。 taro支持npm构建,所以也可以使用此npm包,使用示例可参考uniapp的。

待续

目前因为只需要支持微信小程序端,所以只针对微信小程序环境做了polyfill处理,其他的小程序平台没有测试过,不过应该是类似的处理方式。