Skip to content
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

Added outDir option for pbts #43

Closed
wants to merge 1 commit into from
Closed

Conversation

katel0k
Copy link
Contributor

@katel0k katel0k commented Jan 2, 2025

While working on my project, I've stumbled upon import issues. I've wanted to declare proto files only in the protos directory outside of my typescript client application. I wanted to have highlightning for typescript files whilst doing import 'msg.proto'. It didn't work because of include issues in vs code. And importing files via import '../some_path/msg.proto' is just ugly. Thus, I've added this option, that allows creating .d.ts files in some custom directory instead of the directory with protos

@kmontag
Copy link
Owner

kmontag commented Jan 5, 2025

Hey, thanks for the PR. This is definitely something I'd like to support, however I think the functionality needs to be a bit more dynamic - for example, in case of imports with different nesting levels like foo.proto and bar/baz.proto, I think we'd want to maintain that structure in the output destination. I'd also like to support things like choosing the output directory depending on the path where the input was located.

My first thought is that this option should actually be a function which receives the absolute import path (and possibly the string import name) and returns an output path. I'm not sure if it also makes sense to allow a simple string specifying the root output directory...it seems like there would be ambiguity in the output location for something like ../foo.proto.

Feel free to update this PR with an alternative proposal, or I'll try to draw something up in the coming days.

@kmontag
Copy link
Owner

kmontag commented Jan 6, 2025

@katel0k I believe #46 should handle your use case. please let me know if I'm missing anything.

@katel0k
Copy link
Contributor Author

katel0k commented Jan 6, 2025

Yep, that very much covers my case, thanks a lot! I honestly don't think it can be done better, and I would be glad to use that feature in my project. Also, Happy New Year!
Closing this issue

@katel0k katel0k closed this Jan 6, 2025
kmontag added a commit that referenced this pull request Jan 7, 2025
This adds the `output` option to the `pbts` config, which accepts a
function to map resource paths (i.e. protobuf file paths) to their
typescript declaration (`.d.ts`) paths.

This is an alternate approach to
#43.

---------

Co-authored-by: katel0k <katelkin2003@mail.ru>
@kmontag
Copy link
Owner

kmontag commented Jan 7, 2025

Great, merged/released.
Happy new year as well!

@katel0k katel0k deleted the outDirOption branch January 8, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants