Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
react-dep-analyzer
Advanced tools
npm install react-dep-analyzer
import { createAnalyzer } from 'react-dep-analyzer';
// 使用預設配置建立分析器
const analyzer = createAnalyzer();
// 執行分析
analyzer.run();
// 生成 Markdown 報告
analyzer.generateMarkDown();
// 生成依賴樹圖
analyzer.generateDependencyTree();
你可以透過傳入配置物件來自定義分析器的行為:
interface ComponentPathConfig {
path: string; // 元件目錄路徑
importPrefix: string; // import 語句的前綴
}
const analyzer = createAnalyzer({
name: 'Component', // 分析報告的標題名稱
targetPath: 'src/components', // 要分析的元件目錄
pagesPath: 'src/pages', // 頁面檔案目錄
fileExtensions: ['.tsx'], // 要分析的檔案副檔名
componentPaths: [ // 元件搜尋路徑配置
{
path: 'src/components',
importPrefix: '@/components'
},
{
path: 'src/elements',
importPrefix: '@/elements'
}
],
outputDir: 'tools/usageAnalyzer', // 輸出目錄
exportNamePattern: /^[A-Z]/, // 元件名稱匹配模式(預設匹配大寫開頭)
});
工具內建以下預設配置:
const defaultConfig = {
name: 'Component',
targetPath: 'src/components',
pagesPath: 'src/pages',
fileExtensions: ['.tsx'],
componentPaths: [
{
path: 'src/components',
importPrefix: '@/components'
},
{
path: 'src/elements',
importPrefix: '@/elements'
}
],
outputDir: 'tools/usageAnalyzer',
exportNamePattern: /^[A-Z]/,
};
# Component Dependencies and Usage
- Button (src/components/Button.tsx)
Dependencies:
- @/elements/Icon (src/elements/Icon.tsx)
Imports: Icon
Used in pages:
- src/pages/home.tsx
- src/pages/about.tsx
- Card (src/components/Card.tsx)
Dependencies:
- @/components/Button (src/components/Button.tsx)
Imports: Button
Used in pages:
- src/pages/products.tsx
工具會生成一個使用 Mermaid 語法的依賴樹圖,可以直接在支援 Mermaid 的 Markdown 檢視器中顯示(如 GitHub)。
flowchart TD
Button["Button"]
Card["Card"]
Icon["Icon"]
Button --> Icon
Card --> Button
Button --> page_home["home"]
Button --> page_about["about"]
Card --> page_products["products"]
.tsx
檔案的分析,可透過配置擴展支援其他檔案類型MIT
FAQs
分析 React 元件依賴關係和使用情況的工具
We found that react-dep-analyzer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.