Open boneskull opened 5 years ago
Note:
import path from "path"
also causes the failure import "path"
does not cause the failure@global
with proxyquire. Just don't. It does not play well.What's happening:
require.extensions[extension]
to hook into module loading.parentModule
=== testModule
require
order.There the problem is probably bound to tree shaking - unused import was not required in esm, which, however, is required by a fact (just tested it).
I don't know what the problem is, but that's why I'm commenting on this issue.
@theKashey you may or may not wish to comment on #799
I've adapted the "proxyquire" scenario from the tests to show an issue. Below, I've added a second assertion, and a third file,
c.js
. The assertions made below, using CJS, pass (to prove it works as intended):Now, if we write these using ES modules via
node -r esm
:The result:
If we remove that unused import in
c.js
:the assertion passes.
I don't know what the problem is, but that's why I'm making this issue.
I can replicate this behavior in both rewiremock and proxyquire. I'll probably send a PR to add some rewiremock tests.