how do you import a NPM package which exports a fu...
# javascript
e
how do you import a NPM package which exports a function, not a module? e.g. the JS looks like
Copy code
module.exports = function...
✔️ 1
a
Looks like a culprit for require to me. Use the require function, instead of import, coz imports works for modules only
t
Copy code
// this
@JsModule("my-super-lib")
external fun mySuperFun()

// or this
@file:JsModule("my-super-lib")

@JsName("default")
external fun mySuperFun()
🙏 1
👆 1
e
the second one doesn't work,
Copy code
@file:JsModule("detect-mocha")
@file:JsNonModule

external fun detectMocha(): Boolean
results in
Copy code
TypeError: detectMocha_0 is not a function
but the first one seems to work
🙂 1