Skip to content

Commit 4c0e525

Browse files
committed
Merge branch 'main' of github.com:/reasonml/reason-react into 19
* 'main' of github.com:/reasonml/reason-react: test: update snapshot tests to melange v5 (#875) nix: remove nix-filter dependency (#874) chore(nix): remove flake-utils (#873) Get rid of .t from linguist (#868)
2 parents 52e585a + c8c3d22 commit 4c0e525

File tree

5 files changed

+114
-152
lines changed

5 files changed

+114
-152
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.re linguist-language=Reason
22
*.rei linguist-language=Reason
3+
*.t text eol=lf -linguist-detectable

flake.lock

Lines changed: 7 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 83 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2,93 +2,101 @@
22
description = "Reason React Nix Flake";
33

44
inputs = {
5-
nix-filter.url = "github:numtide/nix-filter";
6-
flake-utils.url = "github:numtide/flake-utils";
7-
nixpkgs = {
8-
url = "github:nix-ocaml/nix-overlays";
9-
inputs.flake-utils.follows = "flake-utils";
10-
};
5+
nixpkgs.url = "github:nix-ocaml/nix-overlays";
116
};
127

13-
outputs = { self, nixpkgs, flake-utils, nix-filter }:
14-
flake-utils.lib.eachDefaultSystem (system:
15-
let
16-
pkgs = nixpkgs.legacyPackages."${system}".appendOverlays [
17-
(self: super: { ocamlPackages = super.ocaml-ng.ocamlPackages_5_2; })
18-
];
8+
outputs = { self, nixpkgs }:
9+
let
10+
forAllSystems = f: nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (system:
11+
let
12+
pkgs = nixpkgs.legacyPackages.${system}.extend (self: super: {
13+
ocamlPackages = super.ocaml-ng.ocamlPackages_5_2.overrideScope (oself: osuper: {
14+
ppxlib = osuper.ppxlib.overrideAttrs (o: {
15+
propagatedBuildInputs = o.propagatedBuildInputs ++ [ osuper.stdio ];
16+
});
17+
});
18+
});
19+
in
20+
f pkgs);
21+
in
22+
{
23+
packages = forAllSystems (pkgs:
24+
let
25+
inherit (pkgs.ocamlPackages)
26+
buildDunePackage melange merlin ppxlib reason;
27+
packages = rec {
28+
reason-react-ppx = buildDunePackage {
29+
pname = "reason-react-ppx";
30+
version = "n/a";
1931

20-
makeDevShell = { packages, release-mode ? false }:
21-
pkgs.mkShell {
22-
# dontDetectOcamlConflicts = true;
23-
inputsFrom = pkgs.lib.attrValues packages;
24-
nativeBuildInputs =
25-
with pkgs.ocamlPackages; [ ocamlformat pkgs.nodejs_latest ]
26-
++ pkgs.lib.optionals release-mode (with pkgs; [
27-
cacert
28-
curl
29-
ocamlPackages.dune-release
30-
ocamlPackages.odoc
31-
git
32-
]);
33-
propagatedBuildInputs = with pkgs.ocamlPackages; [ merlin ];
34-
};
35-
in
32+
src =
33+
let fs = pkgs.lib.fileset; in
34+
fs.toSource {
35+
root = ./.;
36+
fileset = fs.unions [
37+
./dune-project
38+
./dune
39+
./reason-react-ppx.opam
40+
./ppx
41+
];
42+
};
3643

37-
rec {
38-
packages = with pkgs.ocamlPackages; rec {
39-
reason-react-ppx = buildDunePackage {
40-
pname = "reason-react-ppx";
41-
version = "n/a";
42-
src = with nix-filter.lib; filter {
43-
root = ./.;
44-
include = [
45-
"dune-project"
46-
"dune"
47-
"reason-react-ppx.opam"
48-
"reason-react.opam"
49-
"ppx"
50-
];
44+
# Due to a Reason version mismatch, the generated OCaml PPX diff
45+
# looks different
46+
doCheck = false;
47+
propagatedBuildInputs = [ ppxlib ];
5148
};
52-
# Due to a Reason version mismatch, the generated OCaml PPX diff
53-
# looks different
54-
doCheck = false;
55-
checkInputs = [ ];
56-
checkPhase = "dune build @runtest -p reason-react,reason-react-ppx";
57-
nativeCheckInputs = [ reason merlin pkgs.jq ];
58-
propagatedBuildInputs = [ ppxlib ];
59-
};
6049

61-
reason-react = buildDunePackage {
62-
pname = "reason-react";
63-
version = "n/a";
64-
src = with nix-filter.lib; filter {
65-
root = ./.;
66-
include = [
67-
"dune-project"
68-
"dune"
69-
"reason-react-ppx.opam"
70-
"reason-react.opam"
71-
"src"
72-
"test"
73-
];
50+
reason-react = buildDunePackage {
51+
pname = "reason-react";
52+
version = "n/a";
53+
54+
src =
55+
let fs = pkgs.lib.fileset; in
56+
fs.toSource {
57+
root = ./.;
58+
fileset = fs.unions [
59+
./dune-project
60+
./dune
61+
./reason-react.opam
62+
./src
63+
./test
64+
];
65+
};
66+
67+
doCheck = true;
68+
nativeBuildInputs = [ melange reason ];
69+
propagatedBuildInputs = [ melange reason-react-ppx ];
7470
};
75-
doCheck = true;
76-
nativeBuildInputs = [ pkgs.ocamlPackages.melange reason ];
77-
propagatedBuildInputs = [
78-
pkgs.ocamlPackages.melange
79-
reason-react-ppx
80-
];
8171
};
72+
in
73+
packages // { default = packages.reason-react; });
8274

83-
default = packages.reason-react;
84-
};
85-
86-
devShells = {
75+
devShells = forAllSystems (pkgs:
76+
let
77+
makeDevShell = { packages, release-mode ? false }:
78+
pkgs.mkShell {
79+
# dontDetectOcamlConflicts = true;
80+
inputsFrom = pkgs.lib.attrValues packages;
81+
nativeBuildInputs =
82+
with pkgs.ocamlPackages; [ ocamlformat pkgs.nodejs_latest ]
83+
++ pkgs.lib.optionals release-mode (with pkgs; [
84+
cacert
85+
curl
86+
ocamlPackages.dune-release
87+
ocamlPackages.odoc
88+
git
89+
]);
90+
propagatedBuildInputs = with pkgs.ocamlPackages; [ merlin ];
91+
};
92+
packages = self.packages.${pkgs.system};
93+
in
94+
{
8795
default = makeDevShell { inherit packages; };
8896
release = makeDevShell {
8997
inherit packages;
9098
release-mode = true;
9199
};
92-
};
93-
});
100+
});
101+
};
94102
}

ppx/test/react.t

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ Demonstrate how to use the React JSX PPX
4040
4141
function X$App(Props) {
4242
return Belt__Belt_List.toArray(Belt__Belt_List.map({
43-
hd: "Hello!",
44-
tl: {
45-
hd: "This is React!",
46-
tl: /* [] */0
47-
}
48-
}, (function (greeting) {
49-
return JsxRuntime.jsx("h1", {
50-
children: greeting
51-
});
52-
})));
43+
hd: "Hello!",
44+
tl: {
45+
hd: "This is React!",
46+
tl: /* [] */ 0
47+
}
48+
}, (function (greeting) {
49+
return JsxRuntime.jsx("h1", {
50+
children: greeting
51+
});
52+
})));
5353
}
5454
5555
const App = {
@@ -60,5 +60,7 @@ Demonstrate how to use the React JSX PPX
6060
6161
JsxRuntime.jsx(X$App, {});
6262
63-
exports.App = App;
63+
module.exports = {
64+
App,
65+
}
6466
/* Not a pure module */

test/blackbox-tests/useCallback.t

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
const React = require("react");
2525
2626
const cb = React.useCallback((function (a, b) {
27-
return a + b | 0;
28-
}), []);
27+
return a + b | 0;
28+
}), []);
2929
30-
exports.cb = cb;
30+
module.exports = {
31+
cb,
32+
}
3133
/* cb Not a pure module */
3234
3335
Using an Uncurried function:
@@ -45,9 +47,11 @@ Using an Uncurried function:
4547
const React = require("react");
4648
4749
const cb = React.useCallback((function (a, b) {
48-
return a + b | 0;
49-
}), []);
50+
return a + b | 0;
51+
}), []);
5052
51-
exports.cb = cb;
53+
module.exports = {
54+
cb,
55+
}
5256
/* cb Not a pure module */
5357

0 commit comments

Comments
 (0)