From 100c6628f5129f1659aad78c87cab06bb838bd10 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 19 Nov 2024 12:26:03 +0100 Subject: [PATCH] meta(utils): Don't use import assertion in rollup config (#14362) --- packages/utils/rollup.npm.config.mjs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/utils/rollup.npm.config.mjs b/packages/utils/rollup.npm.config.mjs index 8e219b3c2d9b..cc3ad4064820 100644 --- a/packages/utils/rollup.npm.config.mjs +++ b/packages/utils/rollup.npm.config.mjs @@ -1,6 +1,18 @@ +// @ts-check + +import { readFileSync } from 'fs'; +import { dirname, join } from 'path'; +import { fileURLToPath } from 'url'; import replace from '@rollup/plugin-replace'; import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils'; -import packageJson from './package.json' with { type: 'json' }; + +const packageJson = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'package.json'), 'utf-8')); + +if (!packageJson.version) { + throw new Error('invariant: package version not found'); +} + +const packageVersion = packageJson.version; export default makeNPMConfigVariants( makeBaseNPMConfig({ @@ -18,7 +30,7 @@ export default makeNPMConfigVariants( replace({ preventAssignment: true, values: { - __SENTRY_SDK_VERSION__: JSON.stringify(packageJson.version), + __SENTRY_SDK_VERSION__: JSON.stringify(packageVersion), }, }), ],