Colocate types with their resources #11565
Labels
area/codegen
SDK-gen, program-gen, convert
kind/engineering
Work that is not visible to an external user
language/javascript
size/M
Estimated effort to complete (up to 5 days).
Hello!
Issue details
It's been suggested that the current file layout, where
types/{{module}}/index.ts
declares module types, is less effective than colocating the types with the resources. I'm going to do my best to argue this position, but I confess I don't have a few deep understanding of the API surface of generated types, so please offer criticism and feedback, and correct me where I'm wrong. It's likely I'm missing something that necessitated this file layout in the first place.It's less idiomatic. There's no real technical benefit to have modules declared at the top level, and module types declared under a separate folder. It makes more sense to have a resource
Foo
, and all of the typesFooArgs
, FooFilterRuleArgs`, etc. all located in the same folder. This will minimize the diff in the import path between these resources, cleaning up import paths.This allows large packages (i.e. Azure Native, AWS-Native) to split along module boundaries. For example, we may be able to take a subset of modules (e.g.
s3
,ec2
,rds
) and package them in their own NPM package, cleaving currently massive packages into smaller packages. This will help us maneuver around NPM package size limits. (Corresponding Go issue, Python issue).Goal: To make this change in a backward-compatible way, we will still need to generates a
types
directory and re-export the files from the resource modules.AFAIK this issue is not as simple as dropping the files from #10831) both because we need to be backward-compatible, and because there are conflicting names within
input.ts
andoutput.ts
for a given module. I'd need to iterate on the new API before starting work on this.It might be as simple as moving those files, adding the compatibility files in
/types
, and adding re-exports to theindex.ts
of each module to namespace theinput.ts
andoutput.ts
files. For example:Affected area/feature
codegen/nodejs
The text was updated successfully, but these errors were encountered: