WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@davesnx
Copy link

@davesnx davesnx commented Oct 4, 2023

Fixes #79

This PR is a first attempt to migrate the promise version of previously builded from BuckleScript to Melange (and all of the related constraints).

I believe the change it's on a good direction since Melange enables sharing code and the original idea of this project seems to share the same interface between native and JS. If we want to keep the BuckleScript/ReScript version I could do a similar trick done in styled-ppx davesnx/styled-ppx#353

I vendor promise under server-reason-react here: https://github.com/ml-in-barcelona/server-reason-react/tree/main/packages/promise in order to enjoy the same experience as this library will provide (eventually will remove the vendor lib).


What are the changes:

  • Install melange and adapt dependencies (requires dune 3.10 and OCaml 5.1)
  • Remove [@bs.val] (Melange don't need those)
  • Update bs.* into mel.*
  • Updates root dune file from 1.0 to 3.10
  • Have a dune file under js/ folder where we specify the modes melange
  • Arrange completely the test folder into a more sharing code between the two targets can live together. Heavy usage of copy_files with different libraries.
  • Added a few (wrapped false) under test/ to avoid changing the source-code.

What hasn't been done:

  • Take consideration of the naming (came up with .js and .native for a few places but I don't hold any strong reasoning behind any naming)
  • Remove bs-platform, bs-config
  • Test the workflow on esy
  • Update the CI to run the new build command (and new location of compiled JS files)

Status

The proposition for this is to gather feedback about the changes and eventually release this as a new opam version.

Current test can be ran with:

# test_main
node _build/default/test/js/test/test/js/test_main.js

# benchmark
node _build/default/test/js/test/test/js/benchmark.js

[@ocaml.warning "-33"]
test("resolved: Almost-Promise-like", () => {
let open Js_OO;
/* let open Js_OO; */
Copy link
Author

Choose a reason for hiding this comment

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

I commented this out since didn't seem needed, but wanted to acknowledge that I have no clue what's Js_OO

@@ -0,0 +1,3 @@
(library
Copy link
Author

Choose a reason for hiding this comment

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

ffi is a lib under test now, with the 2 separate versions

@@ -1,3 +1,3 @@
(library
Copy link
Author

Choose a reason for hiding this comment

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

The run file/lib isn't needed anymore since we can share framework

@davesnx davesnx marked this pull request as ready for review June 18, 2024 11:34
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.

Melange compatibility

1 participant