Given the following wrapper function over `require...
# javascript
e
Given the following wrapper function over
require
Copy code
inline fun <T : Any> jsRequire(name: String): T =
  js("require(name)")
The JS output is something like:
Copy code
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?
i
Not sure if I understand what you're trying to do. In our project we just do this and it has been working fine for us
Copy code
external fun require(module: String): dynamic
e
@ian.shaun.thomas hey! The thing is I'd prefer to pass by a wrapper function instead of using the
external
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.
👍 1