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

Error "Missing dependency …… in search path"

Open remitbri opened this issue 7 months ago • 2 comments

Hello

I'm using ReScript 11.1.4 and extension 1.63.6

I have several modules in the style of

module FooBar = {
  let make = React.lazy_(() => Js.import(FooBar.make))
}

module App = {
  @react.component
  let make = () => {
    <div>
      {React.string("Foobar: ")}
      <FooBar />
    </div>
  }
}

where FooBar is another (existing) module.

The compiler running in the terminal is perfectly happy. If I open the module containing the code above in VSCode it's fine. But as soon as I edit the module, I've got an error from the extension displaying "Missing dependency FooBar in search path" at the beginning of the file. If I reload the module, no extension error until I edit the module. And again, the compiler in the terminal shows zero problem.

It's more an annoying than a stopping issue, sure (it took me, err, months to open the issue)

remitbri avatar Apr 29 '25 16:04 remitbri

So you've narrowed it down to when there are "overlapping" modules like that?

(the issue has to do with incremental typechecking)

zth avatar Apr 29 '25 16:04 zth

Indeed. In fact, I used to have just in the App module when I was still using ReScript v10

module App = {
  @react.component
  let make = () => {
    <div>
      {React.string("Foobar: ")}
      <LoadableFooBar />
    </div>
  }
}

and in the LoadableFooBar

module type FooBarType = module type of FooBar

@val
external FooBarType: module(FooBarType) = "undefined"

include unpack(FooBarType)

@val
external import: (@as("./FooBar.mjs") _, unit) => Js.Promise.t<'a> = "import"

let make = ReactLazy.make(() =>
  import() |> Js.Promise.then_((module(FooBar: FooBarType)) =>
    Js.Promise.resolve({"default": FooBar.make})
  )
)

and it was rewritten to the code at the beginning when I moved to v11, and that's when the extension error appeared (…I think. It might have appeared at a later extension update. Sorry!)

remitbri avatar Apr 29 '25 17:04 remitbri