Open IlyaSemenov opened 4 months ago
It's ugly, but I've worked around this in my own code with this wrapper:
import advisoryLock from 'advisory-lock'
type AdvisoryLock = typeof advisoryLock
let _advisoryLock = advisoryLock as any
// See https://github.com/olalonde/advisory-lock/issues/1 for why we need this
if (_advisoryLock.default) {
_advisoryLock = _advisoryLock.default
}
export default _advisoryLock as AdvisoryLock
With Typescript or native ESM, the module doesn't import correctly:
Run it with
tsx
(same will happen withvite
and probably most other bundlers):or just run as an ESM script in a project with
{ "type": "module" }
inpackage.json
:This is because the imported module, despite being typed as a function, is in fact an object:
I see you're using old plain
tsc
for compile. I suggest to rework the project build setup to use tsup and emit modern CJS and ESM builds (and updatepackage.json
accordingly). I can come up with a PR if that's something that you will possibly accept.