Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monorepo support is missing #930

Open
rvetere opened this issue May 30, 2024 · 0 comments
Open

Monorepo support is missing #930

rvetere opened this issue May 30, 2024 · 0 comments

Comments

@rvetere
Copy link
Contributor

rvetere commented May 30, 2024

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;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant