mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
This commit is contained in:
parent
8f775c0f7e
commit
b1fd7f7796
@ -27,10 +27,10 @@ const terser = require('terser');
|
|||||||
|
|
||||||
const bifyModuleGroups = require('bify-module-groups');
|
const bifyModuleGroups = require('bify-module-groups');
|
||||||
|
|
||||||
|
const phishingWarningManifest = require('@metamask/phishing-warning/package.json');
|
||||||
const { streamFlatMap } = require('../stream-flat-map');
|
const { streamFlatMap } = require('../stream-flat-map');
|
||||||
const { BuildType } = require('../lib/build-type');
|
const { BuildType } = require('../lib/build-type');
|
||||||
const { generateIconNames } = require('../generate-icon-names');
|
const { generateIconNames } = require('../generate-icon-names');
|
||||||
const phishingWarningManifest = require('../../node_modules/@metamask/phishing-warning/package.json');
|
|
||||||
const { BUILD_TARGETS, ENVIRONMENT } = require('./constants');
|
const { BUILD_TARGETS, ENVIRONMENT } = require('./constants');
|
||||||
const { getConfig, getProductionConfig } = require('./config');
|
const { getConfig, getProductionConfig } = require('./config');
|
||||||
const {
|
const {
|
||||||
|
@ -8,6 +8,7 @@ const { BuildType } = require('../lib/build-type');
|
|||||||
|
|
||||||
const { TASKS } = require('./constants');
|
const { TASKS } = require('./constants');
|
||||||
const { createTask, composeSeries } = require('./task');
|
const { createTask, composeSeries } = require('./task');
|
||||||
|
const { getPathInsideNodeModules } = require('./utils');
|
||||||
|
|
||||||
const EMPTY_JS_FILE = './development/empty.js';
|
const EMPTY_JS_FILE = './development/empty.js';
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ function getCopyTargets(shouldIncludeLockdown, shouldIncludeSnow) {
|
|||||||
dest: `images`,
|
dest: `images`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
src: `./node_modules/@metamask/contract-metadata/images/`,
|
src: getPathInsideNodeModules('@metamask/contract-metadata', 'images/'),
|
||||||
dest: `images/contract`,
|
dest: `images/contract`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -137,11 +138,14 @@ function getCopyTargets(shouldIncludeLockdown, shouldIncludeSnow) {
|
|||||||
dest: `vendor`,
|
dest: `vendor`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
src: `./node_modules/@fortawesome/fontawesome-free/webfonts/`,
|
src: getPathInsideNodeModules(
|
||||||
|
'@fortawesome/fontawesome-free',
|
||||||
|
'webfonts/',
|
||||||
|
),
|
||||||
dest: `fonts/fontawesome`,
|
dest: `fonts/fontawesome`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
src: `./node_modules/react-responsive-carousel/lib/styles`,
|
src: getPathInsideNodeModules('react-responsive-carousel', 'lib/styles/'),
|
||||||
dest: 'react-gallery/',
|
dest: 'react-gallery/',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -154,7 +158,7 @@ function getCopyTargets(shouldIncludeLockdown, shouldIncludeSnow) {
|
|||||||
dest: `loading.html`,
|
dest: `loading.html`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
src: `./node_modules/globalthis/dist/browser.js`,
|
src: getPathInsideNodeModules('globalthis', 'dist/browser.js'),
|
||||||
dest: `globalthis.js`,
|
dest: `globalthis.js`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -169,7 +173,7 @@ function getCopyTargets(shouldIncludeLockdown, shouldIncludeSnow) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
src: shouldIncludeLockdown
|
src: shouldIncludeLockdown
|
||||||
? `./node_modules/ses/dist/lockdown.umd.min.js`
|
? getPathInsideNodeModules('ses', 'dist/lockdown.umd.min.js')
|
||||||
: EMPTY_JS_FILE,
|
: EMPTY_JS_FILE,
|
||||||
dest: `lockdown-install.js`,
|
dest: `lockdown-install.js`,
|
||||||
},
|
},
|
||||||
@ -190,13 +194,11 @@ function getCopyTargets(shouldIncludeLockdown, shouldIncludeSnow) {
|
|||||||
dest: `lockdown-more.js`,
|
dest: `lockdown-more.js`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// eslint-disable-next-line node/no-extraneous-require
|
src: getPathInsideNodeModules('@lavamoat/lavapack', 'src/runtime-cjs.js'),
|
||||||
src: require.resolve('@lavamoat/lavapack/src/runtime-cjs.js'),
|
|
||||||
dest: `runtime-cjs.js`,
|
dest: `runtime-cjs.js`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// eslint-disable-next-line node/no-extraneous-require
|
src: getPathInsideNodeModules('@lavamoat/lavapack', 'src/runtime.js'),
|
||||||
src: require.resolve('@lavamoat/lavapack/src/runtime.js'),
|
|
||||||
dest: `runtime-lavamoat.js`,
|
dest: `runtime-lavamoat.js`,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -210,7 +212,10 @@ function getCopyTargets(shouldIncludeLockdown, shouldIncludeSnow) {
|
|||||||
|
|
||||||
for (const tag of languageTags) {
|
for (const tag of languageTags) {
|
||||||
allCopyTargets.push({
|
allCopyTargets.push({
|
||||||
src: `./node_modules/@formatjs/intl-relativetimeformat/dist/locale-data/${tag}.json`,
|
src: getPathInsideNodeModules(
|
||||||
|
'@formatjs/intl-relativetimeformat',
|
||||||
|
`dist/locale-data/${tag}.json`,
|
||||||
|
),
|
||||||
dest: `intl/${tag}/relative-time-format-data.json`,
|
dest: `intl/${tag}/relative-time-format-data.json`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
const path = require('path');
|
||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
const { BuildType } = require('../lib/build-type');
|
const { BuildType } = require('../lib/build-type');
|
||||||
const { BUILD_TARGETS, ENVIRONMENT } = require('./constants');
|
const { BUILD_TARGETS, ENVIRONMENT } = require('./constants');
|
||||||
@ -117,10 +118,33 @@ function logError(error) {
|
|||||||
console.error(error.stack || error);
|
console.error(error.stack || error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the path of a file or folder inside the node_modules folder
|
||||||
|
*
|
||||||
|
* require.resolve was causing errors on Windows, once the paths were fed into fast-glob
|
||||||
|
* (The backslashes had to be converted to forward-slashes)
|
||||||
|
* This helper function was written to fix the Windows problem, and also end reliance on writing paths that start with './node_modules/'
|
||||||
|
*
|
||||||
|
* @see {@link https://github.com/MetaMask/metamask-extension/pull/16550}
|
||||||
|
* @param {string} packageName - The name of the package, such as '@lavamoat/lavapack'
|
||||||
|
* @param {string} pathToFiles - The path of the file or folder inside the package, optionally starting with /
|
||||||
|
*/
|
||||||
|
function getPathInsideNodeModules(packageName, pathToFiles) {
|
||||||
|
let targetPath = path.dirname(require.resolve(`${packageName}/package.json`));
|
||||||
|
|
||||||
|
targetPath = path.join(targetPath, pathToFiles);
|
||||||
|
|
||||||
|
// Force POSIX separators
|
||||||
|
targetPath = targetPath.split(path.sep).join(path.posix.sep);
|
||||||
|
|
||||||
|
return targetPath;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getBrowserVersionMap,
|
getBrowserVersionMap,
|
||||||
getEnvironment,
|
getEnvironment,
|
||||||
isDevBuild,
|
isDevBuild,
|
||||||
isTestBuild,
|
isTestBuild,
|
||||||
logError,
|
logError,
|
||||||
|
getPathInsideNodeModules,
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@ const {
|
|||||||
collectiblesBytecode,
|
collectiblesBytecode,
|
||||||
failingContractAbi,
|
failingContractAbi,
|
||||||
failingContractBytecode,
|
failingContractBytecode,
|
||||||
} = require('../../../node_modules/@metamask/test-dapp/dist/constants.json');
|
} = require('@metamask/test-dapp/dist/constants.json');
|
||||||
|
|
||||||
const hstFactory = {
|
const hstFactory = {
|
||||||
initialAmount: 100,
|
initialAmount: 100,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user