attempt fix typescript modules error for runno runtime#324
Conversation
|
This seems right, but I can't find good documentation on what the correct thing to do is. This stackoverflow link suggests this approach is not enough, and the import and require need to be split: https://stackoverflow.com/questions/58990498/package-json-exports-field-not-working-with-typescript Can you find some documentation on this? We should also update all package.json files in the repo if this change is necessary, not just this one. |
I can help answer this 🙂 TS's docs on publishing types are here: https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html. They seem to not have been updated1 with regard to Node's own docs on this are here: https://nodejs.org/api/packages.html#exports. That links to more detailed docs that involve all the different permutations. Given the current usage, "conditional exports" and "subpath exports" are particularly relevant.
Normally this is specifically in the case where you have different, "conditional" exports for CJS (
So this answer appears to be most correct, where they are split.
If you're confused by this, well, I feel like I get confused every time I look at this and I help maintain a TS compiler integration (and maintained and contributed to lots of other TS tooling in the past, including the TS docs) 😅 To add to the confusion, Node's support for ESM in the module VM API was still experimental last I checked and so was blocking test runners like Jest jestjs/jest#9430 from natively supporting it too (there are workarounds) Tbh, it's a lot easier to only support newer, LTS versions of Node that all support ESM as a standard spec (see also https://deno.com/blog/commonjs-is-hurting-javascript, https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). Backward-compat is hard and confusing, so big respect to all those who attempt it, and I extensively try to do so too, but even I'm planning to move my supported libraries to pure ESM in breaking changes eventually to simplify builds and reduce the maintenance burden, especially as older Node is now out-of-support. Footnotes
|
|
Thanks so much @agilgur5 - those links were very useful. Okay so it seems like the right fixes are either:
Or
Is that right? If that's the case deleting seems to be the right move. |
|
Hey sorry for the delayed response, I had a pretty bad flare-up in my medical condition the past ~2ish weeks and so haven't really touched a computer much at all in that timeframe 😕 Feeling better overall now, but not fully back yet. removing
|
|
hey sorry! I need some help with this, I dont understand many of the links sent and how I would begin to modify do I need to close the PR so someone else can take lead? |
|
@jonathanpv from a quick read @agilgur5 is suggesting that your fix in this PR is correct, and that to ship it we'll need to update each of the packages in Runno. @agilgur5 is that right? If so could you please make the same change in the other packages? (see the packages folder at the root of the repo) |
Essentially1 yes 👍
no, anyone can file a superseding PR, but I figure you might want to update it yourself and get this merged as the original author and bug finder! Footnotes
|
|
This has been superceded by #333 and has been released as |
maybe am wrong lmk
related: