Open
Description
Expected Behavior
If a module exports a variable that was defined with let
and can be reassigned, other modules that import that variable should always see the current value of the variable.
E.g.
env.js:
let env = { FOO: 'baz' }; // Starts with an old value
function setEnv(newEnv) {
// Allow callers to set a new value
env = newEnv;
}
export { env, setEnv };
If module1 calls setEnv
with a new value, and module2 references env
, module2 should see the new value.
Actual Behavior
With the Node flag --experimental-loader=import-in-the-middle/hook.mjs
, module2 actually sees the old value.
Steps to Reproduce the Problem
I made a repro here: https://github.com/dennisjlee/iitm-assign-module-var-repro
Specifications
- Version: import-in-the-middle 1.4.2
- Platform: Node 18.18.2 or 20.9.0