fix: build the query without the querystring module - #65
Merged
Conversation
querystring is a legacy Node API with a WHATWG replacement, and it is not resolvable under bundlers that only provide web globals, which is what breaks the package under Metro. Closes #44. URLSearchParams cannot be handed the query object directly: it would join the dt array into a single comma separated value, and Google needs the key repeated. The helper appends array values one at a time. The only difference in output is that spaces encode as + rather than %20, which the endpoint accepts identically. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
iamtraction
added a commit
that referenced
this pull request
Aug 4, 2026
Both branches changed the requires at the top of src/index.js: #65 dropped the querystring module, this one added EnvHttpProxyAgent. Resolved by keeping the undici import with both names and leaving querystring out, so the query is still built by the stringify helper from #65. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
querystringis a legacy Node API with a WHATWG replacement, and bundlers that only provide web globals can't resolve it — which is what breaks the package under Metro. Closes #44.URLSearchParamscan't be handed the query object directly: it joins thedtarray into one comma-separated value, and Google needs the key repeated (dt=at&dt=bd&…). The helper appends array values one at a time.The only difference in output is that spaces encode as
+rather than%20. I checked against the live endpoint that both forms return identical translations, for plain and unicode input.This doesn't make the package work under React Native on its own —
undiciis still Node-only — but it removes one blocker and drops a deprecated dependency regardless.🤖 Generated with Claude Code