-
Notifications
You must be signed in to change notification settings - Fork 67
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
Node importing broken #294
Comments
@bdougherty I updated the package.json in this way the last time |
@bdougherty Did the suggestion from @matheo help you? He is the npm expert here, so please let us know if you there is still a problem we can help you with. |
Sorry, I haven't had a chance to try anything out yet. I'll let you know what I find out when I'm able to get back to it. |
I'm building a project with
Everything works as expected, my project builds perfectly, the library works on the browser and all my unit tests are green. This is far from ideal but hopefully this helps someone move on. I'd love to know when this is fixed so I can go back to relying on the package itself and be able to update it as I would with any other package instead of having to copy the file manually. |
Is this still broken? I would like to support hassle-free package usage for Node.js, but it's not clear to me how to proceed. |
Had the same issue here in a typescript project. I pulled the source typescript in and used it directly to solve the problem so I'm all good, but I wanted to confirm it is still an issue. By the way this is an amazing library. The level of clear and apparent care and passion that went into this is astounding! Thank you for the craftsmanship and great work. |
As mentioned by @bdougherty creating this issue, apparently 40cd7e3 fixed problems for Deno users but broke stuff for Node users. It looks like the main change is the addition of an "exports" section to package.json, and changing "typings" to "types". I'm still hoping someone who is an expert on JavaScript module stuff can drop by and help sort this out. This is too far outside my realm of expertise!
Hi @KenAKAFrosty and thank you for the kind words. |
Include TypeScript type definitions in the exported files. This might be a fix for #294, but I'm not sure. The only real way to test is to publish on npm and see what happens!
I have the same problem. Tried to remove astronomy/source/js/package.json Lines 39 to 45 in 61dc070
Is it really necessary to define |
@cosinekitty I change the exports to the following, by removing /esm and it works with node. Maybe this minor change is all that's needed.
|
@talyguryn and @pep108, I would like to try either or both of these to close this issue, but unfortunately I do not know enough about the Node/JavaScript world to evaluate whether these changes will work for everyone, or only in the specific cases we are testing. I'm concerned about continuing to make changes that break existing projects using the I guess what we need is a Node.js expert to come forward and help educate us with best practices for exporting the code and types for a TypeScript-based npm package. |
As I found to use Related links: |
I think this was broken by #263.
When importing using
import * as Astronomy from 'astronomy-engine';
into a Node project that is marked as a module in package.json or into an .mjs file, it works correctly when using version 2.1.7, but if you use the latest 2.1.15 version, you will get the following error:It seems to work in both versions when using
require
.The text was updated successfully, but these errors were encountered: