How do I use Temporal?

Hi everyone, I’m a newbie.

I noticed that Node 26 comes with Temporal by default, and I wanted to try using it in Rescript. If I understand correctly, Node “stuff” is used this way:

@module("fs/promises") external rm: (string, fileSystemOptions) => Promise.t<unit> = "rm"

However, I’m having trouble with Temporal. I’ve tried various things, and I pretty much always end up getting the error: The module or file Temporal can't be found.

Is this a problem with Rescript or with my Node installation (from the Arch Linux repositories)?

Temporal is not an importable node module, it is a global JavaScript module.

Here is an example:

module Temporal = {
  module Instant = {
    type t
    @send external toString: t => string = "toString"
  }

  module Now = {
    @val @scope(("Temporal", "Now"))
    external instant: unit => Instant.t = "instant"
  }
}

let now = Temporal.Now.instant()
Console.log(now->Temporal.Instant.toString)

And I am sorry that the ReScript Stdlib does not (yet) include Temporal. The reason is it would tank build times as it has a huge API surface. ReScript 13 will have a mitigation strategy for that though. For v12 users, we hope to have a small separate library soon (help here is appreciated).