@@ -74,70 +74,91 @@ let newBsPackage ~rootPath =
74
74
let projectFiles, dependenciesFiles, pathsForModule =
75
75
match cached with
76
76
| Some cached ->
77
- ( cached.projectFiles,
78
- cached.dependenciesFiles,
79
- cached.pathsForModule )
77
+ ( Lazy. from_val cached.projectFiles,
78
+ Lazy. from_val cached.dependenciesFiles,
79
+ Lazy. from_val cached.pathsForModule )
80
80
| None ->
81
81
let dependenciesFilesAndPaths =
82
- match FindFiles. findDependencyFiles rootPath config with
83
- | None -> []
84
- | Some (_dependencyDirectories , dependenciesFilesAndPaths ) ->
85
- dependenciesFilesAndPaths
82
+ Lazy. from_fun (fun () ->
83
+ match FindFiles. findDependencyFiles rootPath config with
84
+ | None -> []
85
+ | Some (_dependencyDirectories , dependenciesFilesAndPaths ) ->
86
+ dependenciesFilesAndPaths)
86
87
in
87
88
let sourceDirectories =
88
- FindFiles. getSourceDirectories ~include Dev:true ~base Dir:rootPath
89
- config
89
+ Lazy. from_fun (fun () ->
90
+ FindFiles. getSourceDirectories ~include Dev:true
91
+ ~base Dir:rootPath config)
90
92
in
91
93
let projectFilesAndPaths =
92
- FindFiles. findProjectFiles
93
- ~public: (FindFiles. getPublic config)
94
- ~namespace ~path: rootPath ~source Directories ~lib Bs
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)
95
100
in
96
101
let pathsForModule =
97
- makePathsForModule ~project FilesAndPaths
98
- ~dependencies FilesAndPaths
102
+ Lazy. from_fun (fun () ->
103
+ makePathsForModule
104
+ ~project FilesAndPaths:(Lazy. force projectFilesAndPaths)
105
+ ~dependencies FilesAndPaths:
106
+ (Lazy. force dependenciesFilesAndPaths))
99
107
in
100
108
let projectFiles =
101
- projectFilesAndPaths |> List. map fst |> FileSet. of_list
109
+ Lazy. from_fun (fun () ->
110
+ projectFilesAndPaths |> Lazy. force |> List. map fst
111
+ |> FileSet. of_list)
102
112
in
103
113
let dependenciesFiles =
104
- dependenciesFilesAndPaths |> List. map fst |> FileSet. of_list
114
+ Lazy. from_fun (fun () ->
115
+ dependenciesFilesAndPaths |> Lazy. force |> List. map fst
116
+ |> FileSet. of_list)
105
117
in
106
118
(projectFiles, dependenciesFiles, pathsForModule)
107
119
in
108
120
Some
109
121
(let opens_from_namespace =
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]
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])
117
133
in
118
134
let opens_from_bsc_flags =
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 -> []
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 -> [] )
135
152
in
136
153
let opens =
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" ])
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" ]))
141
162
in
142
163
{
143
164
genericJsxModule;
@@ -150,59 +171,60 @@ let newBsPackage ~rootPath =
150
171
opens;
151
172
namespace;
152
173
builtInCompletionModules =
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
- });
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
+ });
206
228
uncurried;
207
229
}))
208
230
| None -> None
0 commit comments