-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
googleapis/gapic-generator-typescript
#1383Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-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.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- Programming language: Node.js
- OS: Ubuntu
- Language runtime version: 17.x, 18.x
- Package version: 3.0.5 (latest)
Steps to reproduce
- generate a client with this GAPIC generator on a Bazel remote worker such as BuildBuddy with RBE enabled
Solution
See https://github.com/googleapis/gapic-generator-typescript/blob/main/BUILD.bazel#L26
The following group is incomplete:
filegroup(
name = "protos",
srcs = ["//:protos/index.js"],
)
And should instead include the protos.json file as well as part of the source files:
filegroup(
name = "protos",
srcs = ["//:protos/index.js", "//:protos/protos.json"],
)
Context
The reason why protos.json is required in the source is that it is imported here:
https://github.com/googleapis/gapic-generator-typescript/blob/main/typescript/src/generator.ts#L22
import protoJson from '../../protos/protos.json' assert { type: 'json' };
This import is required during runtime or otherwise, the file will not be found and the generation of API clients will fail:
node:internal/errors:465
ErrorCaptureStackTrace(err);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '[...]/bin/external/gapic_generator_typescript/protoc_plugin.sh.runfiles/gapic_generator_typescript/protos/protos.json' imported from [...]/bin/external/gapic_generator_typescript/protoc_plugin.sh.runfiles/gapic_generator_typescript/typescript/src/generator.js
at new NodeError (node:internal/errors:372:5)
at finalizeResolution (node:internal/modules/esm/resolve:405:11)
at moduleResolve (node:internal/modules/esm/resolve:964:10)
at defaultResolve (node:internal/modules/esm/resolve:1173:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:604:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)
at link (node:internal/modules/esm/module_job:78:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
We fixed this internally with the following patch (described also above in the solution) to the BUILD.bazel:
--- BUILD.bazel
+++ BUILD.bazel
@@ -23,7 +23,7 @@ filegroup(
filegroup(
name = "protos",
- srcs = ["//:protos/index.js"],
+ srcs = ["//:protos/index.js", "//:protos/protos.json"],
)
npm_runtime_dependencies = [
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-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.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.