-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Generate Index Files #821
Conversation
It might be better to change the final type imports from:
to:
I think that since all of the exports are from the same package, there will be no name collisions because protoc doesn't allow duplicate names in the same package. The only change to the exports that will be required is to omit exporting Edit: applied this change |
Hi @blorgon1 , thanks for the PR! Can you pick either an existing |
@stephenh no problem! I've added a new integration test, although it's a bit lacking because the integration codegen only processes one proto |
Hi @blorgon1 ! I had a chance to review the PR. The nested exports initially threw me off, but reading your PR description, I get your goal, i.e. the
It is nice that this approach avoids conflicts, b/c each package gets its own output. Fwiw I have two musings:
No need to build that in your PR, just thinking that maybe someday we'd have an
We could generate a single index.ts that looked like:
Then use it as:
Granted, you've already got the export-N-levels of working, but, dunno, I think the camel-case-the-name seems simpler to implement and possibly consume, just b/c there are less "shell packages" that exist solely to mimic namespaces. I'm not completely against the current approach, but do have a general preference for using something like camelized package names to avoid the N-level exports; what do you think? |
Hi @stephenh, thanks for the review.
|
Hi @stephenh apologies for the bump on this, are there any further changes you think should be made here? I was hoping to start using it in one of my projects soon (without having to use submodules) 😄 |
@stephenh tests and lint should pass now, can this PR be merged? |
Hey @blorgon1 , thanks for the pings! Yep, the tests pass, and I'll go ahead and merge. Just fwiw I am still a little hesitant about the "imports to mimic namespaces" approach, so on the very low chance that I end up having to debug/support this in more esoteric cases, I can't promise to not fallback to a less-Russian-doll-of-imports approach, but hopefully we won't need to do that. Thanks for the PR! This has been a popular ask for a long time! |
# [1.148.0](v1.147.3...v1.148.0) (2023-05-23) ### Features * Generate Index Files ([#821](#821)) ([85bf206](85bf206))
🎉 This PR is included in version 1.148.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
[#212] These changes add an
outputIndex
option for generating index files, based on the proto package namespaces.An index file is generated for each sub-namespace of a package, so that they can be imported using the same path as the proto package, without relying on TS namespaces.
Example - Given the following proto files:
Three index files will be generated:
The index can then be used as: