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

react-dependence-analyze

v0.1.2

Published

reactjs project tool

Downloads

6

Readme

react-dependence-analyze Build Status npm version

只支持 import 依赖的解析,赞不支持 require

使用说明

FileUtils

  • 实例属性
    • allFiles 显示所有文件
  • 实例方法
    • constructor(options)
      • options.baseDir string 工程路径(默认:'./')
      • options.ext string[] 解析的文件后缀(默认:['.jsx', '.js'])
      • options.blackList RegExp[] 用文件绝对路径名过滤,不包含在分析中
      • options.whiteList RegExp[] 用文件绝对路径名过滤,包含在分析中(whiteList 存在则无视 blackList)
      • options.ignoreModule string[] 忽略分析的模块(默认:['react', 'react-router', 'react-dom', 'antd', 'moment', 'lodash', 'classnames', 'babel-polyfill'])
    • getCurrentFilesFromDir(path: string): Promise<IFileInfo> 获取所有目录下的文件
      • path 相对工程目录的路径
    • getAllFiles(): Promise<void> 获取工程下的所有文件
      • 解析后 allFiles 才有值
    • analyzeDependence(): Promise<void> 获取依赖
      • 解析后 每个 FileInfo.dependenceList 才有值
  • 静态方法
    • 待完成...

FileInfo

  • 实例属性
    • ext string 后缀
    • path string 路径
    • filename string 文件名
    • dependenceList FileInfo[] 依赖文件
  • 实例方法
    • equals(fileInfo: string | FileInfo): boolean 比较是否相同(dependenceList 中的文件存放的并不是 FileInfo 的引用,而是重新生成的 FileInfo)
    • toString(): string 路径 + 文件名

example 1

var rcDepAnalyze = require('react-dependence-analyze');

var options = {
  baseDir: '/home/usr1/project/react-proj', // 工程路径
}
var fileUtil = new rcDepAnalyze.FileUtils(options);
fileUtil.getAllFiles()
  .then(function() {
    return fileUtil.analyzeDependence();
  }).then(function() {
    console.log(fileUtil.allFiles); // 依赖获取完成
  });

example 2

For command line syntax:

​rda-cli 工程根目录 -t filename 依赖分析对象 [-e ext(逗号分隔)] [-b blackList(逗号分隔 RegExp 表达式)] [-w whiteList(逗号分隔 RegExp 表达式)] [-i ignoreModule(逗号分隔)] [-full(显示为绝对路径)]

node_modules/.bin/rda-cli test/testData -t test/testData/components/MainMenu.jsx
// => dependence trace:
// => .../react-dependence-analyze/test/testData/containers/Application.jsx

history log

0.1.1 => 0.1.2

  • 支持 import 指定到文件夹、默认取文件夹下 index.js 或者 index.jsx 的这种情况
  • cli 默认输出相对路径,添加 cli 参数 -full,若设置 -full 则输出绝对路径

0.1.0 => 0.1.1

  • 修剪 npm 包内容、依赖