Skip to content

Conversation

@backy22
Copy link

@backy22 backy22 commented Jul 5, 2024

  • Add condition to ignore when the specifier doesn't have an imported name
  • Fix the place to get import kind

@backy22 backy22 changed the base branch from main to de-barrelify July 5, 2024 15:01
[newSpecifier],
builder.stringLiteral(finalizedImportSource),
path.node.importKind
specifier?.importKind
Copy link
Author

Choose a reason for hiding this comment

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

It seems path.node.importKind gets value even when it's type.

Copy link
Author

Choose a reason for hiding this comment

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

For example, ./src/store/catalogFilters/useUpdateCatalogFilters/useUpdateCatalogFilters.ts

import { useSetCatalogFilters, type Filters, type Filter } from "@store/catalogFilters";

path.node.importKind returns value, specifier?.importKind returns type.

the current js-transform generates this

import { Filter } from "@store/catalogFilters/catalogFilters";
import { Filters } from "@store/catalogFilters/catalogFilters";
import { useSetCatalogFilters } from "@store/catalogFilters/catalogFilters";

but prettier will add type.

Also there are opposite cases too.
path.node.importKind returns type, specifier?.importKind returns value.

So probably this fix isn't right. will revert this fix for now

@backy22 backy22 marked this pull request as draft July 5, 2024 15:22
@backy22 backy22 marked this pull request as ready for review July 5, 2024 15:22
@charle692 charle692 self-requested a review July 5, 2024 15:29
@charle692
Copy link
Collaborator

This is great Aya, thanks for the change and update :)

@charle692 charle692 merged commit 173f999 into Fullscript:de-barrelify Jul 26, 2024
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