grantila/suretype

Browser support

hborchardt opened this issue · 1 comments

Hello, I am looking into using suretype in a web project using angular, and the browser complains that the dependency awesome-ajv-errors depends on terminal-link, which depends on ansi-escapes, which is a node.js-only library.

It would be super helpful to be able to validate backend responses in my frontend using suretype, so I would like to inquire if you see any possibility to make suretype run in a browser.

If you could layout how to approach this and don't oppose the idea, I would also be happy to help with implementing this.

Turns out you just need to add an empty polyfill for the process.env global to the polyfills.js that is part of every angular project:

(window as any).process = {
  env: { },
};

I don't know if it should be mentioned somewhere or if this is basic knowledge. Anyway, I am glad it works now.