Skip to content

Commit 49698c1

Browse files
authored
Merge pull request #4395 from jchavarri/fix-jsoo-remt
fix jsoo_refmt_main + delete playground folder
2 parents 18a1eab + be706e4 commit 49698c1

File tree

8 files changed

+10
-177
lines changed

8 files changed

+10
-177
lines changed

.github/workflows/playground.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

jscomp/refmt/jsoo_refmt_main.ml

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ let error_of_exn e =
3939
| Some `Already_displayed
4040
| None -> None
4141

42-
type react_ppx_version = V2 | V3
43-
44-
let implementation ?prefix ~use_super_errors ?(react_ppx_version=V3) impl str : Js.Unsafe.obj =
42+
let implementation ~use_super_errors impl str : Js.Unsafe.obj =
4543
let modulename = "Test" in
4644
(* let env = !Toploop.toplevel_env in *)
4745
(* Compmisc.init_path false; *)
@@ -56,17 +54,10 @@ let implementation ?prefix ~use_super_errors ?(react_ppx_version=V3) impl str :
5654
Lazy.force Super_main.setup ;
5755
end;
5856

59-
60-
6157
try
62-
let code = match prefix with
63-
| None -> str
64-
| Some(prefix) -> prefix ^ str in
65-
let ast = impl (Lexing.from_string code) in
66-
let ast = match react_ppx_version with
67-
| V2 -> Reactjs_jsx_ppx_v2.rewrite_implementation ast
68-
| V3 -> Reactjs_jsx_ppx_v3.rewrite_implementation ast in
69-
let ast = Bs_builtin_ppx.rewrite_implementation ast in
58+
Js_config.jsx_version := 3 ; (* default *)
59+
let ast = impl (Lexing.from_string str) in
60+
let ast = Ppx_entry.rewrite_implementation ast in
7061
let typed_tree =
7162
let (a,b,_,signature) = Typemod.type_implementation_more modulename modulename modulename env ast in
7263
(* finalenv := c ; *)
@@ -108,11 +99,8 @@ let implementation ?prefix ~use_super_errors ?(react_ppx_version=V3) impl str :
10899
end
109100

110101

111-
let compile ~use_super_errors ?react_ppx_version impl =
112-
implementation ~use_super_errors ?react_ppx_version impl
113-
114-
let shake_compile ~prefix ~use_super_errors ?react_ppx_version impl =
115-
implementation ~prefix ~use_super_errors ?react_ppx_version impl
102+
let compile ~use_super_errors impl =
103+
implementation ~use_super_errors impl
116104

117105
(* let load_module cmi_path cmi_content cmj_name cmj_content =
118106
Js.create_file cmi_path cmi_content;
@@ -137,38 +125,19 @@ module Converter = Refmt_api.Migrate_parsetree.Convert(Refmt_api.Migrate_parsetr
137125
let reason_parse lexbuf =
138126
Refmt_api.Reason_toolchain.RE.implementation lexbuf |> Converter.copy_structure;;
139127

140-
let make_compiler ~name ~prefix impl=
128+
let make_compiler ~name impl=
141129
export name
142130
(Js.Unsafe.(obj
143131
[|"compile",
144132
inject @@
145133
Js.wrap_meth_callback
146134
(fun _ code ->
147135
(compile impl ~use_super_errors:false (Js.to_string code)));
148-
"shake_compile",
149-
inject @@
150-
Js.wrap_meth_callback
151-
(fun _ code ->
152-
(shake_compile impl ~use_super_errors:false ~prefix (Js.to_string code)));
153136
"compile_super_errors",
154137
inject @@
155138
Js.wrap_meth_callback
156139
(fun _ code ->
157140
(compile impl ~use_super_errors:true (Js.to_string code)));
158-
"compile_super_errors_ppx_v2",
159-
inject @@
160-
Js.wrap_meth_callback
161-
(fun _ code ->
162-
(compile impl ~use_super_errors:true ~react_ppx_version:V2 (Js.to_string code)));
163-
"compile_super_errors_ppx_v3",
164-
inject @@
165-
Js.wrap_meth_callback
166-
(fun _ code ->
167-
(compile impl ~use_super_errors:true ~react_ppx_version:V3 (Js.to_string code)));
168-
"shake_compile_super_errors",
169-
inject @@
170-
Js.wrap_meth_callback
171-
(fun _ code -> (shake_compile impl ~use_super_errors:true ~prefix (Js.to_string code)));
172141
"version", Js.Unsafe.inject (Js.string (match name with | "reason" -> Refmt_api.version | _ -> Bs_version.version));
173142
(* "load_module",
174143
inject @@
@@ -181,8 +150,8 @@ let make_compiler ~name ~prefix impl=
181150
load_module cmi_path cmi_content (Js.to_string cmj_name) cmj_bytestring); *)
182151
|]))
183152

184-
let () = make_compiler ~name:"ocaml" ~prefix:"[@@@bs.config {no_export}]\n#1 \"repl.ml\"\n" Parse.implementation
185-
let () = make_compiler ~name:"reason" ~prefix:"[@bs.config {no_export: no_export}];\n#1 \"repl.re\";\n" reason_parse
153+
let () = make_compiler ~name:"ocaml" Parse.implementation
154+
let () = make_compiler ~name:"reason" reason_parse
186155

187156
(* local variables: *)
188157
(* compile-command: "ocamlbuild -use-ocamlfind -pkg compiler-libs -no-hygiene driver.cmo" *)

jscomp/refmt/jsoo_refmt_main.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525

26-
val make_compiler : name:string -> prefix:string -> (Lexing.lexbuf -> Parsetree.structure) -> unit
26+
val make_compiler : name:string -> (Lexing.lexbuf -> Parsetree.structure) -> unit

playground/.gitignore

Lines changed: 0 additions & 7 deletions
This file was deleted.

playground/README.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

playground/bsconfig.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

playground/package.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

playground/yarn.lock

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)