Code Monkey home page Code Monkey logo

Comments (2)

sindresorhus avatar sindresorhus commented on May 20, 2024

I have no plans to add back CJS support.

Unfortunately as a library developer I cannot force my decisions down everyone else's throat

You definitely can and should. ESM has been here for many years now. Be aware that ESM+CJS has downsides too: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c?permalink_comment_id=3850849#gistcomment-3850849

that is especially true due to the still suboptimal esm experience with Typescript

ESM works fine with TypeScript if you use the correct tsconfig: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-make-my-typescript-project-output-esm

from emittery.

darkbasic avatar darkbasic commented on May 20, 2024

Be aware that ESM+CJS has downsides too

Unless I use a wrapper (which wouldn't work on deno so that would be pointless) there is little I can do about that, especially since the whole graphql ecosystem bundles dual packages and thus using instanceof is already a big hazard (let's not talk about yarn link which creates a similar issue).

By the way the dual package hazard also exists for esm-only packages that get imported in commonjs projects via async imports, yet it is being advertized as the solution to import pure esm modules into commonjs projects.

You definitely can and should

If that would be the solution to this mess I would be glad to do so, but the only goal that it will accomplish would be to flee my users to some ancient alternative without accomplishing any global transition to pure esm.

ESM works fine with TypeScript if you use the correct tsconfig

Fine, but annoying nonetheless: importing commonjs modules with default exports is a mess and the js extension in the import is counterintuitive as well.

from emittery.

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.