Skip to content

Commit

Permalink
fix: ensure gax is usable from electron (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation committed Jun 13, 2020
1 parent c8b4d68 commit 34b9fe2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
13 changes: 5 additions & 8 deletions packages/google-cloud-language/src/v1/language_service_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,11 @@ export class LanguageServiceClient {
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};

const isBrowser = typeof window !== 'undefined';
if (isBrowser) {
opts.fallback = true;
}
// If we are in browser, we are already using fallback because of the
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the LanguageServiceClient constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;

// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,11 @@ export class LanguageServiceClient {
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};

const isBrowser = typeof window !== 'undefined';
if (isBrowser) {
opts.fallback = true;
}
// If we are in browser, we are already using fallback because of the
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the LanguageServiceClient constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;

// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-language/synth.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/nodejs-language.git",
"sha": "df4d71c7a3c6a4b02fb48ee5cfed76f795a446ea"
"sha": "3c67c269d13636e9e645e4fdca50d312202abcfd"
}
},
{
Expand Down

0 comments on commit 34b9fe2

Please sign in to comment.