Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Make Credo a pure ESM package #2157

Open
TimoGlastra opened this issue Jan 27, 2025 · 4 comments
Open

Make Credo a pure ESM package #2157

TimoGlastra opened this issue Jan 27, 2025 · 4 comments

Comments

@TimoGlastra
Copy link
Contributor

TimoGlastra commented Jan 27, 2025

Currently Credo outputs only CommonJS (CJS) code. This is the old way of doing things, and a new method "ESM" has been available for a long time.

Using ESM can be somewhat tricky to setup, however with modern tooling it's actually quite doable. Trouble comes when you try to import ESM from CommonJS, especially if you need to support multiple module syntaxes.

The Cheqd SDK has moved to ESM, and for that reason we're now on a very old version that still supports CJS.

I want to suggest we move Credo to a full ESM module. Node.JS fully supports ESM, and it's easy import ESM modules in Node.JS if you're also using ESM. React Native allows to easily transpile and use ESM modules as well.

For users of Node.JS that do not want to use ESM yet, there are several ways to import Credo:

The reason for moving to ESM is that it's becoming hard to not support ESM, but it's a pain to support both ESM and CJS due to how different they are in the resolution and compilation part.

I'd like to gather some input on whether moving to ESM is acceptable?

Also see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

@TimoGlastra
Copy link
Contributor Author

cc @jakubkoci @berendsliedrecht @genaris @sairanjit @cvarjao @jleach

@TimoGlastra
Copy link
Contributor Author

Side note: for dcql-ts, and oid4vc-ts we have a build system that outputs to both cjs and esm. However due to the complexity of Credo's setup I don't want to support that for Credo. also because we depend on packages that have become ESM only, the model doesn't work, unless we bundle all dependencies within Credo

@sairanjit
Copy link
Contributor

@TimoGlastra This is acceptable, as moving from CJS to ESM also enhances security by utilizing modern module handling and enforcing stricter syntax.

@TimoGlastra
Copy link
Contributor Author

We will also have to wait for #2127 before doing such a task, as it would require a lot of changes to imports.

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

No branches or pull requests

2 participants