Closed catalin-bratu closed 2 months ago
Hi, @catalin-bratu.
Yes, you can use @mswjs/source
in the browser. The code it ships is neutral and doesn't rely on the Node.js API.
however process.env and process.cwd are undefined in dev mode.
These are likely coming from your code. There's no dependency on process
in Source.
I will try to set up a sandbox to see if I can reproduce the issue in a fresh install of vite.
Maybe, I wasn't very clear. I tried to use this in the browser.
import { fromOpenApi } from '@mswjs/source/open-api' import spec from './api.spec.json'
const handlers = await fromOpenApi(spec)
@catalin-bratu there's an upstream dependency @mswjs/source
-> @apidevtools/swagger-parser
-> @apidevtools/json-schema-ref-parser
which is probably the source of your error see https://github.com/APIDevTools/json-schema-ref-parser/issues/354#issuecomment-2263894801 for solution
@kettanaito if you want to add a short sentence about browser support somewhere in the docs
Description
I'm trying to use the library in a vue vite application, however process.env and process.cwd are undefined in dev mode.
Is the library solely for usage with Node.js?
It looks quite promising in compassion to your competitors.