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

fix: remove Long import statement when Long was unused #599

Merged
merged 3 commits into from
Jun 22, 2022

Conversation

3846masa
Copy link
Contributor

Somethimes (e.g. when outputEncodeMethods=false), Long is not required, but included in generated codes.

This PR ensures that unused Long is not included in generated codes.

Releated: #330

@3846masa 3846masa changed the title remove Long when unused fix: remove Long import statement when Long was unused Jun 20, 2022
Copy link
Owner

@stephenh stephenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

const longInit = options.onlyTypes
? code``
: code`
const Long = conditionalOutput(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah neat! This is smart. @3846masa do you mind adding an in-source comment right before this:

// Instead of exposing `LongImp` directly, let callers think that they are getting the
// `imp(Long)` but really it is that + our long initialization snippet. This means the
// initialization code will only be emitted in files that actually use the Long import.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'll add it 👍

@3846masa
Copy link
Contributor Author

@stephenh
Thanks for the review. I added a comment to the code.

@stephenh
Copy link
Owner

Looks great, thanks @3846masa !

@stephenh stephenh merged commit 58dc10c into stephenh:main Jun 22, 2022
stephenh pushed a commit that referenced this pull request Jun 22, 2022
## [1.115.5](v1.115.4...v1.115.5) (2022-06-22)

### Bug Fixes

* remove Long import statement when Long was unused ([#599](#599)) ([58dc10c](58dc10c))
@stephenh
Copy link
Owner

🎉 This PR is included in version 1.115.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

haines added a commit to cerbos/cerbos-sdk-javascript that referenced this pull request Jun 30, 2022
Signed-off-by: Andrew Haines <haines@cerbos.dev>
haines added a commit to cerbos/cerbos-sdk-javascript that referenced this pull request Jun 30, 2022
* chore(deps-dev): Bump ts-proto from 1.115.4 to 1.115.5

Bumps [ts-proto](https://github.com/stephenh/ts-proto) from 1.115.4 to 1.115.5.
- [Release notes](https://github.com/stephenh/ts-proto/releases)
- [Changelog](https://github.com/stephenh/ts-proto/blob/main/CHANGELOG.md)
- [Commits](stephenh/ts-proto@v1.115.4...v1.115.5)

---
updated-dependencies:
- dependency-name: ts-proto
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Remove ts-proto patch (merged in stephenh/ts-proto#599)

Signed-off-by: Andrew Haines <haines@cerbos.dev>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrew Haines <haines@cerbos.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants