redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

Core package should not depend on colorette

Open akx opened this issue 2 years ago • 2 comments

Describe the bug

The core package depends on colorette to be able to color error messages using ANSI codes.

That package attempts to read process.env during import time, which isn't a thing in browsers (unless transpiled), causing trouble trying to use @redocly/openapi-core with e.g. https://vitejs.dev/.

(Another related issue is node-fetch, which doesn't work OOTB in a Vite environment either.)

To Reproduce Steps to reproduce the behavior:

  1. Try to import @redocly/openapi-core 1.0.0-beta.80 in a non-bundling browser environment.
  2. See error

Expected behavior

The library should not depend on a console coloring library.

akx avatar Jan 31 '22 14:01 akx

It also relates to https://github.com/Redocly/redoc/issues/1820.

AlexVarchuk avatar May 19 '22 09:05 AlexVarchuk

Hello @akx In 1.0.0-beta.108 was added browser support. We're still depending on colorette but it is not used in browser env (replacement for node-fetch is still in progress but you can provide customFetch field with browser-compatible implementation). Please let us know if you still have issues with it

roman-sainchuk avatar Aug 23 '22 07:08 roman-sainchuk

I think this has been fixed, so I'll close the issue but please let us know if this still causes a problem.

lornajane avatar Apr 03 '23 07:04 lornajane