Using the rescript-lang/std library

Hey folks. Came across this -> https://github.com/rescript-lang/std

While I am rummaging through code, I come across errors like the following:

/Volumes/SSD/Github/bs-easy-format/node_modules/.pnpm/bs-platform@9.0.2/node_modules/bs-platform/lib/js/caml_external_polyfill.js:16
    throw new Error(s + " not polyfilled by BuckleScript yet\n")
    ^

Error: caml_ml_output_bytes not polyfilled by BuckleScript yet

    at Object.resolve (/Volumes/SSD/Github/bs-easy-format/node_modules/.pnpm/bs-platform@9.0.2/node_modules/bs-platform/lib/js/caml_external_polyfill.js:16:11)
    at Object.output (/Volumes/SSD/Github/bs-easy-format/node_modules/.pnpm/bs-platform@9.0.2/node_modules/bs-platform/lib/js/pervasives.js:253:33)
    at Object.output_buffer (/Volumes/SSD/Github/bs-easy-format/node_modules/.pnpm/bs-platform@9.0.2/node_modules/bs-platform/lib/js/buffer.js:330:21)
    at to_channel$1 (/Volumes/SSD/Github/bs-easy-format/src/easy_format.bs.js:719:19)
    at Object.to_stdout$1 [as to_stdout] (/Volumes/SSD/Github/bs-easy-format/src/easy_format.bs.js:723:10)
    at Object.<anonymous> (/Volumes/SSD/Github/bs-easy-format/test/test_easy_format.bs.js:326:21)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)

Would using https://github.com/rescript-lang/std/blob/master/lib/js/caml_external_polyfill.js be a solution to this?

If so how would you use in your lib?

Thank you.

Hey, the rationale behind the rescript/std package and its recommended usage is explained in our 9.0 release blog post: https://rescript-lang.org/blog/release-9-0#new-external-stdlib-configuration

What are you using this library for?

1 Like

Just trying to get this to run without error: https://github.com/idkjs/bs-easy-format/blob/main/test/test_easy_format.re

Quoting ocaml easy format lib docs:

This module offers a high-level and functional interface to the Format module of the OCaml standard library.

Not sure if it already happened, but Format was planned to be removed for rescript: What stable type system features we are going to preserve from OCaml

@idkjs Shouldn’t you run the ˋregisterˋ function of the polyfill module before attempting using it?

@ryyppy i have no idea what you are talking about. Where can I read about that or how is it done?

Thank you.