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

Feature request: use rescript binary from ancestor node_modules #412

Closed
ellbur opened this issue May 11, 2022 · 3 comments · Fixed by #478
Closed

Feature request: use rescript binary from ancestor node_modules #412

ellbur opened this issue May 11, 2022 · 3 comments · Fixed by #478
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@ellbur
Copy link

ellbur commented May 11, 2022

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).

@ah-yu
Copy link
Contributor

ah-yu commented May 11, 2022

Same problem when trying to use rescript in deno project. I installed rescript package globally but the extension can't find it, so I have to install the rescript package in the local directory.

I think it would be better to provide an option to let users customize their path of the rescript module. Something like rescript.path: "~/node_modules/rescript"

@zth
Copy link
Collaborator

zth commented May 17, 2022

Thanks for the report! We also think this might be a good candidate for being configurable in the extension. We're going to work on the basic infra needed for configuration (it's slightly complicated because of the language client<->server relationship), but once that's done, this sounds like a good thing to build.

@zth
Copy link
Collaborator

zth commented May 31, 2022

Update: The foundations needed for this are now ready in the repo. This would be a good first issue for someone interested in contributing (ping @carere).

8d6000d this commit adds a setting to the extension. As long as the setting is nested under the scope rescript.settings it'll be automatically forwarded and synced to the server. You'll just need to update the extensionConfiguration interface to include the relevant type for the new setting.

Should be fairly straight forward, I hope.

@zth zth added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants