rescript-lang / rescript-lang/rescript

Dependency analysis

Open
#8,499 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
7.5k
Forks
485
Avg merge
1d 2h
Merged PRs (30d)
55

Description

Currently it is very hard to analyze where a dependency will be imported, for example:

type t

@module("dep") external make: unit => t = "make"

let timeMake = () => {
  Js.Console.timeStart("make")
  let t = make()
  Js.Console.timeEnd("make")
  t
} 

A consuming module may import dep directly, or it may not depending on which function is used and if there is an interface file.

If dependencies, devDependencies, and peerDependencies are not properly set this may become a problem for certain package manager setups. A small change could end up causing a runtime error. It could be particularly insidious if it is a rarely used or lazy loaded binding.

Due to the different dependency types often being misunderstood and the complexity of analysis, I believe ReScript should have the ability to check package.json dependencies for correctness.

I've had Claude create an example project here that failures when using pnpm style linking. The main branch uses ReScript 12 and ESM, but there is also a rescript-11-cjs branch for reference.

BTW it could be helpful if this feature was implemented in a way that we could integrate with Knip as a plugin

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked res-dep-issue example, comparing its main and rescript-11-cjs branches and reproducing the pnpm-style linking failure. Then read the compiler's dependency-analysis entry points and determine how package.json dependencies should be checked. Done means the proposed analysis reliably identifies incorrect dependencies and has a clear path for Knip integration.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.