Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch output to ES modules #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Switch output to ES modules #33

wants to merge 1 commit into from

Conversation

kasbah
Copy link

@kasbah kasbah commented Aug 9, 2023

fixes #32

@ide
Copy link
Owner

ide commented Aug 9, 2023

Does this allow the package to be used from a CommonJS project (that is, with require() under the hood)? That is a requirement for now.

@kasbah
Copy link
Author

kasbah commented Aug 10, 2023

I believe only if you use dynamic import. I read your answer on #5 as you dropping support for Commonjs but I guess it's still supported but only with a .default?

const AwaitLock = require('await-lock').default

@ide
Copy link
Owner

ide commented Aug 10, 2023

The main use case I care about for this package right now is that it works in a CommonJS environment running JS that has been compiled from TS (or another compiler like esbuild) with esModuleInterop enabled. So, require() needs to work without dynamic import().

@kasbah
Copy link
Author

kasbah commented Aug 10, 2023

Fair enough, I just can't figure out how to actually use it from TS. If I set target to ES5 it complains about the #private identifiers (more details). Do you just ignore those compilation errors?

Thanks for this lib and all your responses by the way!

@ide
Copy link
Owner

ide commented Aug 10, 2023

I use a preset like @tsconfig/node18/tsconfig.json in the project's tsconfig.json, including the preset's settings for module resolution.

@kasbah
Copy link
Author

kasbah commented Aug 10, 2023

That also doesn't work for me unfortunately but I won't drag you further into the module resolution tarpit. I'll likely just vendor your lib or create a fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AwaitLock is not a constructor when importing in Typescript
2 participants