Git Product home page Git Product logo

Comments (7)

jonkoops avatar jonkoops commented on July 17, 2024 7

We are currently compiling this package in the CommonJS format, the quirkiness we are seeing here is a side-effect of the TypeScript compiler. Now that Node.js 12 is no longer supported we intend to compile to ESM instead.

There are no intentions to have this package contain both ESM and CommonJS entry points and we'd rather opt for a pure ESM package instead. Node.js provides interoperability between these two so that it should 'just work' so I expect this will improve the developer experience.

from keycloak-nodejs-admin-client.

jonkoops avatar jonkoops commented on July 17, 2024

Closing this as we landed pure ES module support in #381.

from keycloak-nodejs-admin-client.

alexagc avatar alexagc commented on July 17, 2024

@jonkoops, i would reconsider the distribution of commonjs module(following this rules https://nodejs.org/api/esm.html#esm_commonjs_namespaces), if only ships ESM modules this project force to move all code database of project to use ESM (or transpile code), this, even now, its not clear in nodejs core maintainers because commonjs its not going to be deprecate in a future and a large number of packages are still only in commonjs. Here its the personal recommendation of a nodejs maintainer (Matteo collina) about this topic:

nodejs/node#33954 (comment)

from keycloak-nodejs-admin-client.

claytongulick avatar claytongulick commented on July 17, 2024

@jonkoops, i would reconsider the distribution of commonjs module(following this rules https://nodejs.org/api/esm.html#esm_commonjs_namespaces), if only ships ESM modules this project force to move all code database of project to use ESM (or transpile code), this, even now, its not clear in nodejs core maintainers because commonjs its not going to be deprecate in a future and a large number of packages are still only in commonjs. Here its the personal recommendation of a nodejs maintainer (Matteo collina) about this topic:

nodejs/node#33954 (comment)

I agree, our solution for now is to move away from keycloak due to the response to this ticket and some other technical limitations.

I was disappointed with the response, it seemed needlessly strict, especially since packaging for both esm and cjs is pretty simple and a common practice.

from keycloak-nodejs-admin-client.

jonkoops avatar jonkoops commented on July 17, 2024

especially since packaging for both esm and cjs is pretty simple and a common practice.

No, it's not.

if only ships ESM modules this project force to move all code database of project to use ESM

It doesn't force you to do this, you can still import ES modules from CommonJS. However there are caveats. You'll have to use the dynamic import(), and since top-level await is not supported in CommonJS you'll have to wrap your code in an IIFE.

You can find more information about this in this excellent blog post by @adam-coster.

That said, I am a fervent supporter of moving things to ESM, so my recommendation will always be to try to use it wherever possible.

from keycloak-nodejs-admin-client.

claytongulick avatar claytongulick commented on July 17, 2024

No, it's not.

Are you sure? https://antfu.me/posts/publish-esm-and-cjs

I've bundled for both without any major issues.

from keycloak-nodejs-admin-client.

belinde avatar belinde commented on July 17, 2024

I agree with claytongulick. I investigated for a few hours how to get the latest wersions of the package working with the existing codebase and I've decided that it's not worth the effort. Keycloak seerver is a great software, but this library can be easily replaced with some homemade call. It's a shame because I always prefere to use official clients, but I cannot afford to lose days and days of work just to have some REST call done.

Surely ES modules are the future, but at the moment commonjs is too much ubiquitous to be ignored.

from keycloak-nodejs-admin-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.