rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

Dependency issue with pinned-dependencies

Open Minnozz opened this issue 4 years ago • 3 comments

Repository with test case

How to reproduce:

$ git clone --branch pinned-dependency-issue https://github.com/Minnozz/rescript-reproduce-issue.git
$ cd rescript-reproduce-issue
$ yarn
$ cd main-project && yarn rescript build -w

In other terminal:

$ cd dependency-project && yarn rescript build -w

Both projects compile successfully.

In other terminal:

$ touch main-project/src/MainProject.res

main-project recompiles successfully.

$ touch dependency-project/src/DependencyProject.res

dependency-project recompilation fails:

>>>> Start compiling 
rescript: [3/3] src/DependencyProject.cmj
FAILED: src/DependencyProject.cmj

  We've found a bug for you!
  /home/bart.schuurmans/src/github.com/Minnozz/rescript-reproduce-issue/dependency-project/src/DependencyProject.res:1:16-25

  1 │ let fn = () => React.null
  2 │ 

  The module or file React can't be found.
  - If it's a third-party dependency:
    - Did you list it in bsconfig.json?
    - Did you run `rescript build` instead of `rescript build -with-deps`
      (latter builds third-parties)?
  - Did you include the file's directory in bsconfig.json?

FAILED: cannot make progress due to previous errors.
>>>> Finish compiling(exit: 1)

If I run rescript build -w -with-deps, this fixes the compilation the first time, but it can happen again later.

For some reason the test case does not always reproduce this issue; I can't figure out what exactly triggers it.

Minnozz avatar Jun 18 '21 10:06 Minnozz

$ cd dependency-project && yarn rescript build -w

It is required to run the build in the toplevel project, this applies to pinned-dependencies too

bobzhang avatar Jun 20 '21 00:06 bobzhang

This section of the docs states:

Important: ReScript will not rebuild any pinned-dependencies in watch mode! This is due to the complexity of file watching, so you'd need to set up your own file-watcher process that runs rescript build on specific file changes.

Shall I add a note that running a second rescript build -w for the pinned dependency is not allowed?

Is there a different long-term solution for this that we want?

Minnozz avatar Jun 20 '21 06:06 Minnozz

I use a custom external watch script which I originally wrote because I wanted a native watcher (the rescript one is implemented in JS). But it's useful for pinned packages too.

I meant to post it at the time but I forgot 🤦‍♂️

TheSpyder avatar Jul 01 '21 00:07 TheSpyder

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 23 '23 02:06 stale[bot]