Skip to main content
Codegen provides powerful tools for managing and reorganizing exports in TypeScript codebases. This tutorial builds on the concepts covered in exports to show you how to automate common export management tasks and ensure your module boundaries stay clean and maintainable.

Common Export Management Tasks

Collecting and Processing Exports

When reorganizing exports, the first step is identifying which exports need to be processed:

Moving Exports to Public Files

When centralizing exports in public-facing files:

Managing Different Export Types

Codegen can handle all types of exports automatically:

Updating Import References

After moving exports, you need to update all import references:

Best Practices

  1. Check for Wildcards First: Always check for existing wildcard exports before adding new ones:
  1. Handle Path Translations: Use TypeScript config for path translations:
  1. Clean Up Empty Files: Remove files that no longer contain exports or symbols:

Next Steps

After reorganizing your exports:
  1. Run your test suite to verify everything still works
  2. Review the generated import statements
  3. Check for any empty files that should be removed
  4. Verify that all export types (wildcard, type, named) are working as expected
Remember that managing exports is an iterative process. You may need to run the codemod multiple times as your codebase evolves.

Complete Codemod

Here’s the complete codemod that you can copy and use directly: