@@ -147,6 +147,12 @@ let getLibrariesForVersion = (~version: Semver.t): array<string> => {
147147 libraries
148148}
149149
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+
150156/*
151157 This function loads the compiler, plus a defined set of libraries that are available
152158 on our bs-platform-js-releases channel.
@@ -398,6 +404,7 @@ let useCompilerManager = (
398404 | Ok () =>
399405 let instance = Compiler .make ()
400406 let apiVersion = apiVersion -> Version .fromString
407+ let open_modules = getOpenModules (~apiVersion , ~libraries )
401408
402409 // Note: The compiler bundle currently defaults to
403410 // commonjs when initiating the compiler, but our playground
@@ -407,6 +414,7 @@ let useCompilerManager = (
407414 let config = {
408415 ... instance -> Compiler .getConfig ,
409416 module_system : "es6" ,
417+ ?open_modules ,
410418 }
411419 instance -> Compiler .setConfig (config )
412420
@@ -455,11 +463,7 @@ let useCompilerManager = (
455463
456464 let instance = Compiler .make ()
457465 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 )
463467
464468 let config = {... instance -> Compiler .getConfig , ?open_modules }
465469 instance -> Compiler .setConfig (config )
0 commit comments