Cannot read property 'require' of undefined when using ES6 modules
Closed this issue · 5 comments
springcomp commented
Here is a minimal repro case.
bendrucker commented
Proxyquire works with require
only and doesn't support ES Modules.
springcomp commented
Thanks for the feedback.
pabx06 commented
I Have the same issue. ES6 module is getting more and more popular...
sokraflex commented
Same here. This forces us to switch to another library.
damusix commented
@sokraflex I looked into this earlier this year and I don't think anyone can support stubbing ESM imports by transforming them into CJS. IIRC, it seems like everything that transpiles into CJS from ESM implements the literal standard, which is to return your module as a getter only, which means it's never allowed to be set. You'll never get to stub.