@@ -147,6 +147,12 @@ let getLibrariesForVersion = (~version: Semver.t): array<string> => {
147
147
libraries
148
148
}
149
149
150
+ let getOpenModules = (~apiVersion : Version .t , ~libraries : array <string >): option <array <string >> =>
151
+ switch apiVersion {
152
+ | V1 | V2 | V3 | UnknownVersion (_ ) => None
153
+ | V4 => libraries -> Belt .Array .some (el => el === "@rescript/core" ) ? Some (["RescriptCore" ]) : None
154
+ }
155
+
150
156
/*
151
157
This function loads the compiler, plus a defined set of libraries that are available
152
158
on our bs-platform-js-releases channel.
@@ -398,6 +404,7 @@ let useCompilerManager = (
398
404
| Ok () =>
399
405
let instance = Compiler .make ()
400
406
let apiVersion = apiVersion -> Version .fromString
407
+ let open_modules = getOpenModules (~apiVersion , ~libraries )
401
408
402
409
// Note: The compiler bundle currently defaults to
403
410
// commonjs when initiating the compiler, but our playground
@@ -407,6 +414,7 @@ let useCompilerManager = (
407
414
let config = {
408
415
... instance -> Compiler .getConfig ,
409
416
module_system : "es6" ,
417
+ ?open_modules ,
410
418
}
411
419
instance -> Compiler .setConfig (config )
412
420
@@ -455,11 +463,7 @@ let useCompilerManager = (
455
463
456
464
let instance = Compiler .make ()
457
465
let apiVersion = apiVersion -> Version .fromString
458
-
459
- let open_modules =
460
- libraries -> Belt .Array .some (el => el === "@rescript/core" )
461
- ? Some (["RescriptCore" ])
462
- : None
466
+ let open_modules = getOpenModules (~apiVersion , ~libraries )
463
467
464
468
let config = {... instance -> Compiler .getConfig , ?open_modules }
465
469
instance -> Compiler .setConfig (config )
0 commit comments