You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using jsdom-worker to support third party libs that use service workers in a jest runtime. The third party lib uses require all over the place, which causes issues when jest is otherwise configured as a module (i.e. using import). One way to solve this is to polyfill require -- for example, https://stackoverflow.com/a/71883023/3269537
Update: gave this a shot, ran into some issues. Because this library uses the Function object constructor to generate the code from string, it's using CommonJS regardless of what runtime you're actually configuring. This means that import * as foo from 'foo' as well as require(foo) don't work
I'm using jsdom-worker to support third party libs that use service workers in a jest runtime. The third party lib uses require all over the place, which causes issues when jest is otherwise configured as a module (i.e. using import). One way to solve this is to polyfill require -- for example, https://stackoverflow.com/a/71883023/3269537
It would be really convenient if jsdom-worker supported both require and import, so that it is agnostic to what code is actually being loaded. Can we simply inject the above here: https://github.com/developit/jsdom-worker/blob/main/src/index.js#L129? Happy to send out a pr that tries this
The text was updated successfully, but these errors were encountered: