Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add importType #33

Merged
merged 4 commits into from
Feb 20, 2021
Merged

Add importType #33

merged 4 commits into from
Feb 20, 2021

Conversation

vladkosinov
Copy link
Contributor

Hey! Thanks for a great tool!

I'm building a dashboard for tracking components usages of my company's private UI kit.

And I'm having an issue when an import of a default export of the same component using different names results in the different components in the report:

// file_1.ts
import component_1 from "module-name";
// file_2.ts
import component_2 from "module-name";

will end up with:

{
  component_1: {
  },
  component_2: {
  },
}

Since the module name is the only way to uniquely identify components with default export I can suggest only few ideas:

  • use a module name as a component name
  • reuse already parsed name for the same module name

This PR allows users to choose their own naming strategy by providing a importType field along with other import data.

It can be used inside getComponentName callback or during processor step by merging data for components with the same module name and importType === 'ImportDefaultSpecifier'

@moroshko moroshko merged commit 77bd162 into moroshko:master Feb 20, 2021
@moroshko
Copy link
Owner

Thanks @vladkosinov, that's a great addition 👍
I published 0.7.0, give it a go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants