Summary
With sourceType: "module", ECMAScript treats module code as strict mode code. In Sval, a minimal strict-mode check still behaves as if the code were not strict.
Reproduction
import Sval from "sval";
const interpreter = new Sval({
ecmaVer: 11,
sandBox: true,
sourceType: "module",
});
interpreter.run(`
var isStrict = (function () { return !this; })();
export { isStrict };
`);
console.log(interpreter.exports.isStrict);
Expected
In a real ES module, plain function calls have this === undefined, so !this is true. The variable should reflect strict behavior (isStrict === true).
Actual
interpreter.exports.isStrict is false, which matches sloppy mode (this is the global object).
Environment
Summary
With
sourceType: "module", ECMAScript treats module code as strict mode code. In Sval, a minimal strict-mode check still behaves as if the code were not strict.Reproduction
Expected
In a real ES module, plain function calls have
this === undefined, so!thisistrue. The variable should reflect strict behavior (isStrict === true).Actual
interpreter.exports.isStrictisfalse, which matches sloppy mode (thisis the global object).Environment