diff --git a/packages/build-scripts/package.json b/packages/build-scripts/package.json index 65101fd9b8fe..add1908d18c7 100644 --- a/packages/build-scripts/package.json +++ b/packages/build-scripts/package.json @@ -3,6 +3,7 @@ "version": "0.0.0", "private": true, "files": [ + "register-node-globals.mjs", "tsup.config.library.ts", "tsup.config.package.ts" ], diff --git a/packages/build-scripts/register-node-globals.cjs b/packages/build-scripts/register-node-globals.cjs new file mode 100644 index 000000000000..f4007d6640ca --- /dev/null +++ b/packages/build-scripts/register-node-globals.cjs @@ -0,0 +1,4 @@ +globalThis.__DEV__ = false; +globalThis.__BROWSER = false; +globalThis.__NODEJS__ = true; +globalThis.__REACTNATIVE__ = false; diff --git a/packages/codecs-core/src/__benchmarks__/run.ts b/packages/codecs-core/src/__benchmarks__/run.ts index c67641292f43..ed37a47f518a 100755 --- a/packages/codecs-core/src/__benchmarks__/run.ts +++ b/packages/codecs-core/src/__benchmarks__/run.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env -S pnpm dlx tsx +#!/usr/bin/env -S pnpm dlx tsx -r ../build-scripts/register-node-globals.cjs import { webcrypto as crypto } from 'node:crypto'; diff --git a/packages/codecs-strings/src/__benchmarks__/run.ts b/packages/codecs-strings/src/__benchmarks__/run.ts index d48793060422..ff47932959bc 100755 --- a/packages/codecs-strings/src/__benchmarks__/run.ts +++ b/packages/codecs-strings/src/__benchmarks__/run.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env -S pnpm dlx tsx +#!/usr/bin/env -S pnpm dlx tsx -r ../build-scripts/register-node-globals.cjs import { webcrypto as crypto } from 'node:crypto'; diff --git a/packages/fetch-impl/src/__benchmarks__/run.ts b/packages/fetch-impl/src/__benchmarks__/run.ts index 06295f7a778e..1ff3bc876e0e 100755 --- a/packages/fetch-impl/src/__benchmarks__/run.ts +++ b/packages/fetch-impl/src/__benchmarks__/run.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env -S pnpm dlx tsx +#!/usr/bin/env -S pnpm dlx tsx -r ../build-scripts/register-node-globals.cjs import { ok } from 'node:assert'; import process from 'node:process'; diff --git a/packages/keys/src/__benchmarks__/run.ts b/packages/keys/src/__benchmarks__/run.ts index 6b134810f810..058ff6410f39 100755 --- a/packages/keys/src/__benchmarks__/run.ts +++ b/packages/keys/src/__benchmarks__/run.ts @@ -1,16 +1,9 @@ -#!/usr/bin/env -S pnpm dlx tsx -- +#!/usr/bin/env -S pnpm dlx tsx -r ../build-scripts/register-node-globals.cjs import { Bench } from 'tinybench'; import { generateKeyPair, SignatureBytes, signBytes, verifySignature } from '../index'; -Object.assign(globalThis, { - __BROWSER__: false, - __DEV__: false, - __NODEJS__: true, - __REACTNATIVE____: false, -}); - const bench = new Bench({ throws: true, }); diff --git a/packages/rpc-transport-http/src/__benchmarks__/run.ts b/packages/rpc-transport-http/src/__benchmarks__/run.ts index 5ea867520c42..2b94ab5a564d 100755 --- a/packages/rpc-transport-http/src/__benchmarks__/run.ts +++ b/packages/rpc-transport-http/src/__benchmarks__/run.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env -S pnpm dlx tsx -- +#!/usr/bin/env -S pnpm dlx tsx -r ../build-scripts/register-node-globals.cjs import { ok } from 'node:assert'; @@ -15,13 +15,6 @@ ok( ); VALIDATOR_URL ??= 'http://127.0.0.1:8899'; -Object.assign(globalThis, { - __BROWSER__: false, - __DEV__: false, - __NODEJS__: true, - __REACTNATIVE____: false, -}); - const NUM_CONCURRENT_REQUESTS = 1024; const bench = new Bench({