quickjs-kt icon indicating copy to clipboard operation
quickjs-kt copied to clipboard

Request a new feature: esModule linker

Open Gaubee opened this issue 9 months ago • 0 comments

Is it possible to implement support for dynamic module resolution?
Reference: nodejs/vm/module.link(linker)

quickJs {
    // ...
    evaluate<String>(
        """
            import * as hello from "hello";
            // Use hello
        """.trimIndent(),
        asModule = true,
        linker = { specifier, referencingModule, extra ->
            val code = fs.open('/path/local/' + specifier).text() // suspend read file func
            val moduleBytecode = compile(
                code = code,
                filename = specifier,
                asModule = true,
            )
            return moduleBytecode
        }
    )
}

Gaubee avatar Mar 13 '25 09:03 Gaubee