Skip to content

Question: why isn't protos.json loaded with a require call in Node environment? #1493

@hmaurer

Description

@hmaurer

Hello!

During an attempt to bundle (via esbuild) a Node application using the firebase-admin SDK I noticed that protos.json is loaded using a require call in a browser environment, but loaded differently in a Node environment, c.f.

require('../../protos/protos.json')

While I acknowledge that bundling Node applications may not be a use-case you want to support, I was wondering why you made the explicit choice of not using require in a Node environment? My suggestion would be to use require in all environments, like so:

this._protos = this._gaxGrpc.loadProto(require('../../protos/protos.json'));

It'd appear that I am not the only one who ran into this issue:

Bundling back-end applications has some benefits (in my case, generate the smallest possible package for services deployed to Cloud Run / Cloud Functions), so if making this small change would enable it it'd be wonderful!

Thanks for your work.


Related threads:

Metadata

Metadata

Labels

api: firestoreIssues related to the googleapis/nodejs-firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions