Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

fix: require fast-text-encoding only in browser#951

Merged
alexander-fenster merged 2 commits intomasterfrom
text-encoder
Feb 1, 2021
Merged

fix: require fast-text-encoding only in browser#951
alexander-fenster merged 2 commits intomasterfrom
text-encoder

Conversation

@alexander-fenster
Copy link
Contributor

Fixes googleapis/google-cloud-node-core#380 by requiring the TextEncoder / TextDecoder polyfill only in browser context. Since they exist in global scope in Node.js 11+, we also need to use the polyfill in Node 10 but this is temporary until Node 10 is EOL.

@alexander-fenster alexander-fenster requested a review from a team as a code owner January 30, 2021 01:07
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jan 30, 2021
@codecov
Copy link

codecov bot commented Jan 30, 2021

Codecov Report

Merging #951 (48f8e4e) into master (50c091e) will increase coverage by 0.15%.
The diff coverage is 60.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     googleapis/gax-nodejs#951      +/-   ##
==========================================
+ Coverage   88.52%   88.67%   +0.15%     
==========================================
  Files          43       43              
  Lines        7014     7030      +16     
  Branches      601      607       +6     
==========================================
+ Hits         6209     6234      +25     
+ Misses        795      786       -9     
  Partials       10       10              
Impacted Files Coverage Δ
src/fallback.ts 79.38% <60.00%> (+0.85%) ⬆️
src/normalCalls/retries.ts 98.72% <0.00%> (+5.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50c091e...1d694c4. Read the comment docs.

Copy link

@bcoe bcoe left a comment

Choose a reason for hiding this comment

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

Is there an easy way to add a test for this?

if (
isBrowser() &&
// eslint-disable-next-line node/no-unsupported-features/node-builtins
(typeof TextEncoder === 'undefined' || typeof TextDecoder === 'undefined')
Copy link

Choose a reason for hiding this comment

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

Perhaps add a TODO comment here, reminding us to remove this check once we drop Node 10.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added TODO for myself.

@alexander-fenster alexander-fenster merged commit 33f02e9 into master Feb 1, 2021
@alexander-fenster alexander-fenster deleted the text-encoder branch February 1, 2021 18:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fast-text-encoding usage breaks compatibility with Emscripten based libaries

2 participants