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

esm-optimize

v1.0.8

Published

optimize cjs to esm by vite

Downloads

45

Readme

ESM Optimize

拆分 vite2.0 optimize 能力,做到项目无关,同时不需要创建 vite.config 配置文件。根据入参找到具体的模块进行更新,方便上层业务根据实际情况决定要如何使用 optimize 能力。

使用方式

我们提供 cli 的形式或者模块的形式直接导入使用

$ npm i -g esm-optimize
$ esm react vue # 优化 react vue 模块
$ esm react vue --force # 删除 cache 目录 强制重新 optimize
$ esm react vue --shadowforce # 不删除 cache 目录 强制重新 optimize
$ esm react vue --config # 显示最终生成的 config
$ esm vue --withVersion # 生成后的文件带有 package.json version 版本号 include: ['vue'] => .vite/vue.2.6.12.js

生成后的文件与模块名一一对应,但如若存在多版本共存的情况则无法处理,需要上层业务手动处理。例如可能同时存在 vue2, vue3

vue -> node_modules/.vite/vue.js react -> node_modules/.vite/react.js

以模块的形式导入使用

import { optimize } from 'esm-optimize'

await optimize({
  root: string, // 默认为 cwd 
  optimizeCacheDir: string, // 默认的 vite 缓存文件夹为 `node_modules/.vite`
  optimizeDeps: {
    include: [] // 要处理的 模块
  },
  force: true, // 删除 cache文件夹 强制优化
  shadowforce: true, // 不删除 cache文件夹 强制优化
  withVersion: true // 生成后的文件带有版本号,通常使用于多版本共存的情况
})

完整配置

查看 vite 配置文档