-
Notifications
You must be signed in to change notification settings - Fork 75
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: don't use .fromBinary on import #681
Conversation
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.
Thanks for the fix! I think the dependence cycle is problematic, see comment below.
const r = inject(content, ` "${defaults.toString("base64url")}" `); | ||
const base64String = defaults.toString("base64url"); | ||
const buffer = protoBase64.dec(base64String); | ||
const featureSetDefaults = FeatureSetDefaults.fromBinary(buffer); |
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.
Depending on our own runtime can be an issue here, because we need this package to bootstrap it 😓
I'm not completely sure it'll be problem in practice now or in the future, but I'm sure that not using our own runtime within this helper package avoids the problem 100% 🙂
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.
Yep I did think about it, but as we only depend on some google types, it didn't seem to be an issue. However I do agree it's best to avoid it :)
Superseded by #683, but thanks for the PR ❤️ |
This PR fixes #680, by transforming the b64 feature set to a JSON string describing the message, at buildtime (bootstrap step /
npm run -w packages/protobuf bootstrap:featureset-defaults
).This allows to import
@bufbuild/protobuf
in a context that doesn't provide aTextEncoder
globally.Please let me know if you have any feedback :)