diff --git a/client/gatsby-node.js b/client/gatsby-node.js index 008208d441..3bc54eacca 100644 --- a/client/gatsby-node.js +++ b/client/gatsby-node.js @@ -229,7 +229,7 @@ exports.onCreateWebpackConfig = ({ stage, actions }) => { path: require.resolve('path-browserify'), assert: require.resolve('assert'), crypto: require.resolve('crypto-browserify'), - util: false, + util: require.resolve('util/util'), buffer: require.resolve('buffer'), stream: require.resolve('stream-browserify'), process: require.resolve('process/browser') diff --git a/client/package.json b/client/package.json index 0e0a549def..0601c2c401 100644 --- a/client/package.json +++ b/client/package.json @@ -124,6 +124,7 @@ "stream-browserify": "3.0.0", "tone": "14.7.77", "typescript": "4.5.5", + "util": "^0.12.4", "uuid": "8.3.2", "validator": "13.7.0" }, diff --git a/client/src/client/workers/test-evaluator.ts b/client/src/client/workers/test-evaluator.ts index d7592b1ea5..589292d02d 100644 --- a/client/src/client/workers/test-evaluator.ts +++ b/client/src/client/workers/test-evaluator.ts @@ -25,6 +25,7 @@ const __utils = (() => { const oldLog = ctx.console.log.bind(ctx.console); function proxyLog(...args: string[]) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return logs.push(args.map(arg => __format(arg)).join(' ')); if (logs.join('\n').length > MAX_LOGS_SIZE) { flushLogs(); diff --git a/client/src/utils/format.js b/client/src/utils/format.js index 3cf2049750..ecdba273b3 100644 --- a/client/src/utils/format.js +++ b/client/src/utils/format.js @@ -1,4 +1,4 @@ -import { inspect } from 'util'; +import { inspect } from 'util/util'; export function format(x) { // we're trying to mimic console.log, so we avoid wrapping strings in quotes: @@ -10,6 +10,10 @@ export function format(x) { x.entries(), ([k, v]) => `${k} => ${v}` ).join(', ')}})`; + } else if (typeof x === 'bigint') { + return x.toString() + 'n'; + } else if (typeof x === 'symbol') { + return x.toString(); } return inspect(x); } diff --git a/client/src/utils/format.test.ts b/client/src/utils/format.test.ts index 2856010f46..f00eaa34fc 100644 --- a/client/src/utils/format.test.ts +++ b/client/src/utils/format.test.ts @@ -35,17 +35,17 @@ describe('format', () => { const primitives = [ 'str', 57, - BigInt(10), true, false, null, // eslint-disable-next-line no-undefined - undefined, - Symbol('Sym') + undefined ]; expect(format(primitives)).toBe( - `[ 'str', 57, 10n, true, false, null, undefined, Symbol(Sym) ]` + `[ 'str', 57, true, false, null, undefined ]` ); + expect(format(BigInt(10))).toBe(`10n`); + expect(format(Symbol('Sym'))).toBe(`Symbol(Sym)`); }); it(`outputs NaN as 'NaN'`, () => { expect(format(NaN)).toBe('NaN');