1
- (* * Bundled by ocamlpack 08/12-16:52 *)
1
+ (* * Bundled by ocamlpack 08/15-11:16 *)
2
2
module String_map : sig
3
3
#1 " string_map.mli"
4
4
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -797,6 +797,12 @@ val bs_deriving : string
797
797
val bs_deriving_dot : string
798
798
val bs_type : string
799
799
800
+ (* * nodejs *)
801
+
802
+ val node_modules : string
803
+ val node_modules_length : int
804
+ val package_json : string
805
+
800
806
end = struct
801
807
#1 " literals.ml"
802
808
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -870,6 +876,13 @@ let bs_deriving = "bs.deriving"
870
876
let bs_deriving_dot = " bs.deriving."
871
877
let bs_type = " bs.type"
872
878
879
+
880
+ (* * nodejs *)
881
+ let node_modules = " node_modules"
882
+ let node_modules_length = String. length " node_modules"
883
+ let package_json = " package.json"
884
+
885
+
873
886
end
874
887
module Ast_attributes : sig
875
888
#1 " ast_attributes.mli"
@@ -1842,7 +1855,7 @@ val to_js_type :
1842
1855
1843
1856
1844
1857
(* * TODO: make it work for browser too *)
1845
- val to_js_undefined_type :
1858
+ val to_undefined_type :
1846
1859
Location .t -> Parsetree .core_type -> Parsetree .core_type
1847
1860
1848
1861
val to_js_re_type : Location .t -> Parsetree .core_type
@@ -1928,7 +1941,7 @@ let to_js_type loc x =
1928
1941
let to_js_re_type loc =
1929
1942
Typ. constr ~loc { txt = re_id ; loc} []
1930
1943
1931
- let to_js_undefined_type loc x =
1944
+ let to_undefined_type loc x =
1932
1945
Typ. constr ~loc
1933
1946
{txt = Ast_literal.Lid. js_undefined ; loc}
1934
1947
[x]
@@ -3237,65 +3250,6 @@ let rec dump r =
3237
3250
let dump v = dump (Obj. repr v)
3238
3251
3239
3252
3240
- end
3241
- module Ext_sys : sig
3242
- #1 " ext_sys.mli"
3243
- (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
3244
- *
3245
- * This program is free software: you can redistribute it and/or modify
3246
- * it under the terms of the GNU Lesser General Public License as published by
3247
- * the Free Software Foundation, either version 3 of the License, or
3248
- * (at your option) any later version.
3249
- *
3250
- * In addition to the permissions granted to you by the LGPL, you may combine
3251
- * or link a "work that uses the Library" with a publicly distributed version
3252
- * of this file to produce a combined library or application, then distribute
3253
- * that combined work under the terms of your choosing, with no requirement
3254
- * to comply with the obligations normally placed on you by section 4 of the
3255
- * LGPL version 3 (or the corresponding section of a later version of the LGPL
3256
- * should you choose to use a later version).
3257
- *
3258
- * This program is distributed in the hope that it will be useful,
3259
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3260
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3261
- * GNU Lesser General Public License for more details.
3262
- *
3263
- * You should have received a copy of the GNU Lesser General Public License
3264
- * along with this program; if not, write to the Free Software
3265
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
3266
-
3267
- val is_directory_no_exn : string -> bool
3268
-
3269
- end = struct
3270
- #1 " ext_sys.ml"
3271
- (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
3272
- *
3273
- * This program is free software: you can redistribute it and/or modify
3274
- * it under the terms of the GNU Lesser General Public License as published by
3275
- * the Free Software Foundation, either version 3 of the License, or
3276
- * (at your option) any later version.
3277
- *
3278
- * In addition to the permissions granted to you by the LGPL, you may combine
3279
- * or link a "work that uses the Library" with a publicly distributed version
3280
- * of this file to produce a combined library or application, then distribute
3281
- * that combined work under the terms of your choosing, with no requirement
3282
- * to comply with the obligations normally placed on you by section 4 of the
3283
- * LGPL version 3 (or the corresponding section of a later version of the LGPL
3284
- * should you choose to use a later version).
3285
- *
3286
- * This program is distributed in the hope that it will be useful,
3287
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3288
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3289
- * GNU Lesser General Public License for more details.
3290
- *
3291
- * You should have received a copy of the GNU Lesser General Public License
3292
- * along with this program; if not, write to the Free Software
3293
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
3294
-
3295
-
3296
- let is_directory_no_exn f =
3297
- try Sys. is_directory f with _ -> false
3298
-
3299
3253
end
3300
3254
module Ext_filename : sig
3301
3255
#1 " ext_filename.mli"
@@ -3356,7 +3310,7 @@ val node_relative_path : t -> [`File of string] -> string
3356
3310
val chop_extension : ?loc : string -> string -> string
3357
3311
3358
3312
3359
- val resolve_bs_package : cwd : string -> string -> string
3313
+
3360
3314
3361
3315
3362
3316
@@ -3509,9 +3463,6 @@ let relative_path file_or_dir_1 file_or_dir_2 =
3509
3463
3510
3464
3511
3465
3512
- let node_modules = " node_modules"
3513
- let node_modules_length = String. length " node_modules"
3514
- let package_json = " package.json"
3515
3466
3516
3467
3517
3468
@@ -3526,7 +3477,7 @@ let package_json = "package.json"
3526
3477
*)
3527
3478
let node_relative_path (file1 : t )
3528
3479
(`File file2 as dep_file : [`File of string] ) =
3529
- let v = Ext_string. find file2 ~sub: node_modules in
3480
+ let v = Ext_string. find file2 ~sub: Literals. node_modules in
3530
3481
let len = String. length file2 in
3531
3482
if v > = 0 then
3532
3483
let rec skip i =
@@ -3547,7 +3498,7 @@ let node_relative_path (file1 : t)
3547
3498
*)
3548
3499
in
3549
3500
Ext_string. tail_from file2
3550
- (skip (v + node_modules_length))
3501
+ (skip (v + Literals. node_modules_length))
3551
3502
else
3552
3503
relative_path
3553
3504
(absolute_path dep_file)
@@ -3557,43 +3508,11 @@ let node_relative_path (file1 : t)
3557
3508
3558
3509
3559
3510
3560
- (* * [resolve cwd module_name],
3561
- [cwd] is current working directory, absolute path
3562
- Trying to find paths to load [module_name]
3563
- it is sepcialized for option [-bs-package-include] which requires
3564
- [npm_package_name/lib/ocaml]
3565
- *)
3566
- let resolve_bs_package ~cwd name =
3567
- let sub_path = name // " lib" // " ocaml" in
3568
- let rec aux origin cwd name =
3569
- let destdir = cwd // node_modules // sub_path in
3570
- if Ext_sys. is_directory_no_exn destdir then destdir
3571
- else
3572
- let cwd' = Filename. dirname cwd in
3573
- if String. length cwd' < String. length cwd then
3574
- aux origin cwd' name
3575
- else
3576
- try
3577
- let destdir =
3578
- Sys. getenv " npm_config_prefix"
3579
- // " lib" // node_modules // sub_path in
3580
- if Ext_sys. is_directory_no_exn destdir
3581
- then destdir
3582
- else
3583
- Ext_pervasives. failwithf
3584
- ~loc: __LOC__ " %s not found in %s" name origin
3585
-
3586
- with
3587
- Not_found ->
3588
- Ext_pervasives. failwithf
3589
- ~loc: __LOC__ " %s not found in %s" name origin
3590
- in
3591
- aux cwd cwd name
3592
3511
3593
3512
3594
3513
let find_package_json_dir cwd =
3595
3514
let rec aux cwd =
3596
- if Sys. file_exists (cwd // package_json) then cwd
3515
+ if Sys. file_exists (cwd // Literals. package_json) then cwd
3597
3516
else
3598
3517
let cwd' = Filename. dirname cwd in
3599
3518
if String. length cwd' < String. length cwd then
@@ -4804,7 +4723,7 @@ let handle_attributes
4804
4723
Ldot (Lident " *predef*" , " option" ) },
4805
4724
[ty])}
4806
4725
->
4807
- (s, [] , Ast_comb. to_js_undefined_type loc ty) :: acc
4726
+ (s, [] , Ast_comb. to_undefined_type loc ty) :: acc
4808
4727
| _ -> assert false
4809
4728
end
4810
4729
| (_ , _ ), Ast_core_type. Empty -> acc
@@ -6068,23 +5987,35 @@ let rec unsafe_mapper : Ast_mapper.mapper =
6068
5987
({txt = " bs.node" ; loc},
6069
5988
payload)
6070
5989
->
5990
+ let strip s =
5991
+ let len = String. length s in
5992
+ if s.[len - 1 ] = '_' then
5993
+ String. sub s 0 (len - 1 )
5994
+ else s in
6071
5995
begin match Ast_payload. as_ident payload with
6072
- | Some {txt = Lident (" __filename" | " __dirname" as name); loc}
6073
- ->
6074
-
6075
- Exp. constraint_ ~loc
6076
- (Ast_util. handle_raw loc
6077
- (Ast_payload. raw_string_payload loc
6078
- name ))
6079
- (Ast_literal. type_string ~loc () )
6080
- | Some {txt = Lident " __module" }
5996
+ | Some {txt = Lident
5997
+ (" __filename"
5998
+ | " __dirname"
5999
+ | " module_"
6000
+ | " require" as name); loc}
6081
6001
->
6082
- Exp. constraint_ ~loc
6083
- (Ast_util. handle_raw loc
6084
- (Ast_payload. raw_string_payload loc " module" ))
6085
- (Typ. constr ~loc
6086
- { txt = Ldot (Lident " Bs_node" , " node_module" ) ;
6087
- loc} [] )
6002
+ let exp =
6003
+ Ast_util. handle_raw loc
6004
+ (Ast_payload. raw_string_payload loc
6005
+ (strip name) ) in
6006
+ let typ =
6007
+ Ast_comb. to_undefined_type loc @@
6008
+ if name = " module_" then
6009
+ Typ. constr ~loc
6010
+ { txt = Ldot (Lident " Bs_node" , " node_module" ) ;
6011
+ loc} []
6012
+ else if name = " require" then
6013
+ (Typ. constr ~loc
6014
+ { txt = Ldot (Lident " Bs_node" , " node_require" ) ;
6015
+ loc} [] )
6016
+ else
6017
+ Ast_literal. type_string ~loc () in
6018
+ Exp. constraint_ ~loc exp typ
6088
6019
| Some _ | None -> Location. raise_errorf ~loc " Ilegal payload"
6089
6020
end
6090
6021
@@ -6496,3 +6427,62 @@ let () =
6496
6427
(* end: *)
6497
6428
6498
6429
end
6430
+ module Ext_sys : sig
6431
+ #1 " ext_sys.mli"
6432
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
6433
+ *
6434
+ * This program is free software: you can redistribute it and/or modify
6435
+ * it under the terms of the GNU Lesser General Public License as published by
6436
+ * the Free Software Foundation, either version 3 of the License, or
6437
+ * (at your option) any later version.
6438
+ *
6439
+ * In addition to the permissions granted to you by the LGPL, you may combine
6440
+ * or link a "work that uses the Library" with a publicly distributed version
6441
+ * of this file to produce a combined library or application, then distribute
6442
+ * that combined work under the terms of your choosing, with no requirement
6443
+ * to comply with the obligations normally placed on you by section 4 of the
6444
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
6445
+ * should you choose to use a later version).
6446
+ *
6447
+ * This program is distributed in the hope that it will be useful,
6448
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
6449
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6450
+ * GNU Lesser General Public License for more details.
6451
+ *
6452
+ * You should have received a copy of the GNU Lesser General Public License
6453
+ * along with this program; if not, write to the Free Software
6454
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
6455
+
6456
+ val is_directory_no_exn : string -> bool
6457
+
6458
+ end = struct
6459
+ #1 " ext_sys.ml"
6460
+ (* Copyright (C) 2015-2016 Bloomberg Finance L.P.
6461
+ *
6462
+ * This program is free software: you can redistribute it and/or modify
6463
+ * it under the terms of the GNU Lesser General Public License as published by
6464
+ * the Free Software Foundation, either version 3 of the License, or
6465
+ * (at your option) any later version.
6466
+ *
6467
+ * In addition to the permissions granted to you by the LGPL, you may combine
6468
+ * or link a "work that uses the Library" with a publicly distributed version
6469
+ * of this file to produce a combined library or application, then distribute
6470
+ * that combined work under the terms of your choosing, with no requirement
6471
+ * to comply with the obligations normally placed on you by section 4 of the
6472
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
6473
+ * should you choose to use a later version).
6474
+ *
6475
+ * This program is distributed in the hope that it will be useful,
6476
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
6477
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6478
+ * GNU Lesser General Public License for more details.
6479
+ *
6480
+ * You should have received a copy of the GNU Lesser General Public License
6481
+ * along with this program; if not, write to the Free Software
6482
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
6483
+
6484
+
6485
+ let is_directory_no_exn f =
6486
+ try Sys. is_directory f with _ -> false
6487
+
6488
+ end
0 commit comments