Skip to content

meta(utils): Don't use import assertion in rollup config #14362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions packages/utils/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -18,7 +30,7 @@ export default makeNPMConfigVariants(
replace({
preventAssignment: true,
values: {
__SENTRY_SDK_VERSION__: JSON.stringify(packageJson.version),
__SENTRY_SDK_VERSION__: JSON.stringify(packageVersion),
},
}),
],
Expand Down
Loading