This codemod demonstrates how to automatically convert default exports to named exports in your TypeScript codebase. The migration script makes this process simple by handling all the tedious manual updates automatically.
The script automates the entire migration process in a few key steps:
-
File Detection and Analysis
codebase = Codebase("./") for file in codebase.files: if "/shared/" not in file.filepath: continue
- Automatically identifies shared TypeScript files
- Analyzes export structures
- Determines necessary export modifications
-
Export Conversion
for export in file.exports: if export.is_default_export(): export.make_non_default()
- Converts default exports to named exports
- Ensures corresponding non-shared files are updated
- Preserves existing export configurations
// Before
export default function myFunction() {}
// After
export function myFunction() {}// Before
export { default } from './module';
// After
export { myFunction } from './module';# Install Codegen
pip install codegen
# Run the migration
python run.pyFeel free to submit issues and enhancement requests!