Giter Club home page Giter Club logo

Comments (8)

domoritz avatar domoritz commented on July 19, 2024 1

I see. I personally only need the cli so let's switch back to cjs only until the node ecosystem works better.

from ts-json-schema-generator.

arthurfiorette avatar arthurfiorette commented on July 19, 2024 1

Ill be working on this later today

from ts-json-schema-generator.

arthurfiorette avatar arthurfiorette commented on July 19, 2024

@domoritz, there's currrently some issues with porting to dual builds:

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. literally means that if we want to keep first class ESM support and second class CJS support, we would need to rename all files under /cjs from index.js to index.cjs.

We would also need to make a lot of changes to the exports field inside package.json.

Currently, (until node v22 makes --experimental-require-module stable), CJS code can be imported by ESM and CJS, while ESM code can only be imported by ESM code. What do you think about going back to CJS-only (which fully works in esm projects) instead of making all of these awful changes to support both.

Things were much simpler previously :/

from ts-json-schema-generator.

domoritz avatar domoritz commented on July 19, 2024

Changing the exports field isn't that bad I think. We did this in apache arrow: https://cdn.jsdelivr.net/npm/[email protected]/package.json

from ts-json-schema-generator.

domoritz avatar domoritz commented on July 19, 2024

I think the future is ESM so another option is all ESM and anyone who needs CJS uses an old version. Or is there some high-value project that cannot update to ESM?

from ts-json-schema-generator.

arthurfiorette avatar arthurfiorette commented on July 19, 2024

Changing the exports field isn't that bad I think

Sure it isn't, but in apache-arrow the type field is declared as commonsjs.

We know that ESM cannot be imported by CJS, but CJS can be imported by both, so is there any benefit to write this library in ESM?

A good landmark in time to port again this library to ESM is when https://nodejs.org/api/cli.html#--experimental-require-module gets stable, so ESM/CJS gets fully interoperable in every way and writing esm/cjs starts being only a matter of taste.

I think the future is ESM

The future is indeed ESM, but until node's gets full support for cjs/esm interop a lot of problems would surface with cjs/esm...

My main usecase with this project is with @kitajs, which uses ts-json-schema-generator from inside a typescript language service plugin that is loaded by the tsserver runtime written in CommonsJS, and as you might imagine, there's the typescript source won't be ported to ESM in the near future.

If this project removes support for CJS, I couldn't use it anymore, just like every other project that might be dependent of a tool written in CJS.

from ts-json-schema-generator.

navalex avatar navalex commented on July 19, 2024

Do you have any workaround to make it works for the moment ? Can't make the basic code from the README.md working...

from ts-json-schema-generator.

domoritz avatar domoritz commented on July 19, 2024

Use an old version. We will fix this soon.

from ts-json-schema-generator.

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.