functorSource: arrow function, so that `arguments` doesn't capture
MODIFY
src/helpers.js
src/helpers.js
@@ -205,7 +205,7 @@ function makeModuleInstance(
// uninitialized
const functor = optFunctor;
optFunctor = null;
- // initializing
+ // initializing - call with `this` of `undefined`.
functor(harden(hImport), harden(hOnce), harden(hLive));
// initialized
}

MODIFY
src/index.js
src/index.js
@@ -314,8 +314,12 @@ const makeModuleTransformer = babelCore => {
.map(vname => `${HIDDEN_LIVE}.${vname}();`)
.join('');
+ // The functor captures the SES `arguments`, which is definitely
+ // less bad than the functor's arguments (which we are trying to
+ // hide.
+ // It must also be strict to enforce strictness of modules.
const functorSource = `\
-(function moduleFunctor(${HIDDEN_IMPORTS}, ${HIDDEN_ONCE}, ${HIDDEN_LIVE}) { \
+((${HIDDEN_IMPORTS}, ${HIDDEN_ONCE}, ${HIDDEN_LIVE}) => { \
'use strict'; \
${preamble} \
${scriptSource}

MODIFY
test/test-export-default.js
test/test-export-default.js
@@ -38,6 +38,16 @@ test('export default', async t => {
{ default: 'bingbang' },
`endowed modules`,
);
+
+ const ns = await evaluateModule(`\
+export default arguments;`);
+ t.equal(typeof ns.default, 'object', 'arguments is an object');
+ t.equal(ns.default.length, 1, 'arguments has only one entry');
+ t.equal(typeof ns.default[0], 'string', 'arguments[0] is just string');
+
+ const ns2 = await evaluateModule(`\
+export default this;`);
+ t.equal(ns2.default, undefined, 'this is undefined');
} catch (e) {
console.log('unexpected exception', e);
t.assert(false, e);

functorSource: arrow function, so that `arguments` doesn't capture