Questions tagged [bucklescript]

BuckleScript was previously known as a compiler for compiling OCaml to efficient JavaScript code. It has now evolved into the ReScript language. Use the [rescript] tag instead.

BuckleScript was previously known as a back-end for which emits readable, modular and highly performant JavaScript.

On July 2020, BuckleScript (and some parts of the ReasonML syntax) evolved into the ReScript language platform. The term "BuckleScript" is therefore deprecated. Use the tag for BuckleScript specific questions instead.

Useful resources

Related tags

181 questions
0
votes
2 answers

ReasonML, side effecting call on x if option is Some(x)

I have let intervalId = option(Js.Global.intervalId) I would like a succinct way to do the side effecting call to Js.Global.clearInterval if the option has a value (ie. is Some(id) and not None) Maybe the Belt.Option.map function is the answer, but…
Peter Lamberg
  • 8,151
  • 3
  • 55
  • 69
0
votes
1 answer

How are BuckleScript library names generated?

Where do libraries get the name we use in for example open BsReactNavigation? For example, there is no module in bs-react-navigation named BsReactNavigation? So how does reason know what we are referring to when we say open BsReactNavigation in a…
armand
  • 693
  • 9
  • 29
0
votes
1 answer

Bs.deriving Abstract getter function returns undefined when using capital names

In the bucklescript doc example for bs.deriving abstract, you can get the property on you created object with nameGet() This works: @bs.deriving abstract] type person = { name: string, age: int, job: string, }; let joe = person(~name="Joe",…
armand
  • 693
  • 9
  • 29
0
votes
0 answers

Reasonml map not pure?

I have a string map like this: let table = Belt.Map.String.fromArray([|("A", 1), ("B", 1), ("C", 3)|]); When I compile this single line, BuckleScript JS output says that table is not a pure module. From my understanding of the Map, when you do a…
PKK
  • 753
  • 2
  • 7
  • 18
0
votes
1 answer

How do I include untyped-JavaScript, from an adjacent file, in ReasonML bindings?

While trying to get started with Reason, in one JavaScript project, I've got an extremely light file that tries to be a Reason-typed interface to the existing, heavy, library: /* TheLibrary.re */ type engine external addEngine : string -> engine ->…
ELLIOTTCABLE
  • 17,185
  • 12
  • 62
  • 78
0
votes
1 answer

How to use process.env variables in reason with webpack

Here's the deal: with webpack you can provide environment variables (via DefinePlugin or EnvironmentPlugin) so they can be consumed by the code like process.env.MY_VAR. It works that they'll be inlined with real values at the build time. But I'm…
Saito
  • 694
  • 7
  • 25
0
votes
0 answers

bs.as and unicode strings

Does bs.as work with unicode strings? [@bs.deriving jsConverter] type filterable = [ | `Material | [@bs.as {js|üüüüü|js}] `Umlaut ]; is giving me Unused BuckleScript attribute: bs.as Some fatal warnings were triggered (1 occurrences)
wegry
  • 7,046
  • 6
  • 39
  • 59
0
votes
0 answers

Is there a way to represent JS template literals in Bucklescript type annotations?

I’m using an internationalization library in JS (https://github.com/format-message/format-message) which contains a function that takes a template literal and an object. The template literals don’t have any interpolated JS variables, but the text…
Ashok Bhaskar
  • 361
  • 2
  • 16
0
votes
1 answer

Binding to window.navigator.getUserMedia

[@bs.module] external navigator: unit = "window.navigator"; giving following error Module not found: Can't resolve 'window.navigator' How to access the windows.navigator in ReasonML?
Nimish Gupta
  • 971
  • 7
  • 17
0
votes
1 answer

Full namespacing requires recompilation

Say I have two files: foo.re bar.re Say I now have, at the top of bar.re open MyProject.Foo; This fails to compile with: This module is not a structure; it has type (module MyProject.Foo) If I rerun compilation, everything works fine If I…
Abraham P
  • 15,029
  • 13
  • 58
  • 126
0
votes
1 answer

ReasonML javascript record field

Say I have the following Bucklescript types: type amqp; [@bs.val] external amqpLib: amqp = "Amqp"; [@bs.module] external amqplib : amqp = ""; class type amqpConnectionT = [@bs] { pub createChannel: unit => unit; pub close: unit =>…
Abraham P
  • 15,029
  • 13
  • 58
  • 126
0
votes
2 answers

OCaml polymorphic recursion errors

Given the following types: type _ task = | Success : 'a -> 'a task | Fail : 'a -> 'a task | Binding : (('a task -> unit) -> unit) -> 'a task | AndThen : ('a -> 'b task) * 'a task -> 'b task | OnError : ('a -> 'b task) * 'a task -> 'b task type _…
Erik Lott
  • 697
  • 1
  • 9
  • 17
0
votes
2 answers

Decoding Json/Reading Errors in ReasonML

I have got an graphql query coming back from aws's appsync service. This is the json that comes back from the query. https://github.com/idkjs/reason-apollo-question/blob/600584c454ffb2efd08b8e42e3adca0eb151ba60/scratch/persons.json#L1-L27 { …
armand
  • 693
  • 9
  • 29
0
votes
1 answer

Create binding based on external JS

In this post, the autor teaches how to make a binding from a NodeJS library to Reason. However, I want to create a binding for Google Maps Javascript API, which can't be installed through NPM. Rather, it's usually loaded in the bottom of with…
Mateus Felipe
  • 1,071
  • 2
  • 19
  • 43
0
votes
2 answers

How to pass query string parameters with bs-fetch?

What is the proper way to pass query string parameters to bs-fetch? Currently, I have: Fetch.fetch("https://example.com/api?param1=value1¶m2=value2") Obviously, this is not sustainable for larger parameter lists. Is there a better way to do…
csb
  • 674
  • 5
  • 13