reactjs / reactjs/react-docgen

Monorepo support is missing

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

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

主要言語
TypeScript
スター
3.8k
フォーク
316
平均マージ
5時間 7分
マージ済み PR(30日)
4

説明

We are working in a huge monorepo setup with hundreds of packages. Now if an interface is imported from an "external" package - just another package that i'm currently scoped into - it won't pick up this file and parse it. This results in missing properties that basically would be delivered by this imported interface/type.

Could be fixed with a patch in the makeFsImporter.ts but i didn't made a pull request yet - i just tried it out very specifically for our own repository, but it would need further work to make a generic solution out of it:

function resolveImportedValue(
    path: ImportPath,
    name: string,
    file: FileState,
    seen = new Set<string>(),
  ): NodePath | null {
    // Bail if no filename was provided for the current source file.
    // Also never traverse into react itself.
    let source = path.node.source?.value;
    let { filename } = file.opts;

    // Customization: add support to resolve packages from blocks, segments, and libraries in iso monorepo
    if (
      (typeof filename === "string" && source?.startsWith("@blocks")) ||
      source?.startsWith("@segments") ||
      source?.startsWith("@libraries")
    ) {
      filename = `${getRepoRoot(filename as string)}/${source.replace("@", "")}/src/index.ts`;
      source = "./index";
    }
    // Customization: end

    if (!source || !filename || source === "react") {
      return null;
    }

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

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

はじめの一歩

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

調査の方向性

makeFsImporter.ts、特に resolveImportedValue から始めて、monorepo 内のファイルについて、import されたインターフェースと型がどのように解決されるかを追跡します。報告されているパッケージ解決の挙動を @blocks、@segments、@libraries の例以外にも一般化し、scope 付き monorepo の外部パッケージが解析され、そのプロパティが含まれるようにします。

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

評価

技術スタック
typescript
領域
tooling
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

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

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