interceptors
interceptors copied to clipboard
The `EventEmitter` property is not defined on the browser side
When I using this module in the browser, I can't find the 'EventEmitter' property in the console output. I guess this is because the 'strict-event-emitter' module relies on the native 'events' module of Node.js. Is there any way to solve this problem?
Hi @lenqwang ,
you should use evenemitter3
which is browser compatible. you can take the reference from it's github repo https://github.com/primus/eventemitter3. We were also getting the same error with events
, which is not compatible with Browser i guess so.
I think StrictEventEmitter
cannot run in the browser because it extends EventEmitter
, which is not a thing in the browser.
We should write a different module for it that'd be imported in the browser, and use EventTarget
as the base class instead. The issue here is that EventTarget
and EventEmitter
are not compatible, as emitter has more properties and is, generally, a totally different thing.
Strange that I've never encountered this while working with Interceptors + MSW in the browser. How are you getting this error?
I'm moving forward with this by ditching EventEmitter
and utilizing EventTarget
+ type-safety in https://github.com/open-draft/strict-event-emitter/pull/8. Afaik, we should be fine with the interface EventTarget provides. Will see.
I'm moving forward with this by ditching
EventEmitter
and utilizingEventTarget
+ type-safety in https://github.com/open-draft/strict-event-emitter/pull/8. Afaik, we should be fine with the interface EventTarget provides. Will see.
Thanks @kettanaito
Released: v0.19.5 🎉
This has been released in v0.19.5!
Make sure to always update to the latest version (npm i @mswjs/interceptors@latest
) to get the newest features and bug fixes.
Predictable release automation by @ossjs/release.