Skip to content

Commit 80c0515

Browse files
authored
Merge pull request rescript-lang#2401 from jasonrose/patch-2
Stop tab-aligning imports and exports
2 parents acde34a + cccdfae commit 80c0515

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

jscomp/core/js_dump_import_export.ml

+19-21
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,24 @@ let esModule = "__esModule", "true"
2929
(** Exports printer *)
3030
(** Print exports in Google module format, CommonJS format *)
3131
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) ->
3434
let id_name = id.name in
3535
let s = Ext_ident.convert id_name in
3636
let str,cxt = Ext_pp_scope.str_of_ident cxt id in
3737
cxt, (
3838
if id_name = default_export then
3939
(* TODO check how it will affect AMDJS*)
4040
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
4343
P.newline f ;
4444
Ext_list.rev_iter (fun (s,export) ->
4545
P.group f 0 @@ (fun _ ->
4646
P.string f L.exports;
4747
P.string f L.dot;
4848
P.string f s;
49-
P.nspace f (margin - String.length s + 1) ;
49+
P.space f ;
5050
P.string f L.eq;
5151
P.space f;
5252
P.string f export;
@@ -58,25 +58,25 @@ let exports cxt f (idents : Ident.t list) =
5858

5959
(** Print module in ES6 format, it is ES6, trailing comma is valid ES6 code *)
6060
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) ->
6363
let id_name = id.name in
6464
let s = Ext_ident.convert id_name in
6565
let str,cxt = Ext_pp_scope.str_of_ident cxt id in
6666
cxt, (
6767
if id_name = default_export then
6868
(default_export,str)::(s,str)::acc
6969
else
70-
(s,str) :: acc ) , max len (String.length s) )
71-
(cxt, [], 0) idents in
70+
(s,str) :: acc ))
71+
(cxt, []) idents in
7272
P.newline f ;
7373
P.string f L.export ;
7474
P.space f ;
7575
P.brace_vgroup f 1 begin fun _ ->
7676
Ext_list.rev_iter (fun (s,export) ->
7777
P.group f 0 @@ (fun _ ->
7878
P.string f export;
79-
P.nspace f (margin - String.length s + 1) ;
79+
P.space f ;
8080
if not @@ Ext_string.equal export s then begin
8181
P.string f L.as_ ;
8282
P.space f;
@@ -93,19 +93,19 @@ let es6_export cxt f (idents : Ident.t list) =
9393
let requires require_lit cxt f (modules : (Ident.t * string) list ) =
9494
P.newline f ;
9595
(* the context used to print the following program *)
96-
let outer_cxt, reversed_list, margin =
96+
let outer_cxt, reversed_list =
9797
List.fold_left
9898
(fun (cxt, acc, len) (id,s) ->
9999
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))
101101
)
102-
(cxt, [], 0) modules in
102+
(cxt, []) modules in
103103
P.force_newline f ;
104104
Ext_list.rev_iter (fun (s,file) ->
105105
P.string f L.var;
106106
P.space f ;
107107
P.string f s ;
108-
P.nspace f (margin - String.length s + 1) ;
108+
P.space f ;
109109
P.string f L.eq;
110110
P.space f;
111111
P.string f require_lit;
@@ -120,30 +120,28 @@ let requires require_lit cxt f (modules : (Ident.t * string) list ) =
120120
let imports cxt f (modules : (Ident.t * string) list ) =
121121
P.newline f ;
122122
(* the context used to print the following program *)
123-
let outer_cxt, reversed_list, margin =
123+
let outer_cxt, reversed_list =
124124
List.fold_left
125125
(fun (cxt, acc, len) (id,s) ->
126126
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))
128128
)
129-
(cxt, [], 0) modules in
129+
(cxt, []) modules in
130130
P.force_newline f ;
131131
Ext_list.rev_iter (fun (s,file) ->
132132

133133
P.string f L.import;
134134
P.space f ;
135135
P.string f L.star ;
136-
P.space f ; (* import * as xx \t from 'xx*)
136+
P.space f ; (* import * as xx from 'xx*)
137137
P.string f L.as_ ;
138138
P.space f ;
139139
P.string f s ;
140-
P.nspace f (margin - String.length s + 1) ;
140+
P.space f ;
141141
P.string f L.from;
142142
P.space f;
143143
Js_dump_string.pp_string f file ;
144144
P.string f L.semi ;
145145
P.newline f ;
146146
) reversed_list;
147147
outer_cxt
148-
149-

0 commit comments

Comments
 (0)