[Javascript] Incorrectly generated import paths when using `google/api` or `google/type`
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- grpc, javascript, typescript
- 領域
- tooling
研究方向
先從 annotations_pb.js 中產生的匯入以及 issue 中所示的 grpc_tools_node_protoc 命令開始,接著比較 -I 包含根目錄如何影響 google/api 和 google/type 路徑。完成的標準是產生的 JavaScript 匯入能夠正確解析,包括 google/api/http_pb.js 等傳遞匯入,且不需要手動複製產生的檔案。
由索引模型根據 Issue 內容生成。
描述
/cc @zchee
What version of protobuf and what language are you using?
Version: v3.6.0
Language: Javascript
What operating system (Linux, Windows, ...) and version?
Docker Image: node:9
What runtime / compiler are you using (e.g., python version or gcc version)
What did you do?
Steps to reproduce the behavior:
When using imports for google/api/.. or google/type/... the imports generated for javascript resolve to incorrect paths
Example:
import "google/api/annotations.proto";
import "google/type/date.proto";
What did you expect to see
Correctly resolved import paths
What did you see instead?
Wrongly resolved import paths:
generated output (these directories don't exist):
var google_api_annotations_pb = require('../../../../../../google/api/annotations_pb.js');
var google_type_date_pb = require('../../../../../../google/type/date_pb.js');
We resolved these imports by generating these files ourselves (from https://github.com/googleapis/googleapis repository) and copying them to the correct folder but inside of annotations_pb.js another incorrect import is generated so it seems that this problem is carrying through to any imports down the road:
// inside of annotations_pb.js
var google_api_http_pb = require('../../../../../../google/api/http_pb.js');
We wondered how we could resolve this? Generating the files ourselves and copying them is totally ok but the wrongly generated imports inside these files are an issue we can not resolve on our end unfortunately, so any help is appreciated.
Anything else we should know about your project / environment
We use grpc_tools_node_protoc and grpc_tools_node_protoc_ts plugins to generate typescript and grpc code.
Command we execute:
# Variables:
GRPC_GATEWAY_REPO=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis
GOOGLE_API_REPO=github.com/googleapis/googleapis
VENDOR_DIR=vendor
PROTOC_OPTION=-I. -I$(VENDOR_DIR) -I$(VENDOR_DIR)/$(GRPC_GATEWAY_REPO) -I$(VENDOR_DIR)/$(GOOGLE_API_REPO)
TYPESCRIPT_OUTPUT=gen/typescript
# Command:
grpc_tools_node_protoc $(PROTOC_OPTION) --js_out=import_style=commonjs,binary:$(TYPESCRIPT_OUTPUT) --grpc_out=$(TYPESCRIPT_OUTPUT) --plugin=protoc-gen-grpc=$(shell which grpc_tools_node_protoc_plugin)
# followed by this command for typescript generation:
protoc $(PROTOC_OPTION) --plugin=protoc-gen-ts=`which protoc-gen-ts` --ts_out=$(TYPESCRIPT_OUTPUT)
- 主要語言
- JavaScript
- 星號
- 470
- 分支
- 91
- 平均合併
- 1 天 12 小時
- 30 天內合併 PR
- 6
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 沒有貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
protocolbuffers/protobuf-javascript 的其他 Issue
-
難度 5/5 一週以上 新手友好度 25/100
-
難度 5/5 一週以上 新手友好度 30/100
protocolbuffers/protobuf-javascript#248 · 1 則留言 · 13 個 reaction ·
-
question
難度 3/5 1-2 天 新手友好度 45/100
protocolbuffers/protobuf-javascript#222 · 9 則留言 ·
-
enhancement port-fix triaged
難度 4/5 3-5 天 新手友好度 35/100
protocolbuffers/protobuf-javascript#185 · 1 則留言 ·
-
enhancement port-fix triaged
難度 4/5 3-5 天 新手友好度 35/100
protocolbuffers/protobuf-javascript#182 · 3 則留言 · 1 個 reaction ·
查看 protocolbuffers/protobuf-javascript 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
documentation good first issue help wanted
難度 1/5 1-3 小時 新手友好度 85/100
zmo2s/agent-toolbox#23 ·
-
[Bug]: [MCP/CLI] Bare loopback IP addresses (127.0.0.1:port) and hosts with ports fail to navigate due to erroneous scheme inference可能已有人在做 @alok-108 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
microsoft/playwright#43263 ·
維護者通常 1 天內回覆
-
bug traffic
難度 2/5 1 小時以內 新手友好度 74/100