A very simple component scanner that uses the Babel AST to find all of the component references from a projects JSX files.
npm install component-scan
component-scan -s src -o components.json
node index.js -s examples
This assumes that the client of a component doesn't rename the component. For example, this would probably be good:
var Footer = require('my-footer');
...
render() {
return (
<Footer />
);
}
But this:
var Footer = require('my-footer');
...
render() {
var A = Footer;
return (
<A />
);
}
Is going to say that you are referencing the A
component. And this:
var MyNameForFooter = require('my-footer');
...
render() {
return (
<MyNameForFooter />
);
}
Is going to say that you are referencing MyNameForFooter
. So... don't do that.
Licensed under MIT.