Comments (8)
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.
Ill be working on this later today
from ts-json-schema-generator.
@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.
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.
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.
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.
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.
Use an old version. We will fix this soon.
from ts-json-schema-generator.
Related Issues (20)
- "foo" | "bar" | string; should not only map to a string HOT 9
- Improved Promise handling to support packages like Prisma HOT 1
- Literal and Record<never, never> crates empty object HOT 1
- Cannot migrate to version 2 due to typescript error type CompletedConfig HOT 2
- [Bug]: Error when using the binary (v2.1.0) HOT 9
- V2 creates empty definitions after updating from V1 HOT 5
- CLI usage is throwing an error with node 22 HOT 3
- RegExp types are now emitted, breaking schema validation (v2.1.1) HOT 1
- Error when following exports?
- Dist types now require @types/ts-expose-internals HOT 9
- Invalid index in type HOT 11
- CLI - ENOENT: no such file or directory, open 'package.json' HOT 3
- Error: Unknown type "undefined" HOT 2
- Required types not allowed HOT 1
- Generator crashed when no package version is set HOT 4
- Any way to indicate that a string is actually a date-time? HOT 7
- Breaking changes from v1 to v2 HOT 1
- Support for `"format": "uri-reference"` HOT 3
- Incorrect typing when a type uses Omit and inherits properties from a grandparent interface
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-json-schema-generator.