1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 03:12:42 +02:00

Only build LavaMoat runtime once (#18768)

This commit is contained in:
Frederik Bolding 2023-04-24 18:02:27 +02:00 committed by GitHub
parent 9fcbc554b0
commit cd7cd45ec5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,61 +73,65 @@ async function defineAndRunBuildTasks() {
version,
} = await parseArgv();
// scuttle on production/tests environment only
const shouldScuttle = ['dist', 'prod', 'test'].includes(entryTask);
const isRootTask = ['dist', 'prod', 'test', 'dev'].includes(entryTask);
console.log(
`Building lavamoat runtime file`,
`(scuttling is ${shouldScuttle ? 'on' : 'off'})`,
);
if (isRootTask) {
// scuttle on production/tests environment only
const shouldScuttle = ['dist', 'prod', 'test'].includes(entryTask);
// build lavamoat runtime file
await lavapack.buildRuntime({
scuttleGlobalThis: applyLavaMoat && shouldScuttle,
scuttleGlobalThisExceptions: [
// globals used by different mm deps outside of lm compartment
'toString',
'getComputedStyle',
'addEventListener',
'removeEventListener',
'ShadowRoot',
'HTMLElement',
'Element',
'pageXOffset',
'pageYOffset',
'visualViewport',
'Reflect',
'Set',
'Object',
'navigator',
'harden',
'console',
'Image', // Used by browser to generate notifications
// globals chrome driver needs to function (test env)
/cdc_[a-zA-Z0-9]+_[a-zA-Z]+/iu,
'performance',
'parseFloat',
'innerWidth',
'innerHeight',
'Symbol',
'Math',
'DOMRect',
'Number',
'Array',
'crypto',
'Function',
'Uint8Array',
'String',
'Promise',
// globals sentry needs to function
'__SENTRY__',
'appState',
'extra',
'stateHooks',
'sentryHooks',
'sentry',
],
});
console.log(
`Building lavamoat runtime file`,
`(scuttling is ${shouldScuttle ? 'on' : 'off'})`,
);
// build lavamoat runtime file
await lavapack.buildRuntime({
scuttleGlobalThis: applyLavaMoat && shouldScuttle,
scuttleGlobalThisExceptions: [
// globals used by different mm deps outside of lm compartment
'toString',
'getComputedStyle',
'addEventListener',
'removeEventListener',
'ShadowRoot',
'HTMLElement',
'Element',
'pageXOffset',
'pageYOffset',
'visualViewport',
'Reflect',
'Set',
'Object',
'navigator',
'harden',
'console',
'Image', // Used by browser to generate notifications
// globals chrome driver needs to function (test env)
/cdc_[a-zA-Z0-9]+_[a-zA-Z]+/iu,
'performance',
'parseFloat',
'innerWidth',
'innerHeight',
'Symbol',
'Math',
'DOMRect',
'Number',
'Array',
'crypto',
'Function',
'Uint8Array',
'String',
'Promise',
// globals sentry needs to function
'__SENTRY__',
'appState',
'extra',
'stateHooks',
'sentryHooks',
'sentry',
],
});
}
const browserPlatforms = ['firefox', 'chrome'];