1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-22 17:33:23 +01:00

Don't include document in scuttling config for mv3 builds (#18356)

* Don't include document in scuttling config for mv3 builds

* Fix env var comparison

* lint fix
This commit is contained in:
Dan J Miller 2023-04-04 08:15:50 -07:00 committed by GitHub
parent 2029fb28ff
commit 7a8d0273a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 5 deletions

View File

@ -20,6 +20,7 @@ const configurationPropertyNames = [
'DISABLE_WEB_SOCKET_ENCRYPTION',
'METAMASK_DEBUG',
'SKIP_OTP_PAIRING_FLOW',
'ENABLE_MV3',
];
const productionConfigurationPropertyNames = [

View File

@ -52,7 +52,7 @@ const {
} = require('./transforms/remove-fenced-code');
// map dist files to bag of needed native APIs against LM scuttling
const scuttlingConfig = {
const scuttlingConfigBase = {
'sentry-install.js': {
// globals sentry need to function
window: '',
@ -70,7 +70,6 @@ const scuttlingConfig = {
Number: '',
Request: '',
Date: '',
document: '',
JSON: '',
encodeURIComponent: '',
crypto: '',
@ -87,6 +86,16 @@ const scuttlingConfig = {
},
};
const mv3ScuttlingConfig = { ...scuttlingConfigBase };
const standardScuttlingConfig = {
...scuttlingConfigBase,
'sentry-install.js': {
...scuttlingConfigBase['sentry-install.js'],
document: '',
},
};
/**
* Get the appropriate Infura project ID.
*
@ -932,9 +941,8 @@ function setupBundlerDefaults(
// Setup source maps
setupSourcemaps(buildConfiguration, { buildTarget });
// Setup wrapping of code against scuttling (before sourcemaps generation)
setupScuttlingWrapping(buildConfiguration, applyLavaMoat);
setupScuttlingWrapping(buildConfiguration, applyLavaMoat, envVars);
}
}
@ -988,7 +996,11 @@ function setupMinification(buildConfiguration) {
});
}
function setupScuttlingWrapping(buildConfiguration, applyLavaMoat) {
function setupScuttlingWrapping(buildConfiguration, applyLavaMoat, envVars) {
const scuttlingConfig =
envVars.ENABLE_MV3 === 'true'
? mv3ScuttlingConfig
: standardScuttlingConfig;
const { events } = buildConfiguration;
events.on('configurePipeline', ({ pipeline }) => {
pipeline.get('scuttle').push(
@ -1111,6 +1123,7 @@ async function getEnvironmentVariables({ buildTarget, buildType, version }) {
ICON_NAMES: iconNames,
MULTICHAIN: config.MULTICHAIN === '1',
CONF: devMode ? config : {},
ENABLE_MV3: config.ENABLE_MV3,
IN_TEST: testing,
INFURA_PROJECT_ID: getInfuraProjectId({
buildType,