obs-websocket-community-projects / obs-websocket-js

Consumes https://github.com/obsproject/obs-websocket
MIT License
656 stars 95 forks source link

CommonJS imports with Node16 ModuleResolutions broken #355

Open luuktap opened 2 months ago

luuktap commented 2 months ago

Description:

Package resolution is broken in a TypeScript project using CommonJS with Module and ModuleResolution set to Node16. Also see: https://arethetypeswrong.github.io/?p=obs-websocket-js%405.0.5 => node16 (from CJS). This breaks importing completely.

Any import will get the following TypeScript error: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'.

If I don't specify any export (just import OBSWebSocket from "obs-websocket-js";), an additional TypeError is thrown at runtime: OBSWebSocket is not a constructor. Manually specifying /json or /msgpack gets rid of this. The other error remains.

Versions Used (if applicable):

NotBlue-Dev commented 3 weeks ago

up