Skip to content

Commit e6dd93b

Browse files
authored
Merge pull request #815 from n-osborne/remove-ppx-lwt
Remove `lwt_ppx` dependency
2 parents 8c2864b + a5ff4f1 commit e6dd93b

38 files changed

+605
-520
lines changed

dune-project

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ The client-side code is compiled to JS using Ocsigen Js_of_ocaml or to Wasm usin
3232
(js_of_ocaml-ppx_deriving_json (>= 5.5.0))
3333
(js_of_ocaml-tyxml (>= 5.5.0))
3434
lwt_log
35-
(lwt_ppx (>= 1.2.3))
3635
(tyxml (and (>= 4.6.0) (< 4.7.0)))
3736
(ocsigenserver (and (>= 6.0.0) (< 7.0.0)))
3837
(ipaddr (>= 2.1))

eliom.opam

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ depends: [
3030
"js_of_ocaml-ppx_deriving_json" {>= "5.5.0"}
3131
"js_of_ocaml-tyxml" {>= "5.5.0"}
3232
"lwt_log"
33-
"lwt_ppx" {>= "1.2.3"}
3433
"tyxml" {>= "4.6.0" & < "4.7.0"}
3534
"ocsigenserver" {>= "6.0.0" & < "7.0.0"}
3635
"ipaddr" {>= "2.1"}

pkg/distillery/templates/app.exe/dune

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
(wrapped false)
1111
(preprocess
1212
(pps
13-
lwt_ppx
1413
; pgocaml_ppx
1514
js_of_ocaml-ppx_deriving_json
1615
; ocsigen-i18n
@@ -40,7 +39,6 @@
4039
(modules %%%MODULE_NAME%%%_main)
4140
(preprocess
4241
(pps
43-
lwt_ppx
4442
; pgocaml_ppx
4543
js_of_ocaml-ppx_deriving_json
4644
; ocsigen-i18n
@@ -92,7 +90,6 @@
9290
(preprocess
9391
(pps
9492
js_of_ocaml-ppx
95-
lwt_ppx
9693
; ocsigen-i18n
9794
; --
9895
; --prefix

pkg/distillery/templates/app.exe/tools!dune

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
(name eliom_ppx_client)
33
(modes native)
44
(modules eliom_ppx_client)
5-
(preprocess (pps lwt_ppx))
65
(libraries ocsigen-ppx-rpc eliom.ppx.client))
76

87
(rule

pkg/distillery/templates/app.lib/dune

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
(wrapped false)
1010
(preprocess
1111
(pps
12-
lwt_ppx
1312
; pgocaml_ppx
1413
js_of_ocaml-ppx_deriving_json
1514
; ocsigen-i18n
@@ -62,7 +61,6 @@
6261
(preprocess
6362
(pps
6463
js_of_ocaml-ppx
65-
lwt_ppx
6664
; ocsigen-i18n
6765
; --
6866
; --prefix

pkg/distillery/templates/app.lib/tools!dune

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
(name eliom_ppx_client)
33
(modes native)
44
(modules eliom_ppx_client)
5-
(preprocess (pps lwt_ppx))
65
(libraries ocsigen-ppx-rpc eliom.ppx.client))
76

87
(rule

pkg/distillery/templates/basic.ppx/Makefile.options

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ SERVER_FILES := $(wildcard *.eliomi *.eliom)
1111
CLIENT_FILES := $(wildcard *.eliomi *.eliom)
1212

1313
# OCamlfind packages for the server
14-
SERVER_PACKAGES := lwt_ppx js_of_ocaml-ppx_deriving_json
14+
SERVER_PACKAGES := js_of_ocaml-ppx_deriving_json
1515
# OCamlfind packages for the client
16-
CLIENT_PACKAGES := lwt_ppx js_of_ocaml-ppx js_of_ocaml-ppx_deriving_json
16+
CLIENT_PACKAGES := js_of_ocaml-ppx js_of_ocaml-ppx_deriving_json
1717

1818
# Directory with files to be statically served
1919
LOCAL_STATIC = static

src/_tags

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ true:keep_locs
66
<lib/client/client.cma>:eliomstubs
77

88
<lib/type_dir/*.ml{,i}>:eliom_ppx,thread
9-
<lib/type_dir/*.ml>:package(js_of_ocaml-ppx_deriving_json,lwt_ppx)
9+
<lib/type_dir/*.ml>:package(js_of_ocaml-ppx_deriving_json)
1010
<lib/type_dir/*.ml>:package(js_of_ocaml-ppx)
1111

1212
<lib/server/*.ml{,i}>:eliom_ppx
13-
<lib/server/*.ml>:package(js_of_ocaml-ppx_deriving_json,lwt_ppx)
13+
<lib/server/*.ml>:package(js_of_ocaml-ppx_deriving_json)
1414
<lib/server/*.ml>:package(js_of_ocaml-ppx)
1515

1616
<lib/server/*.ml{,i}>:thread
@@ -22,7 +22,7 @@ true:keep_locs
2222
<lib/*.eliom{,i}>:eliom_ppx
2323

2424
<lib/*.ml{,i}>:eliom_ppx
25-
<lib/client/*.ml>:package(js_of_ocaml-ppx_deriving_json,lwt_ppx,js_of_ocaml-lwt.logger)
25+
<lib/client/*.ml>:package(js_of_ocaml-ppx_deriving_json,js_of_ocaml-lwt.logger)
2626
<lib/client/*.ml>:package(js_of_ocaml-ppx)
2727

2828
<lib/client/*.ml{,i}>: eliom_ppx
@@ -33,7 +33,6 @@ true:keep_locs
3333

3434
<lib/client/*.ml{,i}>:package(js_of_ocaml-ppx_deriving_json)
3535

36-
<lib/server/monitor/*.ml>:package(lwt_ppx)
3736
<lib/server/monitor/*.ml{,i}>:thread
3837
<lib/server/monitor/*.ml{,i}>:package(lwt,ocsigenserver,ocsipersist,tyxml)
3938
<lib/server/monitor/*.ml{,i}>:I(src/lib/server)

src/lib/client/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
eliom_shared_sigs
1414
eliom_wrap)
1515
(preprocess
16-
(pps lwt_ppx js_of_ocaml-ppx js_of_ocaml-ppx_deriving_json))
16+
(pps js_of_ocaml-ppx js_of_ocaml-ppx_deriving_json))
1717
(library_flags
1818
(:standard -linkall))
1919
(libraries

src/lib/client/eliommod_dom.ml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
open Lwt.Syntax
2+
13
(* Ocsigen
24
* http://www.ocsigen.org
35
* Copyright (C) 2011 Pierre Chambart, Grégoire Henry
@@ -576,19 +578,21 @@ let rewrite_css_url ~prefix css pos =
576578
let import_re = Regexp.regexp "@import\\s*"
577579

578580
let rec rewrite_css ~max (media, href, css) =
579-
try%lwt
580-
css >>= function
581-
| None -> Lwt.return_nil
582-
| Some css ->
583-
if !Eliom_config.debug_timings
584-
then Firebug.console ## (time (Js.string ("rewrite_CSS: " ^ href)));
585-
let%lwt imports, css =
586-
rewrite_css_import ~max ~prefix:(basedir href) ~media css 0
587-
in
588-
if !Eliom_config.debug_timings
589-
then Firebug.console ## (timeEnd (Js.string ("rewrite_CSS: " ^ href)));
590-
Lwt.return (imports @ [media, css])
591-
with _ -> Lwt.return [media, Printf.sprintf "@import url(%s);" href]
581+
Lwt.catch
582+
(fun () ->
583+
css >>= function
584+
| None -> Lwt.return_nil
585+
| Some css ->
586+
if !Eliom_config.debug_timings
587+
then Firebug.console ## (time (Js.string ("rewrite_CSS: " ^ href)));
588+
let* imports, css =
589+
rewrite_css_import ~max ~prefix:(basedir href) ~media css 0
590+
in
591+
if !Eliom_config.debug_timings
592+
then
593+
Firebug.console ## (timeEnd (Js.string ("rewrite_CSS: " ^ href)));
594+
Lwt.return (imports @ [media, css]))
595+
(fun _ -> Lwt.return [media, Printf.sprintf "@import url(%s);" href])
592596

593597
and rewrite_css_import ?(charset = "") ~max ~prefix ~media css pos =
594598
match Regexp.search import_re css pos with
@@ -603,7 +607,7 @@ and rewrite_css_import ?(charset = "") ~max ~prefix ~media css pos =
603607
let i = i + String.length (Regexp.matched_string res) in
604608
let i, href = parse_url ~prefix css i in
605609
let i, media' = parse_media css i in
606-
let%lwt import =
610+
let* import =
607611
if max = 0
608612
then
609613
(* Maximum imbrication of @import reached, rewrite url. *)
@@ -623,7 +627,7 @@ and rewrite_css_import ?(charset = "") ~max ~prefix ~media css pos =
623627
Eliom_request.http_get href [] Eliom_request.string_result
624628
in
625629
rewrite_css ~max:(max - 1) (media, href, css >|= snd)
626-
and imports, css =
630+
and* imports, css =
627631
rewrite_css_import ~charset ~max ~prefix ~media css i
628632
in
629633
Lwt.return (import @ imports, css)
@@ -636,7 +640,7 @@ and rewrite_css_import ?(charset = "") ~max ~prefix ~media css pos =
636640
let max_preload_depth = ref 4
637641

638642
let build_style (e, css) =
639-
let%lwt css = rewrite_css ~max:!max_preload_depth css in
643+
let* css = rewrite_css ~max:!max_preload_depth css in
640644
(* lwt css = *)
641645
Lwt_list.map_p
642646
(fun (media, css) ->
@@ -663,7 +667,7 @@ let build_style (e, css) =
663667
let preload_css (doc : Dom_html.element Js.t) =
664668
if !Eliom_config.debug_timings
665669
then Firebug.console ## (time (Js.string "preload_css (fetch+rewrite)"));
666-
let%lwt css = Lwt_list.map_p build_style (fetch_linked_css (get_head doc)) in
670+
let* css = Lwt_list.map_p build_style (fetch_linked_css (get_head doc)) in
667671
let css = List.concat css in
668672
List.iter
669673
(fun (e, css) ->

0 commit comments

Comments
 (0)