diff --git a/.github/workflows/opam.yml b/.github/workflows/opam.yml index 065df9a31..91c3a2aac 100644 --- a/.github/workflows/opam.yml +++ b/.github/workflows/opam.yml @@ -68,6 +68,9 @@ jobs: - name: Test run: make test + - name: Jest + run: make jest + - name: Save cache when not Windows uses: actions/cache/save@v3 if: steps.opam-cache.outputs.cache-hit != 'true' && runner.os != 'Windows' diff --git a/.ocamlformat b/.ocamlformat index e69de29bb..3fe595c05 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -0,0 +1 @@ +version = 0.24.0 diff --git a/Makefile b/Makefile index bcb5c73db..f2c192652 100644 --- a/Makefile +++ b/Makefile @@ -23,10 +23,17 @@ dev: ## Build in watch mode clean: ## Clean artifacts @$(DUNE) clean +.PHONY: jest +jest: ## Run the jest unit tests + @npx jest + +.PHONY: jest-watch +jest-watch: ## Run the jest unit tests in watch mode + @npx jest --watch + .PHONY: test -test: ## Run the unit tests +test: ## Run the runtests from dune (snapshot) @$(DUNE) build @runtest - @npx jest .PHONY: test-watch test-watch: ## Run the unit tests in watch mode diff --git a/dune-project b/dune-project index 1e5afbaf8..f18444141 100644 --- a/dune-project +++ b/dune-project @@ -44,6 +44,10 @@ (opam-check-npm-deps (and (= 1.0.0) + :with-dev-setup)) + (ocamlformat + (and + (= 0.24.0) :with-dev-setup)))) (package @@ -57,4 +61,8 @@ (>= 3.9.0)) (ppxlib (>= 0.28.0)) - (merlin :with-test))) + (merlin :with-test) + (ocamlformat + (and + (= 0.24.0) + :with-dev-setup)))) diff --git a/ppx/dune b/ppx/dune new file mode 100644 index 000000000..2a2ba083d --- /dev/null +++ b/ppx/dune @@ -0,0 +1,14 @@ +(library + (name reason_react_ppx) + (modules reason_react_ppx) + (public_name reason-react-ppx) + (flags :standard -w -9) + (kind ppx_rewriter) + (libraries ppxlib)) + +(executable + (name standalone) + (modules standalone) + (package reason-react-ppx) + (public_name reason-react-ppx) + (libraries reason-react-ppx ppxlib)) diff --git a/ppx/src/reactjs_jsx_ppx.ml b/ppx/reason_react_ppx.ml similarity index 100% rename from ppx/src/reactjs_jsx_ppx.ml rename to ppx/reason_react_ppx.ml diff --git a/ppx/src/dune b/ppx/src/dune deleted file mode 100644 index 02e03c625..000000000 --- a/ppx/src/dune +++ /dev/null @@ -1,6 +0,0 @@ -(library - (name reason_react_ppx) - (kind ppx_rewriter) - (public_name reason-react-ppx) - (flags :standard -w -9) - (libraries ppxlib)) diff --git a/ppx/test/standalone.ml b/ppx/standalone.ml similarity index 59% rename from ppx/test/standalone.ml rename to ppx/standalone.ml index 273cf475e..6f7ee4867 100644 --- a/ppx/test/standalone.ml +++ b/ppx/standalone.ml @@ -1,4 +1,2 @@ -open Ppxlib - (* To run as a standalone binary, run the registered drivers *) -let () = Driver.standalone () +let () = Ppxlib.Driver.standalone () diff --git a/ppx/test/component.t/input.re b/ppx/test/component.t/input.re new file mode 100644 index 000000000..7fdccd901 --- /dev/null +++ b/ppx/test/component.t/input.re @@ -0,0 +1,79 @@ +module React_component_with_props = { + [@react.component] + let make = (~lola) => { +
{React.string(lola)}
; + }; +}; + +let react_component_with_props = ; + +module Upper_case_with_fragment_as_root = { + [@react.component] + let make = (~name="") => + <> +
{React.string("First " ++ name)}
+ {React.string("2nd " ++ name)} + ; +}; + +/* module Using_React_memo = { + [@react.component] + let make = + React.memo((~a) => +
{Printf.sprintf("`a` is %s", a) |> React.string}
+ ); +}; + +module Using_memo_custom_compare_Props = { + [@react.component] + let make = + React.memoCustomCompareProps( + (~a) =>
{Printf.sprintf("`a` is %d", a) |> React.string}
, + (prevPros, nextProps) => false, + ); +}; */ + +module Forward_Ref = { + [@react.component] + let make = + React.forwardRef((~children, ~buttonRef) => { + + }); +}; + +module Onclick_handler_button = { + [@react.component] + let make = (~name, ~isDisabled=?) => { + let onClick = event => Js.log(event); +