aws / aws/jsii

Split Generated Code into Multiple Files

Open
#2,436 2 comments 17 reactions 0 assignees View on GitHub
effort/large feature-request p2
Dominant language
TypeScript
Stars
2.9k
Forks
267
Avg merge
1d 25m
Merged PRs (30d)
14

Description

## :rocket: Feature Request

### Affected Languages

- [ ] `TypeScript` or `Javascript`
- [x] `Python`
- [ ] `Java` (haven't checked)
- [ ] .NET (`C#`, `F#`, ...) (haven't checked)

### General Information
* **JSII Version:** 1.17

* [x] I may be able to implement this feature request

### Description

The `cdktf` provider for AWS generates a 19 MB `__init__.py` file which contains all the classes for the Terraform AWS Provider. You can check it with this [project](https://github.com/terraform-cdk-providers/cdktf-provider-aws) which publishes a prebuilt PyPi [package](https://pypi.org/project/cdktf-cdktf-provider-aws/).

According to this [issue](https://github.com/hashicorp/terraform-cdk/issues/504), this might lead to a subpar development experience in certain IDEs. At least in [PyCharm](https://www.jetbrains.com/pycharm/), it doesn't work out of the box. After setting custom indexing settings for intellisense it seems to work, but the indexing process is still slow. I don't know how other IDEs are behaving.

Copied from the [issue](https://github.com/hashicorp/terraform-cdk/issues/504):

> Change the system property idea.max.intellisense.filesize (https://www.jetbrains.com/help/pycharm/tuning-the-ide.html#configure-platform-properties) to enable intellisense for the imports.aws module, but notice how slow the indexing operation is, because of the large file size.

### Proposed Solution

Without having looked at this in detail, one option could be to somehow provide an option to create submodules for each input class / namespace. Is this possible already, can't really tell from the [docs](https://github.com/aws/jsii/blob/377eae2058bc09e5350a17ab5e8fac627e1fe688/gh-pages/content/specification/2-type-system.md#submodules)?

This is possibly related to https://github.com/aws/jsii/issues/1919

Contributor guide

Open the contributing guide

Research direction

Start by tracing how the Python cdktf provider produces its generated __init__.py file, using the linked provider project as the reproduction case. Compare the current single-file output with the proposed submodule-per-input-class or namespace approach, and verify that the resulting package improves IDE indexing without breaking imports.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, typescript
Domain
developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.