googleapis/packman

Nodejs: Don't use lodash.union if it is unnecessary.

Closed this issue · 4 comments

What

When generating the index.js for an api, we are using lodash.union to combine the sets of scopes. This is unneeded for situations where there is no scopes or there is only one service which a non empty set of scopes.

Example

This can be seen in monitoring where this line is uneeded since the scopes exported by group-service-api and metric-service-api are empty.

Expected

Packman should be smart enough to see that there is no scopes exported, to simply set ALL_SCOPES to [], and to not require lodash.union in index.js or as a dependency.

jmuk commented

Oh, I see. Also some APIs have exactly same set of scopes among services (like pubsub: https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/packages/pubsub/src/v1/publisher_api.js#L56 and https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/packages/pubsub/src/v1/subscriber_api.js#L52). In that case actually union isn't necessary.

However, it's hard to do that because packman does not receive gapic config. I think the way is to move the generation of the index.js to toolkit (codegen) and add behaviors like that.

Agreed. I am filing this issue here until it is moved into toolkit. This should be resolved by the implementation of this.

This seems to be fixed with googleapis/gapic-generator#867.