Skip to content

Commit

Permalink
chore: remove unecessary post process
Browse files Browse the repository at this point in the history
  • Loading branch information
martines3000 committed Mar 27, 2024
1 parent 7262d9b commit 9aaeb7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
3 changes: 1 addition & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"patches/**",
"assets/**",
".changeset/**",
".nx/**",
"post-process.js"
".nx/**"
]
},
"organizeImports": {
Expand Down
26 changes: 8 additions & 18 deletions packages/snap/post-process.js
Original file line number Diff line number Diff line change
@@ -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');

Expand All @@ -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');
Expand All @@ -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);
Expand Down

0 comments on commit 9aaeb7f

Please sign in to comment.