
Security News
Feross on Risky Business Weekly Podcast: npm’s Ongoing Supply Chain Attacks
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
esm-optimize
Advanced tools
拆分 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 配置文档
FAQs
optimize cjs to esm by vite
We found that esm-optimize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.