APIDevTools / json-schema-ref-parser

Parse, Resolve, and Dereference JSON Schema $ref pointers in Node and browsers
https://apitools.dev/json-schema-ref-parser
MIT License
942 stars 226 forks source link

Browser is trying to require `fs/promises` #318

Closed dav-is closed 5 months ago

dav-is commented 1 year ago

The browser is trying to require fs/promises in Next.js, failing to compile when using 10.1.0. Rolling back to 10.0.1 seems to fix it.

In 10.0.1, this library uses fs: https://github.com/APIDevTools/json-schema-ref-parser/blob/12cb26a764b975de38143458d06972772609be76/lib/resolvers/file.js#L1

In 10.1.0, this library uses fs/promises: https://github.com/APIDevTools/json-schema-ref-parser/blob/a5b3946fbb62683ab69e3747a8893014591726af/lib/resolvers/file.ts#L1

In package.json, fs is marked in browser as false: https://github.com/APIDevTools/json-schema-ref-parser/blob/a5b3946fbb62683ab69e3747a8893014591726af/package.json#L46-L48

I think fs/promises should be included in there instead.

ballcoach12 commented 1 year ago

I am getting the same error. Is there a workaround?

dav-is commented 1 year ago

I am getting the same error. Is there a workaround?

I had to downgrade to 10.0.1 and I don't use the fs resolver

jonluca commented 5 months ago

This is fixed in v11+