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