Codegen provides a way to handle imports from external packages and modules through the ExternalModule class.Documentation Index
Fetch the complete documentation index at: https://codegeninc-fix-system-prompt-typo.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
What are External Modules?
When writing code, you often import from packages that aren’t part of your project - likedatetime and requests in Python, or react and axios in TypeScript. In Codegen, these are represented as ExternalModule instances.
External modules are read-only - you can analyze them but can’t modify their
implementation. This makes sense since they live in your project’s
dependencies!
Working with External Modules
The most common use case is handling external modules differently from your project’s code:Identifying Function Calls as External Modules
For FunctionCall instances, you can check if the function definition is an ExternalModule via the FunctionCall.function_definition property:Import Resolution
Similarly, when working with imports, you can determine if they resolve to external modules by checking the Import.resolved_symbol property:Properties and Methods
External modules provide several useful properties:Common Patterns
Here are some typical ways you might work with external modules:Skip External Processing:
When modifying function calls or imports, skip external modules since they can’t be changed:Analyze Dependencies
Track which external packages your code uses:When working with imports, always handle external modules as a special case.
This ensures your codemods work correctly with both local and external code.