Skip to content

Compiler should not rely on Js or Belt module being present #6836

Closed

Description

@cknitt

This is in preparation for switching to the Core standard library.

Currently, the compiler relies on the presence of the Js and Belt modules for quite a few things, for example async/await (Js.Promise.unsafe_async/Js.Promise.unsafe_await) or array/list spread (Belt.List.concatMany/Belt.Array.concatMany).

You can find more such usages by searching for Lident "Js" or Lident "Belt" in the compiler sources.

This should be refactored so that functions from the runtime modules (caml_*) are used instead.

Activity

  1. cknitt commented on Jun 27, 2024

    @cknitt
    MemberAuthor

    This also applies to type definitions. Js.Re.t is used somewhere, and the JSX PPX is using Js.Nullable.t.

    So maybe there should also be a caml_types.res as a source for the type definitions used by Core, Js, Belt, etc.

  2. cknitt commented on Jun 29, 2024

    @cknitt
    MemberAuthor

    The runtime modules are listed in this file BTW:

    jscomp/ext/js_runtime_modules.ml

  3. added this to the v12 milestone on Aug 25, 2024
  4. self-assigned this
    on Aug 25, 2024
  5. zth commented on Sep 12, 2024

    @zth
    Member

    This fixes arrays spreads to not rely on Belt: #7034

  6. modified the milestones: v12, v12.1 on May 5, 2025
  7. modified the milestones: v12.1, v13 on Jan 13, 2026
  8. cknitt commented on Sep 4, 2026

    @cknitt
    MemberAuthor

    This can be marked as done:

    • The deprecated Js namespace was removed in #8531, merged August 9.
    • Belt was extracted into the separate @rescript/belt package in #8554, merged August 19. It is no longer bundled with the runtime; projects using Belt must install and declare the dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions