Something is wrong with a cache #805
Comments
|
I think the cache-disabling flag just prevents it from being loaded from disk. Stuff still goes in an in-memory cache |
|
Another tricky moment:
Then I am adding
From call to call the parent of There is only one place which might set How it works:
Probably it's now easy to create a first test for a problem - overloading The best solution - move cache border one level down. It's quite hard to debug esm, but |
|
The TL;DR of this issue is that “esm and rewiremock do not play nice together” to such a degree that the combination isn’t feasible beyond trivial use of rewiremock. |
|
I think jdalton is on an open-source vacation / starting new job, so don’t expect the usual prompt fix. |
|
Look like |
|
Hi @theKashey! The |
|
This test 👎 fail - 👍 pass - I'll try to extract it in a shorter form, you will be able to integrate to esm's tests. |
Thank you! |
|
https://github.com/theKashey/esm-bug-805
I've tried to make the example as complicated, as possible - but it just works, except this moment. I've also update esm from |
There is a simple test:
A.js<- reexports <-B.js<- reexports <-C.jsC.js, would changeBandAresults, which are the same.Test 1
In this test we are replacing B by "bar". It is working
Test 2
This time test would fail.
Cwould be not mocked, as long as B cache would be reused, so it never gets a change to get mocked - execution enters ESM loader with "B", and exists with a result, never callsModule._loadagain.Test 3
Add one more test, between these two
It would fail, but
test 2which would be executed right after it, will pass.Test 4
Test 2- greenTest3- greenTest1- the test afterTest1is redA.jsbymodule.exports = require('./B');- all tests are green.So - there is something like cache poisoning, which take a place after
A.jsAdd D.js
I've extended chain by
D.js, then started modifying the code.I've also tried to run
rewiremockstests vsesmand majority failed due to cache related issues.I've also tried to disable ESM cache, but it has no effect.
Theory
Some parts of
rewiremockusesrequire.cache, while others usesModule._cache. While it's the same for nodejs and webpack, it might not be the case foresm.The text was updated successfully, but these errors were encountered: