From 3d7e2f2d28fe8c8804e36669a04bc039eab1cce8 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Fri, 1 Nov 2024 10:04:18 +0100 Subject: [PATCH] fix: Use regular import to reference package.json (#2871) Use regular import to reference the package.json of the SDK. This makes referencing the JSON work in the browser as well when using ESM. --- packages/snaps-utils/coverage.json | 2 +- packages/snaps-utils/src/platform-version.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/snaps-utils/coverage.json b/packages/snaps-utils/coverage.json index 185df0be9d..102bd1c6df 100644 --- a/packages/snaps-utils/coverage.json +++ b/packages/snaps-utils/coverage.json @@ -2,5 +2,5 @@ "branches": 99.74, "functions": 98.93, "lines": 99.46, - "statements": 96.36 + "statements": 96.37 } diff --git a/packages/snaps-utils/src/platform-version.ts b/packages/snaps-utils/src/platform-version.ts index c2880ebe2a..140c18bea3 100644 --- a/packages/snaps-utils/src/platform-version.ts +++ b/packages/snaps-utils/src/platform-version.ts @@ -1,3 +1,5 @@ +import packageJson from '@metamask/snaps-sdk/package.json'; + /** * Get the current supported platform version. * @@ -8,6 +10,5 @@ * @returns The platform version. */ export function getPlatformVersion() { - // eslint-disable-next-line import/no-dynamic-require, @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires - return require('@metamask/snaps-sdk/package.json').version; + return packageJson.version; }