Skip to content

Support ESM usage of module #551

Open
@julrich

Description

@julrich

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 of json-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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions