Skip to content

Conversation

@ZauberNerd
Copy link
Contributor

This resolver is basically a direct copy of the
"findExportedComponentDefinition" resolver including the tests.
The most significant difference is, that this resolver does not throw
when it encounters more than one component definition.
It adds all found component definitions into an array (deduplicated)
and returns that array at the end of execution.

@ZauberNerd ZauberNerd force-pushed the find-all-exported-components branch from ac76a11 to 464d466 Compare August 9, 2016 22:24
@fkling
Copy link
Member

fkling commented Aug 10, 2016

This is great, thank you! I was just thinking about this the other day.

@ZauberNerd
Copy link
Contributor Author

Ah, great. Glad to see things go into upstream :)
I'm currently re-thinking my approach to a living style guide generator for react components (https://github.com/nerdlabs/schaufenster) and I think I'll just go with react-docgen and a bunch of custom handlers instead. I started writing a couple of them already here for file-based dependencies and here for the export of the component but those are not really related to this project, so I didn't create PRs for them but will extract them into their own npm modules to allow others to use them too.

@fkling
Copy link
Member

fkling commented Aug 10, 2016

I didn't create PRs for them but will extract them into their own npm modules to allow others to use them too.

That's perfect. I will actually post something very soon about how I see react-docgen moving forward, and that's exactly what I had in mind!

@fkling
Copy link
Member

fkling commented Aug 11, 2016

Could you export this handler from src/resolver/index.js as well?

@ZauberNerd ZauberNerd force-pushed the find-all-exported-components branch from 464d466 to 2ecc54d Compare August 12, 2016 00:54
export default function findExportedComponentDefinitions(
ast: ASTNode,
recast: Object
): ?NodePath {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like you need to change this type annotation to Array<NodePath>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried changing it yesterday and got different errors. I'll look into it when I have a bit more time.

@ZauberNerd ZauberNerd force-pushed the find-all-exported-components branch from 2ecc54d to ccb412e Compare August 14, 2016 09:53
This resolver is basically a copy of the
"findExportedComponentDefinition" resolver inclusive the tests.
The most significant difference is, that this resolver does not throw
when it encounters more than one component definition.
It adds all found component definitions into an array (deduplicated)
and returns that array at the end of execution.
@ZauberNerd ZauberNerd force-pushed the find-all-exported-components branch from ccb412e to 9355af5 Compare August 14, 2016 10:09
@fkling fkling merged commit 5af28f1 into reactjs:master Aug 18, 2016
@ZauberNerd ZauberNerd deleted the find-all-exported-components branch August 19, 2016 13:11
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants