diff --git a/biome.json b/biome.json index 6cded127a..888344a1e 100644 --- a/biome.json +++ b/biome.json @@ -25,8 +25,7 @@ "patches/**", "assets/**", ".changeset/**", - ".nx/**", - "post-process.js" + ".nx/**" ] }, "organizeImports": { diff --git a/packages/snap/post-process.js b/packages/snap/post-process.js index e4b9d118b..fd83aadf9 100644 --- a/packages/snap/post-process.js +++ b/packages/snap/post-process.js @@ -1,5 +1,5 @@ -const fs = require('fs'); -const pathUtils = require('path'); +const fs = require('node:fs'); +const pathUtils = require('node:path'); const { postProcessBundle } = require('@metamask/snaps-utils'); @@ -12,7 +12,7 @@ let bundleString = fs.readFileSync(bundlePath, 'utf8'); console.log('[Start]: MetaMask Snaps transform'); bundleString = postProcessBundle(bundleString, { - stripComments: true, + stripComments: true, }).code; console.log('[End]: MetaMask Snaps transform'); @@ -23,32 +23,22 @@ console.log('[Start]: Custom transform'); bundleString = 'var self = window;\n'.concat(bundleString); bundleString = bundleString.replace( - "/** @type {import('cborg').TagDecoder[]} */", - '', + "/** @type {import('cborg').TagDecoder[]} */", + '' ); // [Polygon ID] Fix Worker bundleString = 'var Worker = {};\n'.concat(bundleString); -// [Polygon ID] Fix promise -bundleString = bundleString.replaceAll( - `new Function("return this;")().Promise`, - 'Promise', -); - // [Polygon ID] fix single thread -bundleString = bundleString.replaceAll(`if (singleThread)`, `if (true)`); +bundleString = bundleString.replaceAll('if (singleThread)', 'if (true)'); // [Polygon ID] fix single thread bundleString = bundleString.replaceAll( - `singleThread: singleThread ? true : false`, - `singleThread: true`, + 'singleThread: singleThread ? true : false', + 'singleThread: true' ); -// [Polygon ID] Remove fs -bundleString = bundleString.replaceAll('fs2.readFileSync;', 'null;'); -bundleString = bundleString.replaceAll('fs3.readFileSync;', 'null;'); - console.log('[End]: Custom transform'); fs.writeFileSync(bundlePath, bundleString);