You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<spanclass="tok-k">$(</span>OCAMLDEP<spanclass="tok-k">)</span><spanclass="tok-k">$(</span>INCLUDES<spanclass="tok-k">)</span><spanclass="tok-k">$(</span>SOURCE_ML<spanclass="tok-k">)</span><spanclass="tok-k">$(</span>SOURCE_MLI<spanclass="tok-k">)</span><spanclass="tok-p">|</span> sed -e <spanclass="tok-s1">'s/\.cmx/.cmj/g'</span> > .depend</code></pre>
3266
-
</div>
3267
-
</div>
3268
-
<divclass="colist arabic">
3269
-
<ol>
3270
-
<li>
3271
-
<p>bsc is the BuckleScript compiler</p>
3272
-
</li>
3273
-
<li>
3274
-
<p>ocamldep executable is part of the OCaml compiler installation</p>
3275
-
</li>
3276
-
</ol>
3277
-
</div>
3278
-
</div>
3279
-
</div>
3280
-
<divclass="sect1">
3281
3209
<h2id="_semantics_difference_from_other_backends"><aclass="anchor" href="#_semantics_difference_from_other_backends"></a>Semantics difference from other backends</h2>
<spanclass="tok-k">$(</span>OCAMLDEP<spanclass="tok-k">)</span><spanclass="tok-k">$(</span>INCLUDES<spanclass="tok-k">)</span><spanclass="tok-k">$(</span>SOURCE_ML<spanclass="tok-k">)</span><spanclass="tok-k">$(</span>SOURCE_MLI<spanclass="tok-k">)</span><spanclass="tok-p">|</span> sed -e <spanclass="tok-s1">'s/\.cmx/.cmj/g'</span> > .depend</code></pre>
3364
+
</div>
3365
+
</div>
3366
+
<divclass="colist arabic">
3367
+
<ol>
3368
+
<li>
3369
+
<p>bsc is the BuckleScript compiler</p>
3370
+
</li>
3371
+
<li>
3372
+
<p>ocamldep executable is part of the OCaml compiler installation</p>
3373
+
</li>
3374
+
</ol>
3375
+
</div>
3376
+
</li>
3377
+
<li>
3378
+
<p><em>How does IO work in browser?</em></p>
3379
+
<p>In general, it is very hard to simulate IO in browser, we recommend users to write bindings to NodeJS directly for server side, or use <code>Js.log</code> in client side, see disucssions in <ahref="https://github.com/bloomberg/bucklescript/issues/748">#748</a></p>
3380
+
</li>
3381
+
<li>
3382
+
<p><em>The compiler does not build?</em></p>
3383
+
<p> In production mode, the compiler is a single file in
3384
+
<code>jscomp/bin/compiler.ml</code>. If it is not compiling, make sure you have the
3385
+
right OCaml compiler version. Currently the OCaml compiler is a
3386
+
submodule of BuckleScript. Make sure the exact commit hash matches (we
3387
+
only update the compiler occasionally).</p>
3388
+
</li>
3389
+
<li>
3390
+
<p><em>Which version of JavaScript syntax does BuckleScript target?</em></p>
3391
+
<p>BuckleScript targets <strong>ES5</strong>.</p>
3392
+
</li>
3393
+
<li>
3394
+
<p><em>What polyfills does BuckleScript need?</em></p>
3395
+
<divclass="ulist">
3396
+
<ul>
3397
+
<li>
3398
+
<p><em>Math.imul</em>:
3399
+
This polyfill is needed for <code>int32</code> multiplication.
3400
+
BuckleScript provides this by default(when feature detection returns false), no action is
3401
+
required from the user.</p>
3402
+
</li>
3403
+
<li>
3404
+
<p><em>TypedArray</em>:
3405
+
The TypedArray polyfill is not provided by BuckleScript and it’s the
3406
+
responsibility of the user to bundle the desired polyfill implementation
3407
+
with the BuckleScript generated code.</p>
3408
+
<divclass="literalblock">
3409
+
<divclass="content">
3410
+
<pre>The following functions from OCaml stdlib
3411
+
require the TypedArray polyfill:</pre>
3412
+
</div>
3413
+
</div>
3414
+
<divclass="ulist">
3415
+
<ul>
3416
+
<li>
3417
+
<p>Int64.float_of_bits</p>
3418
+
</li>
3419
+
<li>
3420
+
<p>Int64.bits_of_float</p>
3421
+
</li>
3422
+
<li>
3423
+
<p>Int32.float_of_bits</p>
3424
+
</li>
3425
+
<li>
3426
+
<p>Int32.bits_of_float</p>
3427
+
<divclass="admonitionblock warning">
3428
+
<table>
3429
+
<tr>
3430
+
<tdclass="icon">
3431
+
<divclass="title">Warning</div>
3432
+
</td>
3433
+
<tdclass="content">
3434
+
<divclass="paragraph">
3435
+
<p>For the current BuckleScript version, if the user does not bundle the
3436
+
TypedArray polyfill, the JavaScript engine does not support it and user used
3437
+
functions mentioned above, the code will fail at runtime.</p>
Copy file name to clipboardexpand all lines: site/docsource/FAQ.adoc
+41-1
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,47 @@
1
-
== Frequently Asked Questions
1
+
== FAQ
2
2
3
3
[qanda]
4
4
5
+
6
+
How to adapt your build system?::
7
+
The BuckleScript compilation model is the same as the OCaml compiler.
8
+
If `b.ml` depends on `a.ml`, you have to compile `a.ml`*and*`a.mli`
9
+
first.
10
+
+
11
+
[NOTE]
12
+
======
13
+
The technical reason is that BuckleScript will generate intermediate
14
+
files with the extension `.cmj` which are later used for cross module
15
+
inlining, arity inference and other information.
16
+
======
17
+
Here is a simple Makefile to get started:
18
+
+
19
+
.Makefile
20
+
[source,make]
21
+
-------------
22
+
OCAMLC=bsc # <1>
23
+
OCAMLDEP=ocamldep # <2>
24
+
SOURCE_LIST := src_a src_b
25
+
SOURCE_MLI = $(addsuffix .mli, $(SOURCE_LIST))
26
+
SOURCE_ML = $(addsuffix .ml, $(SOURCE_LIST))
27
+
TARGETS := $(addsuffix .cmj, $(SOURCE_LIST))
28
+
INCLUDES=
29
+
all: $(TARGETS)
30
+
%.cmi: %.mli
31
+
$(OCAMLC) $(INCLUDES) $(COMPFLAGS) -c $<
32
+
%.ml: %.cmj:
33
+
$(OCAMLC) $(INCLUDES) $(COMPFLAGS) -c $<
34
+
-include .depend
35
+
depend:
36
+
$(OCAMLDEP) $(INCLUDES) $(SOURCE_ML) $(SOURCE_MLI) | sed -e 's/\.cmx/.cmj/g' > .depend
37
+
-------------
38
+
<1> bsc is the BuckleScript compiler
39
+
<2> ocamldep executable is part of the OCaml compiler installation
40
+
41
+
42
+
How does IO work in browser?::
43
+
In general, it is very hard to simulate IO in browser, we recommend users to write bindings to NodeJS directly for server side, or use `Js.log` in client side, see disucssions in {issues}/748[#748]
44
+
5
45
The compiler does not build?::
6
46
In production mode, the compiler is a single file in
7
47
`jscomp/bin/compiler.ml`. If it is not compiling, make sure you have the
0 commit comments