You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Node 14 is released and will soon become LTS, so ESM is pretty usable out of the box in Node. I'm experimenting with converting my app to use modules (without TypeScript), and the UX for the twitch libraries could be improved.
Unfortunately the type definitions still don't allow intellisense to pick this up. TypeScript has some interop features for this but standard Node does not. Most of these issues could be sidestepped by avoiding default exports (they're a JS language design mistake in my opinion), and only using named exports.
For backward compatibility a named export could be introduced alongside the current default export, which would at least alleviate these problems today:
This is currently in the works, there will be a separate ESM build in the package in version 4.1 - keep an eye out, I will publish a prerelease version soon™ 🙂
Currently blocked by lukeed/bundt#3. I forked a lot of other packages, but in this case it's a bit more complicated, since the package I need to modify sits inside a monorepo.
Feature Request
Node 14 is released and will soon become LTS, so ESM is pretty usable out of the box in Node. I'm experimenting with converting my app to use modules (without TypeScript), and the UX for the twitch libraries could be improved.
https://github.com/d-fischer/twitch/blob/9fb614946c95bd14820cfb61f0e353b06bb9fa8b/packages/twitch/src/index.ts#L4
As is, intellisense calls this default import a class (because of the type definitions) but really, to Node, it's the common JS
module.exports
object.So to make it work in a Node ES module we would have to use its
default
property to get the class itself:Unfortunately the type definitions still don't allow intellisense to pick this up. TypeScript has some interop features for this but standard Node does not. Most of these issues could be sidestepped by avoiding default exports (they're a JS language design mistake in my opinion), and only using named exports.
For backward compatibility a named export could be introduced alongside the current default export, which would at least alleviate these problems today:
This would also apply to the other packages like the chat client, and other exposed default exports.
An ES module build could also be introduced but that's a more involved proposition.
The text was updated successfully, but these errors were encountered: