utkarshkukreti / bs-preact Goto Github PK
View Code? Open in Web Editor NEWDeprecated in favor of https://github.com/utkarshkukreti/reaml, which has more features, works with the latest BuckleScript, and can be used with both React and Preact.
Deprecated in favor of https://github.com/utkarshkukreti/reaml, which has more features, works with the latest BuckleScript, and can be used with both React and Preact.
Clone this repo. Update bs-platform
to 7.0.1. Run npm start
:
FAILED: examples/Clock.mlast
/Users/prisc_000/Downloads/bs-preact-master/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.1/node_modules/bs-platform/lib/bsc.exe -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101 -color always -ppx /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx -o examples/Clock.mlast -bs-syntax-only -bs-binary-ast /Users/prisc_000/Downloads/bs-preact-master/examples/Clock.ml
Failure("Ast_mapper: OCaml version mismatch or malformed input")
File "/Users/prisc_000/Downloads/bs-preact-master/examples/Clock.ml", line 1:
Error: Error while running external preprocessor
Command line: /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppx7ccba3' '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppx1368f6'
[2/75] Building examples/Clicks.mlast
FAILED: examples/Clicks.mlast
/Users/prisc_000/Downloads/bs-preact-master/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.1/node_modules/bs-platform/lib/bsc.exe -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101 -color always -ppx /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx -o examples/Clicks.mlast -bs-syntax-only -bs-binary-ast /Users/prisc_000/Downloads/bs-preact-master/examples/Clicks.ml
Failure("Ast_mapper: OCaml version mismatch or malformed input")
File "/Users/prisc_000/Downloads/bs-preact-master/examples/Clicks.ml", line 1:
Error: Error while running external preprocessor
Command line: /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxcb25ae' '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxe20fd1'
[3/75] Building tests/Preact_Test.mlast
FAILED: tests/Preact_Test.mlast
/Users/prisc_000/Downloads/bs-preact-master/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.1/node_modules/bs-platform/lib/bsc.exe -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101 -color always -ppx /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx -o tests/Preact_Test.mlast -bs-syntax-only -bs-binary-ast /Users/prisc_000/Downloads/bs-preact-master/tests/Preact_Test.ml
Failure("Ast_mapper: OCaml version mismatch or malformed input")
File "/Users/prisc_000/Downloads/bs-preact-master/tests/Preact_Test.ml", line 1:
Error: Error while running external preprocessor
Command line: /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxedbca4' '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppx2f24ba'
[4/75] Building tests/Preact_Router_Test.mlast
FAILED: tests/Preact_Router_Test.mlast
/Users/prisc_000/Downloads/bs-preact-master/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.1/node_modules/bs-platform/lib/bsc.exe -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101 -color always -ppx /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx -o tests/Preact_Router_Test.mlast -bs-syntax-only -bs-binary-ast /Users/prisc_000/Downloads/bs-preact-master/tests/Preact_Router_Test.ml
Failure("Ast_mapper: OCaml version mismatch or malformed input")
File "/Users/prisc_000/Downloads/bs-preact-master/tests/Preact_Router_Test.ml", line 1:
Error: Error while running external preprocessor
Command line: /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxdd7638' '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxd8c0b7'
[5/75] Building examples/Ref.mlast
FAILED: examples/Ref.mlast
/Users/prisc_000/Downloads/bs-preact-master/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.1/node_modules/bs-platform/lib/bsc.exe -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101 -color always -ppx /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx -o examples/Ref.mlast -bs-syntax-only -bs-binary-ast /Users/prisc_000/Downloads/bs-preact-master/examples/Ref.ml
Failure("Ast_mapper: OCaml version mismatch or malformed input")
File "/Users/prisc_000/Downloads/bs-preact-master/examples/Ref.ml", line 1:
Error: Error while running external preprocessor
Command line: /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppx202c9b' '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxd56a9f'
[6/75] Building examples/Form.mlast
FAILED: examples/Form.mlast
/Users/prisc_000/Downloads/bs-preact-master/node_modules/.pnpm/registry.npmjs.org/bs-platform/7.0.1/node_modules/bs-platform/lib/bsc.exe -w -30-40+6+7+27+32..39+44+45+101 -warn-error +101 -color always -ppx /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx -o examples/Form.mlast -bs-syntax-only -bs-binary-ast /Users/prisc_000/Downloads/bs-preact-master/examples/Form.ml
Failure("Ast_mapper: OCaml version mismatch or malformed input")
File "/Users/prisc_000/Downloads/bs-preact-master/examples/Form.ml", line 1:
Error: Error while running external preprocessor
Command line: /Users/prisc_000/Downloads/bs-preact-master/node_modules/bs-preact-ppx/ppx '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppx667943' '/var/folders/dz/xzttny_14gs2lgxcvl5lm5680000gn/T/camlppxc146e3'
FAILED: subcommand failed.
ERROR Command failed with exit code 2.
ERROR: "build:bsb" exited with 1.
ERROR Command failed with exit code 1.
➜ bs-preact-master
Can this be used as an alternative to ReasonReact, and does it have JSX support as well?
Users who prefer reason
over ocaml
syntax and who are unfamiliar with the usage of annotations like let [@hook]
may have a hard time understanding where the annotations go in a Reason formatted codebase.
Putting this example:
let useDoubleReducer =
fun [@preact.hook] (reducer, initialValue) ->
let[@hook] state, dispatch = P.useReducer reducer initialValue in
let dispatchTwice action =
let () = dispatch action in
dispatch action
in
state, dispatchTwice
let make =
fun [@preact.component "HelloHooks"] () ->
let reducer state action = state + action in
let[@hook] state, dispatch = useDoubleReducer (reducer, 0) in
P.button [ P.onClick (fun _ -> dispatch 2) ] [ P.int state ]
into the ReasonML playground outputs this:
let useDoubleReducer =
[@preact.hook]
(
((reducer, initialValue)) =>
[@hook]
{
let (state, dispatch) = P.useReducer(reducer, initialValue);
let dispatchTwice = action => {
let () = dispatch(action);
dispatch(action);
};
(state, dispatchTwice);
}
);
let make =
[@preact.component "HelloHooks"]
(
() => {
let reducer = (state, action) => state + action;
[@hook]
{
let (state, dispatch) = useDoubleReducer((reducer, 0));
P.button([P.onClick(_ => dispatch(2))], [P.int(state)]);
};
}
);
As someone who does not know where annotations are supposed to go in Reason formatted code it is unclear if this translation is in fact correct.
PS: thanks for your work, really like the hooks validation at compile time 👌
Proposed solution
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.