thepassle / barrel-begone

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add `--fix` option

thepassle opened this issue · comments

It would be cool to have a --fix option. If anything from your local project imports something from a barrel file, try to see if theres a package-exports allowed import for it and modify the import to that instead

  • If an import leads to a barrel file from a third party dep, try to see if we can get a more specific import for the imported thing
    • If there is a more specific import, we have to verify that it's allowed by the package exports of that third party dep
    • We may have to consider recursive barrel files; if the original barrel file points to another barrel file, we need to dig deeper
  • If an import leads to an internal barrel file, we need to change the import

Also not sure yet what tool we should use for this. Maybe we can get away with simple string replaces? I'd like to avoid babel because it handles new syntax poorly (see unpkg), and so the tool would get outdated quickly and becomes a bit of a maintenance burden. Maybe jscodeshift is good? Im not sure what that uses under the hood though.