@@ -74,91 +74,70 @@ let newBsPackage ~rootPath =
74
74
let projectFiles, dependenciesFiles, pathsForModule =
75
75
match cached with
76
76
| Some cached ->
77
- ( Lazy. from_val cached.projectFiles,
78
- Lazy. from_val cached.dependenciesFiles,
79
- Lazy. from_val cached.pathsForModule )
77
+ ( cached.projectFiles,
78
+ cached.dependenciesFiles,
79
+ cached.pathsForModule )
80
80
| None ->
81
81
let dependenciesFilesAndPaths =
82
- Lazy. from_fun (fun () ->
83
- match FindFiles. findDependencyFiles rootPath config with
84
- | None -> []
85
- | Some (_dependencyDirectories , dependenciesFilesAndPaths ) ->
86
- dependenciesFilesAndPaths)
82
+ match FindFiles. findDependencyFiles rootPath config with
83
+ | None -> []
84
+ | Some (_dependencyDirectories , dependenciesFilesAndPaths ) ->
85
+ dependenciesFilesAndPaths
87
86
in
88
87
let sourceDirectories =
89
- Lazy. from_fun (fun () ->
90
- FindFiles. getSourceDirectories ~include Dev:true
91
- ~base Dir:rootPath config)
88
+ FindFiles. getSourceDirectories ~include Dev:true ~base Dir:rootPath
89
+ config
92
90
in
93
91
let projectFilesAndPaths =
94
- Lazy. from_fun (fun () ->
95
- FindFiles. findProjectFiles
96
- ~public: (FindFiles. getPublic config)
97
- ~namespace ~path: rootPath
98
- ~source Directories:(Lazy. force sourceDirectories)
99
- ~lib Bs)
92
+ FindFiles. findProjectFiles
93
+ ~public: (FindFiles. getPublic config)
94
+ ~namespace ~path: rootPath ~source Directories ~lib Bs
100
95
in
101
96
let pathsForModule =
102
- Lazy. from_fun (fun () ->
103
- makePathsForModule
104
- ~project FilesAndPaths:(Lazy. force projectFilesAndPaths)
105
- ~dependencies FilesAndPaths:
106
- (Lazy. force dependenciesFilesAndPaths))
97
+ makePathsForModule ~project FilesAndPaths
98
+ ~dependencies FilesAndPaths
107
99
in
108
100
let projectFiles =
109
- Lazy. from_fun (fun () ->
110
- projectFilesAndPaths |> Lazy. force |> List. map fst
111
- |> FileSet. of_list)
101
+ projectFilesAndPaths |> List. map fst |> FileSet. of_list
112
102
in
113
103
let dependenciesFiles =
114
- Lazy. from_fun (fun () ->
115
- dependenciesFilesAndPaths |> Lazy. force |> List. map fst
116
- |> FileSet. of_list)
104
+ dependenciesFilesAndPaths |> List. map fst |> FileSet. of_list
117
105
in
118
106
(projectFiles, dependenciesFiles, pathsForModule)
119
107
in
120
108
Some
121
109
(let opens_from_namespace =
122
- Lazy. from_fun (fun () ->
123
- match namespace with
124
- | None -> []
125
- | Some namespace ->
126
- let cmt = Filename. concat libBs namespace ^ " .cmt" in
127
- Hashtbl. add
128
- (Lazy. force pathsForModule)
129
- namespace
130
- (Namespace {cmt});
131
- let path = [FindFiles. nameSpaceToName namespace] in
132
- [path])
110
+ match namespace with
111
+ | None -> []
112
+ | Some namespace ->
113
+ let cmt = Filename. concat libBs namespace ^ " .cmt" in
114
+ Hashtbl. add pathsForModule namespace (Namespace {cmt});
115
+ let path = [FindFiles. nameSpaceToName namespace] in
116
+ [path]
133
117
in
134
118
let opens_from_bsc_flags =
135
- Lazy. from_fun (fun () ->
136
- let bind f x = Option. bind x f in
137
- match Json. get " bsc-flags" config |> bind Json. array with
138
- | Some l ->
139
- List. fold_left
140
- (fun opens item ->
141
- match item |> Json. string with
142
- | None -> opens
143
- | Some s -> (
144
- let parts = String. split_on_char ' ' s in
145
- match parts with
146
- | "-open" :: name :: _ ->
147
- let path = name |> String. split_on_char '.' in
148
- path :: opens
149
- | _ -> opens))
150
- [] l
151
- | None -> [] )
119
+ let bind f x = Option. bind x f in
120
+ match Json. get " bsc-flags" config |> bind Json. array with
121
+ | Some l ->
122
+ List. fold_left
123
+ (fun opens item ->
124
+ match item |> Json. string with
125
+ | None -> opens
126
+ | Some s -> (
127
+ let parts = String. split_on_char ' ' s in
128
+ match parts with
129
+ | "-open" :: name :: _ ->
130
+ let path = name |> String. split_on_char '.' in
131
+ path :: opens
132
+ | _ -> opens))
133
+ [] l
134
+ | None -> []
152
135
in
153
136
let opens =
154
- Lazy. from_fun (fun () ->
155
- [
156
- (if uncurried then " PervasivesU" else " Pervasives" );
157
- " JsxModules" ;
158
- ]
159
- :: Lazy. force opens_from_namespace
160
- |> List. rev_append (Lazy. force opens_from_bsc_flags)
161
- |> List. map (fun path -> path @ [" place holder" ]))
137
+ [(if uncurried then " PervasivesU" else " Pervasives" ); " JsxModules" ]
138
+ :: opens_from_namespace
139
+ |> List. rev_append opens_from_bsc_flags
140
+ |> List. map (fun path -> path @ [" place holder" ])
162
141
in
163
142
{
164
143
genericJsxModule;
@@ -171,60 +150,59 @@ let newBsPackage ~rootPath =
171
150
opens;
172
151
namespace;
173
152
builtInCompletionModules =
174
- Lazy. from_fun (fun () ->
175
- if
176
- opens_from_bsc_flags |> Lazy. force
177
- |> List. find_opt (fun opn ->
178
- match opn with
179
- | [" RescriptCore" ] -> true
180
- | _ -> false )
181
- |> Option. is_some
182
- then
183
- {
184
- arrayModulePath = [" Array" ];
185
- optionModulePath = [" Option" ];
186
- stringModulePath = [" String" ];
187
- intModulePath = [" Int" ];
188
- floatModulePath = [" Float" ];
189
- promiseModulePath = [" Promise" ];
190
- listModulePath = [" List" ];
191
- resultModulePath = [" Result" ];
192
- exnModulePath = [" Exn" ];
193
- regexpModulePath = [" RegExp" ];
194
- }
195
- else if
196
- opens_from_bsc_flags |> Lazy. force
197
- |> List. find_opt (fun opn ->
198
- match opn with
199
- | [" Belt" ] -> true
200
- | _ -> false )
201
- |> Option. is_some
202
- then
203
- {
204
- arrayModulePath = [" Array" ];
205
- optionModulePath = [" Option" ];
206
- stringModulePath = [" Js" ; " String2" ];
207
- intModulePath = [" Int" ];
208
- floatModulePath = [" Float" ];
209
- promiseModulePath = [" Js" ; " Promise" ];
210
- listModulePath = [" List" ];
211
- resultModulePath = [" Result" ];
212
- exnModulePath = [" Js" ; " Exn" ];
213
- regexpModulePath = [" Js" ; " Re" ];
214
- }
215
- else
216
- {
217
- arrayModulePath = [" Js" ; " Array2" ];
218
- optionModulePath = [" Belt" ; " Option" ];
219
- stringModulePath = [" Js" ; " String2" ];
220
- intModulePath = [" Belt" ; " Int" ];
221
- floatModulePath = [" Belt" ; " Float" ];
222
- promiseModulePath = [" Js" ; " Promise" ];
223
- listModulePath = [" Belt" ; " List" ];
224
- resultModulePath = [" Belt" ; " Result" ];
225
- exnModulePath = [" Js" ; " Exn" ];
226
- regexpModulePath = [" Js" ; " Re" ];
227
- });
153
+ (if
154
+ opens_from_bsc_flags
155
+ |> List. find_opt (fun opn ->
156
+ match opn with
157
+ | [" RescriptCore" ] -> true
158
+ | _ -> false )
159
+ |> Option. is_some
160
+ then
161
+ {
162
+ arrayModulePath = [" Array" ];
163
+ optionModulePath = [" Option" ];
164
+ stringModulePath = [" String" ];
165
+ intModulePath = [" Int" ];
166
+ floatModulePath = [" Float" ];
167
+ promiseModulePath = [" Promise" ];
168
+ listModulePath = [" List" ];
169
+ resultModulePath = [" Result" ];
170
+ exnModulePath = [" Exn" ];
171
+ regexpModulePath = [" RegExp" ];
172
+ }
173
+ else if
174
+ opens_from_bsc_flags
175
+ |> List. find_opt (fun opn ->
176
+ match opn with
177
+ | [" Belt" ] -> true
178
+ | _ -> false )
179
+ |> Option. is_some
180
+ then
181
+ {
182
+ arrayModulePath = [" Array" ];
183
+ optionModulePath = [" Option" ];
184
+ stringModulePath = [" Js" ; " String2" ];
185
+ intModulePath = [" Int" ];
186
+ floatModulePath = [" Float" ];
187
+ promiseModulePath = [" Js" ; " Promise" ];
188
+ listModulePath = [" List" ];
189
+ resultModulePath = [" Result" ];
190
+ exnModulePath = [" Js" ; " Exn" ];
191
+ regexpModulePath = [" Js" ; " Re" ];
192
+ }
193
+ else
194
+ {
195
+ arrayModulePath = [" Js" ; " Array2" ];
196
+ optionModulePath = [" Belt" ; " Option" ];
197
+ stringModulePath = [" Js" ; " String2" ];
198
+ intModulePath = [" Belt" ; " Int" ];
199
+ floatModulePath = [" Belt" ; " Float" ];
200
+ promiseModulePath = [" Js" ; " Promise" ];
201
+ listModulePath = [" Belt" ; " List" ];
202
+ resultModulePath = [" Belt" ; " Result" ];
203
+ exnModulePath = [" Js" ; " Exn" ];
204
+ regexpModulePath = [" Js" ; " Re" ];
205
+ });
228
206
uncurried;
229
207
}))
230
208
| None -> None
0 commit comments