Skip to content

CommonJS imports with Node16 ModuleResolutions broken #355

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
luuktap opened this issue Apr 29, 2024 · 2 comments
Closed

CommonJS imports with Node16 ModuleResolutions broken #355

luuktap opened this issue Apr 29, 2024 · 2 comments

Comments

@luuktap
Copy link

luuktap commented Apr 29, 2024

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):

  • obs-websocket-js version: 5.0.5
  • obs-websocket plugin version:
  • obs-studio version:
  • node version:
@NotBlue-Dev
Copy link

up

@t2t2 t2t2 closed this as completed in 0fe4f8c Aug 11, 2024
@t2t2
Copy link
Collaborator

t2t2 commented Aug 11, 2024

Updated tooling, now shows as good

Also made OBSWebSocket available as a named export

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants