murat-dogan / node-datachannel

WebRTC For Node.js and Electron. libdatachannel node bindings.
Mozilla Public License 2.0
280 stars 52 forks source link

Add index.d.cts file to improve CommonJS support #242

Closed ptesavol closed 2 months ago

ptesavol commented 3 months ago

Currently using node-datachannel in a CommonJS typescript projects requires using very specific tsconfig settings in the importing project, namely:

 "compilerOptions": {
         "module": "CommonJS",
        "moduleResolution": "Node10"
    },

To make the import work with other "module" and "moduleResolution" settings, a index.d.cts file would be required in "lib/" This file can be a copy of the current index.d.ts file, and maybe it could be created in the "prepublishOnly" script.

The reason why a separate index.d.cts file is required seems to be related to this open issue in typescript: https://github.com/microsoft/TypeScript/issues/52363

murat-dogan commented 2 months ago

Could you please confirm this PR solves the issue? https://github.com/murat-dogan/node-datachannel/pull/244

ptesavol commented 2 months ago

Thank you for the swift reply, the PR solves the issue.

ptesavol commented 2 months ago

Hi, could you publish v 0.8.0 to NPM so we can take it into use?

murat-dogan commented 2 months ago

Version released