1.0.10 • Published 6 years ago

react-prop-types-parser v1.0.10

Weekly downloads
6
License
MIT
Repository
github
Last release
6 years ago

prop-types-parser

npm.io npm.io

parse prop-types to analysize react components props data stucture

why not react-docgen

react-docgen is based on ast, and only based ast, so it is hard to analysize some runtime code, such as ONECOMPONENT.PropTypes is imported form a module or is produced by a runtime function

prop-types-parser, combines ast and runtime code, it is more flexible and stronger

install

npm install react-prop-types-parser

ussage

import { parse, parseSeries } from 'react-prop-types-parser'

parse(file, options)

options

interface ParserConfig {
    /**
     * @desciption alias in code
     * @example {'@module', path.join(__dirname, ''../lib/@module'')}
     */
    alias?: Object,
    /**
     * @description global object will be injected to runtime code, and removed when finished excuting
     * @example { a: function () {return 'i was injected'}
     }
     */
    globalObject?: Object,
    /**
     * @description replace the third module with your module, so we have the effort to support more prop-types-like library
     * @example {'prop-types', path.join(__dirname, '../lib/prop-types')}
     */
    resolveModule?: Object,
    /**
     * @description babel config used to run the code depended by the main component entry
     *
     */
    babelConfig?: Object
}