@@ -36,9 +36,9 @@ module LoadScript = {
36
36
}
37
37
38
38
module CdnMeta = {
39
- // Splits and sanitizes the content of the VERSIONS file
40
- let parseVersions = ( versions : string ) =>
41
- Js . String2 . split ( versions , "\n " ) -> Js . Array2 . filter ( v => v !== "" )
39
+ // Make sure versions exist on https://cdn.rescript-lang.org
40
+ // [0] = latest
41
+ let versions = [ "v8.4.2" , "v8.3.0-dev.2" ]
42
42
43
43
let getCompilerUrl = (version : string ): string =>
44
44
j ` https://cdn.rescript-lang.org/$version/compiler.js`
@@ -291,67 +291,48 @@ let useCompilerManager = (~initialLang: Lang.t=Res, ~onAction: option<action =>
291
291
| Init =>
292
292
let libraries = ["reason-react" ]
293
293
294
- let completed = res => {
295
- open SimpleRequest
296
- switch res {
297
- | Ok ({text }) =>
298
- switch CdnMeta .parseVersions (text ) {
299
- | [] => dispatchError (SetupError (j ` No compiler versions found` ))
300
- | versions =>
301
- // Fetching the initial compiler is different, since we
302
- // don't have any running version downloaded yet
294
+ switch CdnMeta .versions {
295
+ | [] => dispatchError (SetupError (j ` No compiler versions found` ))
296
+ | versions =>
297
+ let latest = versions [0 ]
303
298
304
- let latest = versions [0 ]
305
-
306
- attachCompilerAndLibraries (~version = latest , ~libraries , ())-> Promise .get (result =>
307
- switch result {
308
- | Ok () =>
309
- let instance = Compiler .make ()
310
- let apiVersion = apiVersion -> Version .fromString
311
- let config = instance -> Compiler .getConfig
312
-
313
- let selected = {
314
- id : latest ,
315
- apiVersion : apiVersion ,
316
- compilerVersion : instance -> Compiler .version ,
317
- ocamlVersion : instance -> Compiler .ocamlVersion ,
318
- reasonVersion : instance -> Compiler .reasonVersion ,
319
- config : config ,
320
- libraries : libraries ,
321
- instance : instance ,
322
- }
299
+ attachCompilerAndLibraries (~version = latest , ~libraries , ())-> Promise .get (result =>
300
+ switch result {
301
+ | Ok () =>
302
+ let instance = Compiler .make ()
303
+ let apiVersion = apiVersion -> Version .fromString
304
+ let config = instance -> Compiler .getConfig
305
+
306
+ let selected = {
307
+ id : latest ,
308
+ apiVersion : apiVersion ,
309
+ compilerVersion : instance -> Compiler .version ,
310
+ ocamlVersion : instance -> Compiler .ocamlVersion ,
311
+ reasonVersion : instance -> Compiler .reasonVersion ,
312
+ config : config ,
313
+ libraries : libraries ,
314
+ instance : instance ,
315
+ }
323
316
324
- let targetLang =
325
- Version .availableLanguages (apiVersion )
326
- -> Js .Array2 .find (l => l === initialLang )
327
- -> Belt .Option .getWithDefault (Version .defaultTargetLang (apiVersion ))
328
-
329
- setState (_ => Ready ({
330
- selected : selected ,
331
- targetLang : targetLang ,
332
- versions : versions ,
333
- errors : [],
334
- result : FinalResult .Nothing ,
335
- }))
336
- | Error (errs ) =>
337
- let msg = Js .Array2 .joinWith (errs , "; " )
338
-
339
- dispatchError (CompilerLoadingError (msg ))
340
- }
341
- )
317
+ let targetLang =
318
+ Version .availableLanguages (apiVersion )
319
+ -> Js .Array2 .find (l => l === initialLang )
320
+ -> Belt .Option .getWithDefault (Version .defaultTargetLang (apiVersion ))
321
+
322
+ setState (_ => Ready ({
323
+ selected : selected ,
324
+ targetLang : targetLang ,
325
+ versions : versions ,
326
+ errors : [],
327
+ result : FinalResult .Nothing ,
328
+ }))
329
+ | Error (errs ) =>
330
+ let msg = Js .Array2 .joinWith (errs , "; " )
331
+
332
+ dispatchError (CompilerLoadingError (msg ))
342
333
}
343
- | Error ({text , status }) =>
344
- dispatchError (SetupError (j ` Error occurred: $text (status-code: $status)` ))
345
- }
346
- ()
334
+ )
347
335
}
348
-
349
- open SimpleRequest
350
- make (
351
- ~contentType = Plain ,
352
- ~completed ,
353
- "https://cdn.rescript-lang.org/VERSIONS" ,
354
- )-> send
355
336
| SwitchingCompiler (ready , version , libraries ) =>
356
337
attachCompilerAndLibraries (~version , ~libraries , ())-> Promise .get (result =>
357
338
switch result {
0 commit comments