
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
miniapp-tools
Advanced tools
小程序打包、性能优化工具
现在只支持原生的小程序,暂时不支持taro等。
npm i miniapp-tools -D
1.执行代码依赖分析并摇树优化
在项目下新建一个js文件,填入以下内容,然后node它:
const { DependContainer } = require('./node_modules/miniapp-tools');
const path = require('path');
const options = {
sourceDir: path.join(__dirname, 'src'), // 源代码目录
targetDir: path.join(__dirname, 'refactor'), // 输出目录(不要把输出目录放在源代码目录中)
analyseDir: path.join(__dirname, 'analyse'), // 分析数据存放目录
isSplitNpm: true, // 是否分包
};
const instance = new DependContainer(options);
instance.init().catch(err => console.error(err));
执行完以上代码会生成以下目录:
分包是指在摇树优化的基础上,将仅在子包中使用的npm包移动到子包中以减少主包的大小
2.查看依赖分析图
npm i parcel-bundler -g // 若已安装不需要执行这一步
parcel ./analyse/index.html --open --out-dir analyse-dist
3.查看所有有大写标签的json文件
node node_modules/miniapp-tools/src/upperTags.js
4.代理所有setData函数查看运行时性能
node node_modules/miniapp-tools/src/perform.js
该命令会在src目录下生成performBehavior.test.js
文件,可以修改该文件来
更改注入的behavior的行为。注意在执行该命令之前必须先执行第1步
以上命令可以写在package.json的script中,以便简化
FAQs
We found that miniapp-tools demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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 discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.