This method sets the module export binding slots with the given value.
import vm from 'node:vm';
const m = new vm.SyntheticModule(['x'], () => {
m.setExport('x', 1);
});
await m.evaluate();
assert.strictEqual(m.namespace.x, 1);
method
This method sets the module export binding slots with the given value.
import vm from 'node:vm';
const m = new vm.SyntheticModule(['x'], () => {
m.setExport('x', 1);
});
await m.evaluate();
assert.strictEqual(m.namespace.x, 1);
Name of the export to set.
The value to set the export to.