Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Generalize npm dependency support for generated js code

オープン
#47 コメント 5 件 リアクション 6 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
32/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
cpp, javascript
領域
compilers

調査の方向性

まず、参照されているインポートパスのロジック周辺にある javascript/net/grpc/web/grpc_generator.cc と、protobuf の src/google/protobuf/compiler/js/js_generator.cc を比較します。現在の google-protobuf 例外を一般化するために必要な、インポートオプションとパッケージパスの動作を特定します。ユーザーが指定した npm パッケージから生成されたインポートで依存関係を明示的に解決でき、override が指定されていない場合は相対インポートが維持されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
JavaScript
スター
471
フォーク
91
平均マージ
3時間 57分
マージ済み PR(30日)
2

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

protocolbuffers/protobuf-javascript のほかの issue

protocolbuffers/protobuf-javascript の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。