Skip to content

Commit 9e41ba0

Browse files
committed
Make playground bundle (+ third party cmijs) default to uncurried mode
1 parent 00170d5 commit 9e41ba0

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

jscomp/jsoo/jsoo_playground_main.ml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@
4444
* and use the proper interfaces as stated by the apiVersion.
4545
*
4646
* -----------------------------
47-
* Version History:
48-
* v2: Remove refmt support (removes compiler.reason apis)
47+
* Version History: * v2: Remove refmt support (removes compiler.reason apis)
48+
* v3: Switched to Uncurried mode by default (requires third party packages
49+
to be built with uncurried: true in bsconfig.json). Also added
50+
`config.uncurried` to the BundleConfig.
4951
* *)
50-
let apiVersion = "2"
52+
let apiVersion = "3"
5153

5254
module Js = Jsoo_common.Js
5355

@@ -73,12 +75,18 @@ module BundleConfig = struct
7375
mutable module_system: Js_packages_info.module_system;
7476
mutable filename: string option;
7577
mutable warn_flags: string;
78+
79+
(* This one can't be mutated since we only provide
80+
third-party packages that were compiled for uncurried
81+
mode *)
82+
uncurried: bool;
7683
}
7784

7885
let make () = {
7986
module_system=Js_packages_info.NodeJS;
8087
filename=None;
8188
warn_flags=Bsc_warnings.defaults_w;
89+
uncurried=(!Config.uncurried = Uncurried);
8290
}
8391

8492

@@ -661,13 +669,16 @@ module Export = struct
661669
);
662670
"warn_flags",
663671
inject @@ (Js.string config.warn_flags);
672+
"uncurried", inject @@ (Js.bool config.uncurried);
664673
|]))
665674
);
666675
|])
667676

668677
end
669678

670679
let () =
680+
(* From now on the default setting will be uncurried mode *)
681+
Config.uncurried := Uncurried;
671682
export "rescript_compiler"
672683
(Js.Unsafe.(obj
673684
[|

packages/playground-bundling/bsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"sources": {
1010
"dir": "src",
1111
"subdirs": true
12-
}
12+
},
13+
"uncurried": true
1314
}

playground/playground_test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ let result = compiler.rescript.compile(`
3030
->Array.map(x => x * 2)
3131
->Array.reduce(0, (acc, item) => acc + item)
3232
33+
34+
// Test uncurried behavior
35+
let runFn = (f, x) => f(x)
36+
runFn(x => x + 1, 1)->Console.log
37+
3338
Console.log("Hello world!")
3439
3540
let a = <B a="hello" />

0 commit comments

Comments
 (0)