Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Generalize npm dependency support for generated js code

Đang mở
#47 5 bình luận 6 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
32/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
cpp, javascript
Lĩnh vực
compilers

Hướng nghiên cứu

Bắt đầu bằng cách so sánh javascript/net/grpc/web/grpc_generator.cc, ở khu vực logic đường dẫn import được đề cập, với src/google/protobuf/compiler/js/js_generator.cc của protobuf. Xác định hành vi của tùy chọn import và đường dẫn package cần thiết để khái quát hóa ngoại lệ google-protobuf hiện tại. Hoàn tất khi các import được tạo có thể phân giải rõ ràng các dependency từ những package npm do người dùng chỉ định, đồng thời giữ nguyên các import tương đối khi không cung cấp override.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

javascript triaged

Sister issue of https://github.com/grpc/grpc-web/issues/584 (copying content)

All generated code currently generates js import paths with similar structure with that of the imported .proto files.
The one exception for protobuf well-known types - google-protobuf based ont he import prefix:
https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/js/js_generator.cc#L128

string GetRootPath(const std::string& from_filename,
                   const std::string& to_filename) {
  if (to_filename.find("google/protobuf") == 0) {
    // Well-known types (.proto files in the google/protobuf directory) are
    // assumed to come from the 'google-protobuf' npm package.  We may want to
    // generalize this exception later by letting others put generated code in
    // their own npm packages.
    return "google-protobuf/";
  }

Equivalent code in grpc-web:
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpc_generator.cc#L461

This will generate something like

import * as google_api_annotations_pb from './google/api/annotations_pb';
import * as google_protobuf_timestamp_pb from 'google-protobuf/google/protobuf/timestamp_pb';

An import option would allow users to explicitly override the relative path and specify a npm package at .proto import could be the right approach to generalize this.

Ngôn ngữ chính
JavaScript
Star
471
Fork
91
Merge trung bình
1 ngày 12 giờ
Pull request đã merge (30 ngày)
6

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của protocolbuffers/protobuf-javascript

Tất cả issue của protocolbuffers/protobuf-javascript

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.