Skip to content

CommonJS imports with Node16 ModuleResolutions broken #355

Closed
@luuktap

Description

@luuktap

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions