-
Notifications
You must be signed in to change notification settings - Fork 348
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: add generated code comments #1037
Conversation
39e13e4
to
71890e4
Compare
const path: string = "../package.json"; | ||
const packageJson = await import(path); | ||
const tsProtoVersion = `v${packageJson?.version ?? "unknown"}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a bit of a hack. When providing the path to the dynamic import directly, tsc
will include it into the compilation, which leads to the build output having the code in the src
sub folder.
By moving it out, and typing it as a string, it can no longer infer that path, and then won't include it in the output.
The path is still valid on the published npm package, from running yarn pack and checking the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah cool, good find!
I'm honestly a little surprised the await import
just works; do we have to worry about whether ts-proto is invoked in a CJS/ESM environment? I guess this passed the build on node 16, so it must be working.
If users report issues, we could also look at doing a post-tsc step that uses sed
/something to replace a hard-coded const tsProtoVersion = "placeholder"
type line with the just-being-published version, in the .js
file, before upload to npm.
But I'm good with using this and seeing how it goes!
# [1.174.0](v1.173.0...v1.174.0) (2024-05-01) ### Features * add generated code comments ([#1037](#1037)) ([cdd4a76](cdd4a76))
🎉 This PR is included in version 1.174.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
ts-proto [added generated code comments in May](stephenh/ts-proto#1037). This updates linguist to properly detect them.
Closes #531