openwallet-foundation / credo-ts

Typescript framework for building decentralized identity and verifiable credential solutions
https://credo.js.org
Apache License 2.0
276 stars 202 forks source link

fix: mdoc fixes #2071

Closed TimoGlastra closed 1 month ago

TimoGlastra commented 1 month ago

Two fixes for mdoc:

changeset-bot[bot] commented 1 month ago

⚠️ No Changeset found

Latest commit: 4efd105ea8ffab436abaafe43bfc56cc7d2b79bd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

nodlesh commented 4 weeks ago

We have been having an Mdoc error running our Credo Backchannel/Agent in the Interop Tests in OATH. Will this fix solve this problem or is this a new issue?

[31m/src/node_modules/@credo-ts/core/build/modules/mdoc/Mdoc.js:4
const mdoc_client_1 = require("@protokoll/mdoc-client");
                      ^
Error [ERR_REQUIRE_ESM]: require() of ES Module /src/node_modules/@protokoll/mdoc-client/dist/cjs/src/index.js from /src/node_modules/@credo-ts/core/build/modules/mdoc/Mdoc.js not supported.
index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /src/node_modules/@protokoll/mdoc-client/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at Object.<anonymous> (/src/node_modules/@credo-ts/core/build/modules/mdoc/Mdoc.js:4:23) {
  code: 'ERR_REQUIRE_ESM'
}
TimoGlastra commented 4 weeks ago

No, but it's weird that you get that error as the library it's complaining about is not a module.

Probably something related to ts-node 🤔