Skip to content

Feature request: use rescript binary from ancestor node_modules #412

Closed
@ellbur

Description

@ellbur

Thanks for creating this tool. I am really enjoying ReScript so far.

I am programming ReScript on my tiny chromebook, and replicating the large rescript node package in each package is taking up a lot of space.

To address this, I installed rescript in ~/node_modules. Building and running works fine! The binaries are detected and the output .js files go in the right place.

Only problem is, the language server does not find node_modules/.bin/rescript. My suggestion is to change findNodeBuildOfProjectRoot to look up the directory stack:

export let findNodeBuildOfProjectRoot = (
  projectRootPath: p.DocumentUri
): null | { buildPath: p.DocumentUri; isReScript: boolean } => {
  while (true) {
    let rescriptNodePath = path.join(projectRootPath, c.rescriptNodePartialPath);
    let bsbNodePath = path.join(projectRootPath, c.bsbNodePartialPath);

    if (fs.existsSync(rescriptNodePath)) {
      return { buildPath: rescriptNodePath, isReScript: true };
    } else if (fs.existsSync(bsbNodePath)) {
      return { buildPath: bsbNodePath, isReScript: false };
    } else {
      let parent = path.dirname(projectRootPath);
      if (fs.existsSync(parent) && parent != projectRootPath) {
        projectRootPath = parent;
      }
      else {
        return null;
      }
    }
  }
};

I tried making this change and it seems to work fine (with vim-rescript).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions