-
Notifications
You must be signed in to change notification settings - Fork 400
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
Support ESM usage of module #551
Comments
Added some initial work for this here: #552 |
Can you please better explain the issue you are running into when consuming JSTT in your ESM project? My understanding is most bundlers have an interop layer, so if something isn't working, it's more likely a misconfiguration on your end than something we should fix in JSTT. If I'm missing something, a good start would be a quick demo of the issue you're running into. Could you throw a demo in a new repo and post a link? |
I'll give it a try: We're not actually using a bundler, only TypeScript for compilation. Not sure how you'd arrive at a miconfigured bundler. When adding
The line marked by the error contains Been a few days now, so not that deep into this any longer... but mainly correct I linked the post by Anthony Fu in the closed PR, which (I think) outlines the whole ordeal quite well: Tried my hand at a small reproduction, but not sure I'll get that ready in a reasonable timeframe. The error comes from a bigger monorepo-based setup, which makes it a bit hard to isolate. If I'm simply missing something here, I'm happy to learn! :) |
We're currently working on some ESM-based tooling (we're going pure ESM there), and in the process of migrating existing code into that cleaned-up code base we've stumbled upon some challenges with
json-schema-to-typescript
.Currently the project only targets CJS. If there's interest in supporting both ESM and CJS, I'd be open to do a PR for that. We'd need to work on that anyways (less preferably as a fork).
One main thing that would be interesting to me in that context is the use of the
json-schema-ref-parser
fork. There seems to be some instability as a consequence of maintainer changes over in that code base. Initially ESM-support was added there (APIDevTools/json-schema-ref-parser@96b805a), but the latest rewrite seems to have completely removed that again (APIDevTools/json-schema-ref-parser@a5b3946#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519).For the use in
json-schema-to-typescript
the fork (https://github.com/bcherny/json-schema-ref-parser) seems to be exactly in between those last big rewrite changes. Is this just coincidence? My impression was that the main fix on the fork was about the node version being wrong in some in between-releases ofjson-schema-ref-parser
.If the intention would be to go back to a non-forked version of
json-schema-ref-parser
as soon as possible, this might be a blocker. Because those last rewrite changes over there removed everything about ESM apparently. If continuing to work of the already existing fork, ESM there should be a pretty easy fix. It's just line 3 over here that needs to be changed to "export default $RefParser" in my first initial, local testing.The text was updated successfully, but these errors were encountered: