Skip to content

Rational behins Global and Globals #9

Open

Description

@nojaf

I very much like this project!
Use it often, but unfortunately I aways have to look at the source code when I'm working with it.

Why are Globals and Global two modules?

An example which I struggle with:

open RescriptBun

let exportData = Bun.file(Path.join2(Globals.import.meta.dir, "export_data.json"))
if !(await exportData->Bun.BunFile.exists) {
  Console.log("export_data.json not found")
  Process.process->Process.exitWithCode(1)
}

Finding Globals.import.meta.dir is tedious.
Adding open RescriptBun.Globals after open RescriptBun leads to

this open statement shadows the value identifier import (which is later used)ReScript(44)

when using import.meta.

Would it not make sense to merge Global and Globals and export importMeta to avoid the duplicate name?

Activity

  1. zth commented on Mar 3, 2025

    @zth
    Owner

    IIRC I modelled it after how the TypeScript d.ts types was structured. Very much open to suggestions though, and there's plenty of stuff I'd like to change for ergonomics as well. The Error constructor is another thing that conflicts with opening the globals here.

    If you want to take a stab at the issue you're talking about here, as well as any other things, please feel free! I'd be happy to see this worked on. I'll eventually get back to it as well, but it might be a little while.

  2. zth commented on Oct 30, 2025

    @zth
    Owner

    @nojaf looked at this again. Maybe worth doing something about this? Mull on it and make sure the structure makes sense, and if not, change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions