Skip to content

fix: build the query without the querystring module - #65

Merged
iamtraction merged 1 commit into
masterfrom
fix/drop-querystring
Aug 4, 2026
Merged

fix: build the query without the querystring module#65
iamtraction merged 1 commit into
masterfrom
fix/drop-querystring

Conversation

@iamtraction

Copy link
Copy Markdown
Owner

querystring is 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.

URLSearchParams can't be handed the query object directly: it joins the dt array 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 — undici is still Node-only — but it removes one blocker and drops a deprecated dependency regardless.

🤖 Generated with Claude Code

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
iamtraction merged commit 05115c7 into master Aug 4, 2026
2 checks passed
@iamtraction
iamtraction deleted the fix/drop-querystring branch August 4, 2026 22:47
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>
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.

Could not run the application after installing, throwing an error mentioned below

1 participant