Skip to content

Commit

Permalink
fix(graalvm): include core module replacements by default in js plugin.
Browse files Browse the repository at this point in the history
Signed-off-by: Dario Valdespino <[email protected]>
  • Loading branch information
darvld authored and sgammon committed Dec 4, 2023
1 parent 23742d7 commit 39660a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ import elide.runtime.plugins.js.JavaScriptVersion.ES2022

public inner class BuiltInModulesConfig {
/** Core module replacement map. */
private val moduleReplacements = mutableMapOf<String, String>()
private val moduleReplacements: MutableMap<String, String> = 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<String, String> {
return moduleReplacements
Expand Down
Original file line number Diff line number Diff line change
@@ -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");""")
}
}
}

0 comments on commit 39660a6

Please sign in to comment.