Edoardo Luppi
06/10/2025, 3:08 PMrequire
inline fun <T : Any> jsRequire(name: String): T =
js("require(name)")
The JS output is something like:
var name = 'something'
return require(name)
The problem here is tools like esbuild do not analyze what name
is, and thus don't correctly bundle the required dependency.
Is there a way to workaround this, that is not unwrapping the require
call?ian.shaun.thomas
06/10/2025, 3:24 PMexternal fun require(module: String): dynamic
Edoardo Luppi
06/10/2025, 3:37 PMexternal
directly.
That's because when switching to ESM, or whenever I need to workaround an inclusion issue, I can simply change a single point in my codebase.