openwallet-foundation / credo-ts

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

openid4vc build fails #2079

Closed Sshovon closed 1 hour ago

Sshovon commented 2 hours ago

I am getting following build fail error if I import anything from openid4vc package.

/home/frcs/my-zone/play-zone/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 /home/frcs/my-zone/play-zone/node_modules/@protokoll/mdoc-client/dist/cjs/src/index.js from /home/frcs/my-zone/play-zone/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 /home/frcs/my-zone/play-zone/node_modules/@protokoll/mdoc-client/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at Object.<anonymous> (/home/frcs/my-zone/play-zone/node_modules/@credo-ts/core/build/modules/mdoc/Mdoc.js:4:23) {
  code: 'ERR_REQUIRE_ESM'
}

I have used the similar ts-config file as credo build ts-config. And my typescript version is 5.5.4 and node version is 20.11 and I am using the latest release v0.5.12. I am a bit confused it thats an issue with my config or not. Can any one please help me on this ?

Sshovon commented 2 hours ago

Hey @TimoGlastra , can you please take a look ?

TimoGlastra commented 2 hours ago

Which version of @protokoll/mdoc-client are you on?

Sshovon commented 1 hour ago

From lock file I got the version @protokoll/mdoc-client@0.2.27

TimoGlastra commented 1 hour ago

Can you update to the latest alpha of credo and retry?

Sshovon commented 1 hour ago

thanks a lot, it works with latest alpha v0.5.13-alpha-20241029105616.