1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-12 04:37:13 +01:00
metamask-extension/app/scripts/app-init.js

51 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-05-26 06:48:23 +02:00
// eslint-disable-next-line import/unambiguous
function tryImport(...fileNames) {
try {
// eslint-disable-next-line
importScripts(...fileNames);
return true;
} catch (e) {
console.error(e);
return false;
}
}
function importAllScripts() {
const startImportScriptsTime = Date.now();
// value of applyLavaMoat below is dynamically replaced at build time with actual value
2022-05-26 06:48:23 +02:00
const applyLavaMoat = true;
tryImport('./globalthis.js');
tryImport('./sentry-install.js');
if (applyLavaMoat) {
tryImport('./runtime-lavamoat.js');
tryImport('./lockdown-more.js');
tryImport('./policy-load.js');
} else {
tryImport('./init-globals.js');
2022-05-26 06:48:23 +02:00
tryImport('./lockdown-install.js');
tryImport('./lockdown-run.js');
tryImport('./lockdown-more.js');
2022-05-26 06:48:23 +02:00
tryImport('./runtime-cjs.js');
}
const fileList = [
// The list of files is injected at build time by replacing comment below with comma separated strings of file names
// https://github.com/MetaMask/metamask-extension/blob/496d9d81c3367931031edc11402552690c771acf/development/build/scripts.js#L406
2022-05-26 06:48:23 +02:00
/** FILE NAMES */
];
fileList.forEach((fileName) => tryImport(fileName));
// for performance metrics/reference
console.log(
`SCRIPTS IMPORT COMPLETE in Seconds: ${
(Date.now() - startImportScriptsTime) / 1000
}`,
);
}
// Placing script import call here ensures that scripts are inported each time service worker is activated.
importAllScripts();