-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Typescript-compatible exports #44
Comments
Using Rather, this should be considered a TypeScript issue. |
Damn I thought that might be the case. I did some digging before opening this issue and it looks like Typescript are being annoyingly earnest about not accepting 'custom' extensions (microsoft/TypeScript#10939) It looks like the only way to include this in a typescript project is to vendor es-module-lexer into the project itself.. |
This is a bit different to that issue actually, and more just that TypeScript should support a |
Interesting! I'll keep a vendored version of es-module-lexer for now and wait and see what progress gets made on the Typescript side. |
You probably shouldn't be loading your dependencies JS directly; while there are compiler options to make it work (sometimes), it is slow. If possible, it's usually better to include a declaration file defining the module. Since there's no
While there are some non-default options to make it so you can use js mains for packages without types, we don't really reccomend loading dependencies as JS (it involves way, way more work), and yes, the resolver we use doesn't support the new stuff introduced to handle/alongside native esm yet. We're trying to wait long enough to handle all the new stuff behind one flag, which means waiting for it to stabilize (and even then, there's a lot of resistance to new handling new extensions because of what it implies for declarations; having side-by-side |
@weswigham very interesting, thanks for the info here. |
Thanks so much for the help @weswigham , I really appreciate the detailed response. I've ended up creating a mostly fleshed-out declaration file and including that in my local build for now but I'll aim to create a Thanks again for filling in the gaps in my Typescript knowledge! |
I'm trying to import
es-module-lexer
into a Typescript project but i'm getting the error 'cannot find module es-module-lexer'. I'm fairly certain this becase the package.jsonmain
entry points todist/lexer.cjs
which typescript can't resolve due to the.cjs
extension. I'm not massively experienced with Typescript so this could well be a problem with my understanding. However, I think it might be best to produce a dist output like:It would also be great to provide type definitions for the package but I think this is probably a whole other PR!
The text was updated successfully, but these errors were encountered: