diff --git a/packages/graalvm/src/main/kotlin/elide/runtime/plugins/js/JavaScriptConfig.kt b/packages/graalvm/src/main/kotlin/elide/runtime/plugins/js/JavaScriptConfig.kt index 7458c4536c..809b27fd0d 100644 --- a/packages/graalvm/src/main/kotlin/elide/runtime/plugins/js/JavaScriptConfig.kt +++ b/packages/graalvm/src/main/kotlin/elide/runtime/plugins/js/JavaScriptConfig.kt @@ -41,7 +41,12 @@ import elide.runtime.plugins.js.JavaScriptVersion.ES2022 public inner class BuiltInModulesConfig { /** Core module replacement map. */ - private val moduleReplacements = mutableMapOf() + private val moduleReplacements: MutableMap = mutableMapOf( + "buffer" to "/__runtime__/buffer/buffer.cjs", + "util" to "/__runtime__/util/util.cjs", + "fs" to "/__runtime__/fs/fs.cjs", + "express" to "/__runtime__/express/express.cjs", + ) internal fun replacements(): Map { return moduleReplacements diff --git a/packages/graalvm/src/test/kotlin/elide/runtime/plugins/js/JsCoreModulesTest.kt b/packages/graalvm/src/test/kotlin/elide/runtime/plugins/js/JsCoreModulesTest.kt new file mode 100644 index 0000000000..93979df42d --- /dev/null +++ b/packages/graalvm/src/test/kotlin/elide/runtime/plugins/js/JsCoreModulesTest.kt @@ -0,0 +1,20 @@ +package elide.runtime.plugins.js + +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.ValueSource +import elide.runtime.core.DelicateElideApi +import elide.runtime.core.PolyglotEngine + +@OptIn(DelicateElideApi::class) +internal class JsCoreModulesTest { + @ParameterizedTest + @ValueSource(strings = ["buffer", "util", "fs", "express"]) + fun testCoreModulePresent(module: String) { + val context = PolyglotEngine { install(JavaScript) }.acquire() + + assertDoesNotThrow("core module replacement for '$module' should be present") { + context.javascript("""require("$module");""") + } + } +} \ No newline at end of file