diff --git a/development/build/index.js b/development/build/index.js index 3e8faa372..456128c1f 100755 --- a/development/build/index.js +++ b/development/build/index.js @@ -73,9 +73,17 @@ async function defineAndRunBuildTasks() { version, } = await parseArgv(); + // scuttle on production/tests environment only + const shouldScuttle = ['dist', 'prod', 'test'].includes(entryTask); + + console.log( + `Building lavamoat runtime file`, + `(scuttling is ${shouldScuttle ? 'on' : 'off'})`, + ); + // build lavamoat runtime file await lavapack.buildRuntime({ - scuttleGlobalThis: true, + scuttleGlobalThis: applyLavaMoat && shouldScuttle, scuttleGlobalThisExceptions: [ // globals used by different mm deps outside of lm compartment 'toString', diff --git a/development/build/utils.js b/development/build/utils.js index fde7afbbd..e003f7c27 100644 --- a/development/build/utils.js +++ b/development/build/utils.js @@ -163,7 +163,7 @@ function wrapAgainstScuttling(content, bag = {}) { const proxy = new Proxy(bag, { set: function set(target, prop, value) { if (bag.hasOwnProperty(prop) || prop.startsWith('on')) { - return bag[prop] = global[prop] = value; + return (bag[prop] = global[prop] = value) || true; } }, });