reactjs / reactjs/react-docgen

Monorepo support is missing

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

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

Ngôn ngữ chính
TypeScript
Star
3.8k
Fork
316
Merge trung bình
5 giờ 7 phút
Pull request đã merge (30 ngày)
4

Mô tả

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;
    }

Hướng dẫn đóng góp

Mở 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.

Hướng nghiên cứu

Bắt đầu trong makeFsImporter.ts, đặc biệt là resolveImportedValue, và theo dõi cách các interface và type được import được phân giải cho các file trong một monorepo. Khái quát hóa hành vi phân giải package đã được báo cáo vượt ra ngoài ví dụ @blocks, @segments và @libraries để các package bên ngoài trong các monorepo có scope được phân tích và các thuộc tính của chúng được đưa vào.

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

Đánh giá

Công nghệ
typescript
Lĩnh vực
tooling
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
38/100

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.