You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: allow configuring jsii namespaces for files-as-submodules (in addition to directories) (#2407)
When a submodule is created, it needs to have a namespace assigned for each target language (e.g. `My.Library.SubmoduleName`, `my_library.submodule_name`, etc).. Those names are usually derived, but can be configured explicitly via a `.jsiirc.json` file. We already used to look for `.jsiirc.json` in the same directory to read the jsii language namespaces for the classes in the subdirectories, but this was intended for use only when a *directory* is exported as a submodule. It starts to conflict when multiple source files in the same directory are exported as submodules: they would all share the same `.jsiirc.json` file, but that would mean they all share the same submodule namespaces which is nonsenical. Consider: ``` - root.ts export * as submodule from './submodule'; - submodule +-- index.ts export * as subsubmodule from './subsubmodule'; +-- subsubmodule.ts +-- .jsiirc.json // <-- gets used for both submodules! ``` In this PR, we make it so the directory-level `.jsiirc.json` is only read if the exported file is `index.ts`. This works both when the directory is exported, as well as if the file is directly exported. Otherwise, for files-as-submodules, read the jsii config from `.<file-base-name>.jsiirc.json`. This also adds a validation for multiple submodules not accidentally sharing the same Python module name (or Go, or Java, ...), which did in fact happen for us but doesn't make sense and should be caught. --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
0 commit comments