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

Convert indexer script into CLI package #67

Open
ArrayKnight opened this issue Oct 22, 2024 · 4 comments
Open

Convert indexer script into CLI package #67

ArrayKnight opened this issue Oct 22, 2024 · 4 comments
Assignees
Labels
feature A new feature

Comments

@ArrayKnight
Copy link
Contributor

ArrayKnight commented Oct 22, 2024

It would be nice to be able to use the indexer script in a slightly more generic manner which is targeted at JS/TS export collating.

My desired features:

  • Accept a config file (CLI flags remain an option)
  • Accept output file path
  • Accept an include glob / glob array for target files to import into output file
  • Input target files are relative to output file
  • Accept banner (in place of hardcoded header, but current value can be default)
  • Accept exclude glob / glob array. Yes, glob negation in includes would work. But this option is more targeted something that might be external or as a shared set of exclude between multiple configs
  • Add in a deduping function that renders // __private-exports unnecessary

Examples:

O: src/index.ts I: **/*.{ts,tsx}
O: src/index.ts I: **/index.{ts,tsx} (similar to current --barrel flag)
O: src/components/index.ts I: */index.ts
O: src/vanilla.ts I: **/*.css.ts, **/types.ts, ./types/*.ts, ./styles/*.ts, ./utils/css.ts
exclude: ['**/*.{spec,stories,test}.*']
@ArrayKnight
Copy link
Contributor Author

image
Thanks, @belsrc

Clarity on the scope of deduping:

  • Potentially do the parsing in a depth first approach, and track the origin of an export, then you might be able to safely ignore imports later in the parsing cycle
  • Deduping can absolutely be a future feature. We could get the initial effort launched and then see if that can be added later
  • If a.ts and b.ts both export type Foo, but they are unique, then that's an error that the user has to deal with
  • If a.ts exports type Foo and b.ts reexports everything from a.ts, then everything that is a dupe export in b.ts can be safely skipped

@ArrayKnight
Copy link
Contributor Author

We also talked about having an option in the config that allows for a custom formatter (Biome, Prettier, etc) to be run against the file contents before write

@belsrc
Copy link
Contributor

belsrc commented Oct 23, 2024

Thinking about that....I think we could probably just handle it like the extensions. postprocessing or something. Leave it for the user to decide. At that point, it would just be receiving essentially a js/ts file body content which is what most expect when they are used from inside code?

@belsrc
Copy link
Contributor

belsrc commented Oct 24, 2024

Unless you have a different opinion, I'm just going to self assign this @ArrayKnight

@belsrc belsrc self-assigned this Oct 24, 2024
@belsrc belsrc added the feature A new feature label Nov 17, 2024
@belsrc belsrc changed the title IDEA: Convert indexer script into CLI package Convert indexer script into CLI package Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature
Projects
None yet
Development

No branches or pull requests

2 participants