@@ -29,24 +29,24 @@ let esModule = "__esModule", "true"
29
29
(* * Exports printer *)
30
30
(* * Print exports in Google module format, CommonJS format *)
31
31
let exports cxt f (idents : Ident.t list ) =
32
- let outer_cxt, reversed_list, margin =
33
- List. fold_left (fun (cxt , acc , len ) (id : Ident.t ) ->
32
+ let outer_cxt, reversed_list =
33
+ List. fold_left (fun (cxt , acc ) (id : Ident.t ) ->
34
34
let id_name = id.name in
35
35
let s = Ext_ident. convert id_name in
36
36
let str,cxt = Ext_pp_scope. str_of_ident cxt id in
37
37
cxt, (
38
38
if id_name = default_export then
39
39
(* TODO check how it will affect AMDJS*)
40
40
esModule :: (default_export, str) :: (s,str)::acc
41
- else (s,str) :: acc ) , max len ( String. length s) )
42
- (cxt, [] , 0 ) idents in
41
+ else (s,str) :: acc ))
42
+ (cxt, [] ) idents in
43
43
P. newline f ;
44
44
Ext_list. rev_iter (fun (s ,export ) ->
45
45
P. group f 0 @@ (fun _ ->
46
46
P. string f L. exports;
47
47
P. string f L. dot;
48
48
P. string f s;
49
- P. nspace f (margin - String. length s + 1 ) ;
49
+ P. space f ;
50
50
P. string f L. eq;
51
51
P. space f;
52
52
P. string f export;
@@ -58,25 +58,25 @@ let exports cxt f (idents : Ident.t list) =
58
58
59
59
(* * Print module in ES6 format, it is ES6, trailing comma is valid ES6 code *)
60
60
let es6_export cxt f (idents : Ident.t list ) =
61
- let outer_cxt, reversed_list, margin =
62
- List. fold_left (fun (cxt , acc , len ) (id : Ident.t ) ->
61
+ let outer_cxt, reversed_list =
62
+ List. fold_left (fun (cxt , acc ) (id : Ident.t ) ->
63
63
let id_name = id.name in
64
64
let s = Ext_ident. convert id_name in
65
65
let str,cxt = Ext_pp_scope. str_of_ident cxt id in
66
66
cxt, (
67
67
if id_name = default_export then
68
68
(default_export,str)::(s,str)::acc
69
69
else
70
- (s,str) :: acc ) , max len ( String. length s) )
71
- (cxt, [] , 0 ) idents in
70
+ (s,str) :: acc ))
71
+ (cxt, [] ) idents in
72
72
P. newline f ;
73
73
P. string f L. export ;
74
74
P. space f ;
75
75
P. brace_vgroup f 1 begin fun _ ->
76
76
Ext_list. rev_iter (fun (s ,export ) ->
77
77
P. group f 0 @@ (fun _ ->
78
78
P. string f export;
79
- P. nspace f (margin - String. length s + 1 ) ;
79
+ P. space f ;
80
80
if not @@ Ext_string. equal export s then begin
81
81
P. string f L. as_ ;
82
82
P. space f;
@@ -93,19 +93,19 @@ let es6_export cxt f (idents : Ident.t list) =
93
93
let requires require_lit cxt f (modules : (Ident.t * string) list ) =
94
94
P. newline f ;
95
95
(* the context used to print the following program *)
96
- let outer_cxt, reversed_list, margin =
96
+ let outer_cxt, reversed_list =
97
97
List. fold_left
98
98
(fun (cxt , acc , len ) (id ,s ) ->
99
99
let str, cxt = Ext_pp_scope. str_of_ident cxt id in
100
- cxt, ((str,s) :: acc), (max len ( String. length str) )
100
+ cxt, ((str,s) :: acc))
101
101
)
102
- (cxt, [] , 0 ) modules in
102
+ (cxt, [] ) modules in
103
103
P. force_newline f ;
104
104
Ext_list. rev_iter (fun (s ,file ) ->
105
105
P. string f L. var;
106
106
P. space f ;
107
107
P. string f s ;
108
- P. nspace f (margin - String. length s + 1 ) ;
108
+ P. space f ;
109
109
P. string f L. eq;
110
110
P. space f;
111
111
P. string f require_lit;
@@ -120,30 +120,28 @@ let requires require_lit cxt f (modules : (Ident.t * string) list ) =
120
120
let imports cxt f (modules : (Ident.t * string) list ) =
121
121
P. newline f ;
122
122
(* the context used to print the following program *)
123
- let outer_cxt, reversed_list, margin =
123
+ let outer_cxt, reversed_list =
124
124
List. fold_left
125
125
(fun (cxt , acc , len ) (id ,s ) ->
126
126
let str, cxt = Ext_pp_scope. str_of_ident cxt id in
127
- cxt, ((str,s) :: acc), (max len ( String. length str) )
127
+ cxt, ((str,s) :: acc))
128
128
)
129
- (cxt, [] , 0 ) modules in
129
+ (cxt, [] ) modules in
130
130
P. force_newline f ;
131
131
Ext_list. rev_iter (fun (s ,file ) ->
132
132
133
133
P. string f L. import;
134
134
P. space f ;
135
135
P. string f L. star ;
136
- P. space f ; (* import * as xx \t from 'xx*)
136
+ P. space f ; (* import * as xx from 'xx*)
137
137
P. string f L. as_ ;
138
138
P. space f ;
139
139
P. string f s ;
140
- P. nspace f (margin - String. length s + 1 ) ;
140
+ P. space f ;
141
141
P. string f L. from;
142
142
P. space f;
143
143
Js_dump_string. pp_string f file ;
144
144
P. string f L. semi ;
145
145
P. newline f ;
146
146
) reversed_list;
147
147
outer_cxt
148
-
149
-
0 commit comments