Skip to content

Conversation

@rickyvetter
Copy link
Contributor

This gets the ppx working in the try page on reasonml.github.io and also sets us up for cppo and the ability to delete the other files. Need some small guidance on how to do that - will post questions. Fixes #3512

@bobzhang
Copy link
Member

This looks good to me, but can you make it stand-alone since make them together may affect the code size of vanilla ocaml playground

@bobzhang
Copy link
Member

btw, it seems we can integrate Reactjs_jsx_ppx_v3.rewrite into bsc.exe process as well, so that it does not need spawn external processor any more?

Copy link
Contributor Author

@rickyvetter rickyvetter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context this file has a total of three conditionals with two conditions each, for a total of 6 possible outputs:

jsoo, native
4.02, 4.06
v2, v3

@@ -0,0 +1,1092 @@
(*
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right location for this file?

try
impl (Lexing.from_string
(if prefix then "[@@@bs.config{no_export}]\n#1 \"repl.ml\"\n" ^ str else str ))
|> Reactjs_jsx_ppx_v3.rewrite
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like this to only be run conditionally?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the playground on the Reason site only compiles conditionally. Are there plans to change it to always compile? Reason JSX vs ReasonReact JSX might be something to consider.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah talking to Bob offline and we will probably compile two different versions - one with this built in.

| [] -> None
| x :: l -> if p x then Some x else find_opt p l

#if OCAML_VERSION =~ ">4.03.0" then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this makes long term support much easier and will avoid a lot of needless copying if we can compile this file to all conditions.

Location.input_name := "Toplevel";
mapper.structure mapper code
#else
let () = Ast_mapper.register "JSX" (fun _argv -> jsxMapper ())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node ./scripts/ninja.js && ninja -C jscomp fails when this is written this way, even though this is "correct", but repl.js seems to set BS_COMPILER_IN_BROWSER and work properly. I think the env isn't set properly in ninja -C jscomp - any ideas?

| {loc; txt = Ldot (modulePath, ("createElement" | "make"))} ->
(match !jsxVersion with
| Some 2 -> transformUppercaseCall modulePath mapper loc attrs callExpression callArguments
| None
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v2 vs v3 should actually be another cppo statement here and a few lines below. Is there a good/easy way to add another conditional variable? That way we can fully replace the other copied files.

@rickyvetter
Copy link
Contributor Author

btw, it seems we can integrate Reactjs_jsx_ppx_v3.rewrite into bsc.exe process as well, so that it does not need spawn external processor any more?

yeah we can do that if you'd prefer - we need to be able to conditionally flip between 2 and 3 though.

@rickyvetter
Copy link
Contributor Author

can you make it stand-alone

What's the best way to do this? Compile it as a separate entry point? Is there an example of how they would call each other? Would it need to be composed in JS?

e(`hash camlp4 2>/dev/null || { echo >&2 "camlp4 not installed. Please install: opam install camlp4"; exit 1; }`)
// e(`hash camlp4 2>/dev/null || { echo >&2 "camlp4 not installed. Please install: opam install camlp4"; exit 1; }`)

// require('../scripts/release').run()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why these lines commented?

Copy link
Contributor

@phated phated Apr 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bobzhang this was commented in your commit at 740f0bf
I think it was because the JSX PPX wasn't compiling.

Sorry, I thought you were talking about the // require('../scripts/release').run() line but now I see the lines above are commented.

build ../lib/reactjs_jsx_ppx_2.exe: link stubs/stubs.cmxa ext/ext.cmxa common/common.cmxa syntax/reactjs_jsx_ppx_v2.cmx
libs = ocamlcommon.cmxa
build ../lib/reactjs_jsx_ppx_js.exe: link stubs/stubs.cmxa ext/ext.cmxa common/common.cmxa syntax/reactjs_jsx_ppx_js.cmx
libs = ocamlcommon.cmxa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not make sense to build reactjs_jsx_ppx_js.exe, right?

@rickyvetter
Copy link
Contributor Author

Closing in favor of #3523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants