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 exports to index file. #790

Open
brunnerh opened this issue Jan 6, 2023 · 2 comments
Open

Add exports to index file. #790

brunnerh opened this issue Jan 6, 2023 · 2 comments
Assignees
Labels
✨ Feature New refactoring or feature

Comments

@brunnerh
Copy link

brunnerh commented Jan 6, 2023

Is this request related to a problem? Please describe.

Often exports are re-exported from an index.ts/js file, adding such exports manually is a bit tedious.

Describe the solution you'd like

Provide a refactorings on exported values if an index file in the same directory exists and does not already export the value.

  • Add export * to index.ts/js - Adds export * from './<current-file>'; to the index
  • Add named export to index.ts/js - Adds export { <current-symbol> } from './<current-file>'; to the index

Extension of index could probably be resolved dynamically.

For default exports, adding a named export should prompt for a name and create:

export { default as <provided-name> } from './<current-file>';

The prompt could be pre-filled with the file name (without extension).

Additional context

N/A

@brunnerh brunnerh added the ✨ Feature New refactoring or feature label Jan 6, 2023
@nicoespeon
Copy link
Owner

Dope! I can relate to this very issue as I had to do this recently with some Firebase functions that had to be exposed in the main index.ts 😁

Definitely adding this idea to "things to do next".

@nicoespeon nicoespeon self-assigned this Jan 6, 2023
@brunnerh
Copy link
Author

brunnerh commented Jan 7, 2023

I suppose if no index exists yet, the refactorings could also create one 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature New refactoring or feature
Projects
None yet
Development

No branches or pull requests

2 participants