Skip to content

Conversation

zth
Copy link
Member

@zth zth commented Sep 1, 2025

Supersedes #7693

Left TODO for this first iteration

  • Support migrating in .resi files as well
  • Error on invalid config etc We'll do this when/if we make this an actual first class feature to be used outside of the stdlib
  • Actual command for running the migration
  • Write a spec for the current state
  • Add migrations for the remaining things in the JS namespace
    • Js_array (data last)
    • Js_string (data last)
    • Js_typed_array
    • Js_typed_array2
    • Js_types
  • Add migrations for the Stdlib functions that have been deprecated
  • (?) Publish a new Core version with migrations for only the APIs that have changed since merging into the compiler
  • Consider if we want to deprecate the functions in Belt that are 1:1/fully covered in the new stdlib. If so, add deprecations and migrations for them as well We'll do Belt in 12.1 or later.

Decide on what to do with:

  • Char - Just leave deprecated as it, people need to migrate manually.
  • Dom_storage, Dom_storage2, Dom - Leave as is for now, deprecate/handle in later versions.
  • Js_blob, Js_file (stub declarations for unboxed + sharing) - Leave as is for now, handle later.

@zth zth mentioned this pull request Sep 1, 2025
6 tasks
Copy link

pkg-pr-new bot commented Sep 4, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7829

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7829

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7829

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7829

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7829

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@7829

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7829

commit: 7ca7ee2

@zth zth force-pushed the tools-migrate-2 branch 2 times, most recently from 0baf11f to 1814366 Compare September 13, 2025 07:46
@zth zth changed the title [WIP/PoC] Automatic migrations Automatic migrations Sep 25, 2025
@zth zth marked this pull request as ready for review September 26, 2025 16:26
@fhammerschmidt fhammerschmidt added this to the v12 milestone Sep 30, 2025
Copy link
Collaborator

@cristianoc cristianoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was expecting complexity, but it's a surprisingly small number of surgical changes to the compiler.
Looks great.
Also, the annotation work is impressive.


- Add optional `message` argument to `Result.getOrThrow` and improve default error message. https://github.com/rescript-lang/rescript/pull/7630
- Add `RegExp.escape` binding. https://github.com/rescript-lang/rescript/pull/7695
- Add `Array.fromString`. https://github.com/rescript-lang/rescript/pull/7693
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

let uri = Uri.fromPath path in
fullFromUri ~uri

let loadCmtInfosFromPath ~path =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are infos new here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, since we don't need to process the CMT as we do in analysis, this just loads the CMT and accesses the new prop.

| _ -> None)
in

(* TODO: Validate and error if expected shape mismatches *)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll leave this in for now, and do proper errors and validations if/when we decide this should be a first class feature in the language itself. For now it's just an internal migration tool for the library (although anyone can use it of course, at their own risk).

cmt_imports : (string * Digest.t option) list;
cmt_interface_digest : Digest.t option;
cmt_use_summaries : bool;
cmt_extra_info: Cmt_utils.cmt_extra_info;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK yes they are new

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually I think I want to move this to a separate sidecar file, probably the one I've added in the Actions PR. But for now (and maybe always) it can live in here, since it has minimal impact.

let get_saved_types () = !saved_types
let set_saved_types l = saved_types := l

let record_deprecated_used ?deprecated_context ?migration_template ?migration_in_pipe_chain_template source_loc deprecated_text =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these going to be reversed at some point?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reversed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reversed?

It's constructed backwards

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't follow 😄

let path, desc =
Typetexp.find_value
?deprecated_context:
(match deprecated_context with
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why an optional then

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll go through again and see if we always pass it (and if so make it non-optional).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants